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