plasmoid:expose Ability Launchers.group

work/spdx
Michail Vourlakos 4 years ago
parent a20302a598
commit 968d8d3a54

@ -720,9 +720,10 @@ PlasmaComponents.ContextMenu {
if (tasksModel.launcherPosition(get(atm.LauncherUrlWithoutIcon)) != -1) {
var launcher = get(atm.LauncherUrl);
if (latteView && root.launchersGroup >= LatteCore.Types.LayoutLaunchers) {
if (latteView && !launchers.inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.removeLauncher(root.viewLayoutName,
root.launchersGroup, launcher);
launchers.group,
launcher);
} else {
root.launcherForRemoval = launcher;
tasksModel.requestRemoveLauncher(launcher);
@ -731,9 +732,10 @@ PlasmaComponents.ContextMenu {
} else {
var launcher = get(atm.LauncherUrl);
if (latteView && root.launchersGroup >= LatteCore.Types.LayoutLaunchers) {
if (latteView && !launchers.inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.addLauncher(root.viewLayoutName,
root.launchersGroup, launcher);
launchers.group,
launcher);
} else {
tasksModel.requestAddLauncher(launcher);
root.launchersUpdatedFor(launcher);
@ -780,9 +782,11 @@ PlasmaComponents.ContextMenu {
result.clicked.connect(
function() {
if (result.checked) {
if (latteView && root.launchersGroup >= LatteCore.Types.LayoutLaunchers) {
if (latteView && !launchers.inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.addLauncherToActivity(root.viewLayoutName,
root.launchersGroup, url, id);
launchers.group,
url,
id);
} else {
if (id !== tasksModel.activity && (activities[0] === "00000000-0000-0000-0000-000000000000")) {
root.launcherForRemoval = url;
@ -792,9 +796,11 @@ PlasmaComponents.ContextMenu {
root.launchersUpdatedFor(url);
}
} else {
if (latteView && root.launchersGroup >= LatteCore.Types.LayoutLaunchers) {
if (latteView && !launchers.inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.removeLauncherFromActivity(root.viewLayoutName,
root.launchersGroup, url, id);
launchers.group,
url,
id);
} else {
if (id === tasksModel.activity) {
root.launcherForRemoval = url;
@ -851,9 +857,10 @@ PlasmaComponents.ContextMenu {
onClicked: {
var launcher = get(atm.LauncherUrlWithoutIcon);
if (latteView && root.launchersGroup >= LatteCore.Types.LayoutLaunchers) {
if (latteView && !launchers.inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.removeLauncher(root.viewLayoutName,
root.launchersGroup, launcher);
launchers.group,
launcher);
} else {
root.launcherForRemoval = launcher
tasksModel.requestRemoveLauncher(launcher);
@ -894,9 +901,10 @@ PlasmaComponents.ContextMenu {
onClicked: {
var launcher = get(atm.LauncherUrlWithoutIcon);
if (latteView && root.launchersGroup >= LatteCore.Types.LayoutLaunchers) {
if (latteView && !launchers.inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.removeLauncher(root.viewLayoutName,
root.launchersGroup, launcher);
launchers.group,
launcher);
} else {
root.launcherForRemoval = launcher;
tasksModel.requestRemoveLauncher(launcher);

@ -27,6 +27,7 @@ import "launchers" as LaunchersPart
Item {
id: _launchers
property int group: LatteCore.Types.UniqueLaunchers
property Item layout: null
property QtObject tasksModel: null
@ -34,6 +35,18 @@ Item {
readonly property LaunchersPart.Syncer syncer: LaunchersPart.Syncer{}
readonly property LaunchersPart.Validator validator: LaunchersPart.Validator{}
function inUniqueGroup() {
return group === LatteCore.Types.UniqueLaunchers;
}
function inLayoutGroup() {
return group === LatteCore.Types.LayoutLaunchers;
}
function inGlobalGroup() {
return group === LatteCore.Types.GlobalLaunchers;
}
function isSeparator(launcher){
return (launcher.indexOf("latte-separator")!==-1 && launcher.indexOf(".desktop")!==1);
}
@ -64,6 +77,10 @@ Item {
}
}
function hasLauncher(url) {
return _launchers.tasksModel.launcherPosition(url) != -1;
}
function inCurrentActivity(url) {
var activities = _launchers.tasksModel.launcherActivities(url);
@ -132,12 +149,11 @@ Item {
if (viewLayout) {
if (latteView && latteView.layoutsManager
&& latteView.viewLayout && latteView.universalSettings
&& (root.launchersGroup === LatteCore.Types.LayoutLaunchers
|| root.launchersGroup === LatteCore.Types.GlobalLaunchers)) {
&& !_launchers.inUniqueGroup()) {
if (root.launchersGroup === LatteCore.Types.LayoutLaunchers) {
if (_launchers.inLayoutGroup()) {
launchersList = latteView.viewLayout.launchers;
} else if (root.launchersGroup === LatteCore.Types.GlobalLaunchers) {
} else if (_launchers.inGlobalGroup()) {
launchersList = latteView.universalSettings.launchers;
}
}
@ -174,27 +190,42 @@ Item {
//! Connections
onGroupChanged:{
if(latteView) {
_launchers.tasksModel.updateLaunchersList();
}
}
Connections {
target: _launchers.tasksModel
target: root
onLatteViewChanged: {
if (root.latteView) {
if (!_launchers.inUniqueGroup()) {
_launchers.tasksModel.updateLaunchersList();
}
}
}
}
Connections {
target: _launchers.tasksModel
onLauncherListChanged: {
if (viewLayout) {
if (latteView && latteView.layoutsManager
&& latteView.viewLayout && latteView.universalSettings
&& (root.launchersGroup === LatteCore.Types.LayoutLaunchers
|| root.launchersGroup === LatteCore.Types.GlobalLaunchers)) {
&& !_launchers.inUniqueGroup()) {
if (root.launchersGroup === LatteCore.Types.LayoutLaunchers) {
if (_launchers.inLayoutGroup()) {
latteView.viewLayout.launchers = _launchers.tasksModel.launcherList;
} else if (root.launchersGroup === LatteCore.Types.GlobalLaunchers) {
} else if (_launchers.inGlobalGroup()) {
latteView.universalSettings.launchers = _launchers.tasksModel.launcherList;
}
if (inDraggingPhase) {
if (latteView && root.launchersGroup >= LatteCore.Types.LayoutLaunchers) {
if (latteView && !_launchers.inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.validateLaunchersOrder(root.viewLayoutName,
plasmoid.id,
root.launchersGroup,
_launchers.group,
_launchers.currentShownLauncherList());
}
}

@ -175,8 +175,6 @@ Item {
property bool titleTooltips: latteView ? latteView.titleTooltips : false
property alias windowPreviewIsShown: windowsPreviewDlg.visible
property int launchersGroup: plasmoid.configuration.launchersGroup
property int leftClickAction: plasmoid.configuration.leftClickAction
property int middleClickAction: plasmoid.configuration.middleClickAction
property int hoverAction: plasmoid.configuration.hoverAction
@ -272,22 +270,11 @@ Item {
if (latteView) {
plasmoid.action("configure").visible = false;
plasmoid.configuration.isInLatteDock = true;
if (root.launchersGroup === LatteCore.Types.LayoutLaunchers
|| root.launchersGroup === LatteCore.Types.GlobalLaunchers) {
tasksModel.updateLaunchersList();
}
} else {
plasmoid.configuration.isInLatteDock = false;
}
}
onLaunchersGroupChanged:{
if(latteView) {
tasksModel.updateLaunchersList();
}
}
Connections {
target: plasmoid
onLocationChanged: {
@ -617,13 +604,11 @@ Item {
property bool anyTaskDemandsAttentionInValidTime: false
function updateLaunchersList(){
if (latteView
&& (root.launchersGroup === LatteCore.Types.LayoutLaunchers
|| root.launchersGroup === LatteCore.Types.GlobalLaunchers)) {
if (root.launchersGroup === LatteCore.Types.LayoutLaunchers) {
if (latteView && !launchers.inUniqueGroup()) {
if (launchers.inLayoutGroup()) {
console.log("Tasks: Applying LAYOUT Launchers List...");
tasksModel.launcherList = latteView.viewLayout.launchers;
} else if (root.launchersGroup === LatteCore.Types.GlobalLaunchers) {
} else if (launchers.inGlobalGroup()) {
console.log("Tasks: Applying GLOBAL Launchers List...");
tasksModel.launcherList = latteView.universalSettings.launchers;
}
@ -661,13 +646,10 @@ Item {
//var loadedLaunchers = ActivitiesTools.restoreLaunchers();
ActivitiesTools.importLaunchersToNewArchitecture();
if (viewLayout && latteView.universalSettings
&& (root.launchersGroup === LatteCore.Types.LayoutLaunchers
|| root.launchersGroup === LatteCore.Types.GlobalLaunchers)) {
if (root.launchersGroup === LatteCore.Types.LayoutLaunchers) {
if (viewLayout && latteView.universalSettings && !launchers.inUniqueGroup()) {
if (launchers.inLayoutGroup()) {
launcherList = latteView.viewLayout.launchers;
} else if (root.launchersGroup === LatteCore.Types.GlobalLaunchers) {
} else if (launchers.inGlobalGroup()) {
launcherList = latteView.universalSettings.launchers;
}
} else {
@ -852,6 +834,7 @@ Item {
Ability.Launchers {
id: _launchers
group: plasmoid.configuration.launchersGroup
layout: icList.contentItem
tasksModel: tasksModel
}
@ -1053,7 +1036,7 @@ Item {
property int maxThickness: (parabolic.isHovered || windowPreviewIsShown || animations.hasThicknessAnimation) ?
metrics.mask.thickness.zoomedForItems : metrics.mask.thickness.normalForItems
function onlyLaunchersInList(list){
function onlyLaunchersInDroppedList(list){
return list.every(function (item) {
return backend.isApplication(item)
});
@ -1061,7 +1044,7 @@ Item {
function urlsDroppedOnArea(urls){
// If all dropped URLs point to application desktop files, we'll add a launcher for each of them.
if (onlyLaunchersInList(urls)) {
if (onlyLaunchersDroppedInList(urls)) {
urls.forEach(function (item) {
addLauncher(item);
});
@ -1082,9 +1065,10 @@ Item {
onUrlsDropped: {
//! inform synced docks for new dropped launchers
if (latteView && root.launchersGroup >= LatteCore.Types.LayoutLaunchers && onlyLaunchersInList(urls)) {
if (latteView && !launchers.inUniqueGroup() && onlyLaunchersInDroppedList(urls)) {
latteView.layoutsManager.launchersSignals.urlsDropped(root.viewLayoutName,
root.launchersGroup, urls);
launchers.group,
urls);
return;
}
@ -1392,9 +1376,10 @@ Item {
if (separatorName !== "") {
tasksExtendedManager.addLauncherToBeMoved(separatorName, Math.max(0,pos));
if (latteView && root.launchersGroup >= LatteCore.Types.LayoutLaunchers) {
if (latteView && !launchers.inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.addLauncher(root.viewLayoutName,
root.launchersGroup, separatorName);
launchers.group,
separatorName);
} else {
tasksModel.requestAddLauncher(separatorName);
}
@ -1449,7 +1434,7 @@ Item {
//! BEGIN ::: external launchers signals in order to update the tasks model
function extSignalAddLauncher(group, launcher) {
if (group === root.launchersGroup) {
if (group === launchers.group) {
tasksModel.requestAddLauncher(launcher);
launchersUpdatedFor(launcher);
tasksModel.syncLaunchers();
@ -1457,7 +1442,7 @@ Item {
}
function extSignalRemoveLauncher(group, launcher) {
if (group === root.launchersGroup) {
if (group === launchers.group) {
root.launcherForRemoval = launcher;
tasksModel.requestRemoveLauncher(launcher);
launchersUpdatedFor(launcher);
@ -1466,7 +1451,7 @@ Item {
}
function extSignalAddLauncherToActivity(group, launcher, activity) {
if (group === root.launchersGroup) {
if (group === launchers.group) {
var launcherActivities = tasksModel.launcherActivities(launcher);
if (activity !== tasksModel.activity && (launcherActivities[0] === "00000000-0000-0000-0000-000000000000")) {
@ -1480,7 +1465,7 @@ Item {
}
function extSignalRemoveLauncherFromActivity(group, launcher, activity) {
if (group === root.launchersGroup) {
if (group === launchers.group) {
if (activity === tasksModel.activity) {
root.launcherForRemoval = launcher;
}
@ -1492,20 +1477,20 @@ Item {
}
function extSignalUrlsDropped(group, urls) {
if (group === root.launchersGroup) {
if (group === launchers.group) {
mouseHandler.urlsDroppedOnArea(urls);
}
}
function extSignalMoveTask(group, from, to) {
if (group === root.launchersGroup && !root.dragSource) {
if (group === launchers.group && !root.dragSource) {
tasksModel.move(from, to);
tasksModel.syncLaunchers();
}
}
function extSignalValidateLaunchersOrder(group, orderedLaunchers) {
if (group === root.launchersGroup && !root.dragSource) {
if (group === launchers.group && !root.dragSource) {
launchers.validateOrder(orderedLaunchers);
}
}
@ -1521,8 +1506,8 @@ Item {
if (separatorName !== "") {
tasksExtendedManager.addLauncherToBeMoved(separatorName, Math.max(0,pos));
if (latteView && root.launchersGroup >= LatteCore.Types.LayoutLaunchers) {
latteView.layoutsManager.launchersSignals.addLauncher(root.launchersGroup, separatorName);
if (latteView && !launchers.inUniqueGroup()) {
latteView.layoutsManager.launchersSignals.addLauncher(launchers.group, separatorName);
} else {
tasksModel.requestAddLauncher(separatorName);
}
@ -1562,10 +1547,6 @@ Item {
return false;
}
function hasLauncher(url) {
return tasksModel.launcherPosition(url) != -1;
}
function addLauncher(url) {
//workaround to protect in case the launcher contains the iconData
var pos = url.indexOf("?iconData=");

Loading…
Cancel
Save