mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Install launcher on every launch on Linux
Just like AppUserModelId on Windows This makes the cheat code and having the function outside of private namespace unnecessary
This commit is contained in:
parent
b62e1d5036
commit
2be4641496
6 changed files with 31 additions and 54 deletions
|
@ -240,7 +240,6 @@ void Application::run() {
|
|||
refreshGlobalProxy(); // Depends on app settings being read.
|
||||
|
||||
if (const auto old = Local::oldSettingsVersion(); old < AppVersion) {
|
||||
Platform::InstallLauncher();
|
||||
InvokeQueued(this, [] { RegisterUrlScheme(); });
|
||||
Platform::NewVersionLaunched(old);
|
||||
}
|
||||
|
|
|
@ -519,6 +519,36 @@ bool GenerateDesktopFile(
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InstallLauncher() {
|
||||
static const auto DisabledByEnv = !qEnvironmentVariableIsEmpty(
|
||||
"DESKTOPINTEGRATION");
|
||||
|
||||
// don't update desktop file for alpha version or if updater is disabled
|
||||
if (cAlphaVersion() || Core::UpdaterDisabled() || DisabledByEnv) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto applicationsPath = QStandardPaths::writableLocation(
|
||||
QStandardPaths::ApplicationsLocation) + '/';
|
||||
|
||||
GenerateDesktopFile(applicationsPath);
|
||||
|
||||
const auto icons = QStandardPaths::writableLocation(
|
||||
QStandardPaths::GenericDataLocation) + u"/icons/"_q;
|
||||
|
||||
if (!QDir(icons).exists()) QDir().mkpath(icons);
|
||||
|
||||
const auto icon = icons + base::IconName() + u".png"_q;
|
||||
QFile::remove(icon);
|
||||
if (QFile::copy(u":/gui/art/logo_256.png"_q, icon)) {
|
||||
DEBUG_LOG(("App Info: Icon copied to '%1'").arg(icon));
|
||||
}
|
||||
|
||||
QProcess::execute("update-desktop-database", {
|
||||
applicationsPath
|
||||
});
|
||||
}
|
||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
|
||||
} // namespace
|
||||
|
@ -753,47 +783,6 @@ void start() {
|
|||
void finish() {
|
||||
}
|
||||
|
||||
void InstallLauncher(bool force) {
|
||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
static const auto DisabledByEnv = !qEnvironmentVariableIsEmpty(
|
||||
"DESKTOPINTEGRATION");
|
||||
|
||||
// don't update desktop file for alpha version or if updater is disabled
|
||||
if ((cAlphaVersion() || Core::UpdaterDisabled() || DisabledByEnv)
|
||||
&& !force) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto applicationsPath = QStandardPaths::writableLocation(
|
||||
QStandardPaths::ApplicationsLocation) + '/';
|
||||
|
||||
GenerateDesktopFile(applicationsPath);
|
||||
|
||||
const auto icons = QStandardPaths::writableLocation(
|
||||
QStandardPaths::GenericDataLocation) + u"/icons/"_q;
|
||||
|
||||
if (!QDir(icons).exists()) QDir().mkpath(icons);
|
||||
|
||||
const auto icon = icons + base::IconName() + u".png"_q;
|
||||
auto iconExists = QFile::exists(icon);
|
||||
if (Local::oldSettingsVersion() < 2008012 && iconExists) {
|
||||
// Icon was changed.
|
||||
if (QFile::remove(icon)) {
|
||||
iconExists = false;
|
||||
}
|
||||
}
|
||||
if (!iconExists) {
|
||||
if (QFile::copy(u":/gui/art/logo_256.png"_q, icon)) {
|
||||
DEBUG_LOG(("App Info: Icon copied to '%1'").arg(icon));
|
||||
}
|
||||
}
|
||||
|
||||
QProcess::execute("update-desktop-database", {
|
||||
applicationsPath
|
||||
});
|
||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
}
|
||||
|
||||
PermissionStatus GetPermissionStatus(PermissionType type) {
|
||||
return PermissionStatus::Granted;
|
||||
}
|
||||
|
@ -871,6 +860,7 @@ void start() {
|
|||
LOG(("Fallback icon theme: %1").arg(QIcon::fallbackThemeName()));
|
||||
|
||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
InstallLauncher();
|
||||
LaunchGApplication();
|
||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
}
|
||||
|
|
|
@ -33,9 +33,6 @@ inline bool SkipTaskbarSupported() {
|
|||
return false;
|
||||
}
|
||||
|
||||
inline void InstallLauncher(bool force) {
|
||||
}
|
||||
|
||||
void ActivateThisProcess();
|
||||
|
||||
inline uint64 ActivationWindowId(not_null<QWidget*> window) {
|
||||
|
|
|
@ -42,7 +42,6 @@ bool TrayIconSupported();
|
|||
bool SkipTaskbarSupported();
|
||||
void WriteCrashDumpDetails();
|
||||
void NewVersionLaunched(int oldVersion);
|
||||
void InstallLauncher(bool force = false);
|
||||
|
||||
[[nodiscard]] std::optional<bool> IsDarkMode();
|
||||
[[nodiscard]] inline bool IsDarkModeSupported() {
|
||||
|
|
|
@ -27,9 +27,6 @@ inline bool SkipTaskbarSupported() {
|
|||
return true;
|
||||
}
|
||||
|
||||
inline void InstallLauncher(bool force) {
|
||||
}
|
||||
|
||||
inline void ActivateThisProcess() {
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "settings/settings_codes.h"
|
||||
|
||||
#include "platform/platform_specific.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
|
@ -180,10 +179,6 @@ auto GenerateCodes() {
|
|||
Core::Application::RegisterUrlScheme();
|
||||
Ui::Toast::Show("Forced custom scheme register.");
|
||||
});
|
||||
codes.emplace(u"installlauncher"_q, [](SessionController *window) {
|
||||
Platform::InstallLauncher(true);
|
||||
Ui::Toast::Show("Forced launcher installation.");
|
||||
});
|
||||
|
||||
#if defined Q_OS_WIN || defined Q_OS_MAC
|
||||
codes.emplace(u"freetype"_q, [](SessionController *window) {
|
||||
|
|
Loading…
Add table
Reference in a new issue