@@ -1785,90 +1785,103 @@ PopupWindow {
17851785 font .bold : true
17861786 }
17871787 Text {
1788- text: " Minutes per day (0 = no limit) "
1788+ text: " Click a preset to set or clear a daily budget "
17891789 color: popup .textDim
17901790 font .family : popup .fontFamily
17911791 font .pixelSize : 9
17921792 }
17931793
17941794 Repeater {
17951795 model: popup .categories || []
1796- delegate: RowLayout {
1796+ delegate: ColumnLayout {
1797+ id: catRow
17971798 required property var modelData
1799+ readonly property int catBudget: (modelData .budget_secs && modelData .budget_secs > 0 ) ? modelData .budget_secs : 0
17981800 Layout .fillWidth : true
1799- spacing: 8
1800-
1801- // Colour dot
1802- Rectangle {
1803- width: 7 ; height: 7 ; radius: 3.5
1804- color: popup .categoryColor (modelData .name )
1805- Layout .alignment : Qt .AlignVCenter
1806- }
1801+ spacing: 4
18071802
1808- Text {
1809- text: modelData .name
1810- color: popup .textColor
1811- font .family : popup .fontFamily
1812- font .pixelSize : 10
1803+ RowLayout {
18131804 Layout .fillWidth : true
1814- }
1805+ spacing : 8
18151806
1816- Rectangle {
1817- Layout .preferredWidth : 52
1818- Layout .preferredHeight : 22
1819- radius: 4
1820- color: Qt .darker (popup .bgSecondary , 1.3 )
1821- border .width : 1
1822- border .color : popup .accentColor
1807+ Rectangle {
1808+ width: 7 ; height: 7 ; radius: 3.5
1809+ color: popup .categoryColor (catRow .modelData .name )
1810+ Layout .alignment : Qt .AlignVCenter
1811+ }
18231812
1824- TextInput {
1825- id: budgetInput
1826- anchors .fill : parent
1827- anchors .leftMargin : 6
1828- anchors .rightMargin : 6
1829- verticalAlignment: TextInput .AlignVCenter
1813+ Text {
1814+ text: catRow .modelData .name
18301815 color: popup .textColor
18311816 font .family : popup .fontFamily
18321817 font .pixelSize : 10
1833- inputMethodHints: Qt .ImhDigitsOnly
1834- // Pre-fill from current budget (budget_secs / 60, rounded)
1835- text: (modelData .budget_secs && modelData .budget_secs > 0 )
1836- ? String (Math .round (modelData .budget_secs / 60 )) : " "
1837- selectByMouse: true
1838- validator: IntValidator { bottom: 0 ; top: 9999 }
1818+ Layout .fillWidth : true
18391819 }
1840- }
1841-
1842- Rectangle {
1843- Layout .preferredWidth : budgetSaveLabel .implicitWidth + 14
1844- Layout .preferredHeight : 22
1845- radius: 11
1846- color: budgetSaveMouse .containsMouse ? Qt .lighter (popup .bgSecondary , 1.2 ) : popup .bgSecondary
1847- border .width : 1
1848- border .color : popup .accentColor
1849-
1850- Behavior on color { ColorAnimation { duration: 120 } }
18511820
18521821 Text {
1853- id : budgetSaveLabel
1854- anchors . centerIn : parent
1855- text : " Save "
1856- color: popup .textDim
1822+ text : catRow . catBudget > 0
1823+ ? popup . formatDuration ( catRow . catBudget ) + " /day "
1824+ : " no limit "
1825+ color: catRow . catBudget > 0 ? popup . watchedAccent : popup .textDim
18571826 font .family : popup .fontFamily
18581827 font .pixelSize : 9
18591828 }
1860- MouseArea {
1861- id: budgetSaveMouse
1862- anchors .fill : parent
1863- hoverEnabled: true
1864- cursorShape: Qt .PointingHandCursor
1865- onClicked: {
1866- var mins = parseInt (budgetInput .text ) || 0 ;
1867- attnSetBudget .budgetCategory = modelData .name ;
1868- attnSetBudget .budgetSecs = mins * 60 ;
1869- attnSetBudget .running = true ;
1829+ }
1830+
1831+ RowLayout {
1832+ Layout .fillWidth : true
1833+ Layout .leftMargin : 15
1834+ spacing: 4
1835+
1836+ Repeater {
1837+ model: [
1838+ {label: " off" , secs: 0 },
1839+ {label: " 15m" , secs: 900 },
1840+ {label: " 30m" , secs: 1800 },
1841+ {label: " 1h" , secs: 3600 },
1842+ {label: " 2h" , secs: 7200 },
1843+ {label: " 4h" , secs: 14400 },
1844+ {label: " 8h" , secs: 28800 },
1845+ ]
1846+ delegate: Rectangle {
1847+ required property var modelData
1848+ readonly property bool active: modelData .secs === catRow .catBudget
1849+ width: budgetPillLabel .implicitWidth + 14
1850+ height: 22
1851+ radius: 11
1852+ color: active
1853+ ? popup .watchedBg
1854+ : (budgetPillMouse .containsMouse ? Qt .lighter (popup .bgSecondary , 1.15 ) : popup .bgSecondary )
1855+ border .width : 1
1856+ border .color : active ? popup .watchedAccent : popup .accentColor
1857+ scale: budgetPillMouse .pressed ? 0.94 : 1.0
1858+
1859+ Behavior on color { ColorAnimation { duration: 140 } }
1860+ Behavior on scale { NumberAnimation { duration: 90 ; easing .type : Easing .OutCubic } }
1861+
1862+ Text {
1863+ id: budgetPillLabel
1864+ anchors .centerIn : parent
1865+ text: modelData .label
1866+ color: parent .active ? popup .watchedAccent : popup .textDim
1867+ font .family : popup .fontFamily
1868+ font .pixelSize : 10
1869+ font .bold : parent .active
1870+ }
1871+ MouseArea {
1872+ id: budgetPillMouse
1873+ anchors .fill : parent
1874+ hoverEnabled: true
1875+ cursorShape: Qt .PointingHandCursor
1876+ onClicked: {
1877+ attnSetBudget .budgetCategory = catRow .modelData .name ;
1878+ attnSetBudget .budgetSecs = modelData .secs ;
1879+ attnSetBudget .running = true ;
1880+ }
1881+ }
18701882 }
18711883 }
1884+ Item { Layout .fillWidth : true }
18721885 }
18731886 }
18741887 }
0 commit comments