Fix QSearchField on macOS
This commit is contained in:
parent
d84aebd8f4
commit
f5bb15f72e
|
@ -248,6 +248,8 @@ void AlbumCoverManager::showEvent(QShowEvent *e) {
|
|||
Reset();
|
||||
}
|
||||
|
||||
QMainWindow::showEvent(e);
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverManager::closeEvent(QCloseEvent *e) {
|
||||
|
@ -270,6 +272,8 @@ void AlbumCoverManager::closeEvent(QCloseEvent *e) {
|
|||
ui_->artists->clear();
|
||||
ui_->albums->clear();
|
||||
|
||||
QMainWindow::closeEvent(e);
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverManager::LoadGeometry() {
|
||||
|
|
|
@ -163,14 +163,6 @@ void AlbumCoverSearcher::Init(AlbumCoverFetcher *fetcher) {
|
|||
|
||||
AlbumCoverImageResult AlbumCoverSearcher::Exec(const QString &artist, const QString &album) {
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
ui_->artist->clear();
|
||||
ui_->album->clear();
|
||||
model_->clear();
|
||||
cover_loading_tasks_.clear();
|
||||
show();
|
||||
#endif
|
||||
|
||||
ui_->artist->setText(artist);
|
||||
ui_->album->setText(album);
|
||||
ui_->artist->setFocus();
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
#include <QPointer>
|
||||
#include <QMenu>
|
||||
|
||||
class QShowEvent;
|
||||
class QCloseEvent;
|
||||
|
||||
class QSearchFieldPrivate;
|
||||
class QSearchField : public QWidget {
|
||||
Q_OBJECT
|
||||
|
@ -34,6 +37,7 @@ class QSearchField : public QWidget {
|
|||
void returnPressed();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *e) override;
|
||||
void resizeEvent(QResizeEvent*) override;
|
||||
bool eventFilter(QObject*, QEvent*) override;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ THE SOFTWARE.
|
|||
#include <QString>
|
||||
#include <QClipboard>
|
||||
#include <QBoxLayout>
|
||||
#include <QShowEvent>
|
||||
#include <QKeyEvent>
|
||||
|
||||
class QSearchFieldPrivate : public QObject {
|
||||
|
@ -164,15 +165,12 @@ QSearchField::QSearchField(QWidget *parent) : QWidget(parent) {
|
|||
pimpl = delegate->pimpl = new QSearchFieldPrivate(this, search);
|
||||
[search setDelegate:(id<NSSearchFieldDelegate>)delegate];
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addWidget(QWidget::createWindowContainer(QWindow::fromWinId(WId(search)), this));
|
||||
|
||||
new QVBoxLayout(this);
|
||||
layout()->setContentsMargins(0, 0, 0, 0);
|
||||
setAttribute(Qt::WA_NativeWindow);
|
||||
setFixedHeight(24);
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
[search release];
|
||||
[pool drain];
|
||||
|
||||
}
|
||||
|
@ -232,6 +230,21 @@ 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);
|
||||
}
|
||||
|
@ -239,4 +252,3 @@ void QSearchField::resizeEvent(QResizeEvent *resizeEvent) {
|
|||
bool QSearchField::eventFilter(QObject *o, QEvent *e) {
|
||||
return QWidget::eventFilter(o, e);
|
||||
}
|
||||
|
||||
|
|
|
@ -165,6 +165,12 @@ QString QSearchField::text() const {
|
|||
|
||||
}
|
||||
|
||||
void QSearchField::showEvent(QShowEvent *e) {
|
||||
|
||||
QWidget::showEvent(e);
|
||||
|
||||
}
|
||||
|
||||
void QSearchField::resizeEvent(QResizeEvent *resizeEvent) {
|
||||
|
||||
Q_ASSERT(pimpl && pimpl->clearbutton_ && pimpl->lineedit_);
|
||||
|
|
Loading…
Reference in New Issue