mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-10 13:54:23 +00:00
Minor cosmetic changes to main window
This commit is contained in:
parent
82788b9a02
commit
dfe5fbe34c
@ -13,43 +13,46 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
LineEdit::LineEdit(QWidget *parent)
|
LineEdit::LineEdit(QWidget *parent)
|
||||||
: QLineEdit(parent)
|
: QLineEdit(parent)
|
||||||
{
|
{
|
||||||
searchButton = new QToolButton(this);
|
searchButton = new QToolButton(this);
|
||||||
QPixmap pixmap1(":/lineeditimages/search.png");
|
QPixmap pixmap1(":/lineeditimages/search.png");
|
||||||
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: 0px; }");
|
searchButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
|
||||||
clearButton = new QToolButton(this);
|
clearButton = new QToolButton(this);
|
||||||
QPixmap pixmap2(":/lineeditimages/clear_left.png");
|
QPixmap pixmap2(":/lineeditimages/clear_left.png");
|
||||||
clearButton->setIcon(QIcon(pixmap2));
|
clearButton->setIcon(QIcon(pixmap2));
|
||||||
clearButton->setIconSize(pixmap2.size());
|
clearButton->setIconSize(pixmap2.size());
|
||||||
clearButton->setCursor(Qt::ArrowCursor);
|
clearButton->setCursor(Qt::ArrowCursor);
|
||||||
clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
|
clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
|
||||||
clearButton->setToolTip(tr("Clear the text"));
|
clearButton->setToolTip(tr("Clear the text"));
|
||||||
clearButton->hide();
|
clearButton->hide();
|
||||||
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&)));
|
||||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||||
setStyleSheet(QString("QLineEdit { padding-right: %1px; padding-left: %2px; } ").arg(clearButton->sizeHint().width() + frameWidth + 1).arg(clearButton->sizeHint().width() + frameWidth + 1));
|
setStyleSheet(QString("QLineEdit { padding-right: %1px; padding-left: %2px; border-radius: 10px; }").arg(clearButton->sizeHint().width() + frameWidth + 1).arg(clearButton->sizeHint().width() + frameWidth + 1));
|
||||||
QSize msz = minimumSizeHint();
|
#ifdef Q_WS_MAC
|
||||||
setMinimumSize(qMax(msz.width(), clearButton->sizeHint().width() + searchButton->sizeHint().width() + frameWidth * 2 + 2),
|
setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||||
qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
|
#endif
|
||||||
|
QSize msz = minimumSizeHint();
|
||||||
|
setMinimumSize(qMax(msz.width(), clearButton->sizeHint().width() + searchButton->sizeHint().width() + frameWidth * 2 + 2),
|
||||||
|
qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEdit::resizeEvent(QResizeEvent *)
|
void LineEdit::resizeEvent(QResizeEvent *)
|
||||||
{
|
{
|
||||||
QSize sz = searchButton->sizeHint();
|
QSize sz = searchButton->sizeHint();
|
||||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||||
searchButton->move(rect().left() + frameWidth, (rect().bottom() + 2 - sz.height())/2);
|
searchButton->move(rect().left() + frameWidth, (rect().bottom() + 2 - sz.height())/2);
|
||||||
sz = clearButton->sizeHint();
|
sz = clearButton->sizeHint();
|
||||||
clearButton->move(rect().right() - frameWidth - sz.width(),
|
clearButton->move(rect().right() - frameWidth - sz.width(),
|
||||||
(rect().bottom() + 2 - sz.height())/2);
|
(rect().bottom() + 2 - sz.height())/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEdit::updateCloseButton(const QString& text)
|
void LineEdit::updateCloseButton(const QString& text)
|
||||||
{
|
{
|
||||||
clearButton->setVisible(!text.isEmpty());
|
clearButton->setVisible(!text.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +163,7 @@ MainWindow::MainWindow(QWidget *parent, QStringList torrentCmdLine) : QMainWindo
|
|||||||
|
|
||||||
// Transfer List tab
|
// Transfer List tab
|
||||||
transferList = new TransferListWidget(hSplitter, this, QBtSession::instance());
|
transferList = new TransferListWidget(hSplitter, this, QBtSession::instance());
|
||||||
|
transferList->setFocusPolicy(Qt::NoFocus);
|
||||||
properties = new PropertiesWidget(hSplitter, this, transferList);
|
properties = new PropertiesWidget(hSplitter, this, transferList);
|
||||||
transferListFilters = new TransferListFiltersWidget(vSplitter, transferList);
|
transferListFilters = new TransferListFiltersWidget(vSplitter, transferList);
|
||||||
hSplitter->addWidget(transferList);
|
hSplitter->addWidget(transferList);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user