-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
64 lines (53 loc) · 1.59 KB
/
mainwindow.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
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->menuBar->setNativeMenuBar(false);
}
void MainWindow::closeEvent(QCloseEvent *event)
{
if(!ui->paintWidget->getSaveState()){
QMessageBox msgBox;
msgBox.setText(tr("Do you want to save your work ?"));
QAbstractButton* pButtonYes = msgBox.addButton(tr("Save"), QMessageBox::YesRole);
QAbstractButton* pButtonNo = msgBox.addButton(tr("Do not save"), QMessageBox::NoRole);
QAbstractButton* pButtonCancel = msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
msgBox.exec();
if (msgBox.clickedButton()==pButtonYes) {
ui->paintWidget->save();
if(ui->paintWidget->getSaveState()){
event->accept();
} else{
event->ignore();
}
}
if (msgBox.clickedButton()==pButtonNo) {
event->accept();
}
if (msgBox.clickedButton()==pButtonCancel) {
event->ignore();
}
}
}
void MainWindow::displayModifiedInfo(QString title)
{
setWindowTitle(title + "*");
}
void MainWindow::displaySavedInfo(QString title)
{
setWindowTitle(title);
}
void MainWindow::displayHelp(){
QMessageBox::information(this,
tr("About Ensi-Mandala"),
tr("Ensi-Mandala: An interactive tool for drawing Mandalas.\n\n"
"(C) 2019 Timothee Soen & Cyprien De Slizewicz"),
QMessageBox::Ok);
}
MainWindow::~MainWindow()
{
delete ui;
}