-
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
Profile dialog #677
Profile dialog #677
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.
This is fantastic, thanks! Just a few nitpicks.
client/mainwindow.cpp
Outdated
this, [=] | ||
{ | ||
auto* dlg = new ProfileDialog(c->user(), this); | ||
dlg->setModal(false); | ||
dlg->setAttribute(Qt::WA_DeleteOnClose); | ||
dlg->reactivate(); | ||
}); |
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 might have seen summon()
used in other places to achieve the same effect and also provide lazy initialisation:
this, [=] | |
{ | |
auto* dlg = new ProfileDialog(c->user(), this); | |
dlg->setModal(false); | |
dlg->setAttribute(Qt::WA_DeleteOnClose); | |
dlg->reactivate(); | |
}); | |
this, [this,c,dlg=QPointer<ProfileDialog>{}]() mutable | |
{ | |
summon(dlg, c->user(), this); | |
}); |
Being pre-C++17, other places use static
declaration instead of an initialisation in the capture block and making the lambda mutable - the C++17 way is slightly cleaner because it destructs the dialog when the lambda is destructed (in this case - when the connection is logged out). Ideally it should destruct the dialog with deleteLater()
but I'm yet to commit the facility class to do that.
client/profiledialog.cpp
Outdated
//auto mainLayout = new QFormLayout; | ||
//profileWidget->setLayout(mainLayout); | ||
|
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.
//auto mainLayout = new QFormLayout; | |
//profileWidget->setLayout(mainLayout); |
client/profiledialog.cpp
Outdated
topLayout->addLayout(essentialsLayout); | ||
} | ||
|
||
//mainLayout->addRow(topLayout); |
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.
//mainLayout->addRow(topLayout); |
client/profiledialog.cpp
Outdated
connect(devicesJob, &BaseJob::success, this, [=] { | ||
m_deviceTable->setRowCount(devicesJob->devices().size()); | ||
|
||
for (int i = 0; i < devicesJob->devices().size(); i++) { |
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.
for (int i = 0; i < devicesJob->devices().size(); i++) { | |
for (int i = 0; i < devicesJob->devices().size(); ++i) { |
client/profiledialog.cpp
Outdated
if (!m_avatarUrl.isEmpty()) | ||
m_user->setAvatar(m_avatarUrl); | ||
|
||
for (auto d: m_devices) { |
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.
for (auto d: m_devices) { | |
for (const auto& deviceIt = m_devices.begin(); it != m_devices.end(); ++it) { |
client/profiledialog.cpp
Outdated
m_user->setAvatar(m_avatarUrl); | ||
|
||
for (auto d: m_devices) { | ||
auto list = m_deviceTable->findItems(m_devices.key(d), Qt::MatchExactly); |
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.
auto list = m_deviceTable->findItems(m_devices.key(d), Qt::MatchExactly); | |
auto list = m_deviceTable->findItems(deviceIt.key(), Qt::MatchExactly); |
client/profiledialog.cpp
Outdated
if (!list.isEmpty() && newName != d) | ||
m_user->connection()->callApi<Quotient::UpdateDeviceJob>(m_devices.key(d), newName); |
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.
if (!list.isEmpty() && newName != d) | |
m_user->connection()->callApi<Quotient::UpdateDeviceJob>(m_devices.key(d), newName); | |
if (!list.isEmpty() && newName != deviceIt.value()) | |
m_user->connection()->callApi<Quotient::UpdateDeviceJob>(deviceIt.key(), newName); |
Changing display name and avatar is now possible.
...and take Quotient::User* instead of Quotient::Connection* as the first argument.
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 a ton!
Added uploading user avatar, changing display name, and viewing and renaming devices.
Closes #28
Contributes to #268 – I have no idea how to reveal an access token here.