Reusable Clock
This commit is contained in:
parent
1b69bab95f
commit
58c8cbbf1d
3 changed files with 39 additions and 24 deletions
|
|
@ -73,7 +73,7 @@ PanelWindow {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
NClock {}
|
Clock {}
|
||||||
|
|
||||||
NIconButton {
|
NIconButton {
|
||||||
id: demoPanelToggler
|
id: demoPanelToggler
|
||||||
|
|
|
||||||
32
Modules/Bar/Clock.qml
Normal file
32
Modules/Bar/Clock.qml
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
import QtQuick
|
||||||
|
import qs.Services
|
||||||
|
import qs.Widgets
|
||||||
|
|
||||||
|
// Clock Icon with attached calendar
|
||||||
|
NClock {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
NTooltip {
|
||||||
|
id: tooltip
|
||||||
|
text: Time.dateString
|
||||||
|
target: root
|
||||||
|
}
|
||||||
|
|
||||||
|
NCalendar {
|
||||||
|
id: calendar
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
|
|
||||||
|
onEntered: function (){
|
||||||
|
if (!calendar.visible) {
|
||||||
|
tooltip.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onExited: function (){
|
||||||
|
tooltip.hide()
|
||||||
|
}
|
||||||
|
onClicked: function () {
|
||||||
|
calendar.visible = !calendar.visible
|
||||||
|
tooltip.hide()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,9 @@ Rectangle {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property real scaling: Scaling.scale(screen)
|
readonly property real scaling: Scaling.scale(screen)
|
||||||
|
property var onEntered: function () {}
|
||||||
|
property var onExited: function () {}
|
||||||
|
property var onClicked: function () {}
|
||||||
|
|
||||||
width: textItem.paintedWidth
|
width: textItem.paintedWidth
|
||||||
height: textItem.paintedHeight
|
height: textItem.paintedHeight
|
||||||
|
|
@ -22,28 +25,8 @@ Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onEntered: {
|
onEntered: root.onEntered()
|
||||||
if (!calendar.visible) {
|
onExited: root.onExited()
|
||||||
tooltip.show()
|
onClicked: root.onClicked()
|
||||||
}
|
|
||||||
}
|
|
||||||
onExited: {
|
|
||||||
tooltip.hide()
|
|
||||||
}
|
|
||||||
onClicked: function () {
|
|
||||||
calendar.visible = !calendar.visible
|
|
||||||
tooltip.hide()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NCalendar {
|
|
||||||
id: calendar
|
|
||||||
visible: false
|
|
||||||
}
|
|
||||||
|
|
||||||
NTooltip {
|
|
||||||
id: tooltip
|
|
||||||
text: Time.dateString
|
|
||||||
target: root
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue