-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettingsdialog.cpp
37 lines (32 loc) · 1.16 KB
/
settingsdialog.cpp
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
#include "settingsdialog.h"
#include "application.h"
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QPushButton>
#include <QTreeView>
SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent)
{
QLayout *layout = new QVBoxLayout();
QTreeView *treeView = new QTreeView();
layout->addWidget(treeView);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Discard | QDialogButtonBox::Apply);
layout->addWidget(buttonBox);
setLayout(layout);
QPushButton *discard = buttonBox->button(QDialogButtonBox::Discard);
QObject::connect(discard, &QPushButton::clicked, this, &SettingsDialog::close);
discard->setDefault(true);
}
void SettingsDialog::showEvent(QShowEvent *event)
{
APP->settings.beginGroup("window/settings");
restoreGeometry(APP->settings.value("geometry").toByteArray());
APP->settings.endGroup();
QDialog::showEvent(event);
}
void SettingsDialog::hideEvent(QHideEvent *event)
{
APP->settings.beginGroup("window/settings");
APP->settings.setValue("geometry", saveGeometry());
APP->settings.endGroup();
QDialog::hideEvent(event);
}