forked from KamelMoohamed/CMP2241_F21_Team01_IRO_Painting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
messagedialog.cpp
100 lines (82 loc) · 2.35 KB
/
messagedialog.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
#include "messagedialog.h"
#include "ui_messagedialog.h"
#include <QFileDialog>
#include "json_utilities.h"
messageDialog::messageDialog(QString message,QString LeftText,QString RightText,QWidget *parent) :
QDialog(parent, Qt::FramelessWindowHint | Qt::WindowSystemMenuHint),
ui(new Ui::messageDialog)
{
ui->setupUi(this);
setAttribute(Qt::WA_TranslucentBackground);
QString yesBtnStyleSheet="QPushButton {"
"background-color: #f9f9f9;"
"color: black;"
"font: 11pt Montserrat;"
"border-radius: 20px;"
"}"
"QPushButton:hover{"
"background-color: #e0e0e0;"
"}"
"QPushButton:pressed{"
"background-color: #06ff7b;"
"}";
QString noBtnStyleSheet="QPushButton {"
"background-color: #f9f9f9;"
"color: black;"
"font: 11pt Montserrat;"
"border-radius: 20px;"
"}"
"QPushButton:hover{"
"background-color: #e0e0e0;"
"}"
"QPushButton:pressed{"
"background-color: #fd2873;"
"}";
ui->yesBtn->setStyleSheet(yesBtnStyleSheet);
ui->noBtn->setStyleSheet(noBtnStyleSheet);
ui->message->setText(message);
ui->yesBtn->setText(LeftText);
ui->noBtn->setText(RightText);
this->setModal(true);
}
messageDialog::~messageDialog()
{
delete ui;
}
void messageDialog::on_yesBtn_clicked()
{
accept();
}
void messageDialog::on_closeBtn_clicked()
{
closed=true;
reject();
}
void messageDialog::on_noBtn_clicked()
{
reject();
}
void messageDialog::mouseMoveEvent(QMouseEvent *event)
{
if( event->buttons().testFlag(Qt::LeftButton) && mMoving){
this->move(this->pos() + (event->pos() - mLastMousePosition));
}
}
void messageDialog::mousePressEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton){
mMoving = true;
mLastMousePosition = event->pos();
}
}
void messageDialog::mouseReleaseEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton){
mMoving = false;
}
}
void messageDialog::closeEvent(QCloseEvent *event)
{
on_closeBtn_clicked();
Q_UNUSED(event)
}