SettingsDialog: finer grain restart prompt

This commit is contained in:
Le Tan 2022-04-01 21:28:01 +08:00
parent 1ca899d8ab
commit cc8ee46efe
6 changed files with 17 additions and 9 deletions

View File

@ -13,9 +13,9 @@ IUnitedEntry::IUnitedEntry(const QString &p_name,
const UnitedEntryMgr *p_mgr, const UnitedEntryMgr *p_mgr,
QObject *p_parent) QObject *p_parent)
: QObject(p_parent), : QObject(p_parent),
m_mgr(p_mgr),
m_name(p_name), m_name(p_name),
m_description(p_description), m_description(p_description)
m_mgr(p_mgr)
{ {
} }

View File

@ -35,7 +35,7 @@ void AppearancePage::setupUI()
mainLayout->addRow(m_systemTitleBarCheckBox); mainLayout->addRow(m_systemTitleBarCheckBox);
addSearchItem(label, m_systemTitleBarCheckBox->toolTip(), m_systemTitleBarCheckBox); addSearchItem(label, m_systemTitleBarCheckBox->toolTip(), m_systemTitleBarCheckBox);
connect(m_systemTitleBarCheckBox, &QCheckBox::stateChanged, connect(m_systemTitleBarCheckBox, &QCheckBox::stateChanged,
this, &AppearancePage::pageIsChanged); this, &AppearancePage::pageIsChangedWithRestartNeeded);
} }
{ {
@ -49,7 +49,7 @@ void AppearancePage::setupUI()
mainLayout->addRow(label, m_toolBarIconSizeSpinBox); mainLayout->addRow(label, m_toolBarIconSizeSpinBox);
addSearchItem(label, m_toolBarIconSizeSpinBox->toolTip(), m_toolBarIconSizeSpinBox); addSearchItem(label, m_toolBarIconSizeSpinBox->toolTip(), m_toolBarIconSizeSpinBox);
connect(m_toolBarIconSizeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), connect(m_toolBarIconSizeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
this, &AppearancePage::pageIsChanged); this, &AppearancePage::pageIsChangedWithRestartNeeded);
} }
{ {

View File

@ -37,7 +37,7 @@ void GeneralPage::setupUI()
mainLayout->addRow(label, m_localeComboBox); mainLayout->addRow(label, m_localeComboBox);
addSearchItem(label, m_localeComboBox->toolTip(), m_localeComboBox); addSearchItem(label, m_localeComboBox->toolTip(), m_localeComboBox);
connect(m_localeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(m_localeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &GeneralPage::pageIsChanged); this, &GeneralPage::pageIsChangedWithRestartNeeded);
} }
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
@ -54,7 +54,7 @@ void GeneralPage::setupUI()
mainLayout->addRow(label, m_openGLComboBox); mainLayout->addRow(label, m_openGLComboBox);
addSearchItem(label, m_openGLComboBox->toolTip(), m_openGLComboBox); addSearchItem(label, m_openGLComboBox->toolTip(), m_openGLComboBox);
connect(m_openGLComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(m_openGLComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &GeneralPage::pageIsChanged); this, &GeneralPage::pageIsChangedWithRestartNeeded);
} }
#endif #endif

View File

@ -64,10 +64,18 @@ void SettingsPage::pageIsChanged()
emit changed(); emit changed();
} }
void SettingsPage::pageIsChangedWithRestartNeeded()
{
m_changed = true;
m_restartNeeded = true;
emit changed();
}
void SettingsPage::load() void SettingsPage::load()
{ {
loadInternal(); loadInternal();
m_changed = false; m_changed = false;
m_restartNeeded = false;
} }
bool SettingsPage::save() bool SettingsPage::save()
@ -78,8 +86,6 @@ bool SettingsPage::save()
if (saveInternal()) { if (saveInternal()) {
m_changed = false; m_changed = false;
// TODO: may need finer-grain check.
m_restartNeeded = true;
return true; return true;
} }

View File

@ -47,6 +47,8 @@ namespace vnotex
protected slots: protected slots:
void pageIsChanged(); void pageIsChanged();
void pageIsChangedWithRestartNeeded();
private: private:
struct SearchItem struct SearchItem
{ {

View File

@ -43,7 +43,7 @@ void ThemePage::setupUI()
this, [this](QListWidgetItem *p_current, QListWidgetItem *p_previous) { this, [this](QListWidgetItem *p_current, QListWidgetItem *p_previous) {
Q_UNUSED(p_previous); Q_UNUSED(p_previous);
loadThemePreview(p_current ? p_current->data(Qt::UserRole).toString() : QString()); loadThemePreview(p_current ? p_current->data(Qt::UserRole).toString() : QString());
pageIsChanged(); pageIsChangedWithRestartNeeded();
}); });
auto refreshBtn = new QPushButton(tr("Refresh"), this); auto refreshBtn = new QPushButton(tr("Refresh"), this);