1
0
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:
Anthony Bilinski 2018-04-19 23:54:14 -07:00
parent 2d87999922
commit 1af3ad69e8
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
3 changed files with 11 additions and 8 deletions

View File

@ -328,7 +328,7 @@ int main(int argc, char* argv[])
!Profile::isEncrypted(profileName)) {
profile = Profile::loadProfile(profileName);
} else {
LoginScreen loginScreen{};
LoginScreen loginScreen{profileName};
loginScreen.exec();
profile = loginScreen.getProfile();
if (profile) {

View File

@ -32,7 +32,7 @@
#include <QMessageBox>
#include <QToolButton>
LoginScreen::LoginScreen(QWidget* parent)
LoginScreen::LoginScreen(QString initialProfile, QWidget* parent)
: QDialog(parent)
, ui(new Ui::LoginScreen)
, 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->importButton, &QPushButton::clicked, this, &LoginScreen::onImportProfile);
reset();
reset(initialProfile);
this->setStyleSheet(Style::getStylesheet(":/ui/loginScreen/loginScreen.css"));
retranslateUi();
@ -75,7 +75,7 @@ LoginScreen::~LoginScreen()
/**
* @brief Resets the UI, clears all fields.
*/
void LoginScreen::reset()
void LoginScreen::reset(QString initialProfile)
{
ui->newUsername->clear();
ui->newPass->clear();
@ -84,13 +84,16 @@ void LoginScreen::reset()
ui->loginUsernames->clear();
Profile::scanProfiles();
QString lastUsed = Settings::getInstance().getCurrentProfile();
if (initialProfile.isEmpty()) {
initialProfile = Settings::getInstance().getCurrentProfile();
}
QVector<QString> profiles = Profile::getProfiles();
for (QString profile : profiles) {
ui->loginUsernames->addItem(profile);
if (profile == lastUsed)
if (profile == initialProfile) {
ui->loginUsernames->setCurrentIndex(ui->loginUsernames->count() - 1);
}
}
if (profiles.isEmpty()) {
ui->stackedWidget->setCurrentIndex(0);

View File

@ -36,9 +36,9 @@ class LoginScreen : public QDialog
Q_OBJECT
public:
explicit LoginScreen(QWidget* parent = nullptr);
LoginScreen(QString selectedProfile = QString(), QWidget* parent = nullptr);
~LoginScreen();
void reset();
void reset(QString selectedProfile = QString());
Profile* getProfile() const;
bool event(QEvent* event) final override;