-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptionsdialog.cpp
127 lines (103 loc) · 3.98 KB
/
optionsdialog.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
120
121
122
123
124
125
126
127
#include "optionsdialog.h"
#include <QMessageBox>
OptionsDialog::OptionsDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(tr("Options"));
setModal(true);
setFixedSize(minimumSize());
create_layout();
create_options();
create_dialog_buttons();
}
void OptionsDialog::create_layout()
{
options_layout = new QGridLayout;
button_box = new QDialogButtonBox;
main_layout = new QVBoxLayout;
main_layout->addLayout(options_layout);
setLayout(main_layout);
}
void OptionsDialog::create_options()
{
no_title_combo = new QComboBox;
no_title_combo->addItem(tr("Infinity"));
no_title_combo->insertSeparator(1);
for(int i=0; i <= 35; i+=5)
no_title_combo->addItem(QString::number(i));
for(int i=40; i<=100; i+=10)
no_title_combo->addItem(QString::number(i));
save_title_lbl = new QLabel(tr("Number of titles saved for reuse:"));
save_title_lbl->setToolTip(tr("The latest number of titles shown in drop down menu"));
save_title_lbl->setBuddy(no_title_combo);
clear_title_btn = new QPushButton(tr("Clear titles"));
clear_title_btn->setToolTip(tr("Clears all buffered titles shown in drop down menu"));
connect(clear_title_btn, &QPushButton::clicked, this, &OptionsDialog::clear_title_clicked);
clear_title_lbl = new QLabel(tr("Clear all buffered titles:"));
clear_title_lbl->setToolTip(tr("Clears all bffered titles shown in drop down menu"));
clear_title_lbl->setBuddy(clear_title_btn);
no_act_combo = new QComboBox;
no_act_combo->addItem(tr("Infinity"));
no_act_combo->insertSeparator(1);
for(int i=0; i <= 35; i+=5)
no_act_combo->addItem(QString::number(i));
for(int i=40; i<=100; i+=10)
no_act_combo->addItem(QString::number(i));
save_act_lbl = new QLabel(tr("Number of activities saved for reuse:"));
save_act_lbl->setToolTip(tr("The latest number of activities shown in drop down menu"));
clear_act_btn = new QPushButton(tr("Clear activities"));
clear_act_btn->setToolTip(tr("Clears all buffered activities shown in drop down menu"));
connect(clear_act_btn, &QPushButton::clicked, this, &OptionsDialog::clear_act_clicked);
clear_act_lbl = new QLabel(tr("Clear all buffered activities:"));
clear_act_lbl->setToolTip(tr("Clears all buffered activities shown in drop down menu"));
clear_act_lbl->setBuddy(clear_act_btn);
options_layout->addWidget(save_title_lbl, 0, 0);
options_layout->addWidget(no_title_combo, 0, 1);
options_layout->addWidget(clear_title_lbl, 1, 0);
options_layout->addWidget(clear_title_btn, 1, 1);
options_layout->addWidget(save_act_lbl, 2, 0);
options_layout->addWidget(no_act_combo, 2, 1);
options_layout->addWidget(clear_act_lbl, 3, 0);
options_layout->addWidget(clear_act_btn, 3, 1);
}
void OptionsDialog::create_dialog_buttons()
{
line = new QFrame();
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
options_layout->addWidget(line, 4, 0, 1, -1);
button_box = new QDialogButtonBox(QDialogButtonBox::Ok |
QDialogButtonBox::Cancel);
connect(button_box, &QDialogButtonBox::accepted, this, &OptionsDialog::ok_clicked);
connect(button_box, &QDialogButtonBox::rejected, this, &OptionsDialog::cancel_clicked);
options_layout->addWidget(button_box, 5, 0, 1, -1);
}
void OptionsDialog::clear_title_clicked()
{
QMessageBox msg_box{this};
msg_box.setWindowTitle(tr("Delete"));
msg_box.setText(tr("Are you sure you want to delete all buffered titles?"));
msg_box.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msg_box.setIcon(QMessageBox::Critical);
int answer = msg_box.exec();
}
void OptionsDialog::clear_act_clicked()
{
QMessageBox msg_box{this};
msg_box.setWindowTitle(tr("Delete"));
msg_box.setText(tr("Are you sure you want to delete all buffered activities?"));
msg_box.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msg_box.setIcon(QMessageBox::Critical);
int answer = msg_box.exec();
}
void OptionsDialog::ok_clicked()
{
delete this;
}
void OptionsDialog::cancel_clicked()
{
delete this;
}
OptionsDialog::~OptionsDialog()
{
}