mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Move icon name getter to cross-platform header
This commit is contained in:
parent
5132fd5010
commit
d9318c9935
7 changed files with 37 additions and 31 deletions
|
@ -26,6 +26,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <KUrlMimeData>
|
||||
#endif
|
||||
|
||||
#if __has_include(<KSandbox>)
|
||||
#include <KSandbox>
|
||||
#endif
|
||||
|
||||
#define qsl(s) QStringLiteral(s)
|
||||
|
||||
namespace base {
|
||||
|
@ -45,6 +49,27 @@ inline auto GetMimeUrls(const QMimeData *data) {
|
|||
#endif
|
||||
}
|
||||
|
||||
#if __has_include(<KSandbox>) && defined DeclareReadSetting
|
||||
inline QString FlatpakID() {
|
||||
static const auto Result = [] {
|
||||
if (!qEnvironmentVariableIsEmpty("FLATPAK_ID")) {
|
||||
return qEnvironmentVariable("FLATPAK_ID");
|
||||
} else {
|
||||
return cExeName();
|
||||
}
|
||||
}();
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline QString IconName() {
|
||||
static const auto Result = KSandbox::isFlatpak()
|
||||
? FlatpakID()
|
||||
: qsl("telegram");
|
||||
return Result;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace base
|
||||
|
||||
static const int32 ScrollMax = INT_MAX;
|
||||
|
|
|
@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/platform/base_platform_info.h"
|
||||
#include "base/platform/linux/base_linux_glibmm_helper.h"
|
||||
#include "base/platform/linux/base_linux_dbus_utilities.h"
|
||||
#include "platform/linux/specific_linux.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "history/history.h"
|
||||
|
@ -553,7 +552,7 @@ void NotificationData::show() {
|
|||
StartServiceAsync(crl::guard(weak, [=] {
|
||||
const auto iconName = _imageKey.empty()
|
||||
|| _hints.find(_imageKey) == end(_hints)
|
||||
? Glib::ustring(GetIconName().toStdString())
|
||||
? Glib::ustring(base::IconName().toStdString())
|
||||
: Glib::ustring();
|
||||
const auto connection = _dbusConnection;
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ namespace Platform {
|
|||
namespace {
|
||||
|
||||
constexpr auto kDesktopFile = ":/misc/telegramdesktop.desktop"_cs;
|
||||
constexpr auto kIconName = "telegram"_cs;
|
||||
|
||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
void PortalAutostart(bool start, bool silent) {
|
||||
|
@ -174,18 +173,6 @@ void PortalAutostart(bool start, bool silent) {
|
|||
}
|
||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
|
||||
QString FlatpakID() {
|
||||
static const auto Result = [] {
|
||||
if (!qEnvironmentVariableIsEmpty("FLATPAK_ID")) {
|
||||
return qEnvironmentVariable("FLATPAK_ID");
|
||||
} else {
|
||||
return cExeName();
|
||||
}
|
||||
}();
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
bool GenerateDesktopFile(
|
||||
const QString &targetPath,
|
||||
const QString &args,
|
||||
|
@ -271,7 +258,7 @@ QString AppRuntimeDirectory() {
|
|||
QStandardPaths::RuntimeLocation);
|
||||
|
||||
if (KSandbox::isFlatpak()) {
|
||||
runtimeDir += qsl("/app/") + FlatpakID();
|
||||
runtimeDir += qsl("/app/") + base::FlatpakID();
|
||||
}
|
||||
|
||||
if (!QFileInfo::exists(runtimeDir)) { // non-systemd distros
|
||||
|
@ -301,13 +288,6 @@ QString SingleInstanceLocalServerName(const QString &hash) {
|
|||
}
|
||||
}
|
||||
|
||||
QString GetIconName() {
|
||||
static const auto Result = KSandbox::isFlatpak()
|
||||
? FlatpakID()
|
||||
: kIconName.utf16();
|
||||
return Result;
|
||||
}
|
||||
|
||||
std::optional<bool> IsDarkMode() {
|
||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
[[maybe_unused]] static const auto Inited = [] {
|
||||
|
@ -476,7 +456,7 @@ void start() {
|
|||
LOG(("Launcher filename: %1").arg(QGuiApplication::desktopFileName()));
|
||||
|
||||
qputenv("PULSE_PROP_application.name", AppName.utf8());
|
||||
qputenv("PULSE_PROP_application.icon_name", GetIconName().toLatin1());
|
||||
qputenv("PULSE_PROP_application.icon_name", base::IconName().toLatin1());
|
||||
|
||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
Glib::init();
|
||||
|
@ -532,7 +512,7 @@ void InstallLauncher(bool force) {
|
|||
|
||||
if (!QDir(icons).exists()) QDir().mkpath(icons);
|
||||
|
||||
const auto icon = icons + kIconName.utf16() + qsl(".png");
|
||||
const auto icon = icons + base::IconName() + qsl(".png");
|
||||
auto iconExists = QFile::exists(icon);
|
||||
if (Local::oldSettingsVersion() < 2008012 && iconExists) {
|
||||
// Icon was changed.
|
||||
|
|
|
@ -16,7 +16,6 @@ class LocationPoint;
|
|||
namespace Platform {
|
||||
|
||||
QString AppRuntimeDirectory();
|
||||
QString GetIconName();
|
||||
|
||||
void InstallLauncher(bool force = false);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/qt_signal_producer.h"
|
||||
#include "core/application.h"
|
||||
#include "core/sandbox.h"
|
||||
#include "platform/linux/specific_linux.h"
|
||||
#include "platform/platform_specific.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "window/window_controller.h"
|
||||
|
@ -87,7 +87,7 @@ QString IconGraphic::panelIconName(int counter, bool muted) const {
|
|||
}
|
||||
|
||||
QString IconGraphic::trayIconName(int counter, bool muted) const {
|
||||
const auto iconName = GetIconName();
|
||||
const auto iconName = base::IconName();
|
||||
const auto panelName = panelIconName(counter, muted);
|
||||
|
||||
if (QIcon::hasThemeIcon(panelName)) {
|
||||
|
|
|
@ -119,6 +119,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "base/basic_types.h"
|
||||
#include "logs.h"
|
||||
#include "settings.h"
|
||||
#include "core/utils.h"
|
||||
#include "config.h"
|
||||
|
||||
|
|
|
@ -125,9 +125,12 @@ QIcon CreateIcon(Main::Session *session, bool returnNullIfDefault) {
|
|||
|
||||
auto result = QIcon(Ui::PixmapFromImage(base::duplicate(Logo())));
|
||||
|
||||
#if defined Q_OS_UNIX && !defined Q_OS_MAC
|
||||
if constexpr (!Platform::IsLinux()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const auto iconFromTheme = QIcon::fromTheme(
|
||||
Platform::GetIconName(),
|
||||
base::IconName(),
|
||||
result);
|
||||
|
||||
result = QIcon();
|
||||
|
@ -163,7 +166,6 @@ QIcon CreateIcon(Main::Session *session, bool returnNullIfDefault) {
|
|||
|
||||
result.addPixmap(iconPixmap);
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue