mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-29 10:39:47 +01:00
Move the search field button to the left, and always display it
This commit is contained in:
parent
7f89e8832e
commit
2c301cde0f
7
3rdparty/qocoa/qsearchfield_nonmac.cpp
vendored
7
3rdparty/qocoa/qsearchfield_nonmac.cpp
vendored
@ -68,12 +68,11 @@ QSearchField::QSearchField(QWidget *parent) : QWidget(parent)
|
||||
clearButton->setIconSize(clearIcon.size());
|
||||
clearButton->setFixedSize(clearIcon.size());
|
||||
clearButton->setStyleSheet("border: none;");
|
||||
clearButton->hide();
|
||||
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
|
||||
|
||||
pimpl = new QSearchFieldPrivate(this, lineEdit, clearButton);
|
||||
|
||||
lineEdit->setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(pimpl->clearButtonPaddedWidth()));
|
||||
lineEdit->setStyleSheet(QString("QLineEdit { padding-left: %1px; } ").arg(clearButton->width()));
|
||||
const int width = qMax(lineEdit->minimumSizeHint().width(), pimpl->clearButtonPaddedWidth());
|
||||
const int height = qMax(lineEdit->minimumSizeHint().height(), pimpl->clearButtonPaddedHeight());
|
||||
lineEdit->setMinimumSize(width, height);
|
||||
@ -91,8 +90,6 @@ void QSearchField::setText(const QString &text)
|
||||
if (!(pimpl && pimpl->clearButton && pimpl->lineEdit))
|
||||
return;
|
||||
|
||||
pimpl->clearButton->setVisible(!text.isEmpty());
|
||||
|
||||
if (text != this->text())
|
||||
pimpl->lineEdit->setText(text);
|
||||
}
|
||||
@ -162,7 +159,7 @@ void QSearchField::resizeEvent(QResizeEvent *resizeEvent)
|
||||
return;
|
||||
|
||||
QWidget::resizeEvent(resizeEvent);
|
||||
const int x = width() - pimpl->clearButtonPaddedWidth();
|
||||
const int x = pimpl->lineEditFrameWidth();
|
||||
const int y = (height() - pimpl->clearButton->height())/2;
|
||||
pimpl->clearButton->move(x, y);
|
||||
}
|
||||
|
BIN
3rdparty/qocoa/qsearchfield_nonmac.png
vendored
BIN
3rdparty/qocoa/qsearchfield_nonmac.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 644 B After Width: | Height: | Size: 603 B |
Binary file not shown.
Before Width: | Height: | Size: 644 B After Width: | Height: | Size: 603 B |
Loading…
x
Reference in New Issue
Block a user