1 /*
2 rows_and_depth_dialog.cpp MindForger thinking notebook
3
4 Copyright (C) 2016-2020 Martin Dvorak <martin.dvorak@mindforger.com>
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #include "rows_and_depth_dialog.h"
20
21 namespace m8r {
22
RowsAndDepthDialog(QWidget * parent)23 RowsAndDepthDialog::RowsAndDepthDialog(QWidget* parent)
24 : QDialog{parent}
25 {
26 purpose = BULLETS;
27
28 QVBoxLayout* mainLayout = new QVBoxLayout{this};
29
30 label = new QLabel{tr("Specify number of rows and depth to generate")+":", this};
31 mainLayout->addWidget(label);
32
33 QWidget* w = new QWidget(this);
34 QHBoxLayout* spinsLayout = new QHBoxLayout{w}; // layout MUST get widget to CONSTRUCTOR
35 rowsSpin = new QSpinBox{this};
36 rowsSpin->setMinimum(1);
37 rowsSpin->setMaximum(50);
38 spinsLayout->addWidget(rowsSpin);
39 spinsLayout->addWidget(new QLabel(tr("rows")));
40 depthSpin = new QSpinBox{this};
41 depthSpin->setMinimum(1);
42 depthSpin->setMaximum(10);
43 spinsLayout->addWidget(depthSpin);
44 spinsLayout->addWidget(new QLabel(tr("depth")));
45 w->setLayout(spinsLayout);
46
47 generateButton = new QPushButton{tr("&Generate")};
48 generateButton->setDefault(true);
49
50 closeButton = new QPushButton{tr("&Cancel")};
51
52 QHBoxLayout *buttonLayout = new QHBoxLayout{};
53 buttonLayout->addStretch(1);
54 buttonLayout->addWidget(closeButton);
55 buttonLayout->addWidget(generateButton);
56 buttonLayout->addStretch();
57
58 mainLayout->addWidget(w);
59 mainLayout->addLayout(buttonLayout);
60
61 setLayout(mainLayout);
62
63 // signals
64 connect(generateButton, SIGNAL(clicked()), this, SLOT(close()));
65 connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
66
67 setWindowTitle(tr("Format Generator"));
68 resize(fontMetrics().averageCharWidth()*55, height());
69 setModal(true);
70 }
71
~RowsAndDepthDialog()72 RowsAndDepthDialog::~RowsAndDepthDialog()
73 {
74 }
75
show()76 void RowsAndDepthDialog::show() {
77 switch(purpose) {
78 case BULLETS:
79 setWindowTitle(tr("Bulleted List Generator"));
80 break;
81 case NUMBERS:
82 setWindowTitle(tr("Numbered List Generator"));
83 break;
84 case TASKS:
85 setWindowTitle(tr("Tasklist Generator"));
86 break;
87 case BLOCKQUOTE:
88 setWindowTitle(tr("Block Quote Generator"));
89 break;
90 }
91
92 rowsSpin->setValue(1);
93 depthSpin->setValue(1);
94
95 QDialog::show();
96 }
97
98 } // m8r namespace
99