Update toolbar style sheet when theme changed

i-have-no-land-and-i-must-scream
Andrei Kortunov 8 months ago
parent d5bbd75828
commit 0262b33067

@ -22,6 +22,11 @@
#include "importpage.hpp" #include "importpage.hpp"
#include "settingspage.hpp" #include "settingspage.hpp"
namespace
{
constexpr const char* toolBarStyle = "QToolBar { border: 0px; } QToolButton { min-width: 70px }";
}
using namespace Process; using namespace Process;
void cfgError(const QString& title, const QString& msg) void cfgError(const QString& title, const QString& msg)
@ -73,6 +78,7 @@ Launcher::MainDialog::MainDialog(const Files::ConfigurationManager& configuratio
QLabel* logo = new QLabel(this); QLabel* logo = new QLabel(this);
logo->setPixmap(QIcon(":/images/openmw-header.png").pixmap(QSize(294, 64))); logo->setPixmap(QIcon(":/images/openmw-header.png").pixmap(QSize(294, 64)));
toolBar->addWidget(logo); toolBar->addWidget(logo);
toolBar->setStyleSheet(toolBarStyle);
} }
Launcher::MainDialog::~MainDialog() Launcher::MainDialog::~MainDialog()
@ -81,6 +87,18 @@ Launcher::MainDialog::~MainDialog()
delete mWizardInvoker; delete mWizardInvoker;
} }
bool Launcher::MainDialog::event(QEvent* event)
{
// Apply style sheet again if style was changed
if (event->type() == QEvent::ThemeChange || event->type() == QEvent::PaletteChange)
{
if (toolBar != nullptr)
toolBar->setStyleSheet(toolBarStyle);
}
return QMainWindow::event(event);
}
void Launcher::MainDialog::createIcons() void Launcher::MainDialog::createIcons()
{ {
if (!QIcon::hasThemeIcon("document-new")) if (!QIcon::hasThemeIcon("document-new"))

@ -60,6 +60,9 @@ namespace Launcher
void play(); void play();
void help(); void help();
protected:
bool event(QEvent* event) override;
private slots: private slots:
void wizardStarted(); void wizardStarted();
void wizardFinished(int exitCode, QProcess::ExitStatus exitStatus); void wizardFinished(int exitCode, QProcess::ExitStatus exitStatus);

@ -75,16 +75,6 @@
<property name="layoutDirection"> <property name="layoutDirection">
<enum>Qt::LeftToRight</enum> <enum>Qt::LeftToRight</enum>
</property> </property>
<property name="styleSheet">
<string notr="true">QToolBar {
border: 0px;
}
QToolButton {
min-width: 70px;
}
</string>
</property>
<property name="movable"> <property name="movable">
<bool>false</bool> <bool>false</bool>
</property> </property>

Loading…
Cancel
Save