diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2014-02-19 10:06:25 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2014-02-19 10:06:25 +0100 |
commit | 30fd22b9574def54726e7b193127cc0c901c1b4c (patch) | |
tree | 96dfc923044db0515064ba39d052d9ed577e3e40 /src/plugins/platforms/cocoa/qcocoahelpers.h | |
parent | d7b0581c1c2ef60c08d238dae39298af6904918f (diff) | |
parent | 6aa09bbce59828d028f6d1e81d2bfc6ba537aae1 (diff) |
Merge remote-tracking branch 'origin/dev' into stable
Change-Id: Ice524edcc51373509f0023ae7f7c2963f4602f88
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoahelpers.h')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoahelpers.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index 3e402673f3..419bf631aa 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.h +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h @@ -116,6 +116,7 @@ inline NSPoint qt_mac_flipPoint(const QPoint &p) inline NSPoint qt_mac_flipPoint(const QPointF &p) { return NSMakePoint(p.x(), qt_mac_flipYCoordinate(p.y())); } +NSRect qt_mac_flipRect(const QRect &rect); NSRect qt_mac_flipRect(const QRect &rect, QWindow *window); Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); @@ -161,6 +162,39 @@ CGContextRef qt_mac_cg_context(QPaintDevice *pdev); CGImageRef qt_mac_toCGImage(const QImage &qImage, bool isMask, uchar **dataCopy); QImage qt_mac_toQImage(CGImageRef image); +template<typename T> +T qt_mac_resolveOption(const T &fallback, const QByteArray &environment) +{ + // check for environment variable + if (!environment.isEmpty()) { + QByteArray env = qgetenv(environment); + if (!env.isEmpty()) + return T(env.toInt()); // works when T is bool, int. + } + + return fallback; +} + +template<typename T> +T qt_mac_resolveOption(const T &fallback, QWindow *window, const QByteArray &property, const QByteArray &environment) +{ + // check for environment variable + if (!environment.isEmpty()) { + QByteArray env = qgetenv(environment); + if (!env.isEmpty()) + return T(env.toInt()); // works when T is bool, int. + } + + // check for window property + if (window && !property.isNull()) { + QVariant windowProperty = window->property(property); + if (windowProperty.isValid()) + return windowProperty.value<T>(); + } + + // return default value. + return fallback; +} QT_END_NAMESPACE #endif //QCOCOAHELPERS_H |