mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 23:27:09 +02:00
Get rid of GetLauncherFilename
Use QGuiApplication::desktopFileName directly instead
This commit is contained in:
parent
4d9c9bbd6f
commit
e493ab12dc
5 changed files with 28 additions and 41 deletions
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "platform/linux/launcher_linux.h"
|
||||
|
||||
#include "platform/linux/specific_linux.h"
|
||||
#include "core/crash_reports.h"
|
||||
#include "core/update_checker.h"
|
||||
|
||||
|
@ -50,7 +49,26 @@ Launcher::Launcher(int argc, char *argv[])
|
|||
|
||||
void Launcher::initHook() {
|
||||
QApplication::setAttribute(Qt::AA_DisableSessionManager, true);
|
||||
QApplication::setDesktopFileName(GetLauncherFilename());
|
||||
QApplication::setDesktopFileName([] {
|
||||
if (!Core::UpdaterDisabled() && !cExeName().isEmpty()) {
|
||||
const auto appimagePath = qsl("file://%1%2")
|
||||
.arg(cExeDir())
|
||||
.arg(cExeName())
|
||||
.toUtf8();
|
||||
|
||||
char md5Hash[33] = { 0 };
|
||||
hashMd5Hex(
|
||||
appimagePath.constData(),
|
||||
appimagePath.size(),
|
||||
md5Hash);
|
||||
|
||||
return qsl("appimagekit_%1-%2.desktop")
|
||||
.arg(md5Hash)
|
||||
.arg(AppName.utf16().replace(' ', '_'));
|
||||
}
|
||||
|
||||
return qsl(MACRO_TO_STRING(TDESKTOP_LAUNCHER_BASENAME) ".desktop");
|
||||
}());
|
||||
}
|
||||
|
||||
bool Launcher::launchUpdater(UpdaterLaunch action) {
|
||||
|
|
|
@ -873,7 +873,8 @@ void MainWindow::updateIconCounters() {
|
|||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
if (UseUnityCounter()) {
|
||||
const auto launcherUrl = Glib::ustring(
|
||||
"application://" + GetLauncherFilename().toStdString());
|
||||
"application://"
|
||||
+ QGuiApplication::desktopFileName().toStdString());
|
||||
const auto counterSlice = std::min(counter, 9999);
|
||||
std::map<Glib::ustring, Glib::VariantBase> dbusUnityProperties;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "lang/lang_keys.h"
|
||||
|
||||
#include <QtCore/QVersionNumber>
|
||||
#include <QtGui/QGuiApplication>
|
||||
|
||||
#include <glibmm.h>
|
||||
#include <giomm.h>
|
||||
|
@ -463,7 +464,7 @@ NotificationData::NotificationData(
|
|||
_hints["category"] = Glib::Variant<Glib::ustring>::create("im.received");
|
||||
|
||||
_hints["desktop-entry"] = Glib::Variant<Glib::ustring>::create(
|
||||
GetLauncherBasename().toStdString());
|
||||
QGuiApplication::desktopFileName().chopped(8).toStdString());
|
||||
|
||||
_notificationClosedSignalId = _dbusConnection->signal_subscribe(
|
||||
sigc::mem_fun(this, &NotificationData::signalEmitted),
|
||||
|
|
|
@ -256,7 +256,7 @@ QString FlatpakID() {
|
|||
if (!qEnvironmentVariableIsEmpty("FLATPAK_ID")) {
|
||||
return qEnvironmentVariable("FLATPAK_ID");
|
||||
} else {
|
||||
return GetLauncherBasename();
|
||||
return cExeName();
|
||||
}
|
||||
}();
|
||||
|
||||
|
@ -275,7 +275,7 @@ bool GenerateDesktopFile(
|
|||
if (!QDir(targetPath).exists()) QDir().mkpath(targetPath);
|
||||
|
||||
const auto sourceFile = kDesktopFile.utf16();
|
||||
const auto targetFile = targetPath + GetLauncherFilename();
|
||||
const auto targetFile = targetPath + QGuiApplication::desktopFileName();
|
||||
|
||||
QString fileText;
|
||||
|
||||
|
@ -407,37 +407,6 @@ QString SingleInstanceLocalServerName(const QString &hash) {
|
|||
}
|
||||
}
|
||||
|
||||
QString GetLauncherBasename() {
|
||||
static const auto Result = [&] {
|
||||
if (!Core::UpdaterDisabled() && !cExeName().isEmpty()) {
|
||||
const auto appimagePath = qsl("file://%1%2")
|
||||
.arg(cExeDir())
|
||||
.arg(cExeName())
|
||||
.toUtf8();
|
||||
|
||||
char md5Hash[33] = { 0 };
|
||||
hashMd5Hex(
|
||||
appimagePath.constData(),
|
||||
appimagePath.size(),
|
||||
md5Hash);
|
||||
|
||||
return qsl("appimagekit_%1-%2")
|
||||
.arg(md5Hash)
|
||||
.arg(AppName.utf16().replace(' ', '_'));
|
||||
}
|
||||
|
||||
return qsl(MACRO_TO_STRING(TDESKTOP_LAUNCHER_BASENAME));
|
||||
}();
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
QString GetLauncherFilename() {
|
||||
static const auto Result = GetLauncherBasename()
|
||||
+ qsl(".desktop");
|
||||
return Result;
|
||||
}
|
||||
|
||||
QString GetIconName() {
|
||||
static const auto Result = InFlatpak()
|
||||
? FlatpakID()
|
||||
|
@ -616,7 +585,7 @@ int psFixPrevious() {
|
|||
namespace Platform {
|
||||
|
||||
void start() {
|
||||
LOG(("Launcher filename: %1").arg(GetLauncherFilename()));
|
||||
LOG(("Launcher filename: %1").arg(QGuiApplication::desktopFileName()));
|
||||
|
||||
qputenv("PULSE_PROP_application.name", AppName.utf8());
|
||||
qputenv("PULSE_PROP_application.icon_name", GetIconName().toLatin1());
|
||||
|
@ -873,7 +842,7 @@ void psAutoStart(bool start, bool silent) {
|
|||
if (start) {
|
||||
GenerateDesktopFile(autostart, qsl("-autostart"), silent);
|
||||
} else {
|
||||
QFile::remove(autostart + GetLauncherFilename());
|
||||
QFile::remove(autostart + QGuiApplication::desktopFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@ bool InFlatpak();
|
|||
bool InSnap();
|
||||
|
||||
QString AppRuntimeDirectory();
|
||||
QString GetLauncherBasename();
|
||||
QString GetLauncherFilename();
|
||||
QString GetIconName();
|
||||
|
||||
void InstallLauncher(bool force = false);
|
||||
|
|
Loading…
Add table
Reference in a new issue