QTfrontend/ui/widget/roomnameprompt.cpp
changeset 9541 312bb4384f33
parent 9163 67334acaaac7
child 9547 f9e82f34c904
equal deleted inserted replaced
9539:ab44d44a6177 9541:312bb4384f33
    21 #include <QHBoxLayout>
    21 #include <QHBoxLayout>
    22 #include <QPushButton>
    22 #include <QPushButton>
    23 #include <QLineEdit>
    23 #include <QLineEdit>
    24 #include <QLabel>
    24 #include <QLabel>
    25 #include <QDebug>
    25 #include <QDebug>
       
    26 #include <QCheckBox>
    26 
    27 
    27 #include "roomnameprompt.h"
    28 #include "roomnameprompt.h"
    28 
    29 
    29 RoomNamePrompt::RoomNamePrompt(QWidget* parent, const QString & roomName) : QDialog(parent)
    30 RoomNamePrompt::RoomNamePrompt(QWidget* parent, const QString & roomName) : QDialog(parent)
    30 {
    31 {
    31     setModal(true);
    32     setModal(true);
    32     setWindowFlags(Qt::Sheet);
    33     setWindowFlags(Qt::Sheet);
    33     setWindowModality(Qt::WindowModal);
    34     setWindowModality(Qt::WindowModal);
    34     setMinimumSize(360, 130);
    35     setMinimumSize(360, 130);
    35     resize(360, 130);
    36     resize(360, 180);
    36     setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    37     setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    37 
    38 
    38     // Layout
    39     // Layout
    39     QVBoxLayout * dialogLayout = new QVBoxLayout(this);
    40     QVBoxLayout * dialogLayout = new QVBoxLayout(this);
    40 
    41 
    41     // Label
    42     // Label
    42     label = new QLabel(tr("Enter a name for your room."));
    43     label = new QLabel(tr("Enter a name for your room."), this);
    43     label->setWordWrap(true);
    44     label->setWordWrap(true);
    44     dialogLayout->addWidget(label, 0);
    45     dialogLayout->addWidget(label);
    45 
    46 
    46     // Input box
    47     // Input box
    47     editBox = new QLineEdit();
    48     leRoomName = new QLineEdit(this);
    48     editBox->setText(roomName);
    49     leRoomName->setText(roomName);
    49     editBox->setMaxLength(59); // It didn't like 60 :(
    50     leRoomName->setMaxLength(59); // It didn't like 60 :(
    50     editBox->setStyleSheet("QLineEdit { padding: 3px; }");
    51     leRoomName->setStyleSheet("QLineEdit { padding: 3px; }");
    51     editBox->selectAll();
    52     leRoomName->selectAll();
    52     dialogLayout->addWidget(editBox, 1);
    53     dialogLayout->addWidget(leRoomName);
       
    54 
       
    55     cbSetPassword = new QCheckBox(this);
       
    56     cbSetPassword->setText(tr("set password"));
       
    57     dialogLayout->addWidget(cbSetPassword);
       
    58 
       
    59     lePassword = new QLineEdit(this);
       
    60     //lePassword->setMaxLength(30);
       
    61     //lePassword->setStyleSheet("QLineEdit { padding: 3px; }");
       
    62     lePassword->setEnabled(false);
       
    63     dialogLayout->addWidget(lePassword);
    53 
    64 
    54     dialogLayout->addStretch(1);
    65     dialogLayout->addStretch(1);
    55 
    66 
    56     // Buttons
    67     // Buttons
    57     QHBoxLayout * buttonLayout = new QHBoxLayout();
    68     QHBoxLayout * buttonLayout = new QHBoxLayout();
    71 #endif
    82 #endif
    72     btnOkay->setDefault(true);
    83     btnOkay->setDefault(true);
    73 
    84 
    74     setStyleSheet("QPushButton { padding: 5px; }");
    85     setStyleSheet("QPushButton { padding: 5px; }");
    75 
    86 
    76     connect(btnOkay, SIGNAL(clicked()), this, SLOT(setRoomName()));
    87     connect(cbSetPassword, SIGNAL(toggled(bool)), this, SLOT(checkBoxToggled()));
    77 }
    88 }
    78 
    89 
    79 void RoomNamePrompt::setRoomName()
    90 QString RoomNamePrompt::getRoomName()
    80 {
    91 {
    81     emit roomNameChosen(editBox->text());
    92     return leRoomName->text();
    82 }
    93 }
       
    94 
       
    95 QString RoomNamePrompt::getPassword()
       
    96 {
       
    97     return lePassword->text();
       
    98 }
       
    99 
       
   100 void RoomNamePrompt::checkBoxToggled()
       
   101 {
       
   102     lePassword->setEnabled(cbSetPassword->isChecked());
       
   103 }