11{-# LANGUAGE BlockArguments #-}
22{-# LANGUAGE NamedFieldPuns #-}
3+ {-# LANGUAGE OverloadedLabels #-}
34{-# LANGUAGE OverloadedRecordDot #-}
45{-# LANGUAGE RecordWildCards #-}
56
@@ -10,23 +11,19 @@ module FF.Qt.TaskWidget (
1011) where
1112
1213import Data.IORef (IORef , atomicWriteIORef , newIORef , readIORef )
13- import Foreign.Hoppy.Runtime (toGc )
1414import Graphics.UI.Qtah.Core.Types qualified as Qt
1515import Graphics.UI.Qtah.Signal (connect_ )
1616import Graphics.UI.Qtah.Widgets.QAbstractButton qualified as QAbstractButton
17- import Graphics.UI.Qtah.Widgets.QBoxLayout qualified as QBoxLayout
18- import Graphics.UI.Qtah.Widgets.QFormLayout qualified as QFormLayout
1917import Graphics.UI.Qtah.Widgets.QFrame (QFrame )
20- import Graphics.UI.Qtah.Widgets.QFrame qualified as QFrame
21- import Graphics.UI.Qtah.Widgets.QHBoxLayout qualified as QHBoxLayout
2218import Graphics.UI.Qtah.Widgets.QLabel (QLabel )
2319import Graphics.UI.Qtah.Widgets.QLabel qualified as QLabel
2420import Graphics.UI.Qtah.Widgets.QPushButton qualified as QPushButton
2521import Graphics.UI.Qtah.Widgets.QScrollArea (QScrollArea )
26- import Graphics.UI.Qtah.Widgets.QScrollArea qualified as QScrollArea
27- import Graphics.UI.Qtah.Widgets.QSizePolicy ( QSizePolicy , QSizePolicyPolicy )
28- import Graphics.UI.Qtah.Widgets.QSizePolicy qualified as QSizePolicy
22+ import Graphics.UI.Qtah.Widgets.QSizePolicy (
23+ QSizePolicyPolicy ( .. ),
24+ )
2925import Graphics.UI.Qtah.Widgets.QWidget qualified as QWidget
26+ import Named ((!) )
3027import RON.Storage.FS (runStorage )
3128import RON.Storage.FS qualified as Storage
3229
@@ -43,6 +40,15 @@ import FF.Types (
4340
4441import FF.Qt.DateComponent (DateComponent )
4542import FF.Qt.DateComponent qualified as DateComponent
43+ import FF.Qt.EDSL (
44+ QBoxLayoutItem (.. ),
45+ QFormLayoutItem (.. ),
46+ hline ,
47+ qFrame ,
48+ qHBoxLayout ,
49+ qLabel ,
50+ qScrollArea ,
51+ )
4652
4753type OnTaskUpdated =
4854 -- | Keep open task view (e.g. on postpone)
@@ -67,31 +73,26 @@ new storage onTaskUpdated = do
6773 start <- DateComponent. new
6874 end <- DateComponent. new
6975
70- -- TODO generate this from .ui
71- parent <- QScrollArea. new
72- innerWidget <- QFrame. new
73- QScrollArea. setWidget parent innerWidget
74- textContent <- QLabel. new
75- QWidget. setSizePolicy textContent
76- =<< makeSimpleSizePolicy QSizePolicy. MinimumExpanding
77- QLabel. setAlignment textContent Qt. AlignTop
78- QLabel. setWordWrap textContent True
79- QLabel. setTextFormat textContent Qt. MarkdownText
80- QLabel. setTextInteractionFlags textContent Qt. TextBrowserInteraction
81- QLabel. setOpenExternalLinks textContent True
82- hline <- QFrame. new
83- QFrame. setFrameShape hline QFrame. HLine
84- form <- QFormLayout. newWithParent innerWidget
85- QFormLayout. addRowWidget form textContent
86- QFormLayout. addRowWidget form hline
87- QFormLayout. addRowStringLayout form " Start:" start. parent
88- QFormLayout. addRowStringLayout form " Deadline:" end. parent
76+ -- setup UI (TODO xDSL?)
77+ textContent <-
78+ qLabel
79+ ! # alignment Qt. AlignTop
80+ ! # openExternalLinks True
81+ ! # sizePolicy (MinimumExpanding , MinimumExpanding )
82+ ! # textInteractionFlags Qt. TextBrowserInteraction
83+ ! # textFormat Qt. MarkdownText
84+ ! # wordWrap True
8985 postpone <- QPushButton. newWithText " Postpone"
90- actions <- QHBoxLayout. new
91- QBoxLayout. addWidget actions postpone
92- QBoxLayout. addStretch actions
93- QFormLayout. addRowLayout form actions
94- -- end generated
86+ innerWidget <-
87+ qFrame
88+ [ RowWidget $ pure textContent
89+ , RowWidget hline
90+ , StringLayout " Start:" start. parent
91+ , StringLayout " Deadline:" end. parent
92+ , RowLayout $ qHBoxLayout [Widget $ pure postpone, Stretch ]
93+ ]
94+ parent <- qScrollArea innerWidget
95+ -- end setup UI
9596
9697 noteId <- newIORef Nothing
9798 let this = TaskWidget {.. }
@@ -122,7 +123,3 @@ update keepOpen this noteDoc = do
122123 DateComponent. setDate this. end note_end
123124 QWidget. adjustSize this. innerWidget
124125 this. onTaskUpdated keepOpen entity
125-
126- makeSimpleSizePolicy :: QSizePolicyPolicy -> IO QSizePolicy
127- makeSimpleSizePolicy policy =
128- toGc =<< QSizePolicy. newWithOptions policy policy QSizePolicy. DefaultType
0 commit comments