mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(login): start login screen on profile select by -p option
This commit is contained in:
parent
2d87999922
commit
1af3ad69e8
|
@ -328,7 +328,7 @@ int main(int argc, char* argv[])
|
||||||
!Profile::isEncrypted(profileName)) {
|
!Profile::isEncrypted(profileName)) {
|
||||||
profile = Profile::loadProfile(profileName);
|
profile = Profile::loadProfile(profileName);
|
||||||
} else {
|
} else {
|
||||||
LoginScreen loginScreen{};
|
LoginScreen loginScreen{profileName};
|
||||||
loginScreen.exec();
|
loginScreen.exec();
|
||||||
profile = loginScreen.getProfile();
|
profile = loginScreen.getProfile();
|
||||||
if (profile) {
|
if (profile) {
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
LoginScreen::LoginScreen(QWidget* parent)
|
LoginScreen::LoginScreen(QString initialProfile, QWidget* parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, ui(new Ui::LoginScreen)
|
, ui(new Ui::LoginScreen)
|
||||||
, quitShortcut{QKeySequence(Qt::CTRL + Qt::Key_Q), this}
|
, quitShortcut{QKeySequence(Qt::CTRL + Qt::Key_Q), this}
|
||||||
|
@ -59,7 +59,7 @@ LoginScreen::LoginScreen(QWidget* parent)
|
||||||
connect(ui->autoLoginCB, &QCheckBox::stateChanged, this, &LoginScreen::onAutoLoginToggled);
|
connect(ui->autoLoginCB, &QCheckBox::stateChanged, this, &LoginScreen::onAutoLoginToggled);
|
||||||
connect(ui->importButton, &QPushButton::clicked, this, &LoginScreen::onImportProfile);
|
connect(ui->importButton, &QPushButton::clicked, this, &LoginScreen::onImportProfile);
|
||||||
|
|
||||||
reset();
|
reset(initialProfile);
|
||||||
this->setStyleSheet(Style::getStylesheet(":/ui/loginScreen/loginScreen.css"));
|
this->setStyleSheet(Style::getStylesheet(":/ui/loginScreen/loginScreen.css"));
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
|
@ -75,7 +75,7 @@ LoginScreen::~LoginScreen()
|
||||||
/**
|
/**
|
||||||
* @brief Resets the UI, clears all fields.
|
* @brief Resets the UI, clears all fields.
|
||||||
*/
|
*/
|
||||||
void LoginScreen::reset()
|
void LoginScreen::reset(QString initialProfile)
|
||||||
{
|
{
|
||||||
ui->newUsername->clear();
|
ui->newUsername->clear();
|
||||||
ui->newPass->clear();
|
ui->newPass->clear();
|
||||||
|
@ -84,13 +84,16 @@ void LoginScreen::reset()
|
||||||
ui->loginUsernames->clear();
|
ui->loginUsernames->clear();
|
||||||
|
|
||||||
Profile::scanProfiles();
|
Profile::scanProfiles();
|
||||||
QString lastUsed = Settings::getInstance().getCurrentProfile();
|
if (initialProfile.isEmpty()) {
|
||||||
|
initialProfile = Settings::getInstance().getCurrentProfile();
|
||||||
|
}
|
||||||
QVector<QString> profiles = Profile::getProfiles();
|
QVector<QString> profiles = Profile::getProfiles();
|
||||||
for (QString profile : profiles) {
|
for (QString profile : profiles) {
|
||||||
ui->loginUsernames->addItem(profile);
|
ui->loginUsernames->addItem(profile);
|
||||||
if (profile == lastUsed)
|
if (profile == initialProfile) {
|
||||||
ui->loginUsernames->setCurrentIndex(ui->loginUsernames->count() - 1);
|
ui->loginUsernames->setCurrentIndex(ui->loginUsernames->count() - 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (profiles.isEmpty()) {
|
if (profiles.isEmpty()) {
|
||||||
ui->stackedWidget->setCurrentIndex(0);
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
|
|
|
@ -36,9 +36,9 @@ class LoginScreen : public QDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit LoginScreen(QWidget* parent = nullptr);
|
LoginScreen(QString selectedProfile = QString(), QWidget* parent = nullptr);
|
||||||
~LoginScreen();
|
~LoginScreen();
|
||||||
void reset();
|
void reset(QString selectedProfile = QString());
|
||||||
Profile* getProfile() const;
|
Profile* getProfile() const;
|
||||||
|
|
||||||
bool event(QEvent* event) final override;
|
bool event(QEvent* event) final override;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user