Skip to content

Commit

Permalink
Adjustments to make Qt example work
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanperez-keera committed Nov 2, 2015
1 parent efd72f2 commit 2b49ee7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
13 changes: 3 additions & 10 deletions keera-hails-reactive-qt/examples/Example.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ add_grid = do

-- Add Text boxes
l1 <- reactiveQLineEdit
addWidget gridLayout (l1, 0 :: Int, 1::Int)
addWidget gridLayout =<< qWidget l1 -- , 0 :: Int, 1::Int)

l2 <- reactiveQLineEdit
addWidget gridLayout (l2, 1 :: Int, 1::Int)
addWidget gridLayout =<< qWidget l2 --, 1 :: Int, 1::Int)

-- Add Button
tb <- reactiveQPushButton "Copy Up"
addWidget gridLayout (tb, 1 :: Int, 2::Int)
addWidget gridLayout =<< qWidget tb --, 1 :: Int, 2::Int)

-- Make widgets reactive
e1 <- lineEditText l1
Expand All @@ -73,10 +73,3 @@ add_grid = do
setColumnStretch gridLayout (2, 20)
setLayout gridGroupBox gridLayout
return $ objectCast gridGroupBox

-- | Temporary: will be moved to Keera Hails' Reactive Values library.
governingR :: (ReactiveValueRead a b m, ReactiveValueRead c d m)
=> a -> c -> ReactiveFieldRead m d
governingR r c = ReactiveFieldRead getter notifier
where getter = reactiveValueRead c
notifier = reactiveValueOnCanRead r
2 changes: 1 addition & 1 deletion keera-hails-reactive-qt/hails-reactive-qt.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ Library
-- Packages needed in order to build this package.
Build-depends: base >= 4
, qt
, hails-reactivevalues
, keera-hails-reactivevalues
16 changes: 10 additions & 6 deletions keera-hails-reactive-qt/src/Graphics/UI/Qt/Reactive.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
module Graphics.UI.Qt.Reactive
( buttonClick
, lineEditText
Expand All @@ -19,14 +21,16 @@ import Qtc.Classes.Qccs
import Qtc.Core.Base
import Qtc.Gui.QLineEdit
import Qtc.Gui.QPushButton
import Qtc.Gui.QWidget

-- * Line edits

type ReactQLineEdit = QLineEditSc CReactQLineEdit
data CReactQLineEdit = CReactQLineEdit

reactiveQLineEdit :: IO ReactQLineEdit
reactiveQLineEdit = qSubClass $ qLineEdit ()
type ReactQLineEdit = QLineEditSc ()

instance QqWidget ReactQLineEdit

reactiveQLineEdit :: IO ReactQLineEdit
reactiveQLineEdit = qSubClass $ qLineEdit ()

-- | Make a line edit's text reactive.
lineEditText :: ReactQLineEdit -> IO (ReactiveFieldReadWrite IO String)
Expand Down

0 comments on commit 2b49ee7

Please sign in to comment.