mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(loginScreen): make loginScreen return values comply with Qt standards
This commit makes LoginScreen return QDialog::Rejected (0) and QDialog::Accepted (1) instead of C standard return values. This should be more robust with regards to special cases in Qt implementation. Fixes #5781
This commit is contained in:
parent
a44cce65be
commit
b4bc09345c
|
@ -391,8 +391,8 @@ int main(int argc, char* argv[])
|
||||||
} else {
|
} else {
|
||||||
nexus.setParser(&parser);
|
nexus.setParser(&parser);
|
||||||
int returnval = nexus.showLogin(profileName);
|
int returnval = nexus.showLogin(profileName);
|
||||||
if (returnval != 0) {
|
if (returnval == QDialog::Rejected) {
|
||||||
return returnval;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,11 @@ int Nexus::showLogin(const QString& profileName)
|
||||||
// The connection order ensures profile will be ready for bootstrap for now
|
// The connection order ensures profile will be ready for bootstrap for now
|
||||||
connect(this, &Nexus::currentProfileChanged, this, &Nexus::bootstrapWithProfile);
|
connect(this, &Nexus::currentProfileChanged, this, &Nexus::bootstrapWithProfile);
|
||||||
int returnval = loginScreen.exec();
|
int returnval = loginScreen.exec();
|
||||||
|
if (returnval == QDialog::Rejected) {
|
||||||
|
// Kriby: This will terminate the main application loop, necessary until we refactor
|
||||||
|
// away the split startup/return to login behavior.
|
||||||
|
qApp->quit();
|
||||||
|
}
|
||||||
disconnect(this, &Nexus::currentProfileChanged, this, &Nexus::bootstrapWithProfile);
|
disconnect(this, &Nexus::currentProfileChanged, this, &Nexus::bootstrapWithProfile);
|
||||||
return returnval;
|
return returnval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,15 +72,6 @@ LoginScreen::~LoginScreen()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginScreen::closeEvent(QCloseEvent* event)
|
|
||||||
{
|
|
||||||
|
|
||||||
// If we are in the bootstrap, returning -1 will give us something to exit with in main.cpp
|
|
||||||
this->setResult(-1);
|
|
||||||
// If we are in application exec, we can quit by closing it, instead.
|
|
||||||
qApp->quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Resets the UI, clears all fields.
|
* @brief Resets the UI, clears all fields.
|
||||||
*/
|
*/
|
||||||
|
@ -110,10 +101,11 @@ void LoginScreen::reset(const QString& initialProfileName)
|
||||||
|
|
||||||
void LoginScreen::onProfileLoaded()
|
void LoginScreen::onProfileLoaded()
|
||||||
{
|
{
|
||||||
done(0);
|
done(QDialog::Accepted);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginScreen::onProfileLoadFailed() {
|
void LoginScreen::onProfileLoadFailed()
|
||||||
|
{
|
||||||
QMessageBox::critical(this, tr("Couldn't load this profile"), tr("Wrong password."));
|
QMessageBox::critical(this, tr("Couldn't load this profile"), tr("Wrong password."));
|
||||||
ui->loginPassword->setFocus();
|
ui->loginPassword->setFocus();
|
||||||
ui->loginPassword->selectAll();
|
ui->loginPassword->selectAll();
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
#ifndef LOGINSCREEN_H
|
#ifndef LOGINSCREEN_H
|
||||||
#define LOGINSCREEN_H
|
#define LOGINSCREEN_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
class Profile;
|
class Profile;
|
||||||
|
|
||||||
|
@ -47,9 +47,6 @@ signals:
|
||||||
void createNewProfile(QString name, const QString& pass);
|
void createNewProfile(QString name, const QString& pass);
|
||||||
void loadProfile(QString name, const QString& pass);
|
void loadProfile(QString name, const QString& pass);
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void closeEvent(QCloseEvent* event) final override;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onProfileLoaded();
|
void onProfileLoaded();
|
||||||
void onProfileLoadFailed();
|
void onProfileLoadFailed();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user