1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
myLoginWindow::myLoginWindow()
{
setWindowTitle("Login");
/* Layout */
QGridLayout *layoutPrincipal = new QGridLayout;
/*Labels*/
QLabel *myFirstTitle = new QLabel(this);
QLabel *mySecondTitle = new QLabel(this);
QLabel *myLabel = new QLabel(this);
QLabel *mySecondLabel = new QLabel(this);
QLabel *myThirdLabel = new QLabel(this);
QLabel *myLabelForExternalIP = new QLabel(this);
QLabel *myLabelForPort = new QLabel(this);
/* Fonts */
QFont myFontForTitle("Arial", 14);
/* Colors */
QPalette pal;
pal.setColor(QPalette::Background, Qt::gray);
setAutoFillBackground(true);
setPalette(pal);
/* InputLine */
myLineForPseudo = new QLineEdit;
myLineForIPAddress = new QLineEdit;
myButtonToContinue = new QPushButton;
/* QSpinBox */
myIntegerInput = new QSpinBox;
//myExternalPort= new QSpinBox;
/* Configuration des QSpinBox */
myIntegerInput->setMaximum(9999);
myIntegerInput->setMinimum(9990);
myIntegerInput->setValue(9999);
/*myExternalPort->setMaximum(9999);
myExternalPort->setMinimum(9990);
myExternalPort->setValue(9999);*/
/* texte dans les labels */
pseudo = "";
myLabel->setText("Pseudo : ");
mySecondLabel->setText("Adresse IP sur laquelle écouter : ");
myThirdLabel->setText("Port sur lequel écouter : ");
myFirstTitle->setText("<b> Informations sur l'utilisateur </b>");
myFirstTitle->setFont(myFontForTitle);
mySecondTitle->setText("<b> Informations sur les utilisateurs extérieurs </b>");
mySecondTitle->setFont(myFontForTitle);
myLabelForExternalIP->setText("Adresse IP à laquelle se connecter : ");
myLabelForPort->setText("Port sur lequel se connecter : ");
/* texte dans les boutons */
myButtonToContinue->setText("Ok");
/* connexion des signaux aux slots */
connect(myButtonToContinue, SIGNAL(clicked()), this, SLOT(endInput()));
connect(myLineForPseudo, SIGNAL(returnPressed()), this, SLOT(endInput()));
connect(this, SIGNAL(endPressed()), qApp, SLOT(quit()));
/* Ajout des widgets au layout */
layoutPrincipal->addWidget(myFirstTitle, 0, 0, 1, 2);
layoutPrincipal->addWidget(myLabel,1 , 0);
layoutPrincipal->addWidget(myLineForPseudo, 1 , 1);
layoutPrincipal->addWidget(mySecondLabel, 2, 0);
layoutPrincipal->addWidget(myLineForIPAddress, 2, 1);
layoutPrincipal->addWidget(myThirdLabel, 3, 0);
layoutPrincipal->addWidget(myIntegerInput, 3, 1);
layoutPrincipal->addWidget(mySecondTitle, 4, 0, 1, 2);
layoutPrincipal->addWidget(myLabelForExternalIP, 5, 0);
layoutPrincipal->addWidget(myLabelForPort, 6, 0);
//layoutPrincipal->addWidget(myExternalPort, 6, 1);
layoutPrincipal->addWidget(myButtonToContinue, 7, 0, 1, 2);
/* Affichage layout */
setLayout(layoutPrincipal);
}
void myLoginWindow::endInput(){
pseudo = myLineForPseudo->text();
if(!pseudo.isEmpty()){
emit endPressed();
}
}
QString myLoginWindow::getPseudo(){
return pseudo;
} |
Partager