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

View file

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

View file

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

View file

@ -46,10 +46,9 @@ bool TrayIconSupported();
bool SkipTaskbarSupported(); bool SkipTaskbarSupported();
void WriteCrashDumpDetails(); void WriteCrashDumpDetails();
void NewVersionLaunched(int oldVersion); void NewVersionLaunched(int oldVersion);
[[nodiscard]] QImage DefaultApplicationIcon(); [[nodiscard]] QImage DefaultApplicationIcon();
[[nodiscard]] bool PreventsQuit(Core::QuitReason reason); [[nodiscard]] bool PreventsQuit(Core::QuitReason reason);
[[nodiscard]] QString ExecutablePathForShortcuts();
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
[[nodiscard]] std::optional<bool> IsDarkMode(); [[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. // Activate window with windowId (if found) or the largest priority.
void ActivateOtherProcess(uint64 processId, uint64 windowId); void ActivateOtherProcess(uint64 processId, uint64 windowId);
inline QString ExecutablePathForShortcuts() {
return cExeDir() + cExeName();
}
namespace ThirdParty { namespace ThirdParty {
void start(); void start();