mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-10 15:32:48 -07:00
Allow styling with QSS stylesheets
This commit is contained in:
parent
33b225ac6d
commit
a24925c858
10 changed files with 292 additions and 56 deletions
|
@ -175,6 +175,8 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
|||
// Languages supported
|
||||
initializeLanguageCombo();
|
||||
|
||||
initializeThemeCombo();
|
||||
|
||||
// Load week days (scheduler)
|
||||
m_ui->comboBoxScheduleDays->addItems(translatedWeekdayNames());
|
||||
|
||||
|
@ -216,6 +218,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
|||
// Apply button is activated when a value is changed
|
||||
// General tab
|
||||
connect(m_ui->comboI18n, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->comboTheme, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->confirmDeletion, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkAltRowColors, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkHideZero, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
|
@ -493,6 +496,38 @@ 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
|
||||
OptionsDialog::~OptionsDialog()
|
||||
{
|
||||
|
@ -563,6 +598,15 @@ void OptionsDialog::saveOptions()
|
|||
|
||||
// General preferences
|
||||
pref->setLocale(locale);
|
||||
|
||||
if (!m_uiThemeFilePath.isEmpty()
|
||||
&& (m_ui->comboTheme->currentIndex() == 1)) {
|
||||
// only change if current selection is still new m_uiThemeFilePath
|
||||
pref->setCustomUIThemePath(m_uiThemeFilePath);
|
||||
m_uiThemeFilePath.clear();
|
||||
}
|
||||
pref->setUseCustomUITheme(m_ui->comboTheme->currentIndex() == 1);
|
||||
|
||||
pref->setConfirmTorrentDeletion(m_ui->confirmDeletion->isChecked());
|
||||
pref->setAlternatingRowColors(m_ui->checkAltRowColors->isChecked());
|
||||
pref->setHideZeroValues(m_ui->checkHideZero->isChecked());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue