Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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
12 changes: 12 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,14 @@ QString MainWindow::windowGroup() const {
QByteArray hash = QCryptographicHash::hash(group, QCryptographicHash::Md5);
return QString::fromUtf8(hash.toHex());
}

void MainWindow::changeEvent(QEvent *e) {
#ifdef Q_OS_MACX
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a headsup, there are tools that replicate this macOS function on Windows etc.

(I don’t know QT, so not sure if this triggers the same event or if it even supports it, so feel free to disregard this.)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes maybe we can use it also for windows and linux

if (e->type() == QEvent::PaletteChange) {
Application *app = qobject_cast<Application *>(QApplication::instance());
if (app)
app->applyTheme();
}
#endif
QMainWindow::changeEvent(e);
}
Comment thread
0verEngineer marked this conversation as resolved.
Outdated
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