-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutilities.cpp
68 lines (63 loc) · 2.32 KB
/
utilities.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
#include "utilities.h"
void assignWithXml(QXmlStreamReader & xmlInput, const std::string tag, std::string & string)
{
xmlInput.readNextStartElement();
if (xmlInput.name() != QString::fromStdString(tag))
throw new std::runtime_error("errore durante il parsing del documento");
string = (xmlInput.readElementText()).toStdString();
}
void showMessage(const QString & message, const QString & details)
{
QMessageBox * m= new QMessageBox;
m->setModal(true);
m->setWindowIcon(QIcon(":/resources/error.svg"));
m->setAttribute(Qt::WA_DeleteOnClose);
m->setWindowTitle("Alert");
m->setIcon(QMessageBox::Warning);
m->setText(message);
if(details!='\0')
m->setDetailedText(details);
QFile file(":/resources/style.css");
file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll());
file.close();
m->setStyleSheet(styleSheet);
m->show();
QObject::connect(m, SIGNAL(buttonClicked(QAbstractButton *)), m, SLOT(close()));
}
void showSuccess(const QString & message, const QString & details)
{
QMessageBox * m= new QMessageBox;
m->setModal(true);
m->setAttribute(Qt::WA_DeleteOnClose);
m->setWindowTitle("Info");
m->setWindowIcon(QIcon(":/resources/info.svg"));
m->setIcon(QMessageBox::Information);
m->setText(message);
if(details!='\0')
m->setDetailedText(details);
QFile file(":/resources/style.css");
file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll());
file.close();
m->setStyleSheet(styleSheet);
m->show();
QObject::connect(m, SIGNAL(buttonClicked(QAbstractButton *)), m, SLOT(close()));
}
int confirmationMessage(QWidget *parent, const QString & text,const QString & details)
{
QMessageBox *conferma=new QMessageBox(parent);
conferma->setWindowTitle("Conferma");
conferma->setText(text);
conferma->setWindowIcon(QIcon(":/resources/warning.svg"));
if(details!='\0')
conferma->setDetailedText(details);
conferma->setStandardButtons(QMessageBox::Yes | QMessageBox::No );
conferma->setDefaultButton(QMessageBox::Yes);
QFile file(":/resources/style.css");
file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll());
file.close();
conferma->setStyleSheet(styleSheet);
return conferma->exec();
}