2022-08-28 21:48:51 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2013-2015 Sebastian Kügler <sebas@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
|
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
|
|
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
2024-02-17 22:51:19 +00:00
|
|
|
import org.kde.kwindowsystem 1.0
|
2022-08-28 21:48:51 +00:00
|
|
|
|
|
|
|
PlasmaCore.ColorScope {
|
|
|
|
property Item toolTip
|
|
|
|
property int preferredTextWidth: PlasmaCore.Units.gridUnit * 10
|
2024-02-17 22:51:19 +00:00
|
|
|
property bool compositing: kwindowsystem.compositingActive
|
|
|
|
KWindowSystem { id: kwindowsystem }
|
2022-08-28 21:48:51 +00:00
|
|
|
// gridUnit is effectively equal to `PlasmaCore.Units.smallSpacing * 4`
|
|
|
|
// which is a double (both sides) of RowLayout's `anchors.margins`.
|
2024-02-17 22:51:19 +00:00
|
|
|
Layout.minimumWidth: compositing ? childrenRect.width + horizontalMargin*2 - PlasmaCore.Units.smallSpacing :
|
|
|
|
tooltipBackground.width - tooltipSvg.margins.left*2 - PlasmaCore.Units.smallSpacing / 2
|
|
|
|
Layout.minimumHeight: compositing ? childrenRect.height + verticalMargin*2 :
|
|
|
|
tooltipBackground.height - tooltipSvg.margins.top*4 - PlasmaCore.Units.smallSpacing / 2
|
|
|
|
Layout.maximumWidth: compositing ? childrenRect.width + horizontalMargin*2 - PlasmaCore.Units.smallSpacing :
|
|
|
|
tooltipBackground.width - tooltipSvg.margins.left*2 - PlasmaCore.Units.smallSpacing / 2
|
|
|
|
|
|
|
|
Layout.maximumHeight: compositing ? childrenRect.height +verticalMargin*2 :
|
|
|
|
tooltipBackground.height - tooltipSvg.margins.top*4 - PlasmaCore.Units.smallSpacing / 2
|
|
|
|
Layout.margins: PlasmaCore.Units.largeSpacing
|
2022-08-28 21:48:51 +00:00
|
|
|
|
|
|
|
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
|
|
|
|
LayoutMirroring.childrenInherit: true
|
|
|
|
|
2024-02-17 22:51:19 +00:00
|
|
|
colorGroup: PlasmaCore.Theme.ViewColorGroup
|
2022-08-28 21:48:51 +00:00
|
|
|
inherit: false
|
|
|
|
|
2024-02-17 22:51:19 +00:00
|
|
|
// Used for margins
|
|
|
|
PlasmaCore.FrameSvgItem {
|
|
|
|
id: tooltipSvg
|
|
|
|
imagePath: "solid/widgets/tooltip"
|
|
|
|
visible: false
|
|
|
|
}
|
2022-08-28 21:48:51 +00:00
|
|
|
|
2024-02-17 22:51:19 +00:00
|
|
|
property int verticalMargin: (-tooltipSvg.margins.top - PlasmaCore.Units.smallSpacing)*1.5
|
|
|
|
property int horizontalMargin: (-tooltipSvg.margins.left - PlasmaCore.Units.smallSpacing / 2)*1.5
|
|
|
|
|
|
|
|
property int tooltipMarginLeft: horizontalMargin + (compositing ? (-PlasmaCore.Units.smallSpacing/2) : PlasmaCore.Units.smallSpacing)
|
|
|
|
property int tooltipMarginTop: verticalMargin + (compositing ? (-PlasmaCore.Units.smallSpacing/2) : PlasmaCore.Units.smallSpacing)
|
|
|
|
PlasmaCore.FrameSvgItem {
|
|
|
|
|
|
|
|
id: tooltipBackground
|
|
|
|
imagePath: "solid/widgets/tooltip"
|
|
|
|
prefix: ""
|
2022-08-28 21:48:51 +00:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
2024-02-17 22:51:19 +00:00
|
|
|
left: parent.left
|
|
|
|
leftMargin: tooltipMarginLeft //horizontalMargin + PlasmaCore.Units.smallSpacing
|
|
|
|
topMargin: tooltipMarginTop //verticalMargin + PlasmaCore.Units.smallSpacing
|
|
|
|
}
|
|
|
|
|
|
|
|
width: rows.width - horizontalMargin - PlasmaCore.Units.smallSpacing / 2
|
|
|
|
height: rows.height - verticalMargin - PlasmaCore.Units.smallSpacing
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: rows
|
|
|
|
anchors {
|
|
|
|
left: compositing ? parent.left : tooltipBackground.left
|
|
|
|
top: compositing ? parent.top : tooltipBackground.top
|
|
|
|
leftMargin: compositing ? horizontalMargin + PlasmaCore.Units.smallSpacing / 2 : PlasmaCore.Units.smallSpacing
|
|
|
|
topMargin: compositing ? verticalMargin : PlasmaCore.Units.smallSpacing / 2
|
2022-08-28 21:48:51 +00:00
|
|
|
//margins: PlasmaCore.Units.smallSpacing
|
|
|
|
}
|
|
|
|
|
2024-02-17 22:51:19 +00:00
|
|
|
//spacing: PlasmaCore.Units.gridUnit
|
2022-08-28 21:48:51 +00:00
|
|
|
|
|
|
|
Image {
|
|
|
|
source: toolTip ? toolTip.image : ""
|
|
|
|
visible: toolTip !== null && toolTip.image !== ""
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
PlasmaCore.IconItem {
|
|
|
|
animated: false
|
|
|
|
source: toolTip ? toolTip.icon : ""
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
|
|
|
visible: toolTip !== null && toolTip.icon !== "" && toolTip.image === "" && valid
|
|
|
|
Layout.preferredWidth: PlasmaCore.Units.iconSizes.medium
|
|
|
|
Layout.preferredHeight: PlasmaCore.Units.iconSizes.medium
|
|
|
|
Layout.leftMargin: PlasmaCore.Units.smallSpacing*2
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.maximumWidth: preferredTextWidth
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
PlasmaExtras.Heading {
|
|
|
|
level: 5
|
|
|
|
Layout.fillWidth: true
|
|
|
|
elide: Text.ElideRight
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
text: toolTip ? toolTip.mainText : ""
|
|
|
|
textFormat: Text.PlainText
|
|
|
|
visible: text !== ""
|
2024-02-17 22:51:19 +00:00
|
|
|
opacity: 0.75
|
2022-08-28 21:48:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PlasmaComponents.Label {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
// Unset Label default height, confuses the layout engine completely
|
|
|
|
// either shifting the item vertically or letting it get too wide
|
|
|
|
height: undefined
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
text: toolTip ? toolTip.subText : ""
|
|
|
|
textFormat: toolTip ? toolTip.textFormat : Text.AutoText
|
2024-02-17 22:51:19 +00:00
|
|
|
opacity: 0.75
|
2022-08-28 21:48:51 +00:00
|
|
|
visible: text !== ""
|
|
|
|
maximumLineCount: 8
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|