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 99 100 101 102 103 104 105 106 107 108 109 110 111
| #include "dialogs.h"
#include "const.h"
#include "div.h"
#include <QString>
#include <QMessageBox>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
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();
_currentOffsetTop = 40;
_currentOffsetLeft = 0;
}
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);
dialogs::connect(qpb,SIGNAL(clicked()), this, SLOT(closeDialog()));
_tmpdiv->appendChild(t);
}
void dialogs::addFormLine(const QString &label)
{
QFont font("verdana", 8);
hdiv *t = new hdiv(QString("form-line-" + label),false,*&_tmpdiv);
QLineEdit *ql = new QLineEdit(t->getWidget());
ql->setFont(font);
ql->setText(label);
QString stylesheet = "border:none; background: ";
stylesheet.append(QString(HS_COLOR_DIALOGS_BACKGROUND));
stylesheet.append("; color:");
stylesheet.append(QString(HS_COLOR_DIALOGS_FONT));
ql->setStyleSheet(stylesheet);
ql->setReadOnly(true);
ql->setGeometry(QRect(0,0,70,20));
// we gonna align all labels, at 70px
// label height = 20 px
QLineEdit *qle = new QLineEdit(t->getWidget());
qle->setObjectName(QString("form-line-" + label + "-inputline"));
qle->setFont(font);
qle->setGeometry(QRect(80,0,70,20));
t->resize(QRect(((_currentOffsetLeft == 0) ? 30 : 0),_currentOffsetTop+_formContents.count()*23,140,23));
t->appendChild(ql);
t->appendChild(qle);
registerFormComponent(qle);
}
void dialogs::addDebugField(hdiv &dbugfld)
{
}
hdiv *dialogs::getDebugField()
{
hdiv *p;
return p;
}
void dialogs::addButtons(QList<QObject *> &qbs)
{
}
void dialogs::registerFormComponent(QLineEdit *qobj)
{
_formContents.append(qobj);
}
void dialogs::closeDialog()
{
QMessageBox mb;
mb.setText("Closing dialog");
mb.exec();
} |
Partager