Skip to content

Commit

Permalink
Set default palette of QuickImageProvider explicitly
Browse files Browse the repository at this point in the history
So it doesn't has to fallback to querying the color from the app palette
for every single icon we need to render.
  • Loading branch information
Martchus committed Jan 17, 2025
1 parent 2e38fd0 commit 1cc4d9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tray/gui/quick/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ static void handleAndroidIntent(JNIEnv *, jobject, jstring page, jboolean fromNo
App::App(bool insecure, QObject *parent)
: QObject(parent)
, m_app(static_cast<QGuiApplication *>(QCoreApplication::instance()))
, m_imageProvider(nullptr)
, m_notifier(m_connection)
, m_dirModel(m_connection)
, m_sortFilterDirModel(&m_dirModel)
Expand Down Expand Up @@ -181,7 +182,7 @@ App::App(bool insecure, QObject *parent)
Qt::QueuedConnection);
connect(&m_engine, &QQmlApplicationEngine::quit, m_app, &QGuiApplication::quit);
m_engine.setProperty("app", QVariant::fromValue(this));
m_engine.addImageProvider(QStringLiteral("fa"), new QtForkAwesome::QuickImageProvider(iconManager.forkAwesomeRenderer()));
m_engine.addImageProvider(QStringLiteral("fa"), m_imageProvider = new QtForkAwesome::QuickImageProvider(iconManager.forkAwesomeRenderer()));

#ifdef Q_OS_ANDROID
// register native methods of Android activity
Expand Down Expand Up @@ -539,6 +540,9 @@ bool App::eventFilter(QObject *object, QEvent *event)
}
switch (event->type()) {
case QEvent::ApplicationPaletteChange:
if (m_app && m_imageProvider) {
m_imageProvider->setDefaultColor(m_app->palette().color(QPalette::Normal, QPalette::Text));
}
qDebug() << "Application palette has changed";
applyDarkmodeChange(m_darkColorScheme, QtUtilities::isPaletteDark());
break;
Expand Down
5 changes: 5 additions & 0 deletions tray/gui/quick/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@

QT_FORWARD_DECLARE_CLASS(QTextDocument)

namespace QtForkAwesome {
class QuickImageProvider;
}

namespace QtGui {

class App : public QObject {
Expand Down Expand Up @@ -303,6 +307,7 @@ private Q_SLOTS:

QQmlApplicationEngine m_engine;
QGuiApplication *m_app;
QtForkAwesome::QuickImageProvider *m_imageProvider;
Data::SyncthingConnection m_connection;
Data::SyncthingNotifier m_notifier;
Data::SyncthingDirectoryModel m_dirModel;
Expand Down

0 comments on commit 1cc4d9b

Please sign in to comment.