mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-27 15:04:36 +00:00
Fix toolbar resizing when m_searchFilter appears/disappears. Closes #5120.
This commit is contained in:
parent
2c2638c1fe
commit
c52a964a8a
@ -16,17 +16,15 @@
|
|||||||
LineEdit::LineEdit(QWidget *parent)
|
LineEdit::LineEdit(QWidget *parent)
|
||||||
: QLineEdit(parent)
|
: QLineEdit(parent)
|
||||||
{
|
{
|
||||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
|
||||||
|
|
||||||
QPixmap pixmap1(":/lineeditimages/search.png");
|
QPixmap pixmap1(":/lineeditimages/search.png");
|
||||||
searchButton = new QToolButton(this);
|
searchButton = new QToolButton(this);
|
||||||
searchButton->setIcon(QIcon(pixmap1));
|
searchButton->setIcon(QIcon(pixmap1));
|
||||||
searchButton->setIconSize(pixmap1.size());
|
searchButton->setIconSize(pixmap1.size());
|
||||||
searchButton->setCursor(Qt::ArrowCursor);
|
searchButton->setCursor(Qt::ArrowCursor);
|
||||||
searchButton->setStyleSheet("QToolButton { border: none; padding: 2px; }");
|
searchButton->setStyleSheet("QToolButton { border: none; padding: 2px; }");
|
||||||
|
QSize searchButtonHint = searchButton->sizeHint();
|
||||||
|
|
||||||
int clearButtonSizeHintWidth = 0;
|
QSize clearButtonHint(0, 0);
|
||||||
int clearButtonSizeHintHeight = 0;
|
|
||||||
#ifndef QBT_USES_QT5
|
#ifndef QBT_USES_QT5
|
||||||
QPixmap pixmap2(":/lineeditimages/clear_left.png");
|
QPixmap pixmap2(":/lineeditimages/clear_left.png");
|
||||||
clearButton = new QToolButton(this);
|
clearButton = new QToolButton(this);
|
||||||
@ -39,17 +37,17 @@ LineEdit::LineEdit(QWidget *parent)
|
|||||||
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
|
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
|
||||||
connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(updateCloseButton(const QString &)));
|
connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(updateCloseButton(const QString &)));
|
||||||
|
|
||||||
clearButtonSizeHintWidth = clearButton->sizeHint().width();
|
clearButtonHint = clearButton->sizeHint();
|
||||||
clearButtonSizeHintHeight = clearButton->sizeHint().height();
|
setStyleSheet(QString("QLineEdit { padding-left: %1px; padding-right: %2px; }").arg(searchButtonHint.width()).arg(clearButtonHint.width()));
|
||||||
setStyleSheet(QString("QLineEdit { padding-left: %1px; padding-right: %2px; }").arg(searchButton->sizeHint().width()).arg(clearButtonSizeHintWidth));
|
|
||||||
#else
|
#else
|
||||||
setClearButtonEnabled(true);
|
setClearButtonEnabled(true);
|
||||||
setStyleSheet(QString("QLineEdit { padding-left: %1px; }").arg(searchButton->sizeHint().width())); // padding between text and widget borders
|
setStyleSheet(QString("QLineEdit { padding-left: %1px; }").arg(searchButtonHint.width())); // padding between text and widget borders
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QSize msz = sizeHint();
|
QSize widgetHint = sizeHint();
|
||||||
setMinimumSize(qMax(msz.width(), searchButton->sizeHint().width() + clearButtonSizeHintWidth),
|
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||||
std::max({ msz.height(), searchButton->sizeHint().height(), clearButtonSizeHintHeight }) + frameWidth * 2);
|
setMaximumHeight(std::max({ widgetHint.height(), searchButtonHint.height(), clearButtonHint.height() }) + frameWidth * 2);
|
||||||
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEdit::resizeEvent(QResizeEvent *e)
|
void LineEdit::resizeEvent(QResizeEvent *e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user