Remove use of some deprecated code and cleanup other macOS code

This commit is contained in:
Jonas Kvinge
2019-08-06 20:31:54 +02:00
parent 20766c1feb
commit 4a934c9dab
11 changed files with 147 additions and 93 deletions

View File

@@ -27,30 +27,33 @@ THE SOFTWARE.
#include <QtMacExtras>
#include <QMacCocoaViewContainer>
static inline NSString* fromQString(const QString &string)
{
const QByteArray utf8 = string.toUtf8();
const char* cString = utf8.constData();
return [[NSString alloc] initWithUTF8String:cString];
static inline NSString* fromQString(const QString &string) {
const QByteArray utf8 = string.toUtf8();
const char* cString = utf8.constData();
return [ [NSString alloc] initWithUTF8String:cString];
}
static inline QString toQString(NSString *string)
{
if (!string)
return QString();
return QString::fromUtf8([string UTF8String]);
static inline QString toQString(NSString *string) {
if (!string) return QString();
return QString::fromUtf8([string UTF8String]);
}
static inline NSImage* fromQPixmap(const QPixmap &pixmap)
{
CGImageRef cgImage = QtMac::toCGImageRef(pixmap);
return [[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize];
static inline NSImage* fromQPixmap(const QPixmap &pixmap) {
CGImageRef cgImage = QtMac::toCGImageRef(pixmap);
return [ [NSImage alloc] initWithCGImage:cgImage size:NSZeroSize];
}
static inline void setupLayout(NSView *cocoaView, QWidget *parent)
{
parent->setAttribute(Qt::WA_NativeWindow);
QVBoxLayout *layout = new QVBoxLayout(parent);
layout->setMargin(0);
layout->addWidget(new QMacCocoaViewContainer(cocoaView, parent));
static inline void setupLayout(NSView *cocoaView, QWidget *parent) {
parent->setAttribute(Qt::WA_NativeWindow);
QVBoxLayout *layout = new QVBoxLayout(parent);
layout->setMargin(0);
layout->addWidget(new QMacCocoaViewContainer(cocoaView, parent));
}