Replace QMacCocoaViewContainer with QWidget::createWindowContainer

This commit is contained in:
Jonas Kvinge 2020-10-01 19:40:55 +02:00
parent c71ccda967
commit 8f9dbfee2c
2 changed files with 13 additions and 18 deletions

View File

@ -26,8 +26,6 @@ THE SOFTWARE.
#include <QString>
#include <QImage>
#include <QPixmap>
#include <QBoxLayout>
#include <QMacCocoaViewContainer>
static inline NSString* fromQString(const QString &string) {
@ -51,16 +49,3 @@ static inline NSImage* fromQPixmap(const QPixmap &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);
// FIXME
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
layout->addWidget(new QMacCocoaViewContainer(cocoaView, parent));
#pragma GCC diagnostic pop
}

View File

@ -21,7 +21,6 @@ THE SOFTWARE.
*/
#include "qsearchfield.h"
#include "qocoa_mac.h"
#import "Foundation/NSAutoreleasePool.h"
@ -29,8 +28,11 @@ THE SOFTWARE.
#import "AppKit/NSSearchField.h"
#include <QApplication>
#include <QKeyEvent>
#include <QWindow>
#include <QString>
#include <QClipboard>
#include <QBoxLayout>
#include <QKeyEvent>
class QSearchFieldPrivate : public QObject {
public:
@ -155,16 +157,24 @@ public:
@end
QSearchField::QSearchField(QWidget *parent) : QWidget(parent) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSSearchField *search = [[QocoaSearchField alloc] init];
QSearchFieldDelegate *delegate = [[QSearchFieldDelegate alloc] init];
pimpl = delegate->pimpl = new QSearchFieldPrivate(this, search);
[search setDelegate:(id<NSSearchFieldDelegate>)delegate];
setupLayout(search, this);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setMargin(0);
layout->addWidget(QWidget::createWindowContainer(QWindow::fromWinId(WId(search)), this));
setAttribute(Qt::WA_NativeWindow);
setFixedHeight(24);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
[search release];
[pool drain];
}
void QSearchField::setIconSize(const int iconsize) {