diff --git a/app/shortcuts/globalshortcuts.cpp b/app/shortcuts/globalshortcuts.cpp index 9caa3e4ac..ee4ae3b27 100644 --- a/app/shortcuts/globalshortcuts.cpp +++ b/app/shortcuts/globalshortcuts.cpp @@ -223,7 +223,7 @@ void GlobalShortcuts::activateLauncherMenu() for (const auto view : sortedViews) { if (view->interface()->containsApplicationLauncher()) { - if (view->visibility()->isHidden()) { + if (view->visibility()->isHidden() && view->interface()->applicationLauncherInPopup()) { if (!m_hideViews.contains(view)) { m_hideViews.append(view); } @@ -247,7 +247,7 @@ void GlobalShortcuts::activateLauncherMenu() } } -bool GlobalShortcuts::activatePlasmaTaskManager(const Latte::View *view, int index, Qt::Key modifier) +bool GlobalShortcuts::activatePlasmaTaskManager(const Latte::View *view, int index, Qt::Key modifier, bool *delayedExecution) { bool activation{modifier == static_cast(Qt::META)}; bool newInstance{!activation}; @@ -262,18 +262,25 @@ bool GlobalShortcuts::activatePlasmaTaskManager(const Latte::View *view, int ind } }); + *delayedExecution = true; + return true; } else { + *delayedExecution = false; + return (activation ? view->interface()->activatePlasmaTask(index) : view->interface()->newInstanceForPlasmaTask(index)); } } -bool GlobalShortcuts::activateLatteEntry(const Latte::View *view, int index, Qt::Key modifier) +bool GlobalShortcuts::activateLatteEntry(Latte::View *view, int index, Qt::Key modifier, bool *delayedExecution) { bool activation{modifier == static_cast(Qt::META)}; bool newInstance{!activation}; - if (view->visibility()->isHidden()) { + int appletId = view->interface()->appletIdForIndex(index); + bool hasPopUp {(appletId>-1 && view->appletIsExpandable(appletId))}; + + if (view->visibility()->isHidden() && hasPopUp) { //! delay the execution in order to show first the view QTimer::singleShot(APPLETEXECUTIONDELAY, [this, view, index, activation]() { if (activation) { @@ -283,8 +290,12 @@ bool GlobalShortcuts::activateLatteEntry(const Latte::View *view, int index, Qt: } }); + *delayedExecution = true; + return true; } else { + *delayedExecution = false; + return (activation ? view->interface()->activateEntry(index) : view->interface()->newInstanceForEntry(index)); } } @@ -307,16 +318,21 @@ void GlobalShortcuts::activateEntry(int index, Qt::Key modifier) continue; } + bool delayed{false}; + if ((!view->latteTasksArePresent() && view->tasksPresent() && - activatePlasmaTaskManager(view, index, modifier)) - || activateLatteEntry(view, index, modifier)) { + activatePlasmaTaskManager(view, index, modifier, &delayed)) + || activateLatteEntry(view, index, modifier, &delayed)) { if (!m_hideViews.contains(view)) { m_hideViews.append(view); } - view->visibility()->setBlockHiding(true); - m_hideViewsTimer.start(); + if (delayed) { + view->visibility()->setBlockHiding(true); + m_hideViewsTimer.start(); + } + return; } } diff --git a/app/shortcuts/globalshortcuts.h b/app/shortcuts/globalshortcuts.h index 78d16a8bd..a9c7abab7 100644 --- a/app/shortcuts/globalshortcuts.h +++ b/app/shortcuts/globalshortcuts.h @@ -73,8 +73,8 @@ private: void showViews(); void showSettings(); - bool activateLatteEntry(const Latte::View *view, int index, Qt::Key modifier); - bool activatePlasmaTaskManager(const Latte::View *view, int index, Qt::Key modifier); + bool activateLatteEntry(Latte::View *view, int index, Qt::Key modifier, bool *delayedExecution); + bool activatePlasmaTaskManager(const Latte::View *view, int index, Qt::Key modifier, bool *delayedExecution); bool viewAtLowerEdgePriority(Latte::View *test, Latte::View *base); bool viewAtLowerScreenPriority(Latte::View *test, Latte::View *base); bool viewsToHideAreValid(); diff --git a/app/view/containmentinterface.cpp b/app/view/containmentinterface.cpp index 9267deaf1..6af5626d2 100644 --- a/app/view/containmentinterface.cpp +++ b/app/view/containmentinterface.cpp @@ -73,12 +73,34 @@ void ContainmentInterface::identifyMethods() int aeIndex = m_mainItem->metaObject()->indexOfMethod("activateEntryAtIndex(QVariant)"); int niIndex = m_mainItem->metaObject()->indexOfMethod("newInstanceForEntryAtIndex(QVariant)"); int sbIndex = m_mainItem->metaObject()->indexOfMethod("setShowAppletShortcutBadges(QVariant,QVariant,QVariant,QVariant)"); + int afiIndex = m_mainItem->metaObject()->indexOfMethod("appletIdForIndex(QVariant)"); m_activateEntryMethod = m_mainItem->metaObject()->method(aeIndex); + m_appletIdForIndexMethod = m_mainItem->metaObject()->method(afiIndex); m_newInstanceMethod = m_mainItem->metaObject()->method(niIndex); m_showShortcutsMethod = m_mainItem->metaObject()->method(sbIndex); } +bool ContainmentInterface::applicationLauncherInPopup() const +{ + if (!containsApplicationLauncher()) { + return false; + } + + int launcherAppletId = applicationLauncherId(); + QString launcherPluginId; + + const auto applets = m_view->containment()->applets(); + + for (auto applet : applets) { + if (applet->id() == launcherAppletId) { + launcherPluginId = applet->kPackage().metadata().pluginId(); + } + } + + return launcherPluginId != "org.kde.plasma.kickerdash"; +} + bool ContainmentInterface::containsApplicationLauncher() const { return applicationLauncherId() == -1 ? false : true; @@ -304,5 +326,21 @@ bool ContainmentInterface::showShortcutBadges(const bool showLatteShortcuts, con return m_showShortcutsMethod.invoke(m_mainItem, Q_ARG(QVariant, showLatteShortcuts), Q_ARG(QVariant, true), Q_ARG(QVariant, showMeta), Q_ARG(QVariant, appLauncherId)); } +int ContainmentInterface::appletIdForIndex(const int index) +{ + identifyMainItem(); + + if (!m_appletIdForIndexMethod.isValid()) { + return false; + } + + QVariant appletId{-1}; + + m_appletIdForIndexMethod.invoke(m_mainItem, Q_RETURN_ARG(QVariant, appletId), Q_ARG(QVariant, index)); + + return appletId.toInt(); +} + + } } diff --git a/app/view/containmentinterface.h b/app/view/containmentinterface.h index dfc5f8e08..06039c526 100644 --- a/app/view/containmentinterface.h +++ b/app/view/containmentinterface.h @@ -42,6 +42,7 @@ public: ContainmentInterface(Latte::View *parent); virtual ~ContainmentInterface(); + bool applicationLauncherInPopup() const; bool containsApplicationLauncher() const; bool isCapableToShowShortcutBadges() const; @@ -59,6 +60,7 @@ public: bool updateBadgeForLatteTask(const QString identifier, const QString value); int applicationLauncherId() const; + int appletIdForIndex(const int index); private slots: void identifyMainItem(); @@ -66,6 +68,7 @@ private slots: private: QMetaMethod m_activateEntryMethod; + QMetaMethod m_appletIdForIndexMethod; QMetaMethod m_newInstanceMethod; QMetaMethod m_showShortcutsMethod; diff --git a/app/view/view.cpp b/app/view/view.cpp index 036809ad7..e68994b24 100644 --- a/app/view/view.cpp +++ b/app/view/view.cpp @@ -1270,6 +1270,25 @@ void View::deactivateApplets() } } +bool View::appletIsExpandable(const int id) +{ + if (!containment()) { + return false; + } + + for (const auto applet : containment()->applets()) { + if (applet->id() == id) { + PlasmaQuick::AppletQuickItem *ai = applet->property("_plasma_graphicObject").value(); + + if (ai) { + return (ai->preferredRepresentation() != ai->fullRepresentation()); + } + } + } + + return false; +} + void View::toggleAppletExpanded(const int id) { if (!containment()) { diff --git a/app/view/view.h b/app/view/view.h index 884894022..24d106197 100644 --- a/app/view/view.h +++ b/app/view/view.h @@ -229,6 +229,7 @@ public slots: Q_INVOKABLE void setBlockHiding(bool block); Q_INVOKABLE void toggleAppletExpanded(const int id); + Q_INVOKABLE bool appletIsExpandable(const int id); Q_INVOKABLE bool mimeContainsPlasmoid(QMimeData *mimeData, QString name); Q_INVOKABLE bool tasksPresent(); diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index 7b0d2f3d2..dc70cb91c 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -426,6 +426,11 @@ Item { return false; } + + function refersEntryIndex(entryIndex) { + return (entryIndex === parabolicManager.pseudoAppletIndex(appletItem.index)); + } + ///END functions //BEGIN connections @@ -589,7 +594,7 @@ Item { onSignalActivateEntryAtIndex: { if (parabolicManager.pseudoIndexBelongsToLatteApplet(entryIndex) && appletItem.isLattePlasmoid) { latteApplet.activateTaskAtIndex(entryIndex - latteApplet.tasksBaseIndex); - } else if (root.unifiedGlobalShortcuts && (entryIndex === parabolicManager.pseudoAppletIndex(appletItem.index))) { + } else if (root.unifiedGlobalShortcuts && refersEntryIndex(entryIndex)) { latteView.toggleAppletExpanded(applet.id); } } @@ -597,7 +602,7 @@ Item { onSignalNewInstanceForEntryAtIndex: { if (parabolicManager.pseudoIndexBelongsToLatteApplet(entryIndex) && appletItem.isLattePlasmoid) { latteApplet.newInstanceForTaskAtIndex(entryIndex - latteApplet.tasksBaseIndex); - } else if (root.unifiedGlobalShortcuts && (entryIndex === parabolicManager.pseudoAppletIndex(appletItem.index))) { + } else if (root.unifiedGlobalShortcuts && refersEntryIndex(entryIndex)) { latteView.toggleAppletExpanded(applet.id); } } diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 5a5b4997b..38080600e 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -1197,7 +1197,7 @@ Item { } } - // This is called by dockcorona in response to a Meta+number shortcut. + //! this is called from Latte::View::ContainmentInterface function activateEntryAtIndex(index) { if (typeof index !== "number") { return; @@ -1212,7 +1212,7 @@ Item { signalActivateEntryAtIndex(index); } - // This is called by dockcorona in response to a Meta+Alt+number shortcut. + //! this is called from Latte::View::ContainmentInterface function newInstanceForEntryAtIndex(index) { if (typeof index !== "number") { return; @@ -1227,6 +1227,39 @@ Item { signalNewInstanceForEntryAtIndex(index); } + //! this is called from Latte::View::ContainmentInterface + function appletIdForIndex(index) { + if (!root.unifiedGlobalShortcuts || parabolicManager.pseudoIndexBelongsToLatteApplet(index)) { + return -1; + } + + for (var i=0; i