enable dark for additional styles

This commit is contained in:
Martin Rotter 2021-11-12 09:17:31 +01:00
parent f460e38336
commit 9aad7e8789
3 changed files with 8 additions and 2 deletions

View file

@ -36,7 +36,7 @@ SettingsGui::SettingsGui(Settings* settings, QWidget* parent) : SettingsPanel(se
m_ui->m_treeSkins->header()->setSectionResizeMode(2, QHeaderView::ResizeMode::ResizeToContents);
connect(m_ui->m_cmbStyles, &QComboBox::currentTextChanged, this, [this](const QString& txt) {
m_ui->m_checkForceDarkFusion->setVisible(txt.toLower() == QSL("fusion"));
m_ui->m_checkForceDarkFusion->setVisible(qApp->skins()->isStyleGoodForDarkVariant(txt));
});
connect(m_ui->m_cmbIconTheme, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &SettingsGui::requireRestart);

View file

@ -42,6 +42,10 @@ void SkinFactory::loadCurrentSkin() {
qCriticalNN << LOGSEC_GUI << "Failed to load selected or default skin. Quitting!";
}
bool SkinFactory::isStyleGoodForDarkVariant(const QString& style_name) const {
return QRegularExpression("^(fusion)|(qt5ct-style)$").match(style_name.toLower()).hasMatch();
}
void SkinFactory::loadSkinFromData(const Skin& skin) {
if (!skin.m_rawData.isEmpty()) {
if (qApp->styleSheet().simplified().isEmpty()) {
@ -57,7 +61,7 @@ void SkinFactory::loadSkinFromData(const Skin& skin) {
qApp->setStyle(style_name);
if (style_name.toLower() == QSL("fusion") &&
if (isStyleGoodForDarkVariant(style_name) &&
qApp->settings()->value(GROUP(GUI), SETTING(GUI::ForceDarkFusion)).toBool()) {
qDebugNN << LOGSEC_GUI << "Activating dark palette for Fusion style.";

View file

@ -45,6 +45,8 @@ class RSSGUARD_DLLSPEC SkinFactory : public QObject {
void loadCurrentSkin();
Skin currentSkin() const;
bool isStyleGoodForDarkVariant(const QString& style_name) const;
// Returns the name of the skin, that should be activated
// after application restart.
QString selectedSkinName() const;