Revert "Move icon name getter to cross-platform header"

This reverts commit d9318c9935.
This commit is contained in:
Ilya Fedin 2025-03-11 05:24:55 +00:00 committed by John Preston
parent 57f10040e1
commit b14c2878b3
9 changed files with 29 additions and 19 deletions

View file

@ -93,6 +93,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtGui/QScreen> #include <QtGui/QScreen>
#include <QtGui/QWindow> #include <QtGui/QWindow>
#include <ksandbox.h>
namespace Core { namespace Core {
namespace { namespace {

View file

@ -21,10 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <set> #include <set>
#include <filesystem> #include <filesystem>
#if __has_include(<ksandbox.h>)
#include <ksandbox.h>
#endif
#define qsl(s) QStringLiteral(s) #define qsl(s) QStringLiteral(s)
namespace base { namespace base {
@ -34,15 +30,6 @@ inline bool in_range(Value &&value, From &&from, Till &&till) {
return (value >= from) && (value < till); return (value >= from) && (value < till);
} }
#if __has_include(<ksandbox.h>)
inline QString IconName() {
static const auto Result = KSandbox::isFlatpak()
? qEnvironmentVariable("FLATPAK_ID")
: u"telegram"_q;
return Result;
}
#endif
inline bool CanReadDirectory(const QString &path) { inline bool CanReadDirectory(const QString &path) {
#ifndef Q_OS_MAC // directory_iterator since 10.15 #ifndef Q_OS_MAC // directory_iterator since 10.15
std::error_code error; std::error_code error;

View file

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/options.h" #include "base/options.h"
#include "base/platform/base_platform_info.h" #include "base/platform/base_platform_info.h"
#include "base/platform/linux/base_linux_dbus_utilities.h" #include "base/platform/linux/base_linux_dbus_utilities.h"
#include "platform/platform_specific.h"
#include "core/application.h" #include "core/application.h"
#include "core/sandbox.h" #include "core/sandbox.h"
#include "core/core_settings.h" #include "core/core_settings.h"
@ -27,6 +28,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtCore/QVersionNumber> #include <QtCore/QVersionNumber>
#include <QtGui/QGuiApplication> #include <QtGui/QGuiApplication>
#include <ksandbox.h>
#include <xdgnotifications/xdgnotifications.hpp> #include <xdgnotifications/xdgnotifications.hpp>
#include <dlfcn.h> #include <dlfcn.h>
@ -547,7 +550,7 @@ void Manager::Private::showNotification(
notification.set_body(info.message.toStdString()); notification.set_body(info.message.toStdString());
notification.set_icon( notification.set_icon(
Gio::ThemedIcon::new_(base::IconName().toStdString())); Gio::ThemedIcon::new_(ApplicationIconName().toStdString()));
// for chat messages, according to // for chat messages, according to
// https://docs.gtk.org/gio/enum.NotificationPriority.html // https://docs.gtk.org/gio/enum.NotificationPriority.html
@ -761,7 +764,7 @@ void Manager::Private::showNotification(
AppName.data(), AppName.data(),
0, 0,
(!hasImage (!hasImage
? base::IconName().toStdString() ? ApplicationIconName().toStdString()
: std::string()).c_str(), : std::string()).c_str(),
(hasBodyMarkup || info.subtitle.isEmpty() (hasBodyMarkup || info.subtitle.isEmpty()
? info.title.toStdString() ? info.title.toStdString()

View file

@ -486,7 +486,7 @@ void InstallLauncher() {
if (!QDir(icons).exists()) QDir().mkpath(icons); if (!QDir(icons).exists()) QDir().mkpath(icons);
const auto icon = icons + base::IconName() + u".png"_q; const auto icon = icons + ApplicationIconName() + u".png"_q;
QFile::remove(icon); QFile::remove(icon);
if (QFile::copy(u":/gui/art/logo_256.png"_q, icon)) { if (QFile::copy(u":/gui/art/logo_256.png"_q, icon)) {
DEBUG_LOG(("App Info: Icon copied to '%1'").arg(icon)); DEBUG_LOG(("App Info: Icon copied to '%1'").arg(icon));
@ -684,7 +684,9 @@ void start() {
} }
qputenv("PULSE_PROP_application.name", AppName.utf8()); qputenv("PULSE_PROP_application.name", AppName.utf8());
qputenv("PULSE_PROP_application.icon_name", base::IconName().toLatin1()); qputenv(
"PULSE_PROP_application.icon_name",
ApplicationIconName().toUtf8());
GLib::set_prgname(cExeName().toStdString()); GLib::set_prgname(cExeName().toStdString());
GLib::set_application_name(AppName.data()); GLib::set_application_name(AppName.data());
@ -755,6 +757,13 @@ QImage DefaultApplicationIcon() {
return Window::Logo(); return Window::Logo();
} }
QString ApplicationIconName() {
static const auto Result = KSandbox::isFlatpak()
? qEnvironmentVariable("FLATPAK_ID")
: u"telegram"_q;
return Result;
}
namespace ThirdParty { namespace ThirdParty {
void start() { void start() {

View file

@ -88,7 +88,7 @@ QIcon IconGraphic::systemIcon() const {
const auto candidates = { const auto candidates = {
_new.monochrome ? PanelIconName(_new.counter, _new.muted) : QString(), _new.monochrome ? PanelIconName(_new.counter, _new.muted) : QString(),
base::IconName(), ApplicationIconName(),
}; };
for (const auto &candidate : candidates) { for (const auto &candidate : candidates) {

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 ApplicationIconName() {
return {};
}
inline QString ExecutablePathForShortcuts() { inline QString ExecutablePathForShortcuts() {
return cExeDir() + cExeName(); return cExeDir() + cExeName();
} }

View file

@ -47,6 +47,7 @@ void AutostartToggle(bool enabled, Fn<void(bool)> done = nullptr);
void WriteCrashDumpDetails(); void WriteCrashDumpDetails();
void NewVersionLaunched(int oldVersion); void NewVersionLaunched(int oldVersion);
[[nodiscard]] QImage DefaultApplicationIcon(); [[nodiscard]] QImage DefaultApplicationIcon();
[[nodiscard]] QString ApplicationIconName();
[[nodiscard]] bool PreventsQuit(Core::QuitReason reason); [[nodiscard]] bool PreventsQuit(Core::QuitReason reason);
[[nodiscard]] QString ExecutablePathForShortcuts(); [[nodiscard]] QString ExecutablePathForShortcuts();

View file

@ -43,6 +43,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 ApplicationIconName() {
return {};
}
inline QString ExecutablePathForShortcuts() { inline QString ExecutablePathForShortcuts() {
return cExeDir() + cExeName(); return cExeDir() + cExeName();
} }

View file

@ -219,7 +219,7 @@ QIcon CreateIcon(Main::Session *session, bool returnNullIfDefault) {
} }
const auto iconFromTheme = QIcon::fromTheme( const auto iconFromTheme = QIcon::fromTheme(
base::IconName(), Platform::ApplicationIconName(),
result); result);
result = QIcon(); result = QIcon();