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
|
||||
}
|
||||
|
||||
NClock {}
|
||||
Clock {}
|
||||
|
||||
NIconButton {
|
||||
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
|
||||
|
||||
readonly property real scaling: Scaling.scale(screen)
|
||||
property var onEntered: function () {}
|
||||
property var onExited: function () {}
|
||||
property var onClicked: function () {}
|
||||
|
||||
width: textItem.paintedWidth
|
||||
height: textItem.paintedHeight
|
||||
|
|
@ -22,28 +25,8 @@ Rectangle {
|
|||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
hoverEnabled: true
|
||||
onEntered: {
|
||||
if (!calendar.visible) {
|
||||
tooltip.show()
|
||||
}
|
||||
}
|
||||
onExited: {
|
||||
tooltip.hide()
|
||||
}
|
||||
onClicked: function () {
|
||||
calendar.visible = !calendar.visible
|
||||
tooltip.hide()
|
||||
}
|
||||
}
|
||||
|
||||
NCalendar {
|
||||
id: calendar
|
||||
visible: false
|
||||
}
|
||||
|
||||
NTooltip {
|
||||
id: tooltip
|
||||
text: Time.dateString
|
||||
target: root
|
||||
onEntered: root.onEntered()
|
||||
onExited: root.onExited()
|
||||
onClicked: root.onClicked()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue