hsqml 0.3.4.1 → 0.3.5.0
raw patch · 10 files changed
+120/−10 lines, 10 filesdep ~QuickCheckdep ~directorydep ~hsqmlsetup-changed
Dependency ranges changed: QuickCheck, directory, hsqml
Files
- CHANGELOG +7/−0
- Setup.hs +3/−1
- cbits/Manager.cpp +37/−0
- cbits/Manager.h +2/−0
- cbits/hsqml.h +8/−0
- hsqml.cabal +12/−5
- src/Graphics/QML/Engine.hs +27/−0
- src/Graphics/QML/Internal/BindCore.chs +12/−1
- src/Graphics/QML/Internal/BindPrim.chs +3/−0
- test/Graphics/QML/Test/ScriptDSL.hs +9/−3
CHANGELOG view
@@ -1,5 +1,12 @@ HsQML - Release History +release-0.3.5.0 - 2017.09.08++ * Added facility for setting Qt application flags.+ * Fixed building GHCi objects with Cabal 1.24.+ * Relaxed Cabal constraint on 'QuickCheck' and fixed test suite.+ * Relaxed Cabal constraint on 'directory'.+ release-0.3.4.1 - 2016.07.21 * Added support for Cabal 1.24 API.
Setup.hs view
@@ -54,7 +54,9 @@ -- 'ComponentLocalBuildInfo' record changed fields in Cabal 1.18 and 1.24 getCompLibName = case () of- _ | post124CabalAPI -> vnameE "def"+ _ | post124CabalAPI ->+ AppE (vnameE "getHSLibraryName") $+ AppE (vnameE "componentUnitId") (vnameE "clbi") | post118CabalAPI -> AppE (LamE [cnameP "LibraryName" [vnameP "n"]] (vnameE "n")) $ AppE (vnameE "head") $
cbits/Manager.cpp view
@@ -159,6 +159,33 @@ return mArgsPtrs; } +bool HsQMLManager::setFlag(HsQMLGlobalFlag flag, bool value)+{+ if (mApp || mShutdown) {+ return false;+ }++ switch (flag) {+#if QT_VERSION >= 0x050400+ case HSQML_GFLAG_SHARE_OPENGL_CONTEXTS:+ QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, value);+ return true;+#endif+ }+ return false;+}++bool HsQMLManager::getFlag(HsQMLGlobalFlag flag)+{+ switch (flag) {+#if QT_VERSION >= 0x050400+ case HSQML_GFLAG_SHARE_OPENGL_CONTEXTS:+ return QCoreApplication::testAttribute(Qt::AA_ShareOpenGLContexts);+#endif+ }+ return false;+}+ void HsQMLManager::registerObject(const QObject* obj) { mObjectSet.insert(obj);@@ -492,6 +519,16 @@ QString* string = reinterpret_cast<QString*>(args[i]); *string = QString::fromLocal8Bit(argv[i]); }+}++extern "C" int hsqml_set_flag(HsQMLGlobalFlag flag, int value)+{+ return gManager->setFlag(flag, value);+}++extern "C" int hsqml_get_flag(HsQMLGlobalFlag flag)+{+ return gManager->getFlag(flag); } extern "C" HsQMLEventLoopStatus hsqml_evloop_run(
cbits/Manager.h view
@@ -46,6 +46,8 @@ void freeStable(HsStablePtr); bool setArgs(const QStringList&); QVector<char*>& argsPtrs();+ bool setFlag(HsQMLGlobalFlag, bool);+ bool getFlag(HsQMLGlobalFlag); void registerObject(const QObject*); void unregisterObject(const QObject*); void hookedConstruct(QVariant::Private*, const void*);
cbits/hsqml.h view
@@ -196,6 +196,14 @@ extern void hsqml_get_args(HsQMLStringHandle**); +typedef enum {+ HSQML_GFLAG_SHARE_OPENGL_CONTEXTS,+} HsQMLGlobalFlag;++extern int hsqml_set_flag(HsQMLGlobalFlag, int);++extern int hsqml_get_flag(HsQMLGlobalFlag);+ extern void hsqml_set_debug_loglevel(int); /* Engine */
hsqml.cabal view
@@ -1,10 +1,10 @@ Name: hsqml-Version: 0.3.4.1+Version: 0.3.5.0 Cabal-version: >= 1.14 Build-type: Custom License: BSD3 License-file: LICENSE-Copyright: (c) 2010-2016 Robin KAY+Copyright: (c) 2010-2017 Robin KAY Author: Robin KAY Maintainer: komadori@gekkou.co.uk Stability: experimental@@ -44,6 +44,13 @@ Allow the QML debug server to be enabled via Qt arguments. Default: False +Custom-Setup+ Setup-depends:+ base == 4.*,+ template-haskell == 2.*,+ Cabal >= 1.14 && < 1.25,+ filepath >= 1.3 && < 1.5+ Library Default-language: Haskell2010 Build-depends:@@ -129,11 +136,11 @@ Build-depends: base == 4.*, containers >= 0.4 && < 0.6,- directory >= 1.1 && < 1.3,+ directory >= 1.1 && < 1.4, text >= 0.11 && < 1.3, tagged >= 0.4 && < 0.9,- QuickCheck >= 2.4 && < 2.9,- hsqml == 0.3.*+ QuickCheck >= 2.4 && < 2.11,+ hsqml if os(darwin) && !flag(UsePkgConfig) -- Library not registered yet GHC-options: -hide-option-framework-path /QT_ROOT/lib
src/Graphics/QML/Engine.hs view
@@ -29,6 +29,10 @@ requireEventLoop, setQtArgs, getQtArgs,+ QtFlag(+ QtShareOpenGLContexts),+ setQtFlag,+ getQtFlag, shutdownQt, EventLoopException(), @@ -247,6 +251,29 @@ argvs <- peekArray0 nullPtr argv Just (arg0:args) <- runMaybeT $ mapM (fmap T.unpack . mFromCVal) argvs return (arg0, args)++-- | Represents a Qt application flag.+data QtFlag+ -- | Enables resource sharing between OpenGL contexts. This must be set in+ -- order to use QtWebEngine. + = QtShareOpenGLContexts+ deriving Show++internalFlag :: QtFlag -> HsQMLGlobalFlag+internalFlag QtShareOpenGLContexts = HsqmlGflagShareOpenglContexts++-- | Sets or clears one of the application flags used by Qt and returns True+-- if successful. If the flag or flag value is not supported then it will+-- return False. Setting flags once the Qt event loop is entered is+-- unsupported and will also cause this function to return False.+setQtFlag :: QtFlag -> Bool -> IO Bool+setQtFlag flag val = do+ hsqmlInit+ hsqmlSetFlag (internalFlag flag) val++-- | Gets the state of one of the application flags used by Qt.+getQtFlag :: QtFlag -> RunQML Bool+getQtFlag = RunQML . hsqmlGetFlag . internalFlag -- | Shuts down and frees resources used by the Qt framework, preventing -- further use of the event loop. The framework is initialised when
src/Graphics/QML/Internal/BindCore.chs view
@@ -10,7 +10,7 @@ import Foreign.C.Types import Foreign.ForeignPtr-import Foreign.Marshal.Utils (toBool)+import Foreign.Marshal.Utils (fromBool, toBool) import Foreign.Ptr #include <HsFFI.h>@@ -44,6 +44,17 @@ {#fun unsafe hsqml_get_args as ^ {id `Ptr HsQMLStringHandle'} -> `()' #}++{#enum HsQMLGlobalFlag as ^ {underscoreToCase} #}++{#fun unsafe hsqml_set_flag as ^+ {enumToCInt `HsQMLGlobalFlag',+ fromBool `Bool'} ->+ `Bool' toBool #}++{#fun unsafe hsqml_get_flag as ^+ {enumToCInt `HsQMLGlobalFlag'} ->+ `Bool' toBool #} type TrivialCb = IO ()
src/Graphics/QML/Internal/BindPrim.chs view
@@ -17,6 +17,9 @@ cIntToEnum :: Enum a => CInt -> a cIntToEnum = toEnum . fromIntegral +enumToCInt :: Enum a => a -> CInt+enumToCInt = fromIntegral . fromEnum+ -- -- String --
test/Graphics/QML/Test/ScriptDSL.hs view
@@ -2,6 +2,7 @@ module Graphics.QML.Test.ScriptDSL where +import Data.Bits import Data.Char import Data.Int import Data.List@@ -47,12 +48,17 @@ foldr (.) id . map f $ T.unpack txt) . showChar '"') where f '\"' = showString "\\\"" f '\\' = showString "\\\\"- f c | ord c < 32 = hexEsc c- | ord c > 127 = hexEsc c- | otherwise = showChar c+ f c | ord c < 32 = hexEsc c+ | ord c > 0xffff = surEsc c+ | ord c > 127 = hexEsc c+ | otherwise = showChar c hexEsc c = let h = showHex (ord c) in showString "\\u" . showString ( replicate (4 - (length $ h "")) '0') . h+ surEsc c = let v = ord c - 0x10000+ hi = chr $ (v `shiftR` 10) + 0xD800+ lo = chr $ (v .&. 0x3ff) + 0xDC00+ in hexEsc hi . hexEsc lo instance Literal a => Literal (Maybe a) where literal Nothing = Expr $ showString "null"