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