[Desktop context menu] Hide Activities menu item when not using Activities

This is something that came up in the monthly VDG meeting: the desktop
context menu has a lot of stuff in it, and we're looking to slim it down
where possible so it isn't so overwhelming.

One potential target is the Activities menu item, which has no real use
for a user who isn't using activities. We can never be 100% sure, but if
there is only one activity, it's a good bet the user isn't using the
feature. In this case, we can hide the menu item that shows the
switcher, because there's nothing to switch to!

Now, the switcher also has a button to add new activities, so it could
be argued that this change makes activities less discoverable. However
the feature is shown pretty prominently in the commonly-accessed
Workspace Behavior group in System Settings, so I think it's already
discoverable enough.

Test plan:
- Have one activity and right-click on the desktop > See no menu item
- Create a second activity and right-click on the desktop > See it

Here's how the menu looks now when there is only one activity:

![smaller_now](/uploads/5b53fe7b3f3937c8c413206f8e179768/smaller_now.png)

cc @teams/vdg @ivan
wilder-5.25
Nate Graham 4 years ago
parent a94740d50d
commit c51c908b16
  1. 1
      containmentactions/contextmenu/CMakeLists.txt
  2. 7
      containmentactions/contextmenu/menu.cpp

@ -15,6 +15,7 @@ kcoreaddons_add_plugin(plasma_containmentactions_contextmenu SOURCES ${contextme
target_link_libraries(plasma_containmentactions_contextmenu
Qt::DBus
KF5::Activities
KF5::I18n
KF5::GlobalAccel
KF5::Plasma

@ -12,6 +12,7 @@
#include <QVBoxLayout>
#include <KActionCollection>
#include <KActivities/Consumer>
#include <KAuthorized>
#include <KGlobalAccel>
#include <KIO/CommandLauncherJob>
@ -202,6 +203,12 @@ QAction *ContextMenu::action(const QString &name)
}
} else if (name == QLatin1String("manage activities")) {
if (c->corona()) {
// Don't show the action if there's only one activity since in this
// case it's clear that the user doesn't use activities
if (KActivities::Consumer().activities().length() == 1) {
return nullptr;
}
return c->corona()->actions()->action(QStringLiteral("manage activities"));
}
} else {

Loading…
Cancel
Save