Make toOF/toQt more powerful and complete QtWidget

This commit is contained in:
Jonathan Schleifer 2017-04-15 19:18:52 +02:00
parent b37c5f6fc5
commit d8f3aa90ec
No known key found for this signature in database
GPG key ID: 28D65178B37F33E3
24 changed files with 1047 additions and 385 deletions

View file

@ -24,14 +24,14 @@
#include <QGuiApplication>
@interface QtGuiApplication: QtCoreApplication
@interface QtGUIApplication: QtCoreApplication
@property (readonly) QGuiApplication *qGuiApplication;
@property (copy) OFString *applicationDisplayName;
@property (copy) OFString *desktopFileName;
@property Qt::LayoutDirection layoutDirection;
@property (readonly, copy) OFString *platformName;
@property (readonly) QScreen *primaryScreen;
@property bool quitOnLastWindowClosed;
@property bool quitsOnLastWindowClosed;
@property QIcon windowIcon;
- initWithQGuiApplication: (QGuiApplication*)qGuiApplication;
@ -41,3 +41,20 @@
- (OFString*)sessionID;
- (OFString*)sessionKey;
@end
namespace ObjQt {
static OF_INLINE QtGUIApplication*
toOF(QGuiApplication *qGuiApplication)
{
return [[[QtGUIApplication alloc]
initWithQGuiApplication: qGuiApplication] autorelease];
}
static OF_INLINE QGuiApplication*
toQt(QtGUIApplication *GUIApplication)
{
return [GUIApplication qGuiApplication];
}
}

View file

@ -20,13 +20,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "QtGuiApplication.h"
#import "helpers.h"
#import "QtGUIApplication.h"
#import "OFString+QString.h"
#include <QIcon>
@implementation QtGuiApplication
using ObjQt::toOF;
using ObjQt::toQt;
@implementation QtGUIApplication
- initWithQCoreApplication: (QCoreApplication*)qCoreApplication
{
OF_INVALID_INIT_METHOD
@ -44,88 +46,86 @@
- (OFString*)applicationDisplayName
{
return toOF([self qGuiApplication]->applicationDisplayName());
return toOF(toQt(self)->applicationDisplayName());
}
- (void)setApplicationDisplayName: (OFString*)applicationDisplayName
{
[self qGuiApplication]->setApplicationDisplayName(
toQt(applicationDisplayName));
toQt(self)->setApplicationDisplayName(toQt(applicationDisplayName));
}
- (OFString*)desktopFileName
{
return toOF([self qGuiApplication]->desktopFileName());
return toOF(toQt(self)->desktopFileName());
}
- (void)setDesktopFileName: (OFString*)desktopFileName
{
[self qGuiApplication]->setDesktopFileName(toQt(desktopFileName));
toQt(self)->setDesktopFileName(toQt(desktopFileName));
}
- (double)devicePixelRatio
{
return [self qGuiApplication]->devicePixelRatio();
return toQt(self)->devicePixelRatio();
}
- (bool)isSavingSession
{
return [self qGuiApplication]->isSavingSession();
return toQt(self)->isSavingSession();
}
- (bool)isSessionRestored
{
return [self qGuiApplication]->isSessionRestored();
return toQt(self)->isSessionRestored();
}
- (Qt::LayoutDirection)layoutDirection
{
return [self qGuiApplication]->layoutDirection();
return toQt(self)->layoutDirection();
}
- (void)setLayoutDirection: (Qt::LayoutDirection)layoutDirection
{
[self qGuiApplication]->setLayoutDirection(layoutDirection);
toQt(self)->setLayoutDirection(layoutDirection);
}
- (OFString*)platformName
{
return toOF([self qGuiApplication]->platformName());
return toOF(toQt(self)->platformName());
}
- (QScreen*)primaryScreen
{
return [self qGuiApplication]->primaryScreen();
return toQt(self)->primaryScreen();
}
- (bool)quitOnLastWindowClosed
- (bool)quitsOnLastWindowClosed
{
return [self qGuiApplication]->quitOnLastWindowClosed();
return toQt(self)->quitOnLastWindowClosed();
}
- (void)setQuitOnLastWindowClosed: (bool)quitOnLastWindowClosed
- (void)setQuitsOnLastWindowClosed: (bool)quitsOnLastWindowClosed
{
[self qGuiApplication]->setQuitOnLastWindowClosed(
quitOnLastWindowClosed);
toQt(self)->setQuitOnLastWindowClosed(quitsOnLastWindowClosed);
}
- (OFString*)sessionID
{
return toOF([self qGuiApplication]->sessionId());
return toOF(toQt(self)->sessionId());
}
- (OFString*)sessionKey
{
return toOF([self qGuiApplication]->sessionKey());
return toOF(toQt(self)->sessionKey());
}
- (QIcon)windowIcon
{
return [self qGuiApplication]->windowIcon();
return toQt(self)->windowIcon();
}
- (void)setWindowIcon: (QIcon)windowIcon
{
[self qGuiApplication]->setWindowIcon(windowIcon);
toQt(self)->setWindowIcon(windowIcon);
}
@end

View file

@ -45,3 +45,13 @@
@interface QtPaintDevice: OFObject <QtPaintDevice>
@property (readonly) QObject *qObject;
@end
namespace ObjQt {
static OF_INLINE QPaintDevice*
toQt(QtPaintDevice *paintDevice)
{
return [paintDevice qPaintDevice];
}
}

View file

@ -24,6 +24,8 @@
#include <QObject>
using ObjQt::toQt;
@implementation QtPaintDevice
@dynamic qObject;
@ -34,71 +36,71 @@
- (int)colorCount
{
return [self qPaintDevice]->colorCount();
return toQt(self)->colorCount();
}
- (int)depth
{
return [self qPaintDevice]->depth();
return toQt(self)->depth();
}
- (int)devicePixelRatio
{
return [self qPaintDevice]->devicePixelRatio();
return toQt(self)->devicePixelRatio();
}
- (double)devicePixelRatioF
{
return [self qPaintDevice]->devicePixelRatioF();
return toQt(self)->devicePixelRatioF();
}
- (int)height
{
return [self qPaintDevice]->height();
return toQt(self)->height();
}
- (int)heightMM
{
return [self qPaintDevice]->heightMM();
return toQt(self)->heightMM();
}
- (int)logicalDPIX
{
return [self qPaintDevice]->logicalDpiX();
return toQt(self)->logicalDpiX();
}
- (int)logicalDPIY
{
return [self qPaintDevice]->logicalDpiY();
return toQt(self)->logicalDpiY();
}
- (QPaintEngine*)paintEngine
{
return [self qPaintDevice]->paintEngine();
return toQt(self)->paintEngine();
}
- (bool)paintingActive
{
return [self qPaintDevice]->paintingActive();
return toQt(self)->paintingActive();
}
- (int)physicalDPIX
{
return [self qPaintDevice]->physicalDpiX();
return toQt(self)->physicalDpiX();
}
- (int)physicalDPIY
{
return [self qPaintDevice]->physicalDpiY();
return toQt(self)->physicalDpiY();
}
- (int)width
{
return [self qPaintDevice]->width();
return toQt(self)->width();
}
- (int)widthMM
{
return [self qPaintDevice]->widthMM();
return toQt(self)->widthMM();
}
@end