Browse Source

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
adaptive-webui-19844
Chocobo1 7 years ago
parent
commit
aaaa67050c
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 13
      src/base/utils/misc.cpp
  2. 2
      src/base/utils/misc.h
  3. 2
      src/gui/CMakeLists.txt
  4. 12
      src/gui/about.ui
  5. 8
      src/gui/about_imp.h
  6. 4
      src/gui/categoryfilterwidget.cpp
  7. 3
      src/gui/cookiesdialog.cpp
  8. 12
      src/gui/cookiesdialog.ui
  9. 10
      src/gui/deletionconfirmationdlg.h
  10. 2
      src/gui/gui.pri
  11. 6
      src/gui/lineedit/CMakeLists.txt
  12. 1
      src/gui/lineedit/lineedit.pri
  13. 5
      src/gui/lineedit/resources/lineeditimages.qrc
  14. BIN
      src/gui/lineedit/resources/lineeditimages/search.png
  15. 35
      src/gui/lineedit/src/lineedit.cpp
  16. 4
      src/gui/lineedit/src/lineedit.h
  17. 3
      src/gui/mainwindow.cpp
  18. 21
      src/gui/optionsdlg.cpp
  19. 40
      src/gui/optionsdlg.ui
  20. 10
      src/gui/properties/propertieswidget.cpp
  21. 13
      src/gui/statusbar.cpp
  22. 4
      src/gui/tagfilterwidget.cpp
  23. 5
      src/gui/transferlistfilterswidget.cpp
  24. 79
      src/gui/utils.cpp
  25. 50
      src/gui/utils.h

13
src/base/utils/misc.cpp

@ -632,19 +632,6 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath) @@ -632,19 +632,6 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath)
#endif
}
QSize Utils::Misc::smallIconSize()
{
// Get DPI scaled icon size (device-dependent), see QT source
int s = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
return QSize(s, s);
}
QSize Utils::Misc::largeIconSize()
{
// Get DPI scaled icon size (device-dependent), see QT source
int s = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize);
return QSize(s, s);
}
#endif // DISABLE_GUI
QString Utils::Misc::osName()

2
src/base/utils/misc.h

@ -103,8 +103,6 @@ namespace Utils @@ -103,8 +103,6 @@ namespace Utils
void openFolderSelect(const QString& absolutePath);
QPoint screenCenter(const QWidget *w);
QSize smallIconSize();
QSize largeIconSize();
#endif
#ifdef Q_OS_WIN

2
src/gui/CMakeLists.txt

@ -74,6 +74,7 @@ transferlistfilterswidget.h @@ -74,6 +74,7 @@ transferlistfilterswidget.h
transferlistsortmodel.h
transferlistwidget.h
updownratiodlg.h
utils.h
)
set(QBT_GUI_SOURCES
@ -119,6 +120,7 @@ transferlistfilterswidget.cpp @@ -119,6 +120,7 @@ transferlistfilterswidget.cpp
transferlistsortmodel.cpp
transferlistwidget.cpp
updownratiodlg.cpp
utils.cpp
)
if (APPLE)

12
src/gui/about.ui

@ -18,11 +18,7 @@ @@ -18,11 +18,7 @@
<item>
<layout class="QHBoxLayout" name="titleHBoxLayout">
<item>
<widget class="QLabel" name="logo">
<property name="pixmap">
<pixmap resource="../icons.qrc">:/icons/skin/qbittorrent32.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="logo"/>
</item>
<item>
<widget class="QLabel" name="lb_name">
@ -57,11 +53,7 @@ @@ -57,11 +53,7 @@
</attribute>
<layout class="QGridLayout" name="aboutTabLayout">
<item row="0" column="0">
<widget class="QLabel" name="mascot_lbl">
<property name="pixmap">
<pixmap resource="../icons.qrc">:/icons/skin/mascot.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="labelMascot"/>
</item>
<item row="0" column="1">
<widget class="QLabel" name="lb_about">

8
src/gui/about_imp.h

@ -31,10 +31,12 @@ @@ -31,10 +31,12 @@
#ifndef ABOUT_H
#define ABOUT_H
#include "ui_about.h"
#include <QFile>
#include "base/utils/misc.h"
#include "base/unicodestrings.h"
#include "ui_about.h"
#include "utils.h"
class about: public QDialog, private Ui::AboutDlg
{
@ -53,6 +55,8 @@ public: @@ -53,6 +55,8 @@ public:
lb_name->setText("<b><h2>qBittorrent " QBT_VERSION " (32-bit)</h2></b>");
#endif
logo->setPixmap(Utils::Gui::scaledPixmap(":/icons/skin/qbittorrent32.png", this));
// About
QString aboutText = QString(
"<p style=\"white-space: pre-wrap;\">"
@ -71,6 +75,8 @@ public: @@ -71,6 +75,8 @@ public:
.arg(tr("Bug Tracker:"));
lb_about->setText(aboutText);
labelMascot->setPixmap(Utils::Gui::scaledPixmap(":/icons/skin/mascot.png", this));
// Thanks
QFile thanksfile(":/thanks.html");
if (thanksfile.open(QIODevice::ReadOnly | QIODevice::Text)) {

4
src/gui/categoryfilterwidget.cpp

@ -35,11 +35,11 @@ @@ -35,11 +35,11 @@
#include <QMessageBox>
#include "base/bittorrent/session.h"
#include "base/utils/misc.h"
#include "categoryfiltermodel.h"
#include "categoryfilterproxymodel.h"
#include "guiiconprovider.h"
#include "torrentcategorydialog.h"
#include "utils.h"
namespace
{
@ -70,7 +70,7 @@ CategoryFilterWidget::CategoryFilterWidget(QWidget *parent) @@ -70,7 +70,7 @@ CategoryFilterWidget::CategoryFilterWidget(QWidget *parent)
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setUniformRowHeights(true);
setHeaderHidden(true);
setIconSize(Utils::Misc::smallIconSize());
setIconSize(Utils::Gui::smallIconSize());
#ifdef Q_OS_MAC
setAttribute(Qt::WA_MacShowFocusRect, false);
#endif

3
src/gui/cookiesdialog.cpp

@ -35,6 +35,7 @@ @@ -35,6 +35,7 @@
#include "cookiesmodel.h"
#include "guiiconprovider.h"
#include "ui_cookiesdialog.h"
#include "utils.h"
#define SETTINGS_KEY(name) "CookiesDialog/" name
const QString KEY_SIZE = SETTINGS_KEY("Size");
@ -50,6 +51,8 @@ CookiesDialog::CookiesDialog(QWidget *parent) @@ -50,6 +51,8 @@ CookiesDialog::CookiesDialog(QWidget *parent)
setWindowIcon(GuiIconProvider::instance()->getIcon("preferences-web-browser-cookies"));
m_ui->buttonAdd->setIcon(GuiIconProvider::instance()->getIcon("list-add"));
m_ui->buttonDelete->setIcon(GuiIconProvider::instance()->getIcon("list-remove"));
m_ui->buttonAdd->setIconSize(Utils::Gui::mediumIconSize());
m_ui->buttonDelete->setIconSize(Utils::Gui::mediumIconSize());
m_ui->treeView->setModel(m_cookiesModel);
if (m_cookiesModel->rowCount() > 0)

12
src/gui/cookiesdialog.ui

@ -49,12 +49,6 @@ @@ -49,12 +49,6 @@
<property name="text">
<string notr="true"/>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
@ -78,12 +72,6 @@ @@ -78,12 +72,6 @@
<property name="text">
<string notr="true"/>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>

10
src/gui/deletionconfirmationdlg.h

@ -33,11 +33,13 @@ @@ -33,11 +33,13 @@
#include <QDialog>
#include <QPushButton>
#include "ui_confirmdeletiondlg.h"
#include "base/preferences.h"
#include "base/utils/misc.h"
#include "base/utils/string.h"
#include "guiiconprovider.h"
#include "ui_confirmdeletiondlg.h"
#include "utils.h"
class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
Q_OBJECT
@ -50,9 +52,11 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { @@ -50,9 +52,11 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
else
label->setText(tr("Are you sure you want to delete these %1 torrents from the transfer list?", "Are you sure you want to delete these 5 torrents from the transfer list?").arg(QString::number(size)));
// Icons
lbl_warn->setPixmap(GuiIconProvider::instance()->getIcon("dialog-warning").pixmap(lbl_warn->height()));
lbl_warn->setFixedWidth(lbl_warn->height());
const QSize iconSize = Utils::Gui::largeIconSize();
lbl_warn->setPixmap(GuiIconProvider::instance()->getIcon("dialog-warning").pixmap(iconSize));
lbl_warn->setFixedWidth(iconSize.width());
rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked"));
rememberBtn->setIconSize(Utils::Gui::mediumIconSize());
checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault());
connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState()));

2
src/gui/gui.pri

@ -64,6 +64,7 @@ HEADERS += \ @@ -64,6 +64,7 @@ HEADERS += \
$$PWD/fspathedit.h \
$$PWD/fspathedit_p.h \
$$PWD/previewselectdialog.h \
$$PWD/utils.h \
SOURCES += \
$$PWD/mainwindow.cpp \
@ -119,6 +120,7 @@ SOURCES += \ @@ -119,6 +120,7 @@ SOURCES += \
$$PWD/fspathedit.cpp \
$$PWD/fspathedit_p.cpp \
$$PWD/previewselectdialog.cpp \
$$PWD/utils.cpp \
win32|macx {
HEADERS += $$PWD/programupdater.h

6
src/gui/lineedit/CMakeLists.txt

@ -6,11 +6,5 @@ set(QBT_LINEEDIT_HEADERS @@ -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})

1
src/gui/lineedit/lineedit.pri

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

5
src/gui/lineedit/resources/lineeditimages.qrc

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

BIN
src/gui/lineedit/resources/lineeditimages/search.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

35
src/gui/lineedit/src/lineedit.cpp

@ -8,37 +8,34 @@ @@ -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();
QSize clearButtonHint(0, 0);
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
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);
}

4
src/gui/lineedit/src/lineedit.h

@ -22,10 +22,10 @@ public: @@ -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

3
src/gui/mainwindow.cpp

@ -93,6 +93,7 @@ @@ -93,6 +93,7 @@
#include "transferlistfilterswidget.h"
#include "transferlistwidget.h"
#include "ui_mainwindow.h"
#include "utils.h"
#ifdef Q_OS_WIN
#include "base/net/downloadhandler.h"
@ -230,7 +231,7 @@ MainWindow::MainWindow(QWidget *parent) @@ -230,7 +231,7 @@ MainWindow::MainWindow(QWidget *parent)
m_searchFilter = new LineEdit(this);
m_searchFilterAction = m_ui->toolBar->insertWidget(m_ui->actionLock, m_searchFilter);
m_searchFilter->setPlaceholderText(tr("Filter torrent list..."));
m_searchFilter->setFixedWidth(200);
m_searchFilter->setFixedWidth(200 * Utils::Gui::screenScalingFactor(this));
QWidget *spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

21
src/gui/optionsdlg.cpp

@ -68,6 +68,7 @@ @@ -68,6 +68,7 @@
#include "ipsubnetwhitelistoptionsdialog.h"
#include "guiiconprovider.h"
#include "scanfoldersdelegate.h"
#include "utils.h"
#include "ui_optionsdlg.h"
@ -99,13 +100,21 @@ OptionsDialog::OptionsDialog(QWidget *parent) @@ -99,13 +100,21 @@ OptionsDialog::OptionsDialog(QWidget *parent)
m_ui->tabSelection->item(TAB_WEBUI)->setHidden(true);
#endif
m_ui->tabSelection->item(TAB_ADVANCED)->setIcon(GuiIconProvider::instance()->getIcon("preferences-other"));
// set uniform size for all icons
int maxHeight = -1;
for (int i = 0; i < m_ui->tabSelection->count(); ++i)
maxHeight = std::max(maxHeight, m_ui->tabSelection->visualItemRect(m_ui->tabSelection->item(i)).size().height());
for (int i = 0; i < m_ui->tabSelection->count(); ++i) {
// uniform size for all icons
m_ui->tabSelection->item(i)->setSizeHint(QSize(std::numeric_limits<int>::max(), 62));
const QSize size(std::numeric_limits<int>::max(), static_cast<int>(maxHeight * 1.2));
m_ui->tabSelection->item(i)->setSizeHint(size);
}
m_ui->IpFilterRefreshBtn->setIcon(GuiIconProvider::instance()->getIcon("view-refresh"));
m_ui->labelGlobalRate->setPixmap(Utils::Gui::scaledPixmap(":/icons/slow_off.png", this, 16));
m_ui->labelAltRate->setPixmap(Utils::Gui::scaledPixmap(":/icons/slow.png", this, 16));
m_ui->deleteTorrentWarningIcon->setPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical).pixmap(16, 16));
m_ui->deleteTorrentWarningIcon->hide();
m_ui->deleteTorrentWarningLabel->hide();
@ -1675,11 +1684,11 @@ bool OptionsDialog::setSslKey(const QByteArray &key) @@ -1675,11 +1684,11 @@ bool OptionsDialog::setSslKey(const QByteArray &key)
// try different formats
const bool isKeyValid = (!QSslKey(key, QSsl::Rsa).isNull() || !QSslKey(key, QSsl::Ec).isNull());
if (isKeyValid) {
m_ui->lblSslKeyStatus->setPixmap(QPixmap(":/icons/qbt-theme/security-high.png").scaledToHeight(20, Qt::SmoothTransformation));
m_ui->lblSslKeyStatus->setPixmap(Utils::Gui::scaledPixmap(":/icons/qbt-theme/security-high.png", this, 24));
m_sslKey = key;
}
else {
m_ui->lblSslKeyStatus->setPixmap(QPixmap(":/icons/qbt-theme/security-low.png").scaledToHeight(20, Qt::SmoothTransformation));
m_ui->lblSslKeyStatus->setPixmap(Utils::Gui::scaledPixmap(":/icons/qbt-theme/security-low.png", this, 24));
m_sslKey.clear();
}
return isKeyValid;
@ -1694,11 +1703,11 @@ bool OptionsDialog::setSslCertificate(const QByteArray &cert) @@ -1694,11 +1703,11 @@ bool OptionsDialog::setSslCertificate(const QByteArray &cert)
#ifndef QT_NO_OPENSSL
const bool isCertValid = !QSslCertificate(cert).isNull();
if (isCertValid) {
m_ui->lblSslCertStatus->setPixmap(QPixmap(":/icons/qbt-theme/security-high.png").scaledToHeight(20, Qt::SmoothTransformation));
m_ui->lblSslCertStatus->setPixmap(Utils::Gui::scaledPixmap(":/icons/qbt-theme/security-high.png", this, 24));
m_sslCert = cert;
}
else {
m_ui->lblSslCertStatus->setPixmap(QPixmap(":/icons/qbt-theme/security-low.png").scaledToHeight(20, Qt::SmoothTransformation));
m_ui->lblSslCertStatus->setPixmap(Utils::Gui::scaledPixmap(":/icons/qbt-theme/security-low.png", this, 24));
m_sslCert.clear();
}
return isCertValid;

40
src/gui/optionsdlg.ui

@ -1823,11 +1823,7 @@ @@ -1823,11 +1823,7 @@
</widget>
</item>
<item row="0" column="0" rowspan="2">
<widget class="QLabel" name="label_5">
<property name="pixmap">
<pixmap resource="../icons.qrc">:/icons/slow_off.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="labelGlobalRate"/>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkDownloadLimit">
@ -1970,11 +1966,7 @@ @@ -1970,11 +1966,7 @@
</widget>
</item>
<item row="0" column="0" rowspan="2">
<widget class="QLabel" name="label_16">
<property name="pixmap">
<pixmap resource="../icons.qrc">:/icons/slow.png</pixmap>
</property>
</widget>
<widget class="QLabel" name="labelAltRate"/>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="checkUploadLimitAlt">
@ -2853,20 +2845,8 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string> @@ -2853,20 +2845,8 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QLabel" name="lblSslCertStatus">
<property name="minimumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="text">
<string/>
<string notr="true"/>
</property>
</widget>
</item>
@ -2906,20 +2886,8 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string> @@ -2906,20 +2886,8 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblSslKeyStatus">
<property name="minimumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="text">
<string/>
<string notr="true"/>
</property>
</widget>
</item>

10
src/gui/properties/propertieswidget.cpp

@ -62,6 +62,7 @@ @@ -62,6 +62,7 @@
#include "torrentcontentmodel.h"
#include "trackerlist.h"
#include "transferlistwidget.h"
#include "utils.h"
#include "ui_propertieswidget.h"
@ -87,10 +88,11 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran @@ -87,10 +88,11 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
m_propListDelegate = new PropListDelegate(this);
m_ui->filesList->setItemDelegate(m_propListDelegate);
m_ui->filesList->setSortingEnabled(true);
// Torrent content filtering
m_contentFilterLine = new LineEdit(this);
m_contentFilterLine->setPlaceholderText(tr("Filter files..."));
m_contentFilterLine->setMaximumSize(300, m_contentFilterLine->size().height());
m_contentFilterLine->setFixedWidth(300 * Utils::Gui::screenScalingFactor(this));
connect(m_contentFilterLine, SIGNAL(textChanged(QString)), this, SLOT(filterText(QString)));
m_ui->contentFilterLayout->insertWidget(3, m_contentFilterLine);
@ -112,7 +114,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran @@ -112,7 +114,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
connect(m_ui->filesList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSettings()));
// set bar height relative to screen dpi
int barHeight = devicePixelRatio() * 18;
const int barHeight = 18 * Utils::Gui::screenScalingFactor(this);
// Downloaded pieces progress bar
m_ui->tempProgressBarArea->setVisible(false);
@ -131,9 +133,9 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran @@ -131,9 +133,9 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
// Tracker list
m_trackerList = new TrackerList(this);
m_ui->trackerUpButton->setIcon(GuiIconProvider::instance()->getIcon("go-up"));
m_ui->trackerUpButton->setIconSize(Utils::Misc::smallIconSize());
m_ui->trackerUpButton->setIconSize(Utils::Gui::smallIconSize());
m_ui->trackerDownButton->setIcon(GuiIconProvider::instance()->getIcon("go-down"));
m_ui->trackerDownButton->setIconSize(Utils::Misc::smallIconSize());
m_ui->trackerDownButton->setIconSize(Utils::Gui::smallIconSize());
connect(m_ui->trackerUpButton, SIGNAL(clicked()), m_trackerList, SLOT(moveSelectionUp()));
connect(m_ui->trackerDownButton, SIGNAL(clicked()), m_trackerList, SLOT(moveSelectionDown()));
m_ui->horizontalLayout_trackers->insertWidget(0, m_trackerList);

13
src/gui/statusbar.cpp

@ -41,6 +41,7 @@ @@ -41,6 +41,7 @@
#include "base/utils/misc.h"
#include "guiiconprovider.h"
#include "speedlimitdlg.h"
#include "utils.h"
StatusBar::StatusBar(QWidget *parent)
: QStatusBar(parent)
@ -100,15 +101,15 @@ StatusBar::StatusBar(QWidget *parent) @@ -100,15 +101,15 @@ StatusBar::StatusBar(QWidget *parent)
// Because on some platforms the default icon size is bigger
// and it will result in taller/fatter statusbar, even if the
// icons are actually 16x16
m_connecStatusLblIcon->setIconSize(QSize(16, 16));
m_dlSpeedLbl->setIconSize(QSize(16, 16));
m_upSpeedLbl->setIconSize(QSize(16, 16));
m_altSpeedsBtn->setIconSize(QSize(28, 16));
m_connecStatusLblIcon->setIconSize(Utils::Gui::smallIconSize());
m_dlSpeedLbl->setIconSize(Utils::Gui::smallIconSize());
m_upSpeedLbl->setIconSize(Utils::Gui::smallIconSize());
m_altSpeedsBtn->setIconSize(QSize(Utils::Gui::mediumIconSize().width(), Utils::Gui::smallIconSize().height()));
// Set to the known maximum width(plus some padding)
// so the speed widgets will take the rest of the space
m_connecStatusLblIcon->setMaximumWidth(16 + 6);
m_altSpeedsBtn->setMaximumWidth(28 + 6);
m_connecStatusLblIcon->setMaximumWidth(Utils::Gui::largeIconSize().width());
m_altSpeedsBtn->setMaximumWidth(Utils::Gui::largeIconSize().width());
QFrame *statusSep1 = new QFrame(this);
statusSep1->setFrameStyle(QFrame::VLine);

4
src/gui/tagfilterwidget.cpp

@ -36,11 +36,11 @@ @@ -36,11 +36,11 @@
#include <QMessageBox>
#include "base/bittorrent/session.h"
#include "base/utils/misc.h"
#include "autoexpandabledialog.h"
#include "guiiconprovider.h"
#include "tagfiltermodel.h"
#include "tagfilterproxymodel.h"
#include "utils.h"
namespace
{
@ -70,7 +70,7 @@ TagFilterWidget::TagFilterWidget(QWidget *parent) @@ -70,7 +70,7 @@ TagFilterWidget::TagFilterWidget(QWidget *parent)
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setUniformRowHeights(true);
setHeaderHidden(true);
setIconSize(Utils::Misc::smallIconSize());
setIconSize(Utils::Gui::smallIconSize());
#if defined(Q_OS_MAC)
setAttribute(Qt::WA_MacShowFocusRect, false);
#endif

5
src/gui/transferlistfilterswidget.cpp

@ -38,6 +38,7 @@ @@ -38,6 +38,7 @@
#include <QMessageBox>
#include <QScrollArea>
#include <QVBoxLayout>
#include <QUrl>
#include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h"
@ -48,7 +49,6 @@ @@ -48,7 +49,6 @@
#include "base/preferences.h"
#include "base/torrentfilter.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "base/utils/string.h"
#include "autoexpandabledialog.h"
#include "categoryfilterwidget.h"
@ -57,6 +57,7 @@ @@ -57,6 +57,7 @@
#include "torrentmodel.h"
#include "transferlistdelegate.h"
#include "transferlistwidget.h"
#include "utils.h"
const QLatin1String GOOGLE_FAVICON_URL("https://www.google.com/s2/favicons?domain=");
@ -71,7 +72,7 @@ FiltersBase::FiltersBase(QWidget *parent, TransferListWidget *transferList) @@ -71,7 +72,7 @@ FiltersBase::FiltersBase(QWidget *parent, TransferListWidget *transferList)
setUniformItemSizes(true);
setSpacing(0);
setIconSize(Utils::Misc::smallIconSize());
setIconSize(Utils::Gui::smallIconSize());
#if defined(Q_OS_MAC)
setAttribute(Qt::WA_MacShowFocusRect, false);

79
src/gui/utils.cpp

@ -0,0 +1,79 @@ @@ -0,0 +1,79 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2017 Mike Tzou
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#include "utils.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QScreen>
#include <QStyle>
#include <QWidget>
#include <QWindow>
qreal Utils::Gui::screenScalingFactor(const QWidget *widget)
{
#ifdef Q_OS_WIN
const int screen = qApp->desktop()->screenNumber(widget);
return (QApplication::screens()[screen]->logicalDotsPerInch() / 96);
#else
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
return widget->devicePixelRatioF();
#else
return widget->devicePixelRatio();
#endif
#endif // Q_OS_WIN
}
QPixmap Utils::Gui::scaledPixmap(const QString &path, const QWidget *widget, const int height)
{
const QPixmap pixmap(path);
const int scaledHeight = ((height > 0) ? height : pixmap.height()) * Utils::Gui::screenScalingFactor(widget);
return pixmap.scaledToHeight(scaledHeight, Qt::SmoothTransformation);
}
QSize Utils::Gui::smallIconSize(const QWidget *widget)
{
// Get DPI scaled icon size (device-dependent), see QT source
// under a 1080p screen is usually 16x16
const int s = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, widget);
return QSize(s, s);
}
QSize Utils::Gui::mediumIconSize(const QWidget *widget)
{
// under a 1080p screen is usually 24x24
return ((smallIconSize(widget) + largeIconSize(widget)) / 2);
}
QSize Utils::Gui::largeIconSize(const QWidget *widget)
{
// Get DPI scaled icon size (device-dependent), see QT source
// under a 1080p screen is usually 32x32
const int s = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize, nullptr, widget);
return QSize(s, s);
}

50
src/gui/utils.h

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2017 Mike Tzou
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#ifndef UTILS_GUI_H
#define UTILS_GUI_H
#include <QtGlobal>
#include <QPixmap>
#include <QSize>
class QWidget;
namespace Utils
{
namespace Gui
{
qreal screenScalingFactor(const QWidget *widget);
QPixmap scaledPixmap(const QString &path, const QWidget *widget, const int height = 0);
QSize smallIconSize(const QWidget *widget = nullptr);
QSize mediumIconSize(const QWidget *widget = nullptr);
QSize largeIconSize(const QWidget *widget = nullptr);
}
}
#endif // UTILS_GUI_H
Loading…
Cancel
Save