93 lines
1.9 KiB
C++
93 lines
1.9 KiB
C++
#include "vvodnomera.h"
|
|
|
|
vvodnomera::vvodnomera(QWidget *parent) :
|
|
QDialog(parent)
|
|
{
|
|
|
|
setWindowTitle(QString::fromLocal8Bit("Ââîä íîìåðà ïîä÷èíåííîãî"));
|
|
|
|
Qt::WindowFlags flag = Qt::Dialog;
|
|
flag |= Qt::WindowCloseButtonHint;
|
|
setWindowFlags(flag);
|
|
|
|
|
|
//
|
|
|
|
abMaxCount = 15;
|
|
abMinNum = 1;
|
|
|
|
QFrame *fr=new QFrame(this);
|
|
fr->setGeometry(20,20,200,54);
|
|
fr->setFrameShape(QFrame::Box);
|
|
fr->setFrameShadow(QFrame::Sunken);
|
|
fr->setLineWidth(2);
|
|
|
|
QLabel *lb= new QLabel(this);
|
|
lb->setGeometry(50,30,130,20);
|
|
lb->setText(QString::fromLocal8Bit("Ââîä íîìåðà"));
|
|
|
|
le = new QLineEdit(this);
|
|
le->setGeometry(170, 30, 35, 20);
|
|
le->setText("1");
|
|
le->selectAll();
|
|
|
|
QPushButton *pbOk = new QPushButton(this);
|
|
pbOk->setGeometry(40,85, 65, 23);
|
|
pbOk->setText(QString::fromLocal8Bit("Ââîä"));
|
|
connect(pbOk, SIGNAL(clicked()), this, SLOT(msOk()));
|
|
|
|
|
|
QPushButton *pbCancel = new QPushButton(this);
|
|
pbCancel->setGeometry(150,85, 65, 23);
|
|
pbCancel->setText(QString::fromLocal8Bit("Îòêàç"));
|
|
connect(pbCancel, SIGNAL(clicked()), this, SLOT(msCancel()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
void vvodnomera::setTitle(QString s)
|
|
{
|
|
setWindowTitle(s);
|
|
}
|
|
|
|
void vvodnomera::msOk()
|
|
{
|
|
int r = le->text().toInt();
|
|
if ((r<abMinNum)||(r>abMaxCount))
|
|
{
|
|
QMessageBox msg(this);
|
|
msg.setWindowTitle(QString::fromLocal8Bit("Íåâåðíûé äèàïàçîí"));
|
|
msg.setIcon(QMessageBox::Information);
|
|
msg.setText(QString::fromLocal8Bit("Íîìåð ïîä÷èíåííîãî: îò %2 äî %1").arg(abMaxCount).arg(abMinNum));
|
|
msg.addButton(QString::fromLocal8Bit("Äà"),QMessageBox::AcceptRole);
|
|
msg.exec();
|
|
}
|
|
else
|
|
|
|
{
|
|
this->done(r);
|
|
|
|
}
|
|
}
|
|
|
|
void vvodnomera::msCancel()
|
|
{
|
|
this->done(-1);
|
|
}
|
|
|
|
void vvodnomera::keyPressEvent(QKeyEvent *e)
|
|
{
|
|
if (e->key() == Qt::Key_Escape)
|
|
{
|
|
msCancel();
|
|
}
|
|
e->accept();
|
|
}
|
|
|
|
void vvodnomera::closeEvent(QCloseEvent *e)
|
|
{
|
|
|
|
}
|