Skip to content

Commit 53d111c

Browse files
committed
ff-qtah: Show rucurring flag
1 parent 0cecbfc commit 53d111c

File tree

2 files changed

+47
-30
lines changed

2 files changed

+47
-30
lines changed

ff-qtah/FF/Qt/EDSL.hs

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{-# LANGUAGE BlockArguments #-}
22
{-# LANGUAGE DataKinds #-}
33
{-# LANGUAGE LambdaCase #-}
4-
{-# LANGUAGE OverloadedLabels #-}
5-
{-# LANGUAGE ViewPatterns #-}
64

75
module FF.Qt.EDSL where
86

@@ -24,7 +22,7 @@ import Graphics.UI.Qtah.Widgets.QSizePolicy (QSizePolicyPolicy)
2422
import Graphics.UI.Qtah.Widgets.QVBoxLayout qualified as QVBoxLayout
2523
import Graphics.UI.Qtah.Widgets.QWidget (QWidgetPtr, toQWidget)
2624
import Graphics.UI.Qtah.Widgets.QWidget qualified as QWidget
27-
import Named (arg, argF, (:!), (:?))
25+
import Named (NamedF (ArgF), (:?))
2826

2927
data QBoxLayoutItem
3028
= Stretch
@@ -34,6 +32,7 @@ data QFormLayoutItem
3432
= forall a. (QLayoutPtr a) => RowLayout (IO a)
3533
| forall a. (QWidgetPtr a) => RowWidget (IO a)
3634
| forall a. (QLayoutPtr a) => StringLayout String a
35+
| forall a. (QWidgetPtr a) => StringWidget String (IO a)
3736

3837
data Layout
3938
= QFormLayout [QFormLayoutItem]
@@ -52,9 +51,11 @@ qFrame lo = do
5251
pure obj
5352
where
5453
addRow form = \case
55-
RowLayout io -> QFormLayout.addRowLayout form . toQLayout =<< io
56-
RowWidget io -> QFormLayout.addRowWidget form . toQWidget =<< io
57-
StringLayout s c -> QFormLayout.addRowStringLayout form s $ toQLayout c
54+
RowLayout a -> QFormLayout.addRowLayout form . toQLayout =<< a
55+
RowWidget a -> QFormLayout.addRowWidget form . toQWidget =<< a
56+
StringLayout s a -> QFormLayout.addRowStringLayout form s $ toQLayout a
57+
StringWidget s a ->
58+
QFormLayout.addRowStringWidget form s . toQWidget =<< a
5859

5960
addBoxLayoutItem :: (QBoxLayoutPtr p) => p -> QBoxLayoutItem -> IO ()
6061
addBoxLayoutItem box = \case
@@ -75,27 +76,30 @@ qHBoxLayout items = do
7576

7677
qLabel ::
7778
(Qt.IsQtTextInteractionFlags textInteractionFlags) =>
78-
"alignment" :! Qt.QtAlignmentFlag ->
79-
"openExternalLinks" :! Bool ->
79+
"alignment" :? Qt.QtAlignmentFlag ->
80+
"openExternalLinks" :? Bool ->
8081
"sizePolicy" :? (QSizePolicyPolicy, QSizePolicyPolicy) ->
81-
"textInteractionFlags" :! textInteractionFlags ->
82-
"textFormat" :! Qt.QtTextFormat ->
83-
"wordWrap" :! Bool ->
82+
"text" :? String ->
83+
"textFormat" :? Qt.QtTextFormat ->
84+
"textInteractionFlags" :? textInteractionFlags ->
85+
"wordWrap" :? Bool ->
8486
IO QLabel
8587
qLabel
86-
(arg #alignment -> a)
87-
(arg #openExternalLinks -> oel)
88-
(argF #sizePolicy -> sp)
89-
(arg #textInteractionFlags -> tif)
90-
(arg #textFormat -> tf)
91-
(arg #wordWrap -> ww) = do
88+
(ArgF alignment)
89+
(ArgF openExternalLinks)
90+
(ArgF sizePolicy)
91+
(ArgF text)
92+
(ArgF textFormat)
93+
(ArgF textInteractionFlags)
94+
(ArgF wordWrap) = do
9295
obj <- QLabel.new
93-
QLabel.setAlignment obj a
94-
QLabel.setOpenExternalLinks obj oel
95-
for_ sp \(sp1, sp2) -> QWidget.setSizePolicyRaw obj sp1 sp2
96-
QLabel.setTextInteractionFlags obj tif
97-
QLabel.setTextFormat obj tf
98-
QLabel.setWordWrap obj ww
96+
for_ alignment $ QLabel.setAlignment obj
97+
for_ openExternalLinks $ QLabel.setOpenExternalLinks obj
98+
for_ sizePolicy \(sp1, sp2) -> QWidget.setSizePolicyRaw obj sp1 sp2
99+
for_ text $ QLabel.setText obj
100+
for_ textFormat $ QLabel.setTextFormat obj
101+
for_ textInteractionFlags $ QLabel.setTextInteractionFlags obj
102+
for_ wordWrap $ QLabel.setWordWrap obj
99103
pure obj
100104

101105
qScrollArea :: (QWidgetPtr widget) => widget -> IO QScrollArea

ff-qtah/FF/Qt/TaskWidget.hs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module FF.Qt.TaskWidget (
1212

1313
import Data.Foldable (for_)
1414
import Data.IORef (IORef, atomicWriteIORef, newIORef, readIORef)
15+
import Data.Maybe (fromMaybe)
1516
import Graphics.UI.Qtah.Core.Types qualified as Qt
1617
import Graphics.UI.Qtah.Signal (connect_)
1718
import Graphics.UI.Qtah.Widgets.QAbstractButton qualified as QAbstractButton
@@ -60,6 +61,9 @@ data TaskWidget = TaskWidget
6061
, end :: DateComponent
6162
, noteId :: IORef (Maybe NoteId)
6263
, onTaskUpdated :: OnTaskUpdated
64+
, created :: QLabel
65+
, updated :: QLabel
66+
, recurring :: QLabel
6367
}
6468

6569
new :: Storage.Handle -> OnTaskUpdated -> IO TaskWidget
@@ -72,17 +76,23 @@ new storage onTaskUpdated = do
7276
qLabel
7377
! #alignment Qt.AlignTop
7478
! #openExternalLinks True
75-
! #textInteractionFlags Qt.TextBrowserInteraction
7679
! #textFormat Qt.MarkdownText
80+
! #textInteractionFlags Qt.TextBrowserInteraction
7781
! #wordWrap True
7882
! defaults
7983
postpone <- QPushButton.newWithText "Postpone"
8084
done <- QPushButton.newWithText "Done"
85+
created <- QLabel.new
86+
updated <- QLabel.new
87+
recurring <- QLabel.new
8188
parent <-
8289
qFrame . QFormLayout $
8390
[ RowWidget $ qScrollArea textContent
8491
, StringLayout "Start:" start.parent
8592
, StringLayout "Deadline:" end.parent
93+
, StringWidget "Created:" $< created
94+
, StringWidget "Updated:" $< updated
95+
, StringWidget "Recurring:" $< recurring
8696
, RowLayout . qHBoxLayout $
8797
[Widget $< postpone, Widget $< done, Stretch]
8898
]
@@ -117,10 +127,13 @@ reload this noteId = do
117127
update :: Bool -> TaskWidget -> EntityDoc Note -> IO ()
118128
update keepOpen this noteDoc = do
119129
entity <- runStorage this.storage $ viewNote noteDoc
120-
let Entity{entityVal} = entity
121-
let NoteView{note} = entityVal
122-
let Note{note_text, note_start, note_end} = note
123-
QLabel.setText this.textContent $ fromRgaM note_text
124-
DateComponent.setDate this.start note_start
125-
DateComponent.setDate this.end note_end
130+
let Entity{entityVal = NoteView{note}} = entity
131+
QLabel.setText this.textContent $ fromRgaM note.note_text
132+
DateComponent.setDate this.start note.note_start
133+
DateComponent.setDate this.end note.note_end
134+
-- TODO created
135+
-- TODO updated
136+
QLabel.setText
137+
this.recurring
138+
if fromMaybe False note.note_recurring then "Yes" else "No"
126139
this.onTaskUpdated keepOpen entity

0 commit comments

Comments
 (0)