00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <mxcpcAuthenticationDialog.h>
00021 #include <mxcpc_gui_config.h>
00022
00023 #include <QHBoxLayout>
00024 #include <QGridLayout>
00025 #include <QLabel>
00026 #include <QLineEdit>
00027 #include <QPushButton>
00028
00029
00030
00031 mxcpcAuthenticationDialog::mxcpcAuthenticationDialog(QWidget *parent)
00032 : mxcpcDialog(parent) {
00033
00034 QHBoxLayout *h_layout;
00035 QGridLayout *grid_layout;
00036 QLabel *label;
00037 QWidget *widget, *widget2;
00038 QLineEdit *line_edit;
00039 QPushButton *button;
00040
00041 setWindowTitle(QString("Authentication Dialog"));
00042
00043 h_layout = new QHBoxLayout(this);
00044 h_layout->setSizeConstraint(QLayout::SetFixedSize);
00045 h_layout->setSpacing(MXCPC_DIALOG_SPACING);
00046
00047 label = new QLabel(QString("KEY"), this);
00048 h_layout->addWidget(label, 0, Qt::AlignTop);
00049 label->setPixmap(QPixmap(":images/dialog_authenticate.png"));
00050 widget = new QWidget(this);
00051 h_layout->addWidget(widget);
00052
00053 grid_layout = new QGridLayout(widget);
00054 grid_layout->setSpacing(MXCPC_DIALOG_SPACING);
00055 grid_layout->setMargin(0);
00056
00057 MessageLabel = label = new QLabel(QString("Message"), widget);
00058 grid_layout->addWidget(label, 0, 0, 1, 2);
00059 label->setWordWrap(true);
00060 label = new QLabel(QString("User :"), widget);
00061 grid_layout->addWidget(label, 1, 0);
00062 label = new QLabel(QString("Password :"), widget);
00063 grid_layout->addWidget(label, 2, 0);
00064 UserEdit = line_edit = new QLineEdit(widget);
00065 grid_layout->addWidget(line_edit, 1, 1);
00066 PasswordEdit = line_edit = new QLineEdit(widget);
00067 grid_layout->addWidget(line_edit, 2, 1);
00068 line_edit->setEchoMode(QLineEdit::Password);
00069
00070 widget2 = new QWidget(widget);
00071 grid_layout->addWidget(widget2, 3, 0, 1, 2);
00072
00073 h_layout = new QHBoxLayout(widget2);
00074 h_layout->setSpacing(MXCPC_DIALOG_SPACING);
00075 h_layout->setMargin(0);
00076
00077 button = new QPushButton(QString("Cancel"), widget2);
00078 h_layout->addWidget(button);
00079 button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
00080 QSizePolicy::Fixed));
00081 QObject::connect(button, SIGNAL(clicked(void)),
00082 this, SLOT(cancelClicked(void)));
00083 button = new QPushButton(QString("OK"), widget2);
00084 h_layout->addWidget(button);
00085 button->setDefault(true);
00086 button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
00087 QSizePolicy::Fixed));
00088 QObject::connect(button, SIGNAL(clicked(void)),
00089 this, SLOT(okClicked(void)));
00090 }
00091
00092
00093 void mxcpcAuthenticationDialog::setMessage(const QString& msg) {
00094
00095 MessageLabel->setText(msg);
00096 }
00097
00098
00099 void mxcpcAuthenticationDialog::openDialog(const QString& msg) {
00100
00101 setMessage(msg);
00102
00103 mxcpcDialog::openDialog();
00104 }
00105
00106
00107 void mxcpcAuthenticationDialog::closeEvent(QCloseEvent *e) {
00108
00109 emit authenticationCancelled();
00110 }
00111
00112
00113 void mxcpcAuthenticationDialog::okClicked(void) {
00114
00115 hide();
00116
00117 emit authenticationCommitted(UserEdit->text(), PasswordEdit->text());
00118 }
00119
00120
00121 void mxcpcAuthenticationDialog::cancelClicked(void) {
00122
00123 hide();
00124
00125 emit authenticationCancelled();
00126 }