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 "settingspage.hpp"
namespace
{
constexpr const char* toolBarStyle = "QToolBar { border: 0px; } QToolButton { min-width: 70px }";
}
using namespace Process;
void cfgError(const QString& title, const QString& msg)
@ -73,6 +78,7 @@ Launcher::MainDialog::MainDialog(const Files::ConfigurationManager& configuratio
QLabel* logo = new QLabel(this);
logo->setPixmap(QIcon(":/images/openmw-header.png").pixmap(QSize(294, 64)));
toolBar->addWidget(logo);
toolBar->setStyleSheet(toolBarStyle);
}
Launcher::MainDialog::~MainDialog()
@ -81,6 +87,18 @@ Launcher::MainDialog::~MainDialog()
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()
{
if (!QIcon::hasThemeIcon("document-new"))

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

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

Loading…
Cancel
Save