Browse Source

Merge pull request #11088 from jagannatharjun/organize-style

Reorganize UI theme selection
adaptive-webui-19844
Vladimir Golovnev 5 years ago committed by GitHub
parent
commit
75ebd54ea3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/gui/advancedsettings.cpp
  2. 4
      src/gui/advancedsettings.h
  3. 63
      src/gui/optionsdialog.cpp
  4. 2
      src/gui/optionsdialog.h
  5. 86
      src/gui/optionsdialog.ui

12
src/gui/advancedsettings.cpp

@ -82,10 +82,6 @@ enum AdvSettingsRows
DOWNLOAD_TRACKER_FAVICON, DOWNLOAD_TRACKER_FAVICON,
SAVE_PATH_HISTORY_LENGTH, SAVE_PATH_HISTORY_LENGTH,
ENABLE_SPEED_WIDGET, ENABLE_SPEED_WIDGET,
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
USE_ICON_THEME,
#endif
// libtorrent section // libtorrent section
LIBTORRENT_HEADER, LIBTORRENT_HEADER,
ASYNC_IO_THREADS, ASYNC_IO_THREADS,
@ -261,10 +257,6 @@ void AdvancedSettings::saveAdvancedSettings()
// Seed choking algorithm // Seed choking algorithm
session->setSeedChokingAlgorithm(static_cast<BitTorrent::SeedChokingAlgorithm>(m_comboBoxSeedChokingAlgorithm.currentIndex())); session->setSeedChokingAlgorithm(static_cast<BitTorrent::SeedChokingAlgorithm>(m_comboBoxSeedChokingAlgorithm.currentIndex()));
// Icon theme
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
pref->useSystemIconTheme(m_checkBoxUseIconTheme.isChecked());
#endif
pref->setConfirmTorrentRecheck(m_checkBoxConfirmTorrentRecheck.isChecked()); pref->setConfirmTorrentRecheck(m_checkBoxConfirmTorrentRecheck.isChecked());
pref->setConfirmRemoveAllTags(m_checkBoxConfirmRemoveAllTags.isChecked()); pref->setConfirmRemoveAllTags(m_checkBoxConfirmRemoveAllTags.isChecked());
@ -579,10 +571,6 @@ void AdvancedSettings::loadAdvancedSettings()
addRow(SEED_CHOKING_ALGORITHM, (tr("Upload choking algorithm") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#seed_choking_algorithm", "(?)")) addRow(SEED_CHOKING_ALGORITHM, (tr("Upload choking algorithm") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#seed_choking_algorithm", "(?)"))
, &m_comboBoxSeedChokingAlgorithm); , &m_comboBoxSeedChokingAlgorithm);
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
m_checkBoxUseIconTheme.setChecked(pref->useSystemIconTheme());
addRow(USE_ICON_THEME, tr("Use system icon theme"), &m_checkBoxUseIconTheme);
#endif
// Torrent recheck confirmation // Torrent recheck confirmation
m_checkBoxConfirmTorrentRecheck.setChecked(pref->confirmTorrentRecheck()); m_checkBoxConfirmTorrentRecheck.setChecked(pref->confirmTorrentRecheck());
addRow(CONFIRM_RECHECK_TORRENT, tr("Confirm torrent recheck"), &m_checkBoxConfirmTorrentRecheck); addRow(CONFIRM_RECHECK_TORRENT, tr("Confirm torrent recheck"), &m_checkBoxConfirmTorrentRecheck);

4
src/gui/advancedsettings.h

@ -69,9 +69,7 @@ private:
QLineEdit m_lineEditAnnounceIP; QLineEdit m_lineEditAnnounceIP;
// OS dependent settings // OS dependent settings
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) #if defined(Q_OS_WIN)
QCheckBox m_checkBoxUseIconTheme;
#elif defined(Q_OS_WIN)
QComboBox m_comboBoxOSMemoryPriority; QComboBox m_comboBoxOSMemoryPriority;
#endif #endif
}; };

63
src/gui/optionsdialog.cpp

@ -175,7 +175,17 @@ OptionsDialog::OptionsDialog(QWidget *parent)
// Languages supported // Languages supported
initializeLanguageCombo(); initializeLanguageCombo();
initializeThemeCombo(); m_ui->checkUseCustomTheme->setChecked(Preferences::instance()->useCustomUITheme());
m_ui->customThemeFilePath->setSelectedPath(Preferences::instance()->customUIThemePath());
m_ui->customThemeFilePath->setMode(FileSystemPathEdit::Mode::FileOpen);
m_ui->customThemeFilePath->setDialogCaption(tr("Select qBittorrent UI Theme file"));
m_ui->customThemeFilePath->setFileNameFilter(tr("qBittorrent UI Theme file (*.qbtheme)"));
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
m_ui->checkUseSystemIcon->setChecked(Preferences::instance()->useSystemIconTheme());
#else
m_ui->checkUseSystemIcon->setVisible(false);
#endif
// Load week days (scheduler) // Load week days (scheduler)
m_ui->comboBoxScheduleDays->addItems(translatedWeekdayNames()); m_ui->comboBoxScheduleDays->addItems(translatedWeekdayNames());
@ -218,7 +228,11 @@ OptionsDialog::OptionsDialog(QWidget *parent)
// Apply button is activated when a value is changed // Apply button is activated when a value is changed
// Behavior tab // Behavior tab
connect(m_ui->comboI18n, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton); connect(m_ui->comboI18n, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
connect(m_ui->comboTheme, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton); connect(m_ui->checkUseCustomTheme, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->customThemeFilePath, &FileSystemPathEdit::selectedPathChanged, this, &ThisType::enableApplyButton);
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
connect(m_ui->checkUseSystemIcon, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
#endif
connect(m_ui->confirmDeletion, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->confirmDeletion, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkAltRowColors, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkAltRowColors, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkHideZero, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkHideZero, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
@ -499,38 +513,6 @@ void OptionsDialog::initializeLanguageCombo()
} }
} }
void OptionsDialog::initializeThemeCombo()
{
m_ui->comboTheme->addItem(tr("Default"));
const QString customUIThemePath = Preferences::instance()->customUIThemePath();
if (!customUIThemePath.isEmpty())
m_ui->comboTheme->addItem(Utils::Fs::toNativePath(customUIThemePath));
m_ui->comboTheme->insertSeparator(m_ui->comboTheme->count());
m_ui->comboTheme->addItem(tr("Select..."));
m_ui->comboTheme->setCurrentIndex(Preferences::instance()->useCustomUITheme() ? 1 : 0);
connect(m_ui->comboTheme, qOverload<int>(&QComboBox::currentIndexChanged), this, [this](const int index)
{
if (index != (m_ui->comboTheme->count() - 1))
return;
m_uiThemeFilePath = QFileDialog::getOpenFileName(this, tr("Select qBittorrent theme file"), {}, tr("qBittorrent Theme File (*.qbtheme)"));
m_ui->comboTheme->blockSignals(true);
if (!m_uiThemeFilePath.isEmpty()) {
if (m_ui->comboTheme->count() == 3)
m_ui->comboTheme->insertItem(1, Utils::Fs::toNativePath(m_uiThemeFilePath));
else
m_ui->comboTheme->setItemText(1, Utils::Fs::toNativePath(m_uiThemeFilePath));
m_ui->comboTheme->setCurrentIndex(1);
}
else {
// don't leave "Select..." as current text
m_ui->comboTheme->setCurrentIndex(Preferences::instance()->useCustomUITheme() ? 1 : 0);
}
m_ui->comboTheme->blockSignals(false);
});
}
// Main destructor // Main destructor
OptionsDialog::~OptionsDialog() OptionsDialog::~OptionsDialog()
{ {
@ -602,13 +584,12 @@ void OptionsDialog::saveOptions()
// Behavior preferences // Behavior preferences
pref->setLocale(locale); pref->setLocale(locale);
if (!m_uiThemeFilePath.isEmpty() pref->setUseCustomUITheme(m_ui->checkUseCustomTheme->isChecked());
&& (m_ui->comboTheme->currentIndex() == 1)) { pref->setCustomUIThemePath(m_ui->customThemeFilePath->selectedPath());
// only change if current selection is still new m_uiThemeFilePath
pref->setCustomUIThemePath(m_uiThemeFilePath); #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
m_uiThemeFilePath.clear(); pref->useSystemIconTheme(m_ui->checkUseSystemIcon->isChecked());
} #endif
pref->setUseCustomUITheme(m_ui->comboTheme->currentIndex() == 1);
pref->setConfirmTorrentDeletion(m_ui->confirmDeletion->isChecked()); pref->setConfirmTorrentDeletion(m_ui->confirmDeletion->isChecked());
pref->setAlternatingRowColors(m_ui->checkAltRowColors->isChecked()); pref->setAlternatingRowColors(m_ui->checkAltRowColors->isChecked());

2
src/gui/optionsdialog.h

@ -117,7 +117,6 @@ private:
void saveOptions(); void saveOptions();
void loadOptions(); void loadOptions();
void initializeLanguageCombo(); void initializeLanguageCombo();
void initializeThemeCombo();
static QString languageToLocalizedString(const QLocale &locale); static QString languageToLocalizedString(const QLocale &locale);
// General options // General options
QString getLocale() const; QString getLocale() const;
@ -184,7 +183,6 @@ private:
AdvancedSettings *m_advancedSettings; AdvancedSettings *m_advancedSettings;
QList<QString> m_addedScanDirs; QList<QString> m_addedScanDirs;
QList<QString> m_removedScanDirs; QList<QString> m_removedScanDirs;
QString m_uiThemeFilePath;
}; };
#endif // OPTIONSDIALOG_H #endif // OPTIONSDIALOG_H

86
src/gui/optionsdialog.ui

@ -133,45 +133,29 @@
<string>Interface</string> <string>Interface</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_81"> <layout class="QGridLayout" name="gridLayout_81">
<item row="0" column="0"> <item row="3" column="0" colspan="3">
<widget class="QLabel" name="label_9"> <widget class="QGroupBox" name="checkUseCustomTheme">
<property name="text"> <property name="title">
<string>Language:</string> <string>Use custom UI Theme</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboI18n">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property> </property>
<property name="sizeAdjustPolicy"> <property name="checkable">
<enum>QComboBox::AdjustToContents</enum> <bool>true</bool>
</property> </property>
<property name="modelColumn"> <layout class="QHBoxLayout" name="horizontalLayout_18">
<number>0</number> <item>
<widget class="QLabel" name="label_16">
<property name="text">
<string>UI Theme file:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item>
<widget class="QLabel" name="lbl_i18n_info_2"> <widget class="FileSystemPathLineEdit" name="customThemeFilePath" native="true"/>
<property name="font"> </item>
<font> </layout>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>(Requires restart)</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="3"> <item row="1" column="2">
<spacer name="horizontalSpacer_111"> <spacer name="horizontalSpacer_111">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -185,27 +169,44 @@
</spacer> </spacer>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_15"> <widget class="QLabel" name="label_9">
<property name="text">
<string>Language:</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="checkUseSystemIcon">
<property name="text"> <property name="text">
<string>Theme:</string> <string>Use system icon theme</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QComboBox" name="comboTheme"/> <widget class="QComboBox" name="comboI18n">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<property name="modelColumn">
<number>0</number>
</property>
</widget>
</item> </item>
<item row="1" column="2"> <item row="0" column="0" colspan="2">
<widget class="QLabel" name="lbl_i18n_info_3"> <widget class="QLabel" name="label_15">
<property name="font"> <property name="font">
<font> <font>
<italic>true</italic> <italic>true</italic>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
<string>(Requires restart)</string> <string>Changing Interface settings requires application restart</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
@ -3258,6 +3259,9 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
<tabstops> <tabstops>
<tabstop>tabOption</tabstop> <tabstop>tabOption</tabstop>
<tabstop>comboI18n</tabstop> <tabstop>comboI18n</tabstop>
<tabstop>checkUseSystemIcon</tabstop>
<tabstop>checkUseCustomTheme</tabstop>
<tabstop>customThemeFilePath</tabstop>
<tabstop>checkStartPaused</tabstop> <tabstop>checkStartPaused</tabstop>
<tabstop>spinPort</tabstop> <tabstop>spinPort</tabstop>
<tabstop>checkUPnP</tabstop> <tabstop>checkUPnP</tabstop>

Loading…
Cancel
Save