22 #include "ui_loginscreen.h"
32 #include <QMessageBox>
33 #include <QToolButton>
38 , quitShortcut{QKeySequence(Qt::CTRL + Qt::Key_Q),
this}
43 this->setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint);
44 this->setFixedSize(this->size());
46 connect(&quitShortcut, &QShortcut::activated,
this, &LoginScreen::close);
54 connect(ui->loginUsernames, &QComboBox::currentTextChanged,
this,
62 reset(initialProfileName);
80 ui->newUsername->clear();
82 ui->newPassConfirm->clear();
83 ui->loginPassword->clear();
84 ui->loginUsernames->clear();
88 if (allProfileNames.isEmpty()) {
89 ui->stackedWidget->setCurrentIndex(0);
90 ui->newUsername->setFocus();
92 for (
const QString& profileName : allProfileNames) {
93 ui->loginUsernames->addItem(profileName);
96 ui->loginUsernames->setCurrentText(initialProfileName);
97 ui->stackedWidget->setCurrentIndex(1);
98 ui->loginPassword->setFocus();
104 done(QDialog::Accepted);
109 QMessageBox::critical(
this, tr(
"Couldn't load this profile"), tr(
"Wrong password."));
110 ui->loginPassword->setFocus();
111 ui->loginPassword->selectAll();
116 ui->autoLoginCB->setChecked(state);
121 switch (
event->type()) {
123 case QEvent::WindowActivate:
124 case QEvent::WindowStateChange:
132 return QWidget::event(
event);
137 ui->stackedWidget->setCurrentIndex(0);
142 ui->stackedWidget->setCurrentIndex(1);
147 QString name =
ui->newUsername->text();
148 QString pass =
ui->newPass->text();
150 if (name.isEmpty()) {
151 QMessageBox::critical(
this, tr(
"Couldn't create a new profile"),
152 tr(
"The username must not be empty."));
156 if (pass.size() != 0 && pass.size() < 6) {
157 QMessageBox::critical(
this, tr(
"Couldn't create a new profile"),
158 tr(
"The password must be at least 6 characters long."));
162 if (
ui->newPassConfirm->text() != pass) {
163 QMessageBox::critical(
this, tr(
"Couldn't create a new profile"),
164 tr(
"The passwords you've entered are different.\nPlease make sure to "
165 "enter the same password twice."));
170 QMessageBox::critical(
this, tr(
"Couldn't create a new profile"),
171 tr(
"A profile with this name already exists."));
183 ui->loginPassword->clear();
185 ui->loginPasswordLabel->show();
186 ui->loginPassword->show();
190 ui->autoLoginCB->hide();
192 ui->loginPasswordLabel->hide();
193 ui->loginPassword->hide();
194 ui->autoLoginCB->show();
195 ui->autoLoginCB->setToolTip(
196 tr(
"Password protected profiles can't be automatically loaded."));
202 QString name =
ui->loginUsernames->currentText();
203 QString pass =
ui->loginPassword->text();
206 if (name.isEmpty()) {
207 QMessageBox::critical(
this, tr(
"Couldn't load profile"),
208 tr(
"There is no selected profile.\n\n"
209 "You may want to create one."));
214 QMessageBox::critical(
this, tr(
"Couldn't load this profile"),
215 tr(
"This profile is already in use."));
229 auto cstate =
static_cast<Qt::CheckState
>(state);
235 ui->retranslateUi(
this);