reorganize repo: move shell sources into shell/, test scripts into test/
This commit is contained in:
parent
344c1f8512
commit
d6cd2f173a
60 changed files with 2 additions and 2 deletions
74
shell/modules/BarIcon.qml
Normal file
74
shell/modules/BarIcon.qml
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import QtQuick
|
||||
import Quickshell
|
||||
import "." as M
|
||||
|
||||
Text {
|
||||
id: root
|
||||
property string icon: ""
|
||||
property string tooltip: ""
|
||||
property string minIcon: ""
|
||||
property color accentColor: parent?.accentColor ?? M.Theme.base05
|
||||
property bool _hovered: false
|
||||
property string _displayIcon: icon
|
||||
property string _pendingIcon: ""
|
||||
|
||||
text: _displayIcon
|
||||
|
||||
onIconChanged: {
|
||||
_pendingIcon = icon;
|
||||
if (!_crossfade.running)
|
||||
_crossfade.start();
|
||||
}
|
||||
|
||||
SequentialAnimation {
|
||||
id: _crossfade
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "opacity"
|
||||
to: 0
|
||||
duration: 60
|
||||
easing.type: Easing.InQuad
|
||||
}
|
||||
ScriptAction {
|
||||
script: root._displayIcon = root._pendingIcon
|
||||
}
|
||||
NumberAnimation {
|
||||
target: root
|
||||
property: "opacity"
|
||||
to: 1
|
||||
duration: 100
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
width: minIcon ? Math.max(implicitWidth, _minIconMetrics.width) : implicitWidth
|
||||
horizontalAlignment: minIcon ? Text.AlignHCenter : Text.AlignLeft
|
||||
color: root.accentColor
|
||||
font.pixelSize: M.Theme.fontSize + 1
|
||||
font.family: M.Theme.iconFontFamily
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
TextMetrics {
|
||||
id: _minIconMetrics
|
||||
text: root.minIcon
|
||||
font.pixelSize: root.font.pixelSize
|
||||
font.family: root.font.family
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
onHoveredChanged: {
|
||||
root._hovered = hovered;
|
||||
if (hovered && root.tooltip !== "") {
|
||||
M.FlyoutState.text = root.tooltip;
|
||||
M.FlyoutState.itemX = root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0);
|
||||
M.FlyoutState.screen = QsWindow.window?.screen ?? null;
|
||||
M.FlyoutState.accentColor = root.accentColor;
|
||||
M.FlyoutState.visible = true;
|
||||
} else if (!hovered && root.tooltip !== "") {
|
||||
M.FlyoutState.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onTooltipChanged: if (_hovered && tooltip !== "")
|
||||
M.FlyoutState.text = tooltip
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue