emailQt/ParametersProvider.cpp

58 lines
1.5 KiB
C++
Raw Normal View History

2024-03-08 12:10:58 -05:00
#include "ParametersProvider.hpp"
ParametersProvider::ParametersProvider(QWidget *parent)
: QDialog(parent) {
auto *layout = new QVBoxLayout;
auto *user = new QLabel("Nom d'utilisateur", this);
userField = new QLineEdit;
auto *pass = new QLabel("Mot de passe", this);
passField = new QLineEdit;
passField->setEchoMode(QLineEdit::Password);
auto *imap = new QLabel("Serveur IMAP", this);
imapField = new QLineEdit("imap.gmail.com");
auto *port = new QLabel("Port", this);
portField = new QLineEdit("993");
portField->setValidator(new QIntValidator(1, 1000, this));
auto *startButton = new QPushButton("OK", this);
layout->addWidget(user);
layout->addWidget(userField);
layout->addWidget(pass);
layout->addWidget(passField);
layout->addWidget(imap);
layout->addWidget(imapField);
layout->addWidget(port);
layout->addWidget(portField);
layout->addStretch(1);
layout->addWidget(startButton);
this->setLayout(layout);
resize(300, 450);
connect(startButton, &QPushButton::clicked, this, &ParametersProvider::start);
}
void ParametersProvider::start() {
sett.port = portField->text().toInt();
sett.userS = userField->text().toStdString();
sett.passS = passField->text().toStdString();
sett.imapS = imapField->text().toStdString();
close();
emit done();
}
void ParametersProvider::setFocusInternal() {
activateWindow();
userField->setFocus();
}
const ParametersProvider::settings &ParametersProvider::getSettings() {
return sett;
}