From f32937ca6d9e2e82d2084702794b09dac0de8f0f Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Tue, 19 May 2020 18:41:49 +0300 Subject: [PATCH] first commit for multi on position shortcuts --- app/shortcuts/globalshortcuts.cpp | 2 +- app/view/containmentinterface.cpp | 2 +- app/view/containmentinterface.h | 2 +- .../ui/abilities/PositionShortcuts.qml | 29 +++++ .../privates/PositionShortcutsPrivate.qml | 115 ++++++++++++++++++ containment/package/contents/ui/main.qml | 90 -------------- 6 files changed, 147 insertions(+), 93 deletions(-) create mode 100644 containment/package/contents/ui/abilities/PositionShortcuts.qml create mode 100644 containment/package/contents/ui/abilities/privates/PositionShortcutsPrivate.qml diff --git a/app/shortcuts/globalshortcuts.cpp b/app/shortcuts/globalshortcuts.cpp index 18623205d..de284b065 100644 --- a/app/shortcuts/globalshortcuts.cpp +++ b/app/shortcuts/globalshortcuts.cpp @@ -300,7 +300,7 @@ bool GlobalShortcuts::activateLatteEntry(Latte::View *view, int index, Qt::Key m bool activation{modifier == static_cast(Qt::META)}; bool newInstance{!activation}; - int appletId = view->extendedInterface()->appletIdForIndex(index); + int appletId = view->extendedInterface()->appletIdForVisualIndex(index); bool hasPopUp {(appletId>-1 && view->extendedInterface()->appletIsExpandable(appletId))}; if (view->visibility()->isHidden() && hasPopUp) { diff --git a/app/view/containmentinterface.cpp b/app/view/containmentinterface.cpp index ed7678c94..4239183c6 100644 --- a/app/view/containmentinterface.cpp +++ b/app/view/containmentinterface.cpp @@ -375,7 +375,7 @@ 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) +int ContainmentInterface::appletIdForVisualIndex(const int index) { identifyMainItem(); diff --git a/app/view/containmentinterface.h b/app/view/containmentinterface.h index cbb9183e0..74402734a 100644 --- a/app/view/containmentinterface.h +++ b/app/view/containmentinterface.h @@ -83,7 +83,7 @@ public: bool updateBadgeForLatteTask(const QString identifier, const QString value); int applicationLauncherId() const; - int appletIdForIndex(const int index); + int appletIdForVisualIndex(const int index); QAbstractListModel *latteTasksModel() const; QAbstractListModel *plasmaTasksModel() const; diff --git a/containment/package/contents/ui/abilities/PositionShortcuts.qml b/containment/package/contents/ui/abilities/PositionShortcuts.qml new file mode 100644 index 000000000..d6cb6509e --- /dev/null +++ b/containment/package/contents/ui/abilities/PositionShortcuts.qml @@ -0,0 +1,29 @@ +/* +* Copyright 2019 Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +import QtQuick 2.8 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.plasmoid 2.0 + +import "./privates" as Ability + +Ability.PositionShortcutsPrivate { + +} diff --git a/containment/package/contents/ui/abilities/privates/PositionShortcutsPrivate.qml b/containment/package/contents/ui/abilities/privates/PositionShortcutsPrivate.qml new file mode 100644 index 000000000..9d0e1089e --- /dev/null +++ b/containment/package/contents/ui/abilities/privates/PositionShortcutsPrivate.qml @@ -0,0 +1,115 @@ +/* +* Copyright 2020 Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +import QtQuick 2.7 + +Item { + objectName: "PositionShortcuts" + + property bool unifiedGlobalShortcuts: true + + property bool showLatteShortcutBadges: false + property bool showAppletShortcutBadges: false + property bool showMetaBadge: false + property int applicationLauncherId: -1 + + signal sglActivateEntryAtIndex(int entryIndex); + signal sglNewInstanceForEntryAtIndex(int entryIndex); + + //! this is called from globalshortcuts c++ side + function setShowAppletShortcutBadges(showLatteShortcuts, showShortcuts, showMeta, applicationLauncher){ + if (latteApplet) { + var base = unifiedGlobalShortcuts ? parabolicManager.pseudoAppletIndex(latteAppletPos) : 1; + latteApplet.setTasksBaseIndex(base - 1); + latteApplet.setShowTaskShortcutBadges(showLatteShortcuts); + } + + showLatteShortcutBadges = showLatteShortcuts; + showAppletShortcutBadges = showShortcuts; + showMetaBadge = showMeta; + applicationLauncherId = applicationLauncher; + + if (latteApplet) { + latteApplet.parabolicManager.updateTasksEdgesIndexes(); + } + } + + //! this is called from Latte::View::ContainmentInterface + function activateEntryAtIndex(index) { + if (typeof index !== "number") { + return; + } + + if (latteApplet) { + var base = unifiedGlobalShortcuts ? parabolicManager.pseudoAppletIndex(latteAppletPos) : 1; + latteApplet.setTasksBaseIndex(base - 1); + latteApplet.parabolicManager.updateTasksEdgesIndexes(); + } + + signalActivateEntryAtIndex(index); + } + + //! this is called from Latte::View::ContainmentInterface + function newInstanceForEntryAtIndex(index) { + if (typeof index !== "number") { + return; + } + + if (latteApplet) { + var base = unifiedGlobalShortcuts ? parabolicManager.pseudoAppletIndex(latteAppletPos) : 1; + latteApplet.setTasksBaseIndex(base - 1); + latteApplet.parabolicManager.updateTasksEdgesIndexes(); + } + + 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