fix #622,support title tooltips for hovered applets

pull/1/head
Michail Vourlakos
parent 9d1dd08191
commit 45add5988f

@ -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();
}

@ -0,0 +1,82 @@
/*
* Copyright 2017 Smith AR <audoban@openmailbox.org>
* 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.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;
}
}
]
}

@ -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,

@ -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();
}

@ -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
}

@ -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;
}
}
}

@ -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

Loading…
Cancel
Save