Warn a user if change in preferences requires restart.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-10-29 19:56:39 +02:00
parent b01305b92f
commit cc5bb4ec15
6 changed files with 31 additions and 8 deletions

View File

@ -118,14 +118,19 @@ TapePreferencesConfigurationPage::~TapePreferencesConfigurationPage()
}
//---------------------------------------------------------------------------------------------------------------------
void TapePreferencesConfigurationPage::Apply()
QStringList TapePreferencesConfigurationPage::Apply()
{
QStringList preferences;
VTapeSettings *settings = qApp->TapeSettings();
settings->SetOsSeparator(ui->osOptionCheck->isChecked());
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
if (settings->GetDarkMode() != ui->darkModeCheck->isChecked())
{
settings->SetDarkMode(ui->darkModeCheck->isChecked());
preferences.append(tr("dark mode"));
}
if (m_langChanged || m_systemChanged)
{
@ -151,6 +156,8 @@ void TapePreferencesConfigurationPage::Apply()
settings->SetDefSize(ui->defSizeCombo->currentText().toInt());
m_defGradationChanged = false;
}
return preferences;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -44,7 +44,7 @@ public:
explicit TapePreferencesConfigurationPage(QWidget *parent = nullptr);
virtual ~TapePreferencesConfigurationPage();
void Apply();
QStringList Apply();
protected:
virtual void changeEvent(QEvent* event) override;
private:

View File

@ -263,7 +263,7 @@
</rect>
</property>
<property name="text">
<string>Activate dark mode(Restart required)</string>
<string>Activate dark mode</string>
</property>
</widget>
</widget>

View File

@ -32,6 +32,7 @@
#include "configpages/tapepreferencesconfigurationpage.h"
#include "configpages/tapepreferencespathpage.h"
#include <QMessageBox>
#include <QPushButton>
#include <QShowEvent>
@ -124,9 +125,18 @@ void DialogTapePreferences::changeEvent(QEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void DialogTapePreferences::Apply()
{
m_configurationPage->Apply();
QStringList preferences;
preferences += m_configurationPage->Apply();
m_pathPage->Apply();
if (not preferences.isEmpty())
{
const QString text = tr("Followed %n option(s) require restart to take effect: %1.", "",
preferences.size()).arg(preferences.join(QStringLiteral(", ")));
QMessageBox::information(this, QCoreApplication::applicationName(), text);
}
qApp->TapeSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
emit UpdateProperties();
setResult(QDialog::Accepted);

View File

@ -171,7 +171,13 @@ QStringList PreferencesConfigurationPage::Apply()
settings->SetOsSeparator(ui->osOptionCheck->isChecked());
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
if (settings->GetDarkMode() != ui->darkModeCheck->isChecked())
{
settings->SetDarkMode(ui->darkModeCheck->isChecked());
preferences.append(tr("dark mode"));
}
settings->SetFreeCurveMode(ui->checkBoxFreeCurve->isChecked());
settings->SetDoubleClickZoomFitBestCurrentPP(ui->checkBoxZoomFitBestCurrentPP->isChecked());

View File

@ -33,7 +33,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-152</y>
<width>624</width>
<height>707</height>
</rect>
@ -266,7 +266,7 @@
<item>
<widget class="QCheckBox" name="darkModeCheck">
<property name="text">
<string>Activate dark mode(Restart required)</string>
<string>Activate dark mode</string>
</property>
<property name="checked">
<bool>true</bool>