11{-# LANGUAGE BlockArguments #-}
22{-# LANGUAGE DataKinds #-}
33{-# LANGUAGE LambdaCase #-}
4- {-# LANGUAGE OverloadedLabels #-}
5- {-# LANGUAGE ViewPatterns #-}
64
75module FF.Qt.EDSL where
86
@@ -24,7 +22,7 @@ import Graphics.UI.Qtah.Widgets.QSizePolicy (QSizePolicyPolicy)
2422import Graphics.UI.Qtah.Widgets.QVBoxLayout qualified as QVBoxLayout
2523import Graphics.UI.Qtah.Widgets.QWidget (QWidgetPtr , toQWidget )
2624import Graphics.UI.Qtah.Widgets.QWidget qualified as QWidget
27- import Named (arg , argF , (:! ) , (:?) )
25+ import Named (NamedF ( ArgF ), (:?) )
2826
2927data 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
3837data 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
5960addBoxLayoutItem :: (QBoxLayoutPtr p ) => p -> QBoxLayoutItem -> IO ()
6061addBoxLayoutItem box = \ case
@@ -75,27 +76,30 @@ qHBoxLayout items = do
7576
7677qLabel ::
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
8587qLabel
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
101105qScrollArea :: (QWidgetPtr widget ) => widget -> IO QScrollArea
0 commit comments