more robust current style detection, particularly when overriden
This commit is contained in:
parent
45751381ec
commit
fe30af4cdd
@ -202,8 +202,7 @@ void SettingsGui::loadSettings() {
|
||||
m_ui->m_cmbStyles->addItem(style_name);
|
||||
}
|
||||
|
||||
int item_style = m_ui->m_cmbStyles->findText(settings()->value(GROUP(GUI), SETTING(GUI::Style)).toString(),
|
||||
Qt::MatchFlag::MatchFixedString);
|
||||
int item_style = m_ui->m_cmbStyles->findText(qApp->skins()->currentStyle(), Qt::MatchFlag::MatchFixedString);
|
||||
|
||||
if (item_style >= 0) {
|
||||
m_ui->m_cmbStyles->setCurrentIndex(item_style);
|
||||
@ -368,7 +367,7 @@ void SettingsGui::saveSettings() {
|
||||
}
|
||||
|
||||
// Set new style.
|
||||
if (m_ui->m_cmbStyles->currentIndex() >= 0) {
|
||||
if (m_ui->m_cmbStyles->currentIndex() >= 0 && m_ui->m_cmbStyles->isEnabled()) {
|
||||
const QString new_style = m_ui->m_cmbStyles->currentText();
|
||||
const QString old_style = qApp->settings()->value(GROUP(GUI), SETTING(GUI::Style)).toString();
|
||||
|
||||
|
@ -65,16 +65,13 @@ void SkinFactory::loadSkinFromData(const Skin& skin) {
|
||||
qWarningNN << LOGSEC_GUI << "Respecting forced style(s):\n"
|
||||
<< " QT_STYLE_OVERRIDE: " QUOTE_NO_SPACE(env_forced_style) << "\n"
|
||||
<< " CLI (-style): " QUOTE_NO_SPACE(cli_forced_style);
|
||||
|
||||
if (!cli_forced_style.isEmpty()) {
|
||||
style_name = cli_forced_style;
|
||||
}
|
||||
else if (!env_forced_style.isEmpty()) {
|
||||
style_name = env_forced_style;
|
||||
}
|
||||
}
|
||||
|
||||
if (isStyleGoodForDarkVariant(style_name) &&
|
||||
// NOTE: We can do this because in Qt source code
|
||||
// they specifically set object name to style name.
|
||||
m_currentStyle = qApp->style()->objectName();
|
||||
|
||||
if (isStyleGoodForDarkVariant(m_currentStyle) &&
|
||||
qApp->settings()->value(GROUP(GUI), SETTING(GUI::ForceDarkFusion)).toBool()) {
|
||||
qDebugNN << LOGSEC_GUI << "Activating dark palette for Fusion style.";
|
||||
|
||||
@ -342,6 +339,10 @@ QString SkinFactory::loadSkinFile(const QString& skin_folder, const QString& fil
|
||||
}
|
||||
}
|
||||
|
||||
QString SkinFactory::currentStyle() const {
|
||||
return m_currentStyle;
|
||||
}
|
||||
|
||||
bool SkinFactory::styleIsFrozen() const {
|
||||
return m_styleIsFrozen;
|
||||
}
|
||||
|
@ -89,6 +89,8 @@ class RSSGUARD_DLLSPEC SkinFactory : public QObject {
|
||||
|
||||
bool styleIsFrozen() const;
|
||||
|
||||
QString currentStyle() const;
|
||||
|
||||
private:
|
||||
|
||||
// Loads the skin from given skin_data.
|
||||
@ -98,6 +100,7 @@ class RSSGUARD_DLLSPEC SkinFactory : public QObject {
|
||||
|
||||
// Holds name of the current skin.
|
||||
Skin m_currentSkin;
|
||||
QString m_currentStyle;
|
||||
bool m_styleIsFrozen;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user