mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
fix: taskbar app icon change after unpinning
This commit is contained in:
@@ -19,7 +19,11 @@ static QImage LAST_LOADED_PAD;
|
|||||||
namespace AyuAssets {
|
namespace AyuAssets {
|
||||||
|
|
||||||
QString appIcoPath() {
|
QString appIcoPath() {
|
||||||
return cWorkingDir() + u"tdata/AyuGram.ico"_q;
|
const auto &settings = AyuSettings::getInstance();
|
||||||
|
return cWorkingDir()
|
||||||
|
+ u"tdata/AyuGram-"_q
|
||||||
|
+ settings.appIcon()
|
||||||
|
+ u".ico"_q;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadAppIco() {
|
void loadAppIco() {
|
||||||
|
|||||||
@@ -139,16 +139,21 @@ void processNewShortcuts(const QString &iconPath) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto shortcut = path + u"AyuGram Desktop/AyuGram.lnk"_q;
|
const auto shortcuts = {
|
||||||
const auto native = QDir::toNativeSeparators(path).toStdWString();
|
path + u"AyuGram Desktop/AyuGram.lnk"_q,
|
||||||
|
path + u"AyuGram/AyuGram.lnk"_q,
|
||||||
|
path + u"AyuGram.lnk"_q,
|
||||||
|
};
|
||||||
|
for (const auto &shortcut : shortcuts) {
|
||||||
|
const auto native = QDir::toNativeSeparators(shortcut).toStdWString();
|
||||||
|
|
||||||
DWORD attributes = GetFileAttributes(native.c_str());
|
DWORD attributes = GetFileAttributes(native.c_str());
|
||||||
if (attributes >= 0xFFFFFFF) {
|
if (attributes >= 0xFFFFFFF) {
|
||||||
return; // file does not exist
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
processIcon(QString::fromStdWString(native), iconPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto normalizedPath = QString::fromStdWString(native);
|
|
||||||
processIcon(normalizedPath, iconPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reloadAppIconFromTaskBar() {
|
void reloadAppIconFromTaskBar() {
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
|
|
||||||
// AyuGram includes
|
// AyuGram includes
|
||||||
#include "ayu/ayu_settings.h"
|
#include "ayu/ayu_settings.h"
|
||||||
|
#include "ayu/ui/ayu_logo.h"
|
||||||
|
#include "platform/win/windows_app_user_model_id.h"
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <propkey.h>
|
||||||
|
#include <propvarutil.h>
|
||||||
|
|
||||||
|
|
||||||
// Taken from qtbase/src/gui/image/qpixmap_win.cpp
|
// Taken from qtbase/src/gui/image/qpixmap_win.cpp
|
||||||
@@ -108,6 +113,35 @@ private:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateTaskbarRelaunchIcon(HWND hWnd) {
|
||||||
|
auto propertyStore = ComPtr<IPropertyStore>();
|
||||||
|
auto hr = SHGetPropertyStoreForWindow(
|
||||||
|
hWnd,
|
||||||
|
IID_PPV_ARGS(&propertyStore));
|
||||||
|
if (!SUCCEEDED(hr)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto setString = [&](
|
||||||
|
const PROPERTYKEY &key,
|
||||||
|
const std::wstring &value) {
|
||||||
|
auto prop = PROPVARIANT();
|
||||||
|
hr = InitPropVariantFromString(value.c_str(), &prop);
|
||||||
|
if (!SUCCEEDED(hr)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hr = propertyStore->SetValue(key, prop);
|
||||||
|
PropVariantClear(&prop);
|
||||||
|
};
|
||||||
|
|
||||||
|
setString(AppUserModelId::Key(), AppUserModelId::Id());
|
||||||
|
setString(
|
||||||
|
PKEY_AppUserModel_RelaunchIconResource,
|
||||||
|
QDir::toNativeSeparators(AyuAssets::appIcoPath()).toStdWString()
|
||||||
|
+ L",0");
|
||||||
|
propertyStore->Commit();
|
||||||
|
}
|
||||||
|
|
||||||
struct RealSize {
|
struct RealSize {
|
||||||
QSize value;
|
QSize value;
|
||||||
bool maximized = false;
|
bool maximized = false;
|
||||||
@@ -616,6 +650,7 @@ void MainWindow::updateTaskbarAndIconCounters() {
|
|||||||
GetSystemMetrics(SM_CXICON),
|
GetSystemMetrics(SM_CXICON),
|
||||||
GetSystemMetrics(SM_CYICON));
|
GetSystemMetrics(SM_CYICON));
|
||||||
const auto supportMode = session && session->supportMode();
|
const auto supportMode = session && session->supportMode();
|
||||||
|
UpdateTaskbarRelaunchIcon(_hWnd);
|
||||||
|
|
||||||
auto iconSmallPixmap16 = Tray::IconWithCounter(
|
auto iconSmallPixmap16 = Tray::IconWithCounter(
|
||||||
Tray::CounterLayerArgs(16, counter, muted),
|
Tray::CounterLayerArgs(16, counter, muted),
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ bool DarkTasbarValueValid/* = false*/;
|
|||||||
static auto lastUsedIcon = AyuAssets::currentAppLogoName();
|
static auto lastUsedIcon = AyuAssets::currentAppLogoName();
|
||||||
|
|
||||||
if (lastUsedIcon != AyuAssets::currentAppLogoName()) {
|
if (lastUsedIcon != AyuAssets::currentAppLogoName()) {
|
||||||
|
lastUsedIcon = AyuAssets::currentAppLogoName();
|
||||||
ScaledLogo = base::flat_map<int, QImage>();
|
ScaledLogo = base::flat_map<int, QImage>();
|
||||||
ScaledLogoNoMargin = base::flat_map<int, QImage>();
|
ScaledLogoNoMargin = base::flat_map<int, QImage>();
|
||||||
ScaledLogoDark = base::flat_map<int, QImage>();
|
ScaledLogoDark = base::flat_map<int, QImage>();
|
||||||
|
|||||||
Reference in New Issue
Block a user