Skip to content
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

Closed
wants to merge 8 commits into from
Closed

Conversation

dragotin
Copy link
Contributor

@dragotin dragotin commented Jan 22, 2017

This is a little beauty feature, to utilize owncloud/core#26872 . Hope you like it.

Looks like this:
avatar

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.
Copy link
Contributor

@ogoffart ogoffart left a 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()) ) {
Copy link
Contributor

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.


AvatarJob *job = new AvatarJob(_account, this);
QObject::connect(job, SIGNAL(avatarPixmap(QPixmap)), this, SLOT(slotAvatarPixmap(QPixmap)));

Copy link
Contributor

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.)

Copy link
Contributor Author

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?

@@ -119,6 +119,7 @@ protected slots:

void slotCapabilitiesRecieved(const QVariantMap&);
void slotUserFetched(const QVariantMap &);
void slotAvatarPixmap(const QPixmap&);
Copy link
Contributor

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.

@dragotin
Copy link
Contributor Author

Btw, I did not mean to push this to 2.3. Probably this PR should have gone to master, but your choice.

@dragotin
Copy link
Contributor Author

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.

Copy link
Contributor

@ogoffart ogoffart left a 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()));
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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)

Copy link
Contributor Author

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?

@guruz guruz added this to the 2.4.0 milestone Jan 24, 2017
{
int http_result_code = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();

QPixmap avPixmap;
Copy link
Member

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.

@dragotin
Copy link
Contributor Author

dragotin commented Mar 9, 2017

5e33898 fixes the testsuite by using QImage instead of QPixmap

@dragotin
Copy link
Contributor Author

dragotin commented Mar 9, 2017

@ogoffart @jturcotte please consider merging

@guruz
Copy link
Contributor

guruz commented Apr 12, 2017

(This would need to be merged in 2.4/master not 2.3)

@guruz
Copy link
Contributor

guruz commented Apr 12, 2017

Bummer. Still needs all the SettingsDialogMac code.
@shadone ? :-P

@guruz
Copy link
Contributor

guruz commented Apr 12, 2017

Why does Jenkins complain? https://jenkins.owncloud.org/job/owncloud-client/job/client/job/PR-5482/102/console

[ 13%] Building CXX object src/libsync/CMakeFiles/owncloudsync.dir/networkjobs.cpp.o
/var/lib/jenkins/workspace/cloud-client_client_PR-5482-YZILCXVUZD7LRF3ZRLYP2JS3Q6G7ZWAKK3GHZ7TY3RB7BIKKIFNA/src/libsync/networkjobs.cpp: In member function ‘virtual void OCC::AvatarJob::start()’:
/var/lib/jenkins/workspace/cloud-client_client_PR-5482-YZILCXVUZD7LRF3ZRLYP2JS3Q6G7ZWAKK3GHZ7TY3RB7BIKKIFNA/src/libsync/networkjobs.cpp:598:47: error: ‘davRequest’ was not declared in this scope
     setReply(davRequest("GET", _avatarUrl, req));
                                               ^
src/libsync/CMakeFiles/owncloudsync.dir/build.make:330: recipe for target 'src/libsync/CMakeFiles/owncloudsync.dir/networkjobs.cpp.o' failed
make[2]: *** [src/libsync/CMakeFiles/owncloudsync.dir/networkjobs.cpp.o] Error 1
CMakeFiles/Makefile2:1084: recipe for target 'src/libsync/CMakeFiles/owncloudsync.dir/all' failed
make[1]: *** [src/libsync/CMakeFiles/owncloudsync.dir/all] Error 2
Makefile:147: recipe for target 'all' failed
make: *** [all] Error 2

@guruz
Copy link
Contributor

guruz commented Apr 12, 2017

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

@guruz
Copy link
Contributor

guruz commented Apr 12, 2017

I pushed the macOS support..

@CLAassistant
Copy link

CLAassistant commented Apr 12, 2017

CLA assistant check
All committers have signed the CLA.

auto accountAction = createColorAwareAction(QLatin1String(":/client/resources/account.png"),
brandingSingleAccount ? tr("Account") : s->account()->displayName());
QAction *accountAction;
QImage avatar = s->account()->avatar();
Copy link
Contributor

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?

@dragotin
Copy link
Contributor Author

Hmm, I added a missing email address to my github account now again. Lets see if I have now signed the CLA again.

@ogoffart
Copy link
Contributor

ogoffart commented Apr 13, 2017

I have the same error locally:

src/libsync/networkjobs.cpp:598:14: error: use of undeclared identifier 'davRequest'

Because the API changed with 4a1a5fa

ogoffart added a commit that referenced this pull request Apr 13, 2017
Also fix compilation because of 22370fdbdadd06f0cacd249a8d7a32f0d3c1374e

Pull request #5482
@ogoffart
Copy link
Contributor

Merged in master via commit 8cb3a77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants