mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 13:33:50 +03:00
use PositionShortuts Ability for activate/new
This commit is contained in:
parent
dc78257962
commit
fa4ffbf521
@ -302,7 +302,7 @@ bool ContainmentInterface::newInstanceForPlasmaTask(const int index)
|
||||
|
||||
for (QQuickItem *item : childItems) {
|
||||
if (auto *metaObject = item->metaObject()) {
|
||||
int methodIndex{metaObject->indexOfMethod("ewInstanceForTaskAtIndex(QVariant)")};
|
||||
int methodIndex{metaObject->indexOfMethod("newInstanceForTaskAtIndex(QVariant)")};
|
||||
|
||||
if (methodIndex == -1) {
|
||||
continue;
|
||||
|
@ -42,25 +42,25 @@ Ability.PositionShortcutsPrivate {
|
||||
}
|
||||
|
||||
//! this is called from Latte::View::ContainmentInterface
|
||||
function activateEntryAtIndex(index) {
|
||||
if (typeof index !== "number") {
|
||||
function activateEntryAtIndex(entryIndex) {
|
||||
if (typeof entryIndex !== "number") {
|
||||
return;
|
||||
}
|
||||
|
||||
sglActivateEntryAtIndex(index);
|
||||
sglActivateEntryAtIndex(entryIndex);
|
||||
}
|
||||
|
||||
//! this is called from Latte::View::ContainmentInterface
|
||||
function newInstanceForEntryAtIndex(index) {
|
||||
if (typeof index !== "number") {
|
||||
function newInstanceForEntryAtIndex(entryIndex) {
|
||||
if (typeof entryIndex !== "number") {
|
||||
return;
|
||||
}
|
||||
|
||||
sglNewInstanceForEntryAtIndex(index);
|
||||
sglNewInstanceForEntryAtIndex(entryIndex);
|
||||
}
|
||||
|
||||
//! this is called from Latte::View::ContainmentInterface
|
||||
function appletIdForIndex(index) {
|
||||
return indexer.appletIdForVisibleIndex(index);
|
||||
function appletIdForIndex(entryIndex) {
|
||||
return indexer.appletIdForVisibleIndex(entryIndex);
|
||||
}
|
||||
}
|
||||
|
@ -19,23 +19,21 @@
|
||||
|
||||
import QtQuick 2.7
|
||||
|
||||
Item {
|
||||
import org.kde.latte.abilities.definitions 0.1 as AbilityDefinition
|
||||
|
||||
AbilityDefinition.PositionShortcuts {
|
||||
id: _shortcutsprivate
|
||||
property Item layouts: null
|
||||
property bool updateIsBlocked: false
|
||||
|
||||
readonly property bool unifiedGlobalShortcuts: appletIdStealingPositionShortcuts === -1
|
||||
|
||||
property bool showPositionShortcutBadges: false
|
||||
property bool showAppletShortcutBadges: false
|
||||
property bool showMetaBadge: false
|
||||
property int applicationLauncherId: -1
|
||||
|
||||
property int appletIdStealingPositionShortcuts: -1
|
||||
|
||||
signal sglActivateEntryAtIndex(int entryIndex);
|
||||
signal sglNewInstanceForEntryAtIndex(int entryIndex);
|
||||
|
||||
Binding {
|
||||
target: _shortcutsprivate
|
||||
property: "appletIdStealingPositionShortcuts"
|
||||
@ -47,7 +45,7 @@ Item {
|
||||
if (appletItem
|
||||
&& appletItem.index>=0
|
||||
&& appletItem.communicator
|
||||
&& appletItem.communicator.onPositionShortcutsAreSupported
|
||||
&& appletItem.communicator.positionShortcutsAreSupported
|
||||
&& appletItem.communicator.bridge.shortcuts.client.isStealingGlobalPositionShortcuts) {
|
||||
return appletItem.index;
|
||||
}
|
||||
@ -59,7 +57,7 @@ Item {
|
||||
if (appletItem
|
||||
&& appletItem.index>=0
|
||||
&& appletItem.communicator
|
||||
&& appletItem.communicator.onPositionShortcutsAreSupported
|
||||
&& appletItem.communicator.positionShortcutsAreSupported
|
||||
&& appletItem.communicator.bridge.shortcuts.client.isStealingGlobalPositionShortcuts) {
|
||||
return appletItem.index;
|
||||
}
|
||||
@ -71,7 +69,7 @@ Item {
|
||||
if (appletItem
|
||||
&& appletItem.index>=0
|
||||
&& appletItem.communicator
|
||||
&& appletItem.communicator.onPositionShortcutsAreSupported
|
||||
&& appletItem.communicator.positionShortcutsAreSupported
|
||||
&& appletItem.communicator.bridge.shortcuts.client.isStealingGlobalPositionShortcuts) {
|
||||
return appletItem.index;
|
||||
}
|
||||
|
@ -616,17 +616,17 @@ Item {
|
||||
target: appletItem.shortcuts
|
||||
|
||||
onSglActivateEntryAtIndex: {
|
||||
if (parabolicManager.pseudoIndexBelongsToLatteApplet(entryIndex) && appletItem.isLattePlasmoid) {
|
||||
latteApplet.activateTaskAtIndex(entryIndex - latteApplet.tasksBaseIndex);
|
||||
} else if (shortcuts.unifiedGlobalShortcuts && refersEntryIndex(entryIndex)) {
|
||||
var visibleIndex = appletItem.indexer.visibleIndex(appletItem.index);
|
||||
|
||||
if (visibleIndex === entryIndex && !communicator.positionShortcutsAreSupported) {
|
||||
latteView.extendedInterface.toggleAppletExpanded(applet.id);
|
||||
}
|
||||
}
|
||||
|
||||
onSglNewInstanceForEntryAtIndex: {
|
||||
if (parabolicManager.pseudoIndexBelongsToLatteApplet(entryIndex) && appletItem.isLattePlasmoid) {
|
||||
latteApplet.newInstanceForTaskAtIndex(entryIndex - latteApplet.tasksBaseIndex);
|
||||
} else if (shortcuts.unifiedGlobalShortcuts && refersEntryIndex(entryIndex)) {
|
||||
var visibleIndex = appletItem.indexer.visibleIndex(appletItem.index);
|
||||
|
||||
if (visibleIndex === entryIndex && !communicator.positionShortcutsAreSupported) {
|
||||
latteView.extendedInterface.toggleAppletExpanded(applet.id);
|
||||
}
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ Item{
|
||||
|
||||
//! BEGIN OF ABILITIES SUPPORT
|
||||
readonly property bool indexerIsSupported: bridge && bridge.indexer.client
|
||||
readonly property bool onPositionShortcutsAreSupported: bridge && bridge.shortcuts.client
|
||||
readonly property bool parabolicEffectIsSupported: bridge && bridge.parabolic.client
|
||||
readonly property bool positionShortcutsAreSupported: bridge && bridge.shortcuts.client
|
||||
|
||||
readonly property Item bridge: bridgeLoader.active ? bridgeLoader.item : null
|
||||
//! END OF ABILITIES SUPPORT
|
||||
|
57
declarativeimports/abilities/applets/PositionShortcuts.qml
Normal file
57
declarativeimports/abilities/applets/PositionShortcuts.qml
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2020 Michail Vourlakos <mvourlakos@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
|
||||
import org.kde.latte.abilities.definitions 0.1 as AbilityDefinition
|
||||
|
||||
AbilityDefinition.PositionShortcuts {
|
||||
id: shortcuts
|
||||
property Item bridge: null
|
||||
readonly property bool isActive: bridge !== null
|
||||
|
||||
property bool isStealingGlobalPositionShortcuts: false
|
||||
readonly property bool showPositionShortcutBadges: ref.shortcuts.showPositionShortcutBadges
|
||||
|
||||
readonly property AbilityDefinition.ParabolicEffect local: AbilityDefinition.ParabolicEffect {}
|
||||
|
||||
Item {
|
||||
id: ref
|
||||
readonly property Item shortcuts: bridge ? bridge.shortcuts.host : local
|
||||
}
|
||||
|
||||
onIsActiveChanged: {
|
||||
if (isActive) {
|
||||
bridge.shortcuts.client = shortcuts;
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (isActive) {
|
||||
bridge.shortcuts.client = shortcuts;
|
||||
}
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
if (isActive) {
|
||||
bridge.shortcuts.client = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,5 @@ Animations 0.1 Animations.qml
|
||||
Indexer 0.1 Indexer.qml
|
||||
Metrics 0.1 Metrics.qml
|
||||
ParabolicEffect 0.1 ParabolicEffect.qml
|
||||
PositionShortcuts 0.1 PositionShortcuts.qml
|
||||
Requirements 0.1 Requirements.qml
|
||||
|
@ -25,4 +25,23 @@ Item {
|
||||
|
||||
property Item host: null
|
||||
property Item client: null
|
||||
|
||||
readonly property bool isConnected: host && client
|
||||
|
||||
onIsConnectedChanged: {
|
||||
if (isConnected) {
|
||||
host.sglActivateEntryAtIndex.connect(client.sglActivateEntryAtIndex);
|
||||
host.sglNewInstanceForEntryAtIndex.connect(client.sglNewInstanceForEntryAtIndex);
|
||||
} else {
|
||||
host.sglActivateEntryAtIndex.disconnect(client.sglActivateEntryAtIndex);
|
||||
host.sglNewInstanceForEntryAtIndex.disconnect(client.sglNewInstanceForEntryAtIndex);
|
||||
}
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
if (isConnected) {
|
||||
host.sglActivateEntryAtIndex.disconnect(client.sglActivateEntryAtIndex);
|
||||
host.sglNewInstanceForEntryAtIndex.disconnect(client.sglNewInstanceForEntryAtIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2020 Michail Vourlakos <mvourlakos@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
|
||||
Item {
|
||||
property bool showPositionShortcutBadges: false
|
||||
|
||||
signal sglActivateEntryAtIndex(int entryIndex);
|
||||
signal sglNewInstanceForEntryAtIndex(int entryIndex);
|
||||
}
|
@ -5,4 +5,5 @@ AppletRequirements 0.1 AppletRequirements.qml
|
||||
Indexer 0.1 Indexer.qml
|
||||
Metrics 0.1 Metrics.qml
|
||||
ParabolicEffect 0.1 ParabolicEffect.qml
|
||||
PositionShortcuts 0.1 PositionShortcuts.qml
|
||||
|
||||
|
@ -155,7 +155,10 @@ AppletAbility.Indexer {
|
||||
}
|
||||
|
||||
function visibleIndex(taskIndex) {
|
||||
if (taskIndex < firstVisibleItemIndex || taskIndex>lastVisibleItemIndex) {
|
||||
if (taskIndex<firstVisibleItemIndex
|
||||
|| taskIndex>lastVisibleItemIndex
|
||||
|| hidden.indexOf(taskIndex) >= 0
|
||||
|| separators.indexOf(taskIndex) >= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -166,7 +169,7 @@ AppletAbility.Indexer {
|
||||
|
||||
for (var i=0; i<layout.children.length; ++i){
|
||||
var item = layout.children[i];
|
||||
if (hidden.indexOf(item.itemIndex) >=0 || separators.indexOf(item.itemIndex) >=0) {
|
||||
if (hidden.indexOf(item.itemIndex)>=0 || separators.indexOf(item.itemIndex)>=0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
29
plasmoid/package/contents/ui/abilities/PositionShortcuts.qml
Normal file
29
plasmoid/package/contents/ui/abilities/PositionShortcuts.qml
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2020 Michail Vourlakos <mvourlakos@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.7
|
||||
|
||||
import org.kde.plasma.plasmoid 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
|
||||
import org.kde.latte.abilities.applets 0.1 as AppletAbility
|
||||
|
||||
AppletAbility.PositionShortcuts {
|
||||
id: shortcuts
|
||||
}
|
@ -75,8 +75,6 @@ Item {
|
||||
property bool initializationStep: false //true
|
||||
property bool isHovered: false
|
||||
property bool showBarLine: plasmoid.configuration.showBarLine
|
||||
property bool showTaskShortcutBadges: false
|
||||
property int tasksBaseIndex: 0
|
||||
property bool useThemePanel: plasmoid.configuration.useThemePanel
|
||||
property bool taskInAnimation: noTasksInAnimation > 0 ? true : false
|
||||
property bool transparentPanel: plasmoid.configuration.transparentPanel
|
||||
@ -139,6 +137,7 @@ Item {
|
||||
readonly property alias indexer: _indexer
|
||||
readonly property alias metrics: _metrics
|
||||
readonly property alias parabolic: _parabolic
|
||||
readonly property alias shortcuts: _shortcuts
|
||||
|
||||
readonly property alias containsDrag: mouseHandler.containsDrag
|
||||
readonly property bool dragAreaEnabled: latteView ? (root.dragSource !== null
|
||||
@ -963,6 +962,11 @@ Item {
|
||||
local.restoreZoomIsBlocked: root.contextMenu || windowsPreviewDlg.containsMouse
|
||||
}
|
||||
|
||||
Ability.PositionShortcuts {
|
||||
id: _shortcuts
|
||||
bridge: latteBridge
|
||||
}
|
||||
|
||||
AppletAbility.Requirements{
|
||||
id: _requires
|
||||
bridge: latteBridge
|
||||
@ -1259,6 +1263,7 @@ Item {
|
||||
metrics: _metrics
|
||||
parabolic: _parabolic
|
||||
requires: _requires
|
||||
shortcuts: _shortcuts
|
||||
}
|
||||
|
||||
property int currentSpot : -1000
|
||||
@ -1629,50 +1634,14 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
// This is called by dockcorona in response to a Meta+number shortcut.
|
||||
function activateTaskAtIndex(index) {
|
||||
if (typeof index !== "number") {
|
||||
return;
|
||||
}
|
||||
|
||||
var tasks = icList.contentItem.children;
|
||||
|
||||
//! this is used to bypass the internal separators if they exist
|
||||
var confirmedIndex = parabolicManager.realTaskIndex(index - 1);
|
||||
|
||||
for(var i=0; i<tasks.length; ++i){
|
||||
var task = tasks[i];
|
||||
|
||||
if (task.itemIndex === confirmedIndex) {
|
||||
if (task.isGroupParent) {
|
||||
task.activateNextTask();
|
||||
} else {
|
||||
task.activateTask();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// This is called with Meta+number shortcuts by plasmashell when Tasks are in a plasma panel.
|
||||
shortcuts.sglActivateEntryAtIndex(index);
|
||||
}
|
||||
|
||||
// This is called by dockcorona in response to a Meta+Alt+number shortcut.
|
||||
function newInstanceForTaskAtIndex(index) {
|
||||
if (typeof index !== "number") {
|
||||
return;
|
||||
}
|
||||
|
||||
var tasks = icList.contentItem.children;
|
||||
|
||||
//! this is used to bypass the internal separators if they exist
|
||||
var confirmedIndex = parabolicManager.realTaskIndex(index - 1);
|
||||
|
||||
for(var i=0; i<tasks.length; ++i){
|
||||
var task = tasks[i];
|
||||
|
||||
if (task.itemIndex === confirmedIndex) {
|
||||
TaskTools.activateTask(task.modelIndex(), task.m, Qt.ControlModifier , task);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// This is called with Meta+Alt+number shortcuts by plasmashell when Tasks are in a plasma panel.
|
||||
shortcuts.sglNewInstanceForEntryAtIndex(index);
|
||||
}
|
||||
|
||||
function getBadger(identifier) {
|
||||
@ -1810,17 +1779,6 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
//! show/hide tasks numbered badges e.g. from global shortcuts
|
||||
function setShowTaskShortcutBadges(showBadges){
|
||||
showTaskShortcutBadges = showBadges;
|
||||
}
|
||||
|
||||
//! setup the tasks first index based on the fact that this is a plasmoid
|
||||
//! and applets could exist before it
|
||||
function setTasksBaseIndex(base){
|
||||
tasksBaseIndex = base;
|
||||
}
|
||||
|
||||
function previewContainsMouse() {
|
||||
return windowsPreviewDlg.containsMouse;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import org.kde.latte.components 1.0 as LatteComponents
|
||||
Loader{
|
||||
id: shorcutBadge
|
||||
anchors.fill: iconImageBuffer
|
||||
active: root.showTaskShortcutBadges && !taskItem.isSeparator && fixedIndex>=0 && fixedIndex<20
|
||||
active: taskItem.shortcuts.showPositionShortcutBadges && !taskItem.isSeparator && !taskItem.isHidden
|
||||
asynchronous: true
|
||||
visible: badgeString !== ""
|
||||
|
||||
@ -33,10 +33,11 @@ Loader{
|
||||
property string badgeString: (shorcutBadge.fixedIndex>=1 && shorcutBadge.fixedIndex<20 && root.badgesForActivate.length===19) ?
|
||||
root.badgesForActivate[shorcutBadge.fixedIndex-1] : ""
|
||||
|
||||
Connections {
|
||||
target: root
|
||||
onShowTaskShortcutBadgesChanged: {
|
||||
shorcutBadge.fixedIndex = taskItem.indexer.visibleIndex(taskItem.itemIndex);
|
||||
onActiveChanged: {
|
||||
if (active && taskItem.shortcuts.showPositionShortcutBadges) {
|
||||
fixedIndex = taskItem.indexer.visibleIndex(taskItem.itemIndex);
|
||||
} else {
|
||||
fixedIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,6 +186,7 @@ MouseArea{
|
||||
property Item metrics: null
|
||||
property Item parabolic: null
|
||||
property Item requires: null
|
||||
property Item shortcuts: null
|
||||
|
||||
onModelLauncherUrlChanged: {
|
||||
if (modelLauncherUrl !== ""){
|
||||
@ -1452,6 +1453,29 @@ MouseArea{
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: shortcuts
|
||||
onSglActivateEntryAtIndex: {
|
||||
var visibleIndex = taskItem.indexer.visibleIndex(taskItem.itemIndex);
|
||||
|
||||
if (visibleIndex === entryIndex) {
|
||||
if (taskItem.isGroupParent) {
|
||||
taskItem.activateNextTask();
|
||||
} else {
|
||||
taskItem.activateTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onSglNewInstanceForEntryAtIndex: {
|
||||
var visibleIndex = taskItem.indexer.visibleIndex(taskItem.itemIndex);
|
||||
|
||||
if (visibleIndex === entryIndex) {
|
||||
tasksModel.requestNewInstance(taskItem.modelIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: latteView
|
||||
onDockIsHiddenChanged: {
|
||||
|
Loading…
Reference in New Issue
Block a user