More complete API for settings panels.
This commit is contained in:
parent
aa04571eee
commit
9cb5c94b92
@ -1,5 +1,8 @@
|
||||
#include "gui/settings/settingsgeneral.h"
|
||||
|
||||
#include "miscellaneous/systemfactory.h"
|
||||
#include "miscellaneous/application.h"
|
||||
|
||||
|
||||
SettingsGeneral::SettingsGeneral(Settings *settings, QWidget *parent)
|
||||
: SettingsPanel(settings, parent), m_ui(new Ui::SettingsGeneral) {
|
||||
@ -10,3 +13,49 @@ SettingsGeneral::SettingsGeneral(Settings *settings, QWidget *parent)
|
||||
SettingsGeneral::~SettingsGeneral() {
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void SettingsGeneral::loadSettings() {
|
||||
m_ui->m_checkForUpdatesOnStart->setChecked(settings()->value(GROUP(General), SETTING(General::UpdateOnStartup)).toBool());
|
||||
|
||||
// Load auto-start status.
|
||||
const SystemFactory::AutoStartStatus autostart_status = qApp->system()->getAutoStartStatus();
|
||||
|
||||
switch (autostart_status) {
|
||||
case SystemFactory::Enabled:
|
||||
m_ui->m_checkAutostart->setChecked(true);
|
||||
break;
|
||||
|
||||
case SystemFactory::Disabled:
|
||||
m_ui->m_checkAutostart->setChecked(false);
|
||||
break;
|
||||
|
||||
default:
|
||||
m_ui->m_checkAutostart->setEnabled(false);
|
||||
m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text() + tr(" (not supported on this platform)"));
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
m_ui->m_checkRemoveTrolltechJunk->setVisible(true);
|
||||
m_ui->m_checkRemoveTrolltechJunk->setChecked(settings()->value(GROUP(General), SETTING(General::RemoveTrolltechJunk)).toBool());
|
||||
#else
|
||||
m_ui->m_checkRemoveTrolltechJunk->setVisible(false);
|
||||
#endif
|
||||
|
||||
SettingsPanel::loadSettings();
|
||||
}
|
||||
|
||||
void SettingsGeneral::saveSettings() {
|
||||
// If auto-start feature is available and user wants to turn it on, then turn it on.
|
||||
if (m_ui->m_checkAutostart->isChecked()) {
|
||||
qApp->system()->setAutoStartStatus(SystemFactory::Enabled);
|
||||
}
|
||||
else {
|
||||
qApp->system()->setAutoStartStatus(SystemFactory::Disabled);
|
||||
}
|
||||
|
||||
settings()->setValue(GROUP(General), General::UpdateOnStartup, m_ui->m_checkForUpdatesOnStart->isChecked());
|
||||
settings()->setValue(GROUP(General), General::RemoveTrolltechJunk, m_ui->m_checkRemoveTrolltechJunk->isChecked());
|
||||
|
||||
SettingsPanel::saveSettings();
|
||||
}
|
||||
|
@ -13,6 +13,10 @@ class SettingsGeneral : public SettingsPanel {
|
||||
explicit SettingsGeneral(Settings *settings, QWidget *parent = 0);
|
||||
virtual ~SettingsGeneral();
|
||||
|
||||
protected:
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
private:
|
||||
Ui::SettingsGeneral *m_ui;
|
||||
};
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "miscellaneous/settings.h"
|
||||
|
||||
|
||||
SettingsPanel::SettingsPanel(Settings *settings, QWidget *parent) : QWidget(parent) {
|
||||
SettingsPanel::SettingsPanel(Settings *settings, QWidget *parent) : QWidget(parent), m_settings(settings) {
|
||||
}
|
||||
|
||||
void SettingsPanel::loadSettings() {
|
||||
@ -44,3 +44,7 @@ bool SettingsPanel::isDirty() const {
|
||||
void SettingsPanel::setIsDirty(bool is_dirty) {
|
||||
m_isDirty = is_dirty;
|
||||
}
|
||||
|
||||
Settings *SettingsPanel::settings() const {
|
||||
return m_settings;
|
||||
}
|
||||
|
@ -30,7 +30,10 @@ class SettingsPanel : public QWidget {
|
||||
public:
|
||||
explicit SettingsPanel(Settings *settings, QWidget *parent = 0);
|
||||
|
||||
// Call this base implementation in the end of your subclass implementation.
|
||||
virtual void loadSettings();
|
||||
|
||||
// Call this base implementation in the end of your subclass implementation.
|
||||
virtual void saveSettings();
|
||||
|
||||
protected:
|
||||
@ -41,11 +44,15 @@ class SettingsPanel : public QWidget {
|
||||
bool isDirty() const;
|
||||
void setIsDirty(bool is_dirty);
|
||||
|
||||
// Settings to use to save/load.
|
||||
Settings *settings() const;
|
||||
|
||||
signals:
|
||||
void settingsChanged();
|
||||
|
||||
private:
|
||||
bool m_isDirty;
|
||||
Settings *m_settings;
|
||||
};
|
||||
|
||||
#endif // SETTINGSPANEL_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user