This repository was archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpreferences.cpp
More file actions
49 lines (40 loc) · 1.83 KB
/
preferences.cpp
File metadata and controls
49 lines (40 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "preferences.h"
#include "ui_preferences.h"
#include <QSettings>
#include <QDebug>
#include <QFileInfo>
#include "preferenceshelper.h"
Preferences::Preferences(QWidget *parent) : QDialog(parent), ui(new Ui::Preferences)
{
// Setup Window
ui->setupUi(this);
// Get preferences
bool useColorUsernamesPreference = PreferencesHelper::sharedInstance()->getPropertyDefault(PreferencesHelper::colorUsernamesKey, true);
bool joinOnConnectPreference = PreferencesHelper::sharedInstance()->getPropertyDefault(PreferencesHelper::joinOnConnectKey, true);
bool hideJoinNotificationsPreference = PreferencesHelper::sharedInstance()->getPropertyDefault(PreferencesHelper::suppressJoinNotificationsKey, false);
// Update UI
this->ui->colorUserNames->setChecked(useColorUsernamesPreference);
this->ui->joinOnConnect->setChecked(joinOnConnectPreference);
this->ui->suppressEnterLeaveNotifications->setChecked(hideJoinNotificationsPreference);
}
Preferences::~Preferences()
{
delete ui;
}
void Preferences::accept()
{
QSettings *settings = PreferencesHelper::sharedInstance()->getSettings();
// Set preferences
bool useColorUsernamesPreference = this->ui->colorUserNames->isChecked();
bool joinOnConnectPreference = this->ui->joinOnConnect->isChecked();
bool hideJoinNotificationsPreference = this->ui->suppressEnterLeaveNotifications->isChecked();
// Persist
settings->beginGroup(PreferencesHelper::displayPreferencesGroupKey);
settings->setValue(PreferencesHelper::colorUsernamesKey, useColorUsernamesPreference);
settings->setValue(PreferencesHelper::joinOnConnectKey, joinOnConnectPreference);
settings->setValue(PreferencesHelper::suppressJoinNotificationsKey, hideJoinNotificationsPreference);
settings->endGroup();
settings->sync();
// Close Window
this->close();
}