QSearchField: Remove NSSearchField workaround

This was a workaround for QTBUG-124160.
This commit is contained in:
Jonas Kvinge 2024-04-13 05:39:19 +02:00
parent 0c6872b352
commit 8b249dc06a
3 changed files with 4 additions and 27 deletions

View File

@ -5,9 +5,6 @@
#include <QPointer>
#include <QMenu>
class QShowEvent;
class QCloseEvent;
class QSearchFieldPrivate;
class QSearchField : public QWidget {
Q_OBJECT
@ -41,7 +38,6 @@ class QSearchField : public QWidget {
void returnPressed();
protected:
void showEvent(QShowEvent *e) override;
void resizeEvent(QResizeEvent*) override;
bool eventFilter(QObject*, QEvent*) override;

View File

@ -162,12 +162,14 @@ QSearchField::QSearchField(QWidget *parent) : QWidget(parent) {
pimpl = delegate->pimpl = new QSearchFieldPrivate(this, search);
[search setDelegate:static_cast<id<NSSearchFieldDelegate>>(delegate)];
new QVBoxLayout(this);
layout()->setContentsMargins(0, 0, 0, 0);
setAttribute(Qt::WA_NativeWindow);
setFixedHeight(24);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
new QVBoxLayout(this);
layout()->setContentsMargins(0, 0, 0, 0);
layout()->addWidget(QWidget::createWindowContainer(QWindow::fromWinId(WId(pimpl->nsSearchField)), this));
[pool drain];
}
@ -227,21 +229,6 @@ void QSearchField::setFocus() {
setFocus(Qt::OtherFocusReason);
}
void QSearchField::showEvent(QShowEvent *e) {
if (!e->spontaneous()) {
for (int i = 0; i < layout()->count(); ++i) {
QWidget *widget = layout()->itemAt(i)->widget();
layout()->removeWidget(widget);
delete widget;
}
layout()->addWidget(QWidget::createWindowContainer(QWindow::fromWinId(WId(pimpl->nsSearchField)), this));
}
QWidget::showEvent(e);
}
void QSearchField::resizeEvent(QResizeEvent *resizeEvent) {
QWidget::resizeEvent(resizeEvent);
}

View File

@ -172,12 +172,6 @@ QString QSearchField::text() const {
}
void QSearchField::showEvent(QShowEvent *e) {
QWidget::showEvent(e);
}
void QSearchField::resizeEvent(QResizeEvent *resizeEvent) {
Q_ASSERT(pimpl && pimpl->clearbutton_ && pimpl->lineedit_);