Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/app/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ Application::Application(int &argc, char **argv, bool haltOnParseError)

// Initialize theme.
mTheme.reset(Theme::create(parser.value("theme")));
setStyle(mTheme->style());
setStyleSheet(mTheme->styleSheet());
applyTheme();

#if defined(Q_OS_WIN)
// Set default font style and hinting.
Expand Down Expand Up @@ -488,4 +487,9 @@ void Application::handleSslErrors(QNetworkReply *reply,
reply->ignoreSslErrors(errors);
settings.setValue("ssl/ignore", true);
}
}
}

void Application::applyTheme() {
setStyle(mTheme->style());
setStyleSheet(mTheme->styleSheet());
}
1 change: 1 addition & 0 deletions src/app/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Application : public QApplication {
void autoUpdate();
bool restoreWindows();
bool runSingleInstance();
void applyTheme();

static bool isInTest();
static void setInTest();
Expand Down
11 changes: 11 additions & 0 deletions src/ui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "git/Repository.h"
#include "git/Config.h"
#include "git/Submodule.h"
#include "app/Application.h"
#include <QApplication>
#include <QCloseEvent>
#include <QGuiApplication>
Expand Down Expand Up @@ -589,3 +590,13 @@ QString MainWindow::windowGroup() const {
QByteArray hash = QCryptographicHash::hash(group, QCryptographicHash::Md5);
return QString::fromUtf8(hash.toHex());
}

void MainWindow::changeEvent(QEvent *e) {
if (e->type() == QEvent::PaletteChange) {
Application *app = qobject_cast<Application *>(QApplication::instance());
if (app)
app->applyTheme();
}

QMainWindow::changeEvent(e);
}
1 change: 1 addition & 0 deletions src/ui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class MainWindow : public QMainWindow {
void closeEvent(QCloseEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
void changeEvent(QEvent *event) override;

private:
void updateTabNames();
Expand Down