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 = Profile::loadProfile(profileName);
|
||||
} else {
|
||||
LoginScreen loginScreen{};
|
||||
LoginScreen loginScreen{profileName};
|
||||
loginScreen.exec();
|
||||
profile = loginScreen.getProfile();
|
||||
if (profile) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user