restructure windows previews to plasma design

--previews showed some strange behavior by
re-introducing faulty or empty previews under
X11. Best way to approach this is to follow up
plasma design idea in order for the code to be
comparable. The code was updated and the introduced
issue shows to be fixed but this wants users
feedback.

BUG: 397193
FIXED-IN: 0.8.1
pull/2/head
Michail Vourlakos 7 years ago
parent 46fa568350
commit b4a7b1ac84

@ -176,7 +176,7 @@ Item {
activationTimer.stop(); activationTimer.stop();
} }
if (hoveredItem && windowsPreviewDlg.visible && toolTipDelegate.parentIndex !== hoveredItem.itemIndex ) { if (hoveredItem && windowsPreviewDlg.visible && toolTipDelegate.rootIndex !== hoveredItem.modelIndex() ) {
windowsPreviewDlg.hide(6); windowsPreviewDlg.hide(6);
} }
} }

@ -38,7 +38,7 @@ import org.kde.taskmanager 0.1 as TaskManager
PlasmaExtras.ScrollArea { PlasmaExtras.ScrollArea {
id: mainToolTip id: mainToolTip
property Item parentTask property Item parentTask
property int parentIndex: -1 property var rootIndex
property string appName property string appName
property int pidParent property int pidParent
@ -62,7 +62,7 @@ PlasmaExtras.ScrollArea {
property bool isOnAllVirtualDesktopsParent property bool isOnAllVirtualDesktopsParent
property var activitiesParent property var activitiesParent
// //
readonly property bool isVerticalPanel: plasmoid.formFactor == PlasmaCore.Types.Vertical readonly property bool isVerticalPanel: plasmoid.formFactor === PlasmaCore.Types.Vertical
Layout.minimumWidth: contentItem.width Layout.minimumWidth: contentItem.width
Layout.maximumWidth: Layout.minimumWidth Layout.maximumWidth: Layout.minimumWidth
@ -83,19 +83,18 @@ PlasmaExtras.ScrollArea {
return isVerticalPanel ? contentItem.height > viewport.height : contentItem.width > viewport.width return isVerticalPanel ? contentItem.height > viewport.height : contentItem.width > viewport.width
}); });
} }
Item{ Item{
width: contentItem.width width: contentItem.width
height: contentItem.height height: contentItem.height
//! DropArea
DropArea { DropArea {
id: dropMainArea id: dropMainArea
anchors.fill: contentItem anchors.fill: parent
enabled: isGroup enabled: isGroup
preventStealing: true preventStealing: true
property bool dragInside: false
property QtObject currentWindow property QtObject currentWindow
onDragLeave: { onDragLeave: {
@ -103,120 +102,117 @@ PlasmaExtras.ScrollArea {
} }
onDragMove: { onDragMove: {
var current = groupTask.childAtPos(event.x, event.y); var current = mainToolTip.instanceAtPos(event.x, event.y);
if (current && currentWindow !== current && current.submodelIndex) { if (current && currentWindow !== current && current.submodelIndex) {
currentWindow = current; currentWindow = current;
tasksModel.requestActivate(current.submodelIndex); tasksModel.requestActivate(current.submodelIndex);
} }
} }
} } //! DropArea
//! Underneath MouseArea
MouseArea { MouseArea {
id: contentItem id: contentItemMouseArea
width: childrenRect.width anchors.fill: parent
height: childrenRect.height
hoverEnabled: true hoverEnabled: true
onContainsMouseChanged: { onContainsMouseChanged: {
checkMouseInside(); mainToolTip.mouseIsInside();
} }
}//! MouseArea
function checkMouseInside(){ Loader {
var isInside = containsMouse || childrenContainMouse() || (parentTask && parentTask.containsMouse); id: contentItem
if (isInside){ active: mainToolTip.rootIndex !== undefined
//root.disableRestoreZoom = true; asynchronous: true
mainToolTip.containsMouse = true; sourceComponent: isGroup ? groupToolTip : singleTooltip
if(!root.latteDock)
checkListHovered.stop();
}
else{
//root.disableRestoreZoom = false;
mainToolTip.containsMouse = false;
if(!root.latteDock)
checkListHovered.startDuration(100);
else
root.latteDock.startCheckRestoreZoomTimer();
}
}
function childrenContainMouse() { Component {
return singleTask.containsMouse() || groupTask.containsMouse(); id: singleTooltip
}
ToolTipInstance { ToolTipInstance {
id: singleTask submodelIndex: mainToolTip.rootIndex
visible: !isGroup }
} }
Grid { Component {
id: groupTask id: groupToolTip
rows: !isVerticalPanel
columns: isVerticalPanel
flow: isVerticalPanel ? Grid.TopToBottom : Grid.LeftToRight
spacing: units.largeSpacing
width: isGroup ? childrenRect.width : 0
height: isGroup ? childrenRect.height : 0
visible: isGroup && parentIndex !== -1 Grid {
rows: !isVerticalPanel
columns: isVerticalPanel
flow: isVerticalPanel ? Grid.TopToBottom : Grid.LeftToRight
spacing: units.largeSpacing
Loader { Repeater {
id: modelLoader
active: groupTask.visible
sourceComponent: Repeater {
id: groupRepeater id: groupRepeater
model: DelegateModel { model: DelegateModel {
id: delegateModel model: mainToolTip.rootIndex ? tasksModel : null
rootIndex: mainToolTip.rootIndex
model: parentIndex !== -1 && isGroup ? tasksModel : undefined delegate: ToolTipInstance {
rootIndex: tasksModel.makeModelIndex(parentIndex, -1) submodelIndex: tasksModel.makeModelIndex(mainToolTip.rootIndex.row, index)
delegate: ToolTipInstance {} }
}
Component.onCompleted: {
parent = groupTask
} }
} }
} }
}
} //! Loader
} //! Item
//! Central Functionality
function mouseIsInside(){
var isInside = contentItemMouseArea.containsMouse || instancesContainMouse() || (parentTask && parentTask.containsMouse);
function containsMouse(){ if (isInside){
for(var i=1; i<children.length-1; ++i) { mainToolTip.containsMouse = true;
if(children[i].containsMouse())
return true;
}
return false; if(!root.latteDock)
} checkListHovered.stop();
} else {
mainToolTip.containsMouse = false;
if(!root.latteDock)
checkListHovered.startDuration(100);
else
root.latteDock.startCheckRestoreZoomTimer();
}
}
function childAtPos(x, y){ function instancesContainMouse() {
var tasks = groupTask.children; var previewInstances = isGroup ? contentItem.children[0].children : contentItem.children;
var instancesLength = previewInstances.length;
for(var i=0; i<tasks.length; ++i){ for(var i=instancesLength-1; i>=0; --i) {
var task = tasks[i]; if( (typeof(previewInstances[i].containsMouse) === "function") //ignore unrelevant objects
&& previewInstances[i].containsMouse())
return true;
}
var choords = contentItem.mapFromItem(task,0, 0); return false;
}
if(choords.y < 0) function instanceAtPos(x, y){
choords.y = 0; var previewInstances = isGroup ? contentItem.children[0].children : contentItem.children;
if(choords.x < 0) var instancesLength = previewInstances.length;
choords.x = 0;
if( (x>=choords.x) && (x<=choords.x+task.width) for(var i=0; i<instancesLength; ++i){
&& (y>=choords.y) && (y<=choords.y+task.height)){ var instance = previewInstances[i];
return task; var choords = contentItem.mapFromItem(instance,0, 0);
}
}
return null; if(choords.y < 0)
} choords.y = 0;
if(choords.x < 0)
choords.x = 0;
if( (x>=choords.x) && (x<=choords.x+instance.width)
&& (y>=choords.y) && (y<=choords.y+instance.height)){
return instance;
} }
} }
return null;
} }
} }

@ -38,7 +38,7 @@ import org.kde.latte 0.1 as Latte
Column { Column {
id: instance id: instance
property var submodelIndex: tasksModel.makeModelIndex(parentIndex, isGroup ? itemIndex : -1) property var submodelIndex
property int flatIndex: isGroup && itemIndex>=0 ? itemIndex : 0 property int flatIndex: isGroup && itemIndex>=0 ? itemIndex : 0
property bool isActive: (typeof model !== 'undefined') && (typeof model.IsActive !== 'undefined') ? IsActive : false property bool isActive: (typeof model !== 'undefined') && (typeof model.IsActive !== 'undefined') ? IsActive : false
@ -166,7 +166,7 @@ Column {
tasksModel.requestClose(submodelIndex) tasksModel.requestClose(submodelIndex)
} }
onContainsMouseChanged: contentItem.checkMouseInside(); onContainsMouseChanged: mainToolTip.mouseIsInside();
PlasmaCore.IconItem { PlasmaCore.IconItem {
anchors.fill: parent anchors.fill: parent
@ -196,7 +196,7 @@ Column {
readonly property bool isMinimized: isGroup ? instance.isMinimized : mainToolTip.isMinimizedParent readonly property bool isMinimized: isGroup ? instance.isMinimized : mainToolTip.isMinimizedParent
// TODO: this causes XCB error message when being visible the first time // TODO: this causes XCB error message when being visible the first time
property int winId: isWin && windows[flatIndex] != undefined ? windows[flatIndex] : 0 property int winId: isWin && windows[flatIndex] !== undefined ? windows[flatIndex] : 0
Loader{ Loader{
@ -356,7 +356,7 @@ Column {
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
hoverEnabled: true hoverEnabled: true
onClicked: mpris2Source.goPrevious(mprisSourceName) onClicked: mpris2Source.goPrevious(mprisSourceName)
onContainsMouseChanged: contentItem.checkMouseInside(); onContainsMouseChanged: mainToolTip.mouseIsInside();
PlasmaCore.IconItem { PlasmaCore.IconItem {
anchors.fill: parent anchors.fill: parent
@ -377,7 +377,7 @@ Column {
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
hoverEnabled: true hoverEnabled: true
onClicked: mpris2Source.playPause(mprisSourceName) onClicked: mpris2Source.playPause(mprisSourceName)
onContainsMouseChanged: contentItem.checkMouseInside(); onContainsMouseChanged: mainToolTip.mouseIsInside();
PlasmaCore.IconItem { PlasmaCore.IconItem {
anchors.fill: parent anchors.fill: parent
@ -398,7 +398,7 @@ Column {
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
hoverEnabled: true hoverEnabled: true
onClicked: mpris2Source.goNext(mprisSourceName) onClicked: mpris2Source.goNext(mprisSourceName)
onContainsMouseChanged: contentItem.checkMouseInside(); onContainsMouseChanged: mainToolTip.mouseIsInside();
PlasmaCore.IconItem { PlasmaCore.IconItem {
anchors.fill: parent anchors.fill: parent
@ -451,8 +451,8 @@ Column {
text = text.replace(/\s*(?:-|—)*\s*$/, ""); text = text.replace(/\s*(?:-|—)*\s*$/, "");
// Add counter back at the end. // Add counter back at the end.
if (counter != null) { if (counter !== null) {
if (text == "") { if (text === "") {
text = counter; text = counter;
} else { } else {
text = text + " " + counter; text = text + " " + counter;
@ -461,14 +461,14 @@ Column {
// In case the window title had only redundant informations (i.e. appName), text is now empty. // In case the window title had only redundant informations (i.e. appName), text is now empty.
// Add a hyphen to indicate that and avoid empty space. // Add a hyphen to indicate that and avoid empty space.
if (text == "") { if (text === "") {
text = "—"; text = "—";
} }
return text.toString(); return text.toString();
} }
function generateSubText() { function generateSubText() {
if (activitiesParent == undefined) { if (activitiesParent === undefined) {
return ""; return "";
} }
@ -479,9 +479,9 @@ Column {
if (!plasmoid.configuration.showOnlyCurrentDesktop if (!plasmoid.configuration.showOnlyCurrentDesktop
&& virtualDesktopInfo.numberOfDesktops > 1 && virtualDesktopInfo.numberOfDesktops > 1
&& (isGroup ? IsOnAllVirtualDesktops : isOnAllVirtualDesktopsParent) !== true && (isGroup ? IsOnAllVirtualDesktops : isOnAllVirtualDesktopsParent) !== true
&& vd != -1 && vd !== -1
&& vd != undefined && vd !== undefined
&& virtualDesktopInfo.desktopNames[vd - 1] != undefined) { && virtualDesktopInfo.desktopNames[vd - 1] !== undefined) {
subTextEntries.push(i18n("On %1", virtualDesktopInfo.desktopNames[vd - 1])); subTextEntries.push(i18n("On %1", virtualDesktopInfo.desktopNames[vd - 1]));
} }
@ -491,7 +491,7 @@ Column {
return subTextEntries.join("\n"); return subTextEntries.join("\n");
} }
if (act.length == 0 && activityInfo.numberOfRunningActivities > 1) { if (act.length === 0 && activityInfo.numberOfRunningActivities > 1) {
subTextEntries.push(i18nc("Which virtual desktop a window is currently on", subTextEntries.push(i18nc("Which virtual desktop a window is currently on",
"Available on all activities")); "Available on all activities"));
} else if (act.length > 0) { } else if (act.length > 0) {
@ -500,14 +500,14 @@ Column {
for (var i = 0; i < act.length; i++) { for (var i = 0; i < act.length; i++) {
var activity = act[i]; var activity = act[i];
var activityName = activityInfo.activityName(act[i]); var activityName = activityInfo.activityName(act[i]);
if (activityName == "") { if (activityName === "") {
continue; continue;
} }
if (plasmoid.configuration.showOnlyCurrentActivity) { if (plasmoid.configuration.showOnlyCurrentActivity) {
if (activity != activityInfo.currentActivity) { if (activity !== activityInfo.currentActivity) {
activityNames.push(activityName); activityNames.push(activityName);
} }
} else if (activity != activityInfo.currentActivity) { } else if (activity !== activityInfo.currentActivity) {
activityNames.push(activityName); activityNames.push(activityName);
} }
} }

@ -41,12 +41,11 @@ MouseArea {
root.createContextMenu(rootTask, modelIndex).show(); root.createContextMenu(rootTask, modelIndex).show();
} }
icList.hoveredIndex = -1; icList.hoveredIndex = -1;
windowsPreviewDlg.hide(); windowsPreviewDlg.hide("7.1");
//rootTask.hideToolTipTemporarily();
} }
onContainsMouseChanged: { onContainsMouseChanged: {
contentItem.checkMouseInside(); mainToolTip.mouseIsInside();
root.windowsHovered([winId], containsMouse); root.windowsHovered([winId], containsMouse);
} }
} }

@ -494,7 +494,7 @@ Item {
} }
function hide(debug){ function hide(debug){
//console.log("on hide previews event called: "+debug); // console.log("on hide previews event called: "+debug);
if (latteDock && signalSent) { if (latteDock && signalSent) {
//it is used to unblock dock hiding //it is used to unblock dock hiding
@ -505,12 +505,6 @@ Item {
windowsPreviewDlg.activeItem = null; windowsPreviewDlg.activeItem = null;
toolTipDelegate.containsMouse = false;
toolTipDelegate.parentTask = null;
toolTipDelegate.parentIndex = -1;
toolTipDelegate.windows = [];
toolTipDelegate.isGroup = false;
if (!contextMenu) if (!contextMenu)
root.disableRestoreZoom = false; root.disableRestoreZoom = false;
@ -522,7 +516,7 @@ Item {
return; return;
} }
//console.log("preview show called..."); // console.log("preview show called...");
if ((!activeItem || (activeItem !== taskItem)) && !root.contextMenu) { if ((!activeItem || (activeItem !== taskItem)) && !root.contextMenu) {
//console.log("preview show called: accepted..."); //console.log("preview show called: accepted...");

@ -1007,7 +1007,7 @@ MouseArea{
windowsPreviewDlg.visualParent = previewsVisualParent; windowsPreviewDlg.visualParent = previewsVisualParent;
toolTipDelegate.parentTask = mainItemContainer; toolTipDelegate.parentTask = mainItemContainer;
toolTipDelegate.parentIndex = itemIndex; toolTipDelegate.rootIndex = tasksModel.makeModelIndex(itemIndex, -1);
toolTipDelegate.hideCloseButtons = hideClose; toolTipDelegate.hideCloseButtons = hideClose;

Loading…
Cancel
Save