-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
68 lines (57 loc) · 1.38 KB
/
mainwindow.cpp
File metadata and controls
68 lines (57 loc) · 1.38 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "colorpalette.h"
#include "tutorialwindow.h"
#include "aboutwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
canvas = new Canvas(this);
ui->workArea->addWidget(canvas);
QActionGroup* group = new QActionGroup( this );
ui->actionDark->setActionGroup(group);
ui->actionLight->setActionGroup(group);
connect(canvas, SIGNAL(toggleTheme()), this, SLOT(toggleTheme()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionExit_triggered()
{
close();
}
void MainWindow::on_actionNew_triggered()
{
MainWindow* w2 = new MainWindow();
w2->show();
}
void MainWindow::on_actionLight_triggered()
{
ColorPalette::lightTheme();
canvas->updateAll();
}
void MainWindow::on_actionDark_triggered()
{
ColorPalette::darkTheme();
canvas->updateAll();
}
// Lazy, not good practice, but good for presentation and debug so sorry
void MainWindow::toggleTheme() {
if (ui->actionDark->isChecked())
ui->actionLight->trigger();
else
ui->actionDark->trigger();
}
void MainWindow::on_actionTutorial_triggered()
{
TutorialWindow* window = new TutorialWindow();
window->show();
}
void MainWindow::on_actionAbout_triggered()
{
AboutWindow* window = new AboutWindow();
window->show();
}