PageRenderTime 28ms CodeModel.GetById 14ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/vp_plugins/print_monitor/getusernamemandatdlg.cpp

http://cupsfilter.googlecode.com/
C++ | 113 lines | 87 code | 23 blank | 3 comment | 2 complexity | f564e2d4e888ec7cb3c48af4ecb122b8 MD5 | raw file
  1#include "getusernamemandatdlg.h"
  2
  3#include <QtGui/QComboBox>
  4#include <QtGui/QDialog>
  5#include <QtGui/QFormLayout>
  6#include <QtGui/QLabel>
  7#include <QtGui/QLineEdit>
  8#include <QtGui/QPushButton>
  9#include <QtGui/QWidget>
 10#include <QSpacerItem>
 11#include <QVBoxLayout>
 12
 13getUserNameMandatDlg::getUserNameMandatDlg(QWidget *parent)
 14    :QDialog(parent)
 15
 16{
 17    QFont font;
 18    font.setFamily(QString::fromUtf8("Times New Roman"));
 19    font.setPointSize(12);
 20    font.setBold(true);
 21    font.setWeight(75);
 22
 23    this->setWindowModality(Qt::WindowModal);
 24    this->setMinimumSize(340,140);
 25    this->setMaximumSize(360,140);
 26    this->setModal(true);
 27    this->setWindowTitle(QObject::trUtf8("???????? ??????...") );
 28
 29    QWidget *centralWidget          = new QWidget();
 30    formLayout = new QFormLayout(centralWidget);
 31    formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
 32
 33    label = new QLabel();
 34    label->setText(QObject::trUtf8("?????"));
 35    label->setFont(font);
 36
 37    userNameEd = new QLineEdit();
 38    userNameEd->setEnabled(false);
 39    userNameEd->setFont(font);
 40
 41    label_2 = new QLabel();
 42    label_2->setText(QObject::trUtf8("??????"));
 43    label_2->setFont(font);
 44
 45    mandatCBox = new QComboBox();
 46
 47    formLayout->setWidget(0, QFormLayout::LabelRole, label);
 48    formLayout->setWidget(0, QFormLayout::FieldRole, userNameEd);
 49    formLayout->setWidget(1, QFormLayout::LabelRole, label_2);
 50    formLayout->setWidget(1, QFormLayout::FieldRole, mandatCBox);
 51
 52    // ------------------ Buttons block ------------------------------
 53
 54    QWidget *horizontalLayoutWidget = new QWidget();
 55    QHBoxLayout *horizontalLayout = new QHBoxLayout(horizontalLayoutWidget);
 56
 57    okButton = new QPushButton(horizontalLayoutWidget);
 58    okButton->setText(QObject::trUtf8("???????"));
 59    okButton->setEnabled(false);
 60
 61    QSpacerItem *horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
 62    cancelButton = new QPushButton(horizontalLayoutWidget);
 63    cancelButton->setText(QObject::trUtf8("??????"));
 64
 65    //-------------------------------------- ?????????? ----------------------------------------------------
 66    horizontalLayout->addWidget(okButton);
 67    horizontalLayout->addItem(horizontalSpacer);
 68    horizontalLayout->addWidget(cancelButton);
 69
 70    QVBoxLayout* mainLayout = new QVBoxLayout(this);
 71    mainLayout->addWidget(centralWidget);
 72    mainLayout->addWidget(horizontalLayoutWidget);
 73
 74    setLayout(mainLayout);
 75    // -------------------- Connectors --------------------------------
 76    connect (okButton, SIGNAL(clicked()),
 77             this, SLOT(accept())
 78             );
 79    connect (cancelButton, SIGNAL(clicked()),
 80             this, SLOT(reject())
 81             );
 82    connect (mandatCBox,SIGNAL(activated(int)),
 83             this,      SLOT  (enableButtons(int) )
 84             );
 85}
 86
 87
 88void getUserNameMandatDlg::enableButtons(int index)
 89{
 90    if (index != -1){
 91        okButton->setEnabled(true);
 92    }
 93}
 94
 95void getUserNameMandatDlg::setUserName(QString &userName)
 96{
 97    userNameEd->setText(userName);
 98}
 99
100void getUserNameMandatDlg::accept()
101{
102    QString m_login  = userNameEd->text();
103    QString m_mandat = mandatCBox->currentText();
104    emit setAuthData(m_login,m_mandat);
105    QDialog::accept();
106}
107
108void getUserNameMandatDlg::setMandatList(const QStringList &mandatList)
109{
110    mandatCBox->addItems(mandatList);
111    mandatCBox->setCurrentIndex(-1);
112}
113