-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add login warning dialog for logging into the same account #505
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for following up on this. I have a few nitpicks, the biggest (and the only mandatory one) is about the for()
declaration.
client/mainwindow.cpp
Outdated
{ | ||
if (a->userId() == connection->userId()) | ||
{ | ||
Dialog warningDialog(tr("Logging in into a logged in account"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You actually don't need a Dialog
here. A QMessageBox::warning()
should cover all your needs, shouldn't it?
client/mainwindow.cpp
Outdated
@@ -760,7 +761,26 @@ void MainWindow::showLoginWindow(const QString& statusMessage) | |||
account.sync(); | |||
|
|||
showFirstSyncIndicator(); | |||
addConnection(connection, dialog.deviceName()); | |||
|
|||
for (auto a: connections) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, instead of an explicit for()
it would be great to do a std::find()
:
for (auto a: connections) | |
const auto it = std::find(connections.cbegin(), connections.cend(), | |
[a] (Connection* c) { return a->userId() == c->userId(); }); | |
if (it != connections.cend()) |
If you hate STL algorithms, at least enclose connections
into qAsConst
to prevent COW-detaching (see, e.g., https://stackoverflow.com/questions/35811053/using-c11-range-based-for-loop-correctly-in-qt).
client/mainwindow.cpp
Outdated
|
||
for (auto a: connections) | ||
{ | ||
if (a->userId() == connection->userId()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With std::find()
this becomes unneeded, of course.
client/mainwindow.cpp
Outdated
warningDialog.addWidget(label); | ||
|
||
if (warningDialog.exec()) | ||
deviceName += "-" + connection->deviceId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's really a nitpick but I believe you can break;
after that (unless rewritten via std::find()
, see above).
client/mainwindow.cpp
Outdated
@@ -746,6 +746,7 @@ void MainWindow::showLoginWindow(const QString& statusMessage) | |||
{ | |||
auto connection = dialog.releaseConnection(); | |||
AccountSettings account(connection->userId()); | |||
QString deviceName = dialog.deviceName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move it down, closer to where it's actually used? It's not C so we can declare variables anywhere in the block (and I prefer it to grouping variable definitions).
…for logging into the same account
Closes #369