Use argv0 for shortcuts when updater is disabled

This commit is contained in:
Ilya Fedin 2023-06-16 00:15:23 +04:00 committed by John Preston
parent 8aee08eaef
commit 1d234ea990
5 changed files with 28 additions and 16 deletions

View File

@ -1762,9 +1762,7 @@ void Application::startShortcuts() {
void Application::RegisterUrlScheme() {
base::Platform::RegisterUrlScheme(base::Platform::UrlSchemeDescriptor{
.executable = (!Platform::IsLinux() || !Core::UpdaterDisabled())
? (cExeDir() + cExeName())
: cExeName(),
.executable = Platform::ExecutablePathForShortcuts(),
.arguments = Launcher::Instance().customWorkingDir()
? u"-workdir \"%1\""_q.arg(cWorkingDir())
: QString(),

View File

@ -191,6 +191,7 @@ bool GenerateDesktopFile(
const auto sourceFile = kDesktopFile.utf16();
const auto targetFile = targetPath + QGuiApplication::desktopFileName();
const auto executable = ExecutablePathForShortcuts();
const auto sourceText = [&] {
QFile source(sourceFile);
@ -224,11 +225,7 @@ bool GenerateDesktopFile(
target->set_string(
group,
"TryExec",
KShell::joinArgs({
!Core::UpdaterDisabled()
? (cExeDir() + cExeName())
: cExeName()
}).replace(
KShell::joinArgs({ executable }).replace(
'\\',
qstr("\\\\")).toStdString());
}
@ -236,9 +233,7 @@ bool GenerateDesktopFile(
if (target->has_key(group, "Exec")) {
if (group == "Desktop Entry" && !args.isEmpty()) {
QStringList exec;
exec.append(!Core::UpdaterDisabled()
? (cExeDir() + cExeName())
: cExeName());
exec.append(executable);
if (Core::Launcher::Instance().customWorkingDir()) {
exec.append(u"-workdir"_q);
exec.append(cWorkingDir());
@ -259,9 +254,7 @@ bool GenerateDesktopFile(
qstr("\\")));
if (!exec.isEmpty()) {
exec[0] = !Core::UpdaterDisabled()
? (cExeDir() + cExeName())
: cExeName();
exec[0] = executable;
if (Core::Launcher::Instance().customWorkingDir()) {
exec.insert(1, u"-workdir"_q);
exec.insert(2, cWorkingDir());
@ -451,6 +444,20 @@ bool SkipTaskbarSupported() {
return false;
}
QString ExecutablePathForShortcuts() {
if (Core::UpdaterDisabled()) {
const auto &arguments = Core::Launcher::Instance().arguments();
if (!arguments.isEmpty()) {
const auto result = QFileInfo(arguments.first()).fileName();
if (!result.isEmpty()) {
return result;
}
}
return cExeName();
}
return cExeDir() + cExeName();
}
} // namespace Platform
QString psAppDataPath() {

View File

@ -40,6 +40,10 @@ inline uint64 ActivationWindowId(not_null<QWidget*> window) {
inline void ActivateOtherProcess(uint64 processId, uint64 windowId) {
}
inline QString ExecutablePathForShortcuts() {
return cExeDir() + cExeName();
}
namespace ThirdParty {
inline void start() {

View File

@ -46,10 +46,9 @@ bool TrayIconSupported();
bool SkipTaskbarSupported();
void WriteCrashDumpDetails();
void NewVersionLaunched(int oldVersion);
[[nodiscard]] QImage DefaultApplicationIcon();
[[nodiscard]] bool PreventsQuit(Core::QuitReason reason);
[[nodiscard]] QString ExecutablePathForShortcuts();
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
[[nodiscard]] std::optional<bool> IsDarkMode();

View File

@ -42,6 +42,10 @@ void SetWindowPriority(not_null<QWidget*> window, uint32 priority);
// Activate window with windowId (if found) or the largest priority.
void ActivateOtherProcess(uint64 processId, uint64 windowId);
inline QString ExecutablePathForShortcuts() {
return cExeDir() + cExeName();
}
namespace ThirdParty {
void start();