summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoahelpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoahelpers.h')
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.h34
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