Improve startup window state handling

Replace current "Start qBittorrent minimized" option with "Initial window state" that allows to start qBittorrent as "hidden in system tray" while retaining regular "minimize to panel" functionality.

PR #18252.
Closes #487.
This commit is contained in:
Vladimir Golovnev 2023-01-16 14:57:56 +03:00 committed by GitHub
parent 0d376e7fd6
commit 32e4371208
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 151 additions and 59 deletions

View file

@ -249,10 +249,16 @@ void OptionsDialog::loadBehaviorTabOptions()
m_ui->checkStartup->setVisible(false);
#endif
m_ui->checkShowSplash->setChecked(!pref->isSplashScreenDisabled());
m_ui->checkStartMinimized->setChecked(pref->startMinimized());
m_ui->checkProgramExitConfirm->setChecked(pref->confirmOnExit());
m_ui->checkProgramAutoExitConfirm->setChecked(!pref->dontConfirmAutoExit());
m_ui->windowStateComboBox->addItem(tr("Normal"), QVariant::fromValue(WindowState::Normal));
m_ui->windowStateComboBox->addItem(tr("Minimized"), QVariant::fromValue(WindowState::Minimized));
#ifndef Q_OS_MACOS
m_ui->windowStateComboBox->addItem(tr("Hidden"), QVariant::fromValue(WindowState::Hidden));
#endif
m_ui->windowStateComboBox->setCurrentIndex(m_ui->windowStateComboBox->findData(QVariant::fromValue(app()->startUpWindowState())));
#if !(defined(Q_OS_WIN) || defined(Q_OS_MACOS))
m_ui->groupFileAssociation->setVisible(false);
m_ui->checkProgramUpdates->setVisible(false);
@ -330,13 +336,13 @@ void OptionsDialog::loadBehaviorTabOptions()
connect(m_ui->checkStartup, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
#endif
connect(m_ui->checkShowSplash, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkStartMinimized, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkProgramExitConfirm, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkProgramAutoExitConfirm, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkShowSystray, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkMinimizeToSysTray, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkCloseToSystray, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->comboTrayIcon, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
connect(m_ui->windowStateComboBox, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
connect(m_ui->checkPreventFromSuspendWhenDownloading, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkPreventFromSuspendWhenSeeding, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
@ -399,7 +405,6 @@ void OptionsDialog::saveBehaviorTabOptions() const
pref->setActionOnDblClOnTorrentFn(m_ui->actionTorrentFnOnDblClBox->currentData().toInt());
pref->setSplashScreenDisabled(isSplashScreenDisabled());
pref->setStartMinimized(startMinimized());
pref->setConfirmOnExit(m_ui->checkProgramExitConfirm->isChecked());
pref->setDontConfirmAutoExit(!m_ui->checkProgramAutoExitConfirm->isChecked());
@ -447,6 +452,8 @@ void OptionsDialog::saveBehaviorTabOptions() const
app()->setFileLoggerDeleteOld(m_ui->checkFileLogDelete->isChecked());
app()->setFileLoggerEnabled(m_ui->checkFileLog->isChecked());
app()->setStartUpWindowState(m_ui->windowStateComboBox->currentData().value<WindowState>());
session->setPerformanceWarningEnabled(m_ui->checkBoxPerformanceWarning->isChecked());
}
@ -1379,11 +1386,6 @@ bool OptionsDialog::isUPnPEnabled() const
return m_ui->checkUPnP->isChecked();
}
bool OptionsDialog::startMinimized() const
{
return m_ui->checkStartMinimized->isChecked();
}
// Return Share ratio
qreal OptionsDialog::getMaxRatio() const
{