Support activities when opening files
ClosedPublic

Authored by sscalabrino on Jul 1 2018, 11:29 AM.

Details

Summary

FEATURE: 395954

Test Plan

I tested this on my environment (Plasma 15.13 on X11), but it should be tested also on Wayland (without activities) and on other DEs.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
sscalabrino created this revision.Jul 1 2018, 11:29 AM
Restricted Application added a project: Kate. · View Herald TranscriptJul 1 2018, 11:29 AM
Restricted Application added a subscriber: kwrite-devel. · View Herald Transcript
sscalabrino requested review of this revision.Jul 1 2018, 11:29 AM
ngraham added a subscriber: ngraham.

Thanks for the patch! Can you change Fixes #395954 to FEATURE: 395954? See https://community.kde.org/Infrastructure/Phabricator#Formatting_your_patch

sscalabrino edited the summary of this revision. (Show Details)Jul 1 2018, 1:27 PM
sscalabrino edited the summary of this revision. (Show Details)

Gotta remove the link, sorry. :) It just needs to be plain old FEATURE: 395954.

sscalabrino edited the summary of this revision. (Show Details)Jul 1 2018, 1:35 PM

Looks already good to me, but one more code iteration would be nice.

@cullmann Any comments from your side?

kate/kateapp.cpp
278 ↗(On Diff #37002)

Simply writing the following is enough:

QStringList allActivities;
279 ↗(On Diff #37002)

Can we use range-based for loops here? Same below?

kate/kateapp.h
194 ↗(On Diff #37002)

Could you add API documentation here as well?

Think that is ok, if the given comments are implemented.

An alternative approach for the API would btw. to have just a function that tells you "I am on activity X", then one doesn't need to send stringlists around and check for contains.

Think that is ok, if the given comments are implemented.

An alternative approach for the API would btw. to have just a function that tells you "I am on activity X", then one doesn't need to send stringlists around and check for contains.

Thanks for the comment. The problem is that it is possible that the window is on more than a single activity (e.g., there are three activities, A, B and C, and a single Kate instance is in both A and C at the same time), that's why I used a StringList. Indeed, I implemented that as you suggested at the beginning, but then I noticed this problem. Also, the check is done only when the user opens a new file, and the list of activities should not be that long. In general, I think that the overhead is acceptable, and it allows us to have a complete support for activities.

Anyways, I will implement all your comments ASAP and I will update the patch.

Thanks for the review.

Hmm, that I don't understand ;=)

You just do:

if (answer.size() == 1) {
                      kateCurrentActivities = answer.at(0).toStringList();
                      for (int j = 0; j < kateCurrentActivities.size(); j++) {
                          if (kateCurrentActivities.at(j) == currentActivity) {
                              anyOnThisActivity = true;
                          }
                      }
                  }

> That means if you would have a dbus function that tells you "haveWindowForActivity(currentActivity)" you would be fine, or?

OK, I got what you mean. I implemented your suggestion and the other suggested fixes. I also changed the logic in main.cpp, because I found a bug in the previous version. It should be also more understandable.

dhaumann added inline comments.Jul 28 2018, 7:31 AM
kate/kateapp.cpp
278

Please remove this->

kate/kateappadaptor.h
56

Please pass as const reference: const QString &

kate/main.cpp
313

const bool ...

sscalabrino marked 2 inline comments as done.
cullmann accepted this revision.Jul 28 2018, 4:13 PM

I am happy with that, thanks for the changes.

This revision is now accepted and ready to land.Jul 28 2018, 4:13 PM

Someone will need to land this for Simone (whose email address is s.scalabrino9@gmail.com).

This revision was automatically updated to reflect the committed changes.