-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrapher.cpp
More file actions
156 lines (128 loc) · 4.22 KB
/
Copy pathgrapher.cpp
File metadata and controls
156 lines (128 loc) · 4.22 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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include "grapher.h"
#include "./ui_grapher.h"
Grapher::Grapher(QWidget *parent)
: QMainWindow{parent}
, ui{new Ui::Grapher}
{
context = std::make_shared<Context>();
ui->setupUi(this);
ui->settingsMenuButton->setCheckable(true);
ui->settingsGroupBox->setVisible(false);
ui->newMenuButton->setCheckable(true);
ui->newGroupBox->setVisible(false);
on_newCalculatorButton_clicked();
ui->darkLightThemeButton->setCheckable(true);
ui->mainArea->setLayout(new QGridLayout);
ui->mainArea->setBackground(QColor(0, 0, 0, 0));
ui->darkLightThemeButton->setText("🌞");
dark_theme = QString::fromUtf8(" {border: 1px solid rgb(37, 37, 37); background-color: rgb(25, 25, 25); color: rgb(232, 232, 232); font: italic 12pt \"Ubuntu\";}");
light_theme = QString::fromUtf8(" {border: 1px solid rgb(220, 220, 220); background-color: rgb(232, 232, 232); color: rgb(25, 25, 25); font: italic 12pt \"Ubuntu\";}");
objects = QList<QWidget*>{
ui->centralwidget,
ui->darkLightThemeButton,
ui->newMenuButton,
ui->settingsMenuButton,
ui->newCalculatorButton,
ui->newMatrixButton,
ui->newGroupBox,
ui->settingsGroupBox,
ui->mainArea
};
for (QWidget* widget : objects) {
widget->setStyleSheet(
QString::fromUtf8(widget->metaObject()->className()) + dark_theme
);
}
}
Grapher::~Grapher()
{
for (calculator::CalculatorLine* line : calculator_lines) {
delete line;
}
for (matrix::MatrixLine* line : matrix_lines) {
delete line;
}
delete ui->mainArea->layout();
delete ui;
}
void Grapher::on_settingsMenuButton_toggled(bool checked)
{
if (checked) {
ui->settingsMenuButton->setText("-");
} else {
ui->settingsMenuButton->setText("+");
}
ui->settingsGroupBox->setVisible(checked);
}
void Grapher::on_newMenuButton_toggled(bool checked)
{
if (checked) {
ui->newMenuButton->setText("-");
} else {
ui->newMenuButton->setText("...");
}
ui->newGroupBox->setVisible(checked);
}
void Grapher::on_newCalculatorButton_clicked()
{
QWidget* box = new QWidget;
QVBoxLayout* layout = new QVBoxLayout{box};
calculator::CalculatorLine* calc = new calculator::CalculatorLine{context, layout};
calculator_lines.append(calc);
QMdiSubWindow* new_window = ui->mainArea->addSubWindow(box);
new_window->setWindowFlags(
new_window->windowFlags() &
~Qt::WindowMaximizeButtonHint
); // disable maximize button
new_window->setWindowFlags(
new_window->windowFlags() |
Qt::CustomizeWindowHint |
Qt::WindowMinimizeButtonHint |
Qt::WindowCloseButtonHint
); // enable closing and minimizing
new_window->setAttribute(Qt::WA_DeleteOnClose);
new_window->show();
}
void Grapher::on_newMatrixButton_clicked()
{
QWidget* box = new QWidget;
QVBoxLayout* layout = new QVBoxLayout(box);
matrix::MatrixLine* mat = new matrix::MatrixLine(3, 3, context, layout);
matrix_lines.append(mat);
QMdiSubWindow* new_window = ui->mainArea->addSubWindow(box);
new_window->setWindowFlags(
new_window->windowFlags() &
~Qt::WindowMaximizeButtonHint
); // disable maximize button
new_window->setWindowFlags(
new_window->windowFlags() |
Qt::CustomizeWindowHint |
Qt::WindowMinimizeButtonHint |
Qt::WindowCloseButtonHint
); // enable closing and minimizing
new_window->setAttribute(Qt::WA_DeleteOnClose);
new_window->show();
}
void Grapher::on_darkLightThemeButton_toggled(bool light_mode)
{
if (light_mode) {
ui->darkLightThemeButton->setText("🌕");
for (QWidget* widget : objects) {
widget->setStyleSheet(
QString::fromUtf8(widget->metaObject()->className()) +
light_theme
);
}
} else {
ui->darkLightThemeButton->setText("🌞");
for (QWidget* widget : objects) {
widget->setStyleSheet(
QString::fromUtf8(widget->metaObject()->className()) +
dark_theme
);
}
}
}
void Grapher::focusNextWindow() {
ui->mainArea->activateNextSubWindow();
}