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
| #include "dialogs.h"
#include "const.h"
#include <QMessageBox>
#include <QPushButton>
dialogs::dialogs(const QString &title, hdiv &parent)
{
hdiv *t = new hdiv(title, false, parent);
_tmpdiv = t;
_tmpdiv->setStyle(QString::fromUtf8("background-color: rgb(0, 0, 0);background-image: url(:/bg-images/background-menu.png)"));
_tmpdiv->resize(QRect(0,0,249,282));
addTitlePicture();
addCloseButton();
}
hdiv *dialogs::getDialog()
{
return _tmpdiv;
}
void dialogs::addTitlePicture()
{
QString divtitle = _tmpdiv->getID();
divtitle.append("-title");
hdiv *t = new hdiv(divtitle,false,*_tmpdiv);
t->resize(QRect(10,10,192,9));
QString stylesheet = "background-color: ";
stylesheet.append(QString(HS_COLOR_DIALOGS_BACKGROUND));
stylesheet.append(";background-image: url(:/bg-images/images/");
stylesheet.append(_tmpdiv->getID());
stylesheet.append("-title-bgpicture.png)");
t->setStyle(stylesheet);
_tmpdiv->appendChild(t);
}
void dialogs::addCloseButton()
{
QString divtitle = _tmpdiv->getID();
divtitle.append("-closebutton");
hdiv *t = new hdiv(divtitle,false,*_tmpdiv);
t->resize(QRect(219,5,24,23));
QPushButton *qpb = new QPushButton(t->getWidget());
qpb->setGeometry(QRect(0,0,24,23));
QString stylesheet = "QPushButton { border:none; background-color: ";
stylesheet.append(QString(HS_COLOR_DIALOGS_BACKGROUND));
stylesheet.append(";background-image: url(:/bg-images/images/");
stylesheet.append("closebutton-bgpicture.png)}");
qpb->setStyleSheet(stylesheet);
t->appendChild(qpb);
stylesheet = "background-color: ";
stylesheet.append(QString(HS_COLOR_DIALOGS_BACKGROUND));
stylesheet.append(";background-image: none;");
t->setStyle(stylesheet);
t->connect(qpb,SIGNAL(clicked()), this, SLOT(closeDialog()));
_tmpdiv->appendChild(t);
}
void dialogs::closeDialog()
{
QMessageBox mb;
mb.setText("Closing dialog");
mb.exec();
} |
Partager