-
Notifications
You must be signed in to change notification settings - Fork 668
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
Display Avatar pictures in the Settingsdialog #5482
Conversation
The avatar pixmap is fetched from the server by the Connectionvalidator, once it has validated the user name, it queries the avatar pixmap. If the server does not have the avatar route, an empty pixmap is stored.
The avatar image is fetched from the server async, thus connect a signal from the account if the avatar changes. Server feature owncloud/core#26872 is needed.
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.
Looks good. Only the timeout need to be added.
@@ -236,6 +261,9 @@ void SettingsDialog::accountRemoved(AccountState *s) | |||
} | |||
} | |||
|
|||
if( _actionForAccount.contains(s->account().data()) ) { |
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.
Small detail: No need of the if here. remove does nothing if it is not there.
src/libsync/connectionvalidator.cpp
Outdated
|
||
AvatarJob *job = new AvatarJob(_account, this); | ||
QObject::connect(job, SIGNAL(avatarPixmap(QPixmap)), this, SLOT(slotAvatarPixmap(QPixmap))); | ||
|
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.
Missing
job->setTimeout(timeoutToUseMsec);
The default timeout is 5 minutes, and that's way to long for the connection validator which must finish much earlier in case of bad connection.
(And actually, since we increased the amount of jobs, timeoutToUseMsec might need to be lowered too. But I'm wondering if it would be possible to fetch the capabilities, user name, and the avatar in parallel.)
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.
I guess capabilities fetching could run in parallel to fetching the username, and following on that, the avatar, because the avatar needs the username. Maybe the fetch job of the avatar (at least) should be owned by the account, and could become fully async?
src/libsync/connectionvalidator.h
Outdated
@@ -119,6 +119,7 @@ protected slots: | |||
|
|||
void slotCapabilitiesRecieved(const QVariantMap&); | |||
void slotUserFetched(const QVariantMap &); | |||
void slotAvatarPixmap(const QPixmap&); |
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.
The ASCII art chart need to be updated at the beginning of this class.
Btw, I did not mean to push this to 2.3. Probably this PR should have gone to master, but your choice. |
Added Avatar fetching
The server displays the avatar cut into a circle, and so we do.
Updated the Ascii-art accordingly and set a 20 seconds timeout. Also, I added code that cuts a circle out of the avatar image, similar to what the server does. Looks better. |
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 does not work for me. If I use the same url as in the webinterface, it works tough. But what URL should we use then. @DeepDiver1975 ?
AvatarJob::AvatarJob(AccountPtr account, QObject *parent) | ||
: AbstractNetworkJob(account, QString(), parent) | ||
{ | ||
_avatarUrl = Utility::concatUrlPath(account->url(), QString("remote.php/dav/avatars/%1/128.png").arg(account->davUser())); |
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.
Does not work for me with this URL. (owncloud master)
The URL that works for me is index.php/avatar/%1/128
@DeepDiver1975 What's the exact URL of the avatars?
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.
Hmm, I think the pull request that is implementing the avatar images is not yet merged in core: owncloud/core#26872
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.
Then let's delay this PR to master/2.4? sorry for that.
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.
yes, sure.
@@ -252,7 +253,18 @@ void ConnectionValidator::slotUserFetched(const QVariantMap &json) | |||
QString user = json.value("ocs").toMap().value("data").toMap().value("id").toString(); | |||
if (!user.isEmpty()) { | |||
_account->setDavUser(user); | |||
|
|||
AvatarJob *job = new AvatarJob(_account, this); | |||
job->setTimeout(20*1000); |
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.
(I think it should use the same timeout as all the other jobs in this file, for consistency)
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.
@ogoffart wouldn''t it make more sense to set it in the constructor of AvatarJob anyway?
src/libsync/networkjobs.cpp
Outdated
{ | ||
int http_result_code = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); | ||
|
||
QPixmap avPixmap; |
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 seems to cause the FolderManTest to fail on your PR, since that needs a QGuiApplication. And you don't seem to need a QPixmap either, since you're creating a new one in circleMask
anyway, so storing it as a QImage could be enough to fix that test.
That fixes the test suite.
5e33898 fixes the testsuite by using QImage instead of QPixmap |
@ogoffart @jturcotte please consider merging |
(This would need to be merged in 2.4/master not 2.3) |
Bummer. Still needs all the |
Why does Jenkins complain? https://jenkins.owncloud.org/job/owncloud-client/job/client/job/PR-5482/102/console
|
It's not easy to adjust this for macOS since we also need API changes in src/3rdparty/qtmacgoodies :-| I propose this gets merged first and then do a commit later for macOS support. Code looks ok to me. So fine to merge in master/2.4 |
I pushed the macOS support.. |
auto accountAction = createColorAwareAction(QLatin1String(":/client/resources/account.png"), | ||
brandingSingleAccount ? tr("Account") : s->account()->displayName()); | ||
QAction *accountAction; | ||
QImage avatar = s->account()->avatar(); |
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.
I think this will never be called since accountAdded is called before the ConnectionValidator can run?
Hmm, I added a missing email address to my github account now again. Lets see if I have now signed the CLA again. |
I have the same error locally: src/libsync/networkjobs.cpp:598:14: error: use of undeclared identifier 'davRequest' Because the API changed with 4a1a5fa |
Also fix compilation because of 22370fdbdadd06f0cacd249a8d7a32f0d3c1374e Pull request #5482
Merged in master via commit 8cb3a77 |
This is a little beauty feature, to utilize owncloud/core#26872 . Hope you like it.
Looks like this: