Fix gui issues on high DPI monitor

Fix LineEdit widget size issues
Up-scale the icons on statusbar
Up-scale the icons in options dialog. Closes #7729.
Fix small icons in cookie manager
Fix progress bar height
Fix small icons in confirm delete dialog
Fix small icons in options dialog
Fix small images in about dialog
This commit is contained in:
Chocobo1
2017-11-24 17:13:22 +08:00
parent 52ae118e3c
commit aaaa67050c
25 changed files with 210 additions and 132 deletions

View File

@@ -6,11 +6,5 @@ set(QBT_LINEEDIT_HEADERS
src/lineedit.h
)
set(QBT_LINEEDIT_RESOURCES
resources/lineeditimages.qrc
)
add_library(qbt_lineedit STATIC ${QBT_LINEEDIT_SOURCES} ${QBT_LINEEDIT_HEADERS})
target_link_libraries(qbt_lineedit Qt5::Widgets)
qbt_target_sources(${QBT_LINEEDIT_RESOURCES})

View File

@@ -1,4 +1,3 @@
INCLUDEPATH += $$PWD/src
HEADERS += $$PWD/src/lineedit.h
SOURCES += $$PWD/src/lineedit.cpp
RESOURCES += $$PWD/resources/lineeditimages.qrc

View File

@@ -1,5 +0,0 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>lineeditimages/search.png</file>
</qresource>
</RCC>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

View File

@@ -8,37 +8,34 @@
****************************************************************************/
#include "lineedit.h"
#include <algorithm>
#include <QResizeEvent>
#include <QStyle>
#include <QToolButton>
#include <QResizeEvent>
#include "guiiconprovider.h"
LineEdit::LineEdit(QWidget *parent)
: QLineEdit(parent)
{
QPixmap pixmap1(":/lineeditimages/search.png");
searchButton = new QToolButton(this);
searchButton->setIcon(QIcon(pixmap1));
searchButton->setIconSize(pixmap1.size());
searchButton->setCursor(Qt::ArrowCursor);
searchButton->setStyleSheet("QToolButton { border: none; padding: 2px; }");
QSize searchButtonHint = searchButton->sizeHint();
m_searchButton = new QToolButton(this);
m_searchButton->setIcon(GuiIconProvider::instance()->getIcon("edit-find"));
m_searchButton->setCursor(Qt::ArrowCursor);
m_searchButton->setStyleSheet("QToolButton { border: none; padding: 2px; }");
setStyleSheet(QString("QLineEdit { padding-left: %1px; }").arg(m_searchButton->sizeHint().width())); // padding between text and widget borders
QSize clearButtonHint(0, 0);
setClearButtonEnabled(true);
setStyleSheet(QString("QLineEdit { padding-left: %1px; }").arg(searchButtonHint.width())); // padding between text and widget borders
QSize widgetHint = sizeHint();
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
setMaximumHeight(std::max({ widgetHint.height(), searchButtonHint.height(), clearButtonHint.height() }) + frameWidth * 2);
const int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
setMaximumHeight(std::max(sizeHint().height(), m_searchButton->sizeHint().height()) + frameWidth * 2);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
}
void LineEdit::resizeEvent(QResizeEvent *e)
{
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
QSize sz = searchButton->sizeHint();
searchButton->move(frameWidth, (e->size().height() - sz.height()) / 2);
const int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
m_searchButton->move(frameWidth, (e->size().height() - m_searchButton->sizeHint().height()) / 2);
}

View File

@@ -22,10 +22,10 @@ public:
LineEdit(QWidget *parent);
protected:
void resizeEvent(QResizeEvent *e);
void resizeEvent(QResizeEvent *e) override;
private:
QToolButton *searchButton;
QToolButton *m_searchButton;
};
#endif // LIENEDIT_H