Compare commits
1 Commits
master
...
avoid-depr
Author | SHA1 | Date |
---|---|---|
Martchus | cf857e0d5d |
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <qtforkawesome/icon.h>
|
||||
|
||||
#include <QEvent>
|
||||
#include <QFile>
|
||||
#include <QGuiApplication>
|
||||
#include <QPainter>
|
||||
|
@ -16,6 +17,8 @@
|
|||
#include <QStringBuilder>
|
||||
#include <QSvgRenderer>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#ifndef LIB_SYNCTHING_MODEL_STATIC
|
||||
ENABLE_QT_RESOURCES_OF_STATIC_DEPENDENCIES
|
||||
#endif
|
||||
|
@ -315,17 +318,8 @@ IconManager::IconManager(const QPalette *palette)
|
|||
, m_trayIcons(m_statusIcons)
|
||||
, m_commonForkAwesomeIcons(
|
||||
m_forkAwesomeRenderer, (palette ? *palette : QGuiApplication::palette()).color(QPalette::Normal, QPalette::Text), QSize(64, 64))
|
||||
, m_usesApplicationPalette(palette == nullptr)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
if (!palette) {
|
||||
QObject::connect(qGuiApp, &QGuiApplication::paletteChanged, this, &IconManager::setPalette);
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
}
|
||||
|
||||
void IconManager::setPalette(const QPalette &palette)
|
||||
|
@ -334,6 +328,19 @@ void IconManager::setPalette(const QPalette &palette)
|
|||
m_commonForkAwesomeIcons = ForkAwesomeIcons(m_forkAwesomeRenderer, palette.color(QPalette::Normal, QPalette::Text), QSize(64, 64)));
|
||||
}
|
||||
|
||||
bool IconManager::event(QEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::ApplicationPaletteChange:
|
||||
std::cout << "this is unfortunately never executed" << std::endl;
|
||||
setPalette(QGuiApplication::palette());
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
return QObject::event(event);
|
||||
}
|
||||
|
||||
IconManager &IconManager::instance(const QPalette *palette)
|
||||
{
|
||||
static auto iconManager = IconManager(palette);
|
||||
|
|
|
@ -166,6 +166,9 @@ Q_SIGNALS:
|
|||
void statusIconsChanged(const Data::StatusIcons &newStatusIcons, const Data::StatusIcons &newTrayIcons);
|
||||
void forkAwesomeIconsChanged(const Data::ForkAwesomeIcons &newForkAwesomeIcons);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event) override;
|
||||
|
||||
private:
|
||||
explicit IconManager(const QPalette *palette = nullptr);
|
||||
|
||||
|
@ -173,6 +176,7 @@ private:
|
|||
StatusIcons m_trayIcons;
|
||||
QtForkAwesome::Renderer m_forkAwesomeRenderer;
|
||||
ForkAwesomeIcons m_commonForkAwesomeIcons;
|
||||
bool m_usesApplicationPalette;
|
||||
};
|
||||
|
||||
inline void IconManager::applySettings(const StatusIconSettings *statusIconSettings, const StatusIconSettings *trayIconSettings)
|
||||
|
|
Loading…
Reference in New Issue