-
Notifications
You must be signed in to change notification settings - Fork 69
/
settingsDialog.cpp
119 lines (99 loc) · 4.43 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
*
* Vulkan hardware capability viewer
*
* Copyright (C) 2016-2021 by Sascha Willems (www.saschawillems.de)
*
* This code is free software, you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3 as published by the Free Software Foundation.
*
* Please review the following information to ensure the GNU Lesser
* General Public License version 3 requirements will be met:
* http://opensource.org/licenses/lgpl-3.0.html
*
* The code is distributed WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU LGPL 3.0 for more details.
*
*/
#include "settingsDialog.h"
#include "settings.h"
#include <QFormLayout>
#include <QPushButton>
#include <QMessageBox>
#include <QLabel>
#include <QLineEdit>
#include <QCheckBox>
#include <QSettings>
#include <QDialogButtonBox>
QLineEdit *createLineEdit(QString name)
{
QLineEdit* edit = new QLineEdit();
edit->setObjectName(name);
return edit;
}
QCheckBox *createCheckBox(QString name)
{
QCheckBox* checkbox = new QCheckBox();
checkbox->setObjectName(name);
return checkbox;
}
settingsDialog::settingsDialog(Settings appSet)
{
appSettings = appSet;
QFormLayout *formLayout = new QFormLayout;
QLabel* labelCaption = new QLabel();
labelCaption->setText("General settings");
labelCaption->setStyleSheet("font: 75 11pt;");
formLayout->addRow(labelCaption);
formLayout->addRow(tr("Submitter:"), createLineEdit("editSubmitterName"));
labelCaption = new QLabel();
labelCaption->setText("Proxy Settings");
labelCaption->setStyleSheet("font: 75 11pt;");
formLayout->addRow(labelCaption);
formLayout->addRow(tr("DNS Name / IP:"), createLineEdit("editProxyDns"));
formLayout->addRow(tr("Port:"), createLineEdit("editProxyPort"));
formLayout->addRow(tr("User name (if required):"), createLineEdit("editProxyUser"));
formLayout->addRow(tr("Password (if required):"), createLineEdit("editProxyPassword"));
formLayout->addRow(tr("Use proxy settings for upload"), createCheckBox("checkBoxUseProxy"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccept()), Qt::QueuedConnection);
connect(buttonBox, SIGNAL(rejected()), this, SLOT(slotCancel()), Qt::QueuedConnection);
formLayout->addWidget(buttonBox);
setLayout(formLayout);
setWindowTitle("Settings");
// Restore settings
QSettings settings("saschawillems", "vulkancapsviewer");
this->findChild<QLineEdit*>("editSubmitterName", Qt::FindChildrenRecursively)->setText(settings.value("global/submitterName", "").toString());
this->findChild<QLineEdit*>("editProxyDns", Qt::FindChildrenRecursively)->setText(settings.value("proxy/dns", "").toString());
this->findChild<QLineEdit*>("editProxyPort", Qt::FindChildrenRecursively)->setText(settings.value("proxy/port", "").toString());
this->findChild<QLineEdit*>("editProxyUser", Qt::FindChildrenRecursively)->setText(settings.value("proxy/user", "").toString());
this->findChild<QLineEdit*>("editProxyPassword", Qt::FindChildrenRecursively)->setText(settings.value("proxy/password", "").toString());
this->findChild<QCheckBox*>("checkBoxUseProxy", Qt::FindChildrenRecursively)->setChecked(settings.value("proxy/enabled", "false").toBool());
}
settingsDialog::~settingsDialog()
{
}
void settingsDialog::slotAccept()
{
QSettings settings("saschawillems", "vulkancapsviewer");
QLineEdit* edit;
edit = this->findChild<QLineEdit*>("editSubmitterName", Qt::FindChildrenRecursively);
settings.setValue("global/submitterName", edit->text());
edit = this->findChild<QLineEdit*>("editProxyDns", Qt::FindChildrenRecursively);
settings.setValue("proxy/dns", edit->text());
edit = this->findChild<QLineEdit*>("editProxyPort", Qt::FindChildrenRecursively);
settings.setValue("proxy/port", edit->text());
edit = this->findChild<QLineEdit*>("editProxyUser", Qt::FindChildrenRecursively);
settings.setValue("proxy/user", edit->text());
edit = this->findChild<QLineEdit*>("editProxyPassword", Qt::FindChildrenRecursively);
settings.setValue("proxy/password", edit->text());
QCheckBox* checkbox = this->findChild<QCheckBox*>("checkBoxUseProxy", Qt::FindChildrenRecursively);
settings.setValue("proxy/enabled", checkbox->isChecked());
this->close();
}
void settingsDialog::slotCancel()
{
this->close();
}