mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-10-22 02:36:15 +03:00
parent
4712eba0dc
commit
063f77bc6c
3 changed files with 26 additions and 20 deletions
|
@ -456,7 +456,10 @@ void OptionsDialog::saveBehaviorTabOptions() const
|
|||
pref->setLocale(locale);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
pref->setStyle(m_ui->comboStyle->currentText());
|
||||
if (const QVariant systemStyle = m_ui->comboStyle->currentData(); systemStyle.isValid())
|
||||
pref->setStyle(systemStyle.toString());
|
||||
else
|
||||
pref->setStyle(m_ui->comboStyle->currentText());
|
||||
#endif
|
||||
|
||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
|
||||
|
@ -1691,18 +1694,27 @@ bool OptionsDialog::isSplashScreenDisabled() const
|
|||
void OptionsDialog::initializeStyleCombo()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
m_ui->labelStyleHint->setText(tr("%1 is recommended for best compatibility with Windows dark mode"
|
||||
, "Fusion is recommended for best compatibility with Windows dark mode").arg(u"Fusion"_s));
|
||||
m_ui->comboStyle->addItem(tr("System", "System default Qt style"), u"system"_s);
|
||||
m_ui->comboStyle->setItemData(0, tr("Let Qt decide the style for this system"), Qt::ToolTipRole);
|
||||
m_ui->comboStyle->insertSeparator(1);
|
||||
|
||||
QStringList styleNames = QStyleFactory::keys();
|
||||
std::sort(styleNames.begin(), styleNames.end(), Utils::Compare::NaturalLessThan<Qt::CaseInsensitive>());
|
||||
m_ui->comboStyle->addItems(styleNames);
|
||||
const QString prefStyleName = Preferences::instance()->getStyle();
|
||||
const QString selectedStyleName = prefStyleName.isEmpty() ? QApplication::style()->name() : prefStyleName;
|
||||
m_ui->comboStyle->setCurrentText(selectedStyleName);
|
||||
|
||||
if (selectedStyleName.compare(u"system"_s, Qt::CaseInsensitive) != 0)
|
||||
m_ui->comboStyle->setCurrentText(selectedStyleName);
|
||||
#else
|
||||
m_ui->labelStyle->hide();
|
||||
m_ui->comboStyle->hide();
|
||||
m_ui->labelStyleHint->hide();
|
||||
m_ui->UISettingsBoxLayout->removeWidget(m_ui->labelStyle);
|
||||
m_ui->UISettingsBoxLayout->removeWidget(m_ui->comboStyle);
|
||||
m_ui->UISettingsBoxLayout->removeItem(m_ui->spacerStyle);
|
||||
m_ui->UISettingsBoxLayout->removeWidget(m_ui->labelStyleHint);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -179,17 +179,13 @@
|
|||
<widget class="QComboBox" name="comboStyle"/>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<spacer name="spacerStyle">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
<widget class="QLabel" name="labelStyleHint">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="checkUseCustomTheme">
|
||||
|
|
|
@ -37,10 +37,6 @@
|
|||
#include <QStyle>
|
||||
#include <QStyleHints>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <QOperatingSystemVersion>
|
||||
#endif
|
||||
|
||||
#include "base/global.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/path.h"
|
||||
|
@ -85,9 +81,11 @@ UIThemeManager::UIThemeManager()
|
|||
#endif
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
const QString defaultStyle = (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10) ? u"Fusion"_s : QString();
|
||||
if (const QString styleName = Preferences::instance()->getStyle(); !QApplication::setStyle(styleName.isEmpty() ? defaultStyle : styleName))
|
||||
LogMsg(tr("Set app style failed. Unknown style: \"%1\"").arg(styleName), Log::WARNING);
|
||||
if (const QString styleName = Preferences::instance()->getStyle(); styleName.compare(u"system", Qt::CaseInsensitive) != 0)
|
||||
{
|
||||
if (!QApplication::setStyle(styleName.isEmpty() ? u"Fusion"_s : styleName))
|
||||
LogMsg(tr("Set app style failed. Unknown style: \"%1\"").arg(styleName), Log::WARNING);
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE: Qt::QueuedConnection can be omitted as soon as support for Qt 6.5 is dropped
|
||||
|
|
Loading…
Reference in a new issue