diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index 39581443b..3733f8a4c 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -106,6 +106,8 @@ Item { property Item appletIconItem; //first applet's IconItem, to be activated onExit signal property Item appletImageItem; + property Item tooltipVisualParent: titleTooltipParent + //this is used for folderView and icon widgets to fake their visual property bool fakeIconItem: applet && appletIconItem //(applet.pluginName === "org.kde.plasma.folder" || applet.pluginName === "org.kde.plasma.icon") @@ -449,7 +451,13 @@ Item { } } - AppletItemWrapper{ id: wrapper } + AppletItemWrapper{ + id: wrapper + + TitleTooltipParent{ + id: titleTooltipParent + } + } // a hidden spacer on the right for the last item to add stability @@ -570,6 +578,8 @@ Item { onEntered: { //AppletIndetifier.reconsiderAppletIconItem(); + root.showTooltipLabel(container, applet.title); + if (lockZoom || !canBeHovered) { return; } @@ -594,6 +604,8 @@ Item { if (appletIconItem && appletIconItem.visible) appletIconItem.active = false; + root.hideTooltipLabel(); + if (root.zoomFactor>1){ checkRestoreZoom.start(); } diff --git a/containment/package/contents/ui/applet/TitleTooltipParent.qml b/containment/package/contents/ui/applet/TitleTooltipParent.qml new file mode 100644 index 000000000..b4a30547d --- /dev/null +++ b/containment/package/contents/ui/applet/TitleTooltipParent.qml @@ -0,0 +1,82 @@ +/* +* Copyright 2017 Smith AR +* 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.0 + +import org.kde.plasma.core 2.0 as PlasmaCore + +Item{ + id: visual + width: root.isVertical ? thickness : size + height: root.isVertical ? size : thickness + + property int size: 1// root.iconSize + property int thickness: (root.zoomFactor * root.realSize) + root.statesLineSize + //border.width: 1 + //border.color: "green" + //color: "transparent" + + states:[ + State{ + name: "bottom" + when: plasmoid.location === PlasmaCore.Types.BottomEdge + + AnchorChanges{ + target: visual; + anchors.horizontalCenter: parent.horizontalCenter; + anchors.verticalCenter: undefined; + anchors.right: undefined; anchors.left: undefined; anchors.top: undefined; anchors.bottom: parent.bottom; + } + }, + State{ + name: "top" + when: plasmoid.location === PlasmaCore.Types.TopEdge + + AnchorChanges{ + target:visual; + anchors.horizontalCenter: parent.horizontalCenter; + anchors.verticalCenter: undefined; + anchors.right: undefined; anchors.left: undefined; anchors.top: parent.top; anchors.bottom: undefined; + } + }, + State{ + name: "left" + when: plasmoid.location === PlasmaCore.Types.LeftEdge + + AnchorChanges{ + target: visual; + anchors.horizontalCenter: undefined; + anchors.verticalCenter: parent.verticalCenter; + anchors.right: undefined; anchors.left: parent.left; anchors.top: undefined; anchors.bottom: undefined; + } + }, + State{ + name: "right" + when: plasmoid.location === PlasmaCore.Types.RightEdge + + AnchorChanges{ + target: visual; + anchors.horizontalCenter: undefined; + anchors.verticalCenter: parent.verticalCenter; + anchors.right: parent.right; anchors.left: undefined; anchors.top: undefined; anchors.bottom: undefined; + } + } + ] +} diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index d441bc264..866e12942 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -457,6 +457,7 @@ DragDrop.DropArea { latteApplet.signalAnimationsNeedThickness.connect(slotAnimationsNeedThickness); latteApplet.signalActionsBlockHiding.connect(slotActionsBlockHiding); latteApplet.signalPreviewsShown.connect(slotPreviewsShown); + latteApplet.clearZoomSignal.connect(titleTooltipDialog.hide); } } @@ -884,6 +885,14 @@ DragDrop.DropArea { layoutManager.save(); } + function hideTooltipLabel(debug){ + titleTooltipDialog.hide(debug); + } + + function showTooltipLabel(taskItem, text){ + titleTooltipDialog.show(taskItem, text); + } + function sizeIsFromAutomaticMode(size){ for(var i=iconsArray.length-1; i>=0; --i){ @@ -1149,6 +1158,83 @@ DragDrop.DropArea { ////END interfaces + /////BEGIN: Title Tooltip/////////// + PlasmaCore.Dialog{ + id: titleTooltipDialog + + type: PlasmaCore.Dialog.Tooltip + flags: Qt.WindowStaysOnTopHint | Qt.WindowDoesNotAcceptFocus | Qt.ToolTip + + location: plasmoid.location + mainItem: Item{ + width: titleLbl.width + height: titleLbl.height + PlasmaComponents.Label{ + id:titleLbl + text: titleTooltipDialog.title + } + } + + visible: false + + property string title: "" + + property bool activeItemHovered: false + property Item activeItem: null + property Item activeItemTooltipParent: null + property string activeItemText: "" + + + Component.onCompleted: { + root.clearZoomSignal.connect(titleTooltipDialog.hide); + } + + function hide(debug){ + activeItemHovered = false; + hideTitleTooltipTimer.start(); + } + + function show(taskItem, text){ + if (!root.titleTooltips || (latteApplet && latteApplet.contextMenu)){ + return; + } + + activeItemHovered = true; + + if (activeItem !== taskItem) { + activeItem = taskItem; + activeItemTooltipParent = taskItem.tooltipVisualParent; + activeItemText = text; + } + + showTitleTooltipTimer.start(); + } + + function update() { + activeItemHovered = true + title = activeItemText; + visualParent = activeItemTooltipParent; + visible = true; + } + } + + Timer { + id: showTitleTooltipTimer + interval: 100 + onTriggered: titleTooltipDialog.update(); + } + + Timer { + id: hideTitleTooltipTimer + interval: 200 + onTriggered: { + if (!titleTooltipDialog.activeItemHovered) { + titleTooltipDialog.visible = false; + } + } + } + /////END: Title Tooltip/////////// + ///////////////BEGIN components Component { id: appletContainerComponent @@ -1165,6 +1251,7 @@ DragDrop.DropArea { id: colorScopePalette } + ///////////////BEGIN UI elements //it is used to check if the mouse is outside the layoutsContainer borders, diff --git a/plasmoid/package/contents/ui/main.qml b/plasmoid/package/contents/ui/main.qml index 7e126c6dd..9e54c78b5 100644 --- a/plasmoid/package/contents/ui/main.qml +++ b/plasmoid/package/contents/ui/main.qml @@ -141,7 +141,7 @@ Item { property bool showOnlyCurrentScreen: latteDock ? latteDock.showOnlyCurrentScreen : plasmoid.configuration.showOnlyCurrentScreen property bool showOnlyCurrentDesktop: latteDock ? latteDock.showOnlyCurrentDesktop : plasmoid.configuration.showOnlyCurrentDesktop property bool showOnlyCurrentActivity: latteDock ? latteDock.showOnlyCurrentActivity : plasmoid.configuration.showOnlyCurrentActivity - property bool showPreviews: latteDock ? latteDock.showToolTips : plasmoid.configuration.showToolTips + property bool showPreviews: latteDock ? (latteDock.showToolTips && !titleTooltips) : plasmoid.configuration.showToolTips property bool showWindowActions: latteDock ? latteDock.showWindowActions : plasmoid.configuration.showWindowActions property bool smartLaunchersEnabled: latteDock ? latteDock.smartLaunchersEnabled : plasmoid.configuration.smartLaunchersEnabled property bool threeColorsWindows: latteDock ? latteDock.threeColorsWindows : plasmoid.configuration.threeColorsWindows @@ -429,69 +429,6 @@ Item { } } - /////BEGIN: Title Tooltip/////////// - PlasmaCore.Dialog{ - id: titleTooltipDlg - - type: PlasmaCore.Dialog.Tooltip - flags: Qt.WindowStaysOnTopHint | Qt.WindowDoesNotAcceptFocus | Qt.ToolTip - - location: plasmoid.location - mainItem: Item{ - width: titleLbl.width - height: titleLbl.height - PlasmaComponents.Label{ - id:titleLbl - text: titleTooltipDlg.title - } - } - - visible: false - - property string title: "" - - property Item activeItem: null - property Item activeItemTooltipParent: null - property string activeItemText: "" - - - Component.onCompleted: { - root.clearZoomSignal.connect(titleTooltipDlg.hide); - } - - function hide(debug){ - visible = false; - } - - function show(taskItem, text){ - if (!root.titleTooltips || root.contextMenu){ - return; - } - - if (activeItem !== taskItem) { - activeItem = taskItem; - activeItemTooltipParent = taskItem.tooltipVisualParent; - activeItemText = text; - } - - showTitleTooltipTimer.start(); - } - - function update() { - title = activeItemText; - visualParent = activeItemTooltipParent; - visible = true; - } - } - - Timer { - id: showTitleTooltipTimer - interval: 100 - onTriggered: titleTooltipDlg.update(); - } - /////END: Title Tooltip/////////// - - /////Window previews/////////// ToolTipDelegate2 { @@ -1508,10 +1445,6 @@ Item { } } - if (titleTooltipDlg.visible) { - titleTooltipDlg.hide(); - } - return false; } @@ -1528,6 +1461,7 @@ Item { icList.currentSpot = -1000; icList.hoveredIndex = -1; + root.clearZoomSignal(); } diff --git a/plasmoid/package/contents/ui/task/TaskDelegate.qml b/plasmoid/package/contents/ui/task/TaskDelegate.qml index 323a4ad03..5704c90f6 100644 --- a/plasmoid/package/contents/ui/task/TaskDelegate.qml +++ b/plasmoid/package/contents/ui/task/TaskDelegate.qml @@ -538,7 +538,9 @@ MouseArea{ return; } - titleTooltipDlg.show(mainItemContainer, model.AppName); + if (root.latteDock){ + root.latteDock.showTooltipLabel(mainItemContainer, model.AppName); + } if((!inAnimation)&&(root.dragSource == null)&&(!root.taskInAnimation) && hoverEnabled){ icList.hoveredIndex = index; @@ -564,6 +566,11 @@ MouseArea{ // IMPORTANT: This must be improved ! even for small miliseconds it reduces performance onExited: { mouseEntered = false; + + if (root.latteDock){ + root.latteDock.hideTooltipLabel(); + } + if(mainItemContainer.contextMenu && mainItemContainer.contextMenu.status == PlasmaComponents.DialogStatus.Open){ ///dont check to restore zooms } diff --git a/shell/package/contents/configuration/TasksConfig.qml b/shell/package/contents/configuration/TasksConfig.qml index 7047c673f..e9e8a3d6c 100644 --- a/shell/package/contents/configuration/TasksConfig.qml +++ b/shell/package/contents/configuration/TasksConfig.qml @@ -112,32 +112,11 @@ PlasmaComponents.Page { Layout.leftMargin: units.smallSpacing * 2 text: i18n("Preview windows on hovering") checked: plasmoid.configuration.showToolTips - tooltip: i18n("This option can be combined with task name tooltips") + tooltip: i18n("This option can be combined with applet/task title tooltips") + enabled: !plasmoid.configuration.titleTooltips onClicked: { plasmoid.configuration.showToolTips = checked; - - if (checked && titleTooltipsChk.checked) { - plasmoid.configuration.titleTooltips = false; - titleTooltipsChk.checked = false; - } - } - } - - PlasmaComponents.CheckBox { - id: titleTooltipsChk - Layout.leftMargin: units.smallSpacing * 2 - text: i18n("Show task name tooltips on hovering") - checked: plasmoid.configuration.titleTooltips - tooltip: i18n("This option can be combined with window previews") - - onClicked: { - plasmoid.configuration.titleTooltips = checked; - - if (checked && showPreviewsChk.checked) { - plasmoid.configuration.showToolTips = false; - showPreviewsChk.checked = false; - } } } diff --git a/shell/package/contents/configuration/TweaksConfig.qml b/shell/package/contents/configuration/TweaksConfig.qml index 9b82fb838..7f2e94ff9 100644 --- a/shell/package/contents/configuration/TweaksConfig.qml +++ b/shell/package/contents/configuration/TweaksConfig.qml @@ -61,6 +61,18 @@ PlasmaComponents.Page { } } + PlasmaComponents.CheckBox { + id: titleTooltipsChk + Layout.leftMargin: units.smallSpacing * 2 + text: i18n("Show applets/task title tooltips on hovering") + checked: plasmoid.configuration.titleTooltips + tooltip: i18n("This option can be combined with tasks window previews") + + onClicked: { + plasmoid.configuration.titleTooltips = checked; + } + } + PlasmaComponents.CheckBox { id: shrinkThickness Layout.leftMargin: units.smallSpacing * 2