Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.3
plasma5-workspace
0015-Changes-to-global-menu-applet.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0015-Changes-to-global-menu-applet.patch of Package plasma5-workspace
From 13bddd5e21fc9d8aca31fab621e2f1068700c177 Mon Sep 17 00:00:00 2001 From: Chinmoy Ranjan Pradhan <chinmoyrp65@gmail.com> Date: Wed, 11 Jan 2017 20:45:24 +0530 Subject: [PATCH 15/44] Changes to global menu applet Some changes made to global menu applet: 1. Use "application-menu" icon in compact view. 2. Show a warning sign when global menu style is not set to "Widget". 3. When in a vertical panel force use compact view. 4. And some minor changes and cleanup. Differential Revision: https://phabricator.kde.org/D4070 --- applets/appmenu/lib/CMakeLists.txt | 1 + applets/appmenu/lib/appmenuapplet.cpp | 25 +++++++++++++++++++ applets/appmenu/lib/appmenuapplet.h | 10 +++++++- .../appmenu/package/contents/ui/configGeneral.qml | 12 ++++++--- applets/appmenu/package/contents/ui/main.qml | 29 ++++++++++++++++------ applets/appmenu/plugin/appmenumodel.cpp | 19 +++++++++++--- applets/appmenu/plugin/appmenumodel.h | 9 +++++-- 7 files changed, 88 insertions(+), 17 deletions(-) diff --git a/applets/appmenu/lib/CMakeLists.txt b/applets/appmenu/lib/CMakeLists.txt index 2947b04b..5b310e7c 100644 --- a/applets/appmenu/lib/CMakeLists.txt +++ b/applets/appmenu/lib/CMakeLists.txt @@ -9,6 +9,7 @@ kcoreaddons_desktop_to_json(plasma_applet_appmenu ../package/metadata.desktop) target_link_libraries(plasma_applet_appmenu Qt5::Widgets Qt5::Quick + Qt5::DBus KF5::Plasma KF5::WindowSystem) diff --git a/applets/appmenu/lib/appmenuapplet.cpp b/applets/appmenu/lib/appmenuapplet.cpp index d70af0d7..51fd3a6c 100644 --- a/applets/appmenu/lib/appmenuapplet.cpp +++ b/applets/appmenu/lib/appmenuapplet.cpp @@ -29,6 +29,7 @@ #include <QQuickItem> #include <QQuickWindow> #include <QScreen> +#include <QDBusConnection> AppMenuApplet::AppMenuApplet(QObject *parent, const QVariantList &data) : Plasma::Applet(parent, data) @@ -40,6 +41,12 @@ AppMenuApplet::~AppMenuApplet() = default; void AppMenuApplet::init() { // TODO Wayland PlasmaShellSurface stuff + QDBusConnection::sessionBus().connect(QStringLiteral("org.kde.kappmenu"), + QStringLiteral("/KAppMenu"), + QStringLiteral("org.kde.kappmenu"), + QStringLiteral("reconfigured"), + this, SLOT(updateAppletEnabled())); + updateAppletEnabled(); } AppMenuModel *AppMenuApplet::model() const @@ -94,6 +101,24 @@ void AppMenuApplet::setButtonGrid(QQuickItem *buttonGrid) } } +bool AppMenuApplet::appletEnabled() const +{ + return m_appletEnabled; +} + +void AppMenuApplet::updateAppletEnabled() +{ + KConfigGroup config(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), QStringLiteral("Appmenu Style")); + const QString &menuStyle = config.readEntry(QStringLiteral("Style")); + + const bool enabled = (menuStyle == QLatin1String("Widget")); + + if (m_appletEnabled != enabled) { + m_appletEnabled = enabled; + emit appletEnabledChanged(); + } +} + QMenu *AppMenuApplet::createMenu(int idx) const { QMenu *menu = nullptr; diff --git a/applets/appmenu/lib/appmenuapplet.h b/applets/appmenu/lib/appmenuapplet.h index 85296720..d08013f6 100644 --- a/applets/appmenu/lib/appmenuapplet.h +++ b/applets/appmenu/lib/appmenuapplet.h @@ -33,6 +33,8 @@ class AppMenuApplet : public Plasma::Applet { Q_OBJECT + Q_PROPERTY(bool appletEnabled READ appletEnabled NOTIFY appletEnabledChanged) + Q_PROPERTY(AppMenuModel* model READ model WRITE setModel NOTIFY modelChanged) Q_PROPERTY(int view READ view WRITE setView NOTIFY viewChanged) @@ -63,15 +65,20 @@ public: int view() const; void setView(int type); - Q_INVOKABLE void trigger(QQuickItem *ctx, int idx); + bool appletEnabled() const; signals: void modelChanged(); void viewChanged(); void currentIndexChanged(); void buttonGridChanged(); + void appletEnabledChanged(); void requestActivateIndex(int index); +public slots: + void updateAppletEnabled(); + void trigger(QQuickItem *ctx, int idx); + protected: bool eventFilter(QObject *watched, QEvent *event); @@ -83,6 +90,7 @@ private: int m_currentIndex = -1; int m_viewType = FullView; + bool m_appletEnabled = true; QPointer<QMenu> m_currentMenu; QPointer<QQuickItem> m_buttonGrid; QPointer<AppMenuModel> m_model; diff --git a/applets/appmenu/package/contents/ui/configGeneral.qml b/applets/appmenu/package/contents/ui/configGeneral.qml index 93de158b..5dc618e4 100644 --- a/applets/appmenu/package/contents/ui/configGeneral.qml +++ b/applets/appmenu/package/contents/ui/configGeneral.qml @@ -22,26 +22,32 @@ import QtQuick 2.0 import QtQuick.Controls 1.0 as Controls import QtQuick.Layouts 1.1 as Layouts +import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore Layouts.ColumnLayout { id: configGeneral - property alias cfg_compactView: compactViewCheckBox.checked + property alias cfg_compactView: compactViewRadioButton.checked + + property bool disableSetting: plasmoid.formFactor === PlasmaCore.Types.Vertical || !plasmoid.nativeInterface.appletEnabled Controls.ExclusiveGroup { id: viewOptionGroup } Controls.RadioButton { - id: compactViewCheckBox + id: compactViewRadioButton + enabled: !disableSetting text: i18n("Use single button for application menu") exclusiveGroup: viewOptionGroup } Controls.RadioButton { + id: fullViewRadioButton //this checked binding is just for the initial load in case //compactViewCheckBox is not checked. Then exclusive group manages it - checked: !compactViewCheckBox.checked + enabled: !disableSetting + checked: !compactViewRadioButton.checked text: i18n("Show full application menu") exclusiveGroup: viewOptionGroup } diff --git a/applets/appmenu/package/contents/ui/main.qml b/applets/appmenu/package/contents/ui/main.qml index e24682ac..ca5a50bc 100644 --- a/applets/appmenu/package/contents/ui/main.qml +++ b/applets/appmenu/package/contents/ui/main.qml @@ -21,35 +21,46 @@ import QtQuick.Layouts 1.1 import QtQuick.Controls 1.4 import org.kde.plasma.plasmoid 2.0 +import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.private.appmenu 1.0 as AppMenuPrivate Item { id: root readonly property bool vertical: plasmoid.formFactor === PlasmaCore.Types.Vertical + readonly property bool appletEnabled: plasmoid.nativeInterface.appletEnabled + readonly property bool view: plasmoid.configuration.compactView + readonly property bool menuAvailable: appMenuModel.menuAvailable - readonly property bool compactView: plasmoid.configuration.compactView - - onCompactViewChanged: { - plasmoid.nativeInterface.view = compactView + onViewChanged: { + plasmoid.nativeInterface.view = view } Layout.minimumWidth: units.gridUnit Layout.minimumHeight: units.gridUnit - Plasmoid.preferredRepresentation: plasmoid.configuration.compactView ? Plasmoid.compactRepresentation : Plasmoid.fullRepresentation + Plasmoid.preferredRepresentation: (plasmoid.configuration.compactView || vertical || !appletEnabled) ? Plasmoid.compactRepresentation : Plasmoid.fullRepresentation Plasmoid.compactRepresentation: PlasmaComponents.ToolButton { + readonly property int fakeIndex: 0 Layout.fillWidth: false Layout.fillHeight: false Layout.minimumWidth: implicitWidth Layout.maximumWidth: implicitWidth - text: i18n("Menu") + enabled: appletEnabled ? menuAvailable : true + checkable: appletEnabled && menuAvailable && plasmoid.nativeInterface.currentIndex === fakeIndex + checked: checkable + iconSource: appletEnabled ? i18n("application-menu") : i18n("emblem-warning") onClicked: { - plasmoid.nativeInterface.trigger(this, 0); + if (appletEnabled) { + plasmoid.nativeInterface.trigger(this, 0); + } else { + KCMShell.open("style") + } + + } } @@ -97,6 +108,8 @@ Item { } } + Plasmoid.toolTipSubText: !appletEnabled ? i18n("Application Menu Widget is disabled in settings.\n\nGo to Settings > Application Style > Fine Tuning(tab) to enable it again.") : "" + AppMenuPrivate.AppMenuModel { id: appMenuModel Component.onCompleted: { diff --git a/applets/appmenu/plugin/appmenumodel.cpp b/applets/appmenu/plugin/appmenumodel.cpp index 2e4b8546..41e030c7 100644 --- a/applets/appmenu/plugin/appmenumodel.cpp +++ b/applets/appmenu/plugin/appmenumodel.cpp @@ -66,6 +66,19 @@ AppMenuModel::AppMenuModel(QObject *parent) AppMenuModel::~AppMenuModel() = default; +bool AppMenuModel::menuAvailable() const +{ + return m_menuAvailable; +} + +void AppMenuModel::setMenuAvailable(bool set) +{ + if (m_menuAvailable != set) { + m_menuAvailable = set; + emit menuAvailableChanged(); + } +} + int AppMenuModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); @@ -80,7 +93,7 @@ void AppMenuModel::update() m_activeActions.clear(); } - if (m_menu && m_winHasMenu) { + if (m_menu && m_menuAvailable) { const auto &actions = m_menu->actions(); for (QAction *action : actions) { m_activeActions.append(action); @@ -141,7 +154,7 @@ void AppMenuModel::onActiveWindowChanged(WId id) updateApplicationMenu(serviceName, menuObjectPath); return true; } - m_winHasMenu = false; + setMenuAvailable(false); emit modelNeedsUpdate(); return false; }; @@ -218,7 +231,7 @@ void AppMenuModel::updateApplicationMenu(const QString &serviceName, const QStri if (m_menu.isNull()) { return; } - m_winHasMenu = true; + setMenuAvailable(true); emit modelNeedsUpdate(); }); diff --git a/applets/appmenu/plugin/appmenumodel.h b/applets/appmenu/plugin/appmenumodel.h index 581cf483..77ad5e9d 100644 --- a/applets/appmenu/plugin/appmenumodel.h +++ b/applets/appmenu/plugin/appmenumodel.h @@ -33,6 +33,8 @@ class AppMenuModel : public QAbstractListModel { Q_OBJECT + Q_PROPERTY(bool menuAvailable READ menuAvailable WRITE setMenuAvailable NOTIFY menuAvailableChanged) + public: explicit AppMenuModel(QObject *parent = 0); ~AppMenuModel(); @@ -48,16 +50,19 @@ public: void updateApplicationMenu(const QString &serviceName, const QString &menuObjectPath); + bool menuAvailable() const; + void setMenuAvailable(bool set); + private Q_SLOTS: void onActiveWindowChanged(WId id); void update(); signals: + void menuAvailableChanged(); void modelNeedsUpdate(); - private: - bool m_winHasMenu; + bool m_menuAvailable; QPointer<QMenu> m_menu; QStringList m_activeMenu; -- 2.12.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor