Skip to content

Commit

Permalink
Merge pull request #505 from krkk/login-warning-dialog
Browse files Browse the repository at this point in the history
Add login warning dialog for logging into the same account
  • Loading branch information
KitsuneRal authored Feb 24, 2019
2 parents cd5564c + 0b36231 commit 8b36a58
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions client/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ void Dialog::buttonClicked(QAbstractButton* button)
switch (buttons->buttonRole(button))
{
case QDialogButtonBox::AcceptRole:
case QDialogButtonBox::YesRole:
if (validate())
{
if (statusLabel)
Expand All @@ -107,6 +108,7 @@ void Dialog::buttonClicked(QAbstractButton* button)
load();
break;
case QDialogButtonBox::RejectRole:
case QDialogButtonBox::NoRole:
reject();
break;
default:
Expand Down
22 changes: 21 additions & 1 deletion client/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,27 @@ void MainWindow::showLoginWindow(const QString& statusMessage)
account.sync();

showFirstSyncIndicator();
addConnection(connection, dialog.deviceName());

QString deviceName = dialog.deviceName();
const auto it = std::find_if(connections.cbegin(), connections.cend(),
[connection] (Connection* c) {
return c->userId() == connection->userId();
});

if (it != connections.cend())
{
int ret = QMessageBox::warning(this,
tr("Logging in into a logged in account"),
tr("You're trying to log in into an account that's "
"already logged in. Do you want to continue?"),
QMessageBox::Yes, QMessageBox::No);

if (ret == QMessageBox::Yes)
deviceName += "-" + connection->deviceId();
else
return;
}
addConnection(connection, deviceName);
}
}

Expand Down

0 comments on commit 8b36a58

Please sign in to comment.