From cb929f7e5913998df9ae4a677c1acf1d4a22826f Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 24 Nov 2017 15:33:11 +0800 Subject: [PATCH 1/5] Cleanup Use Qt5 connect syntax Reorder include headers --- src/gui/mainwindow.cpp | 107 ++++++++++++++++++++--------------------- src/gui/optionsdlg.cpp | 6 +-- 2 files changed, 56 insertions(+), 57 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index f7ac28a3c..f3f876215 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -30,84 +30,83 @@ #include "mainwindow.h" -#ifdef Q_OS_MAC -#include -#include -#endif - -#include -#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) -#include -#include "notifications.h" -#endif +#include +#include +#include #include +#include #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include #include +#include #include +#include #include -#include -#include -#include +#include +#include -#include "base/preferences.h" -#include "base/settingsstorage.h" -#include "base/logger.h" -#include "base/utils/misc.h" -#include "base/utils/fs.h" -#ifdef Q_OS_WIN -#include "base/net/downloadmanager.h" -#include "base/net/downloadhandler.h" +#ifdef Q_OS_MAC +#include +#include #endif +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) +#include +#include "notifications.h" +#endif + +#include "about_imp.h" +#include "addnewtorrentdialog.h" +#include "application.h" +#include "autoexpandabledialog.h" #include "base/bittorrent/session.h" #include "base/bittorrent/sessionstatus.h" #include "base/bittorrent/torrenthandle.h" #include "base/global.h" +#include "base/logger.h" +#include "base/preferences.h" #include "base/rss/rss_folder.h" #include "base/rss/rss_session.h" - -#include "application.h" -#if defined(Q_OS_WIN) || defined(Q_OS_MAC) -#include "programupdater.h" -#endif -#include "powermanagement.h" -#include "guiiconprovider.h" -#include "torrentmodel.h" -#include "autoexpandabledialog.h" -#include "torrentcreatordlg.h" -#include "downloadfromurldlg.h" -#include "addnewtorrentdialog.h" -#include "statsdialog.h" +#include "base/settingsstorage.h" +#include "base/utils/fs.h" +#include "base/utils/misc.h" #include "cookiesdialog.h" -#include "speedlimitdlg.h" -#include "transferlistwidget.h" -#include "search/searchwidget.h" -#include "trackerlist.h" +#include "downloadfromurldlg.h" +#include "executionlog.h" +#include "guiiconprovider.h" +#include "hidabletabwidget.h" +#include "lineedit.h" +#include "optionsdlg.h" #include "peerlistwidget.h" -#include "transferlistfilterswidget.h" +#include "powermanagement.h" #include "propertieswidget.h" -#include "statusbar.h" #include "rss/rsswidget.h" -#include "about_imp.h" -#include "optionsdlg.h" -#if LIBTORRENT_VERSION_NUM < 10100 -#include "trackerlogin.h" -#endif -#include "lineedit.h" -#include "executionlog.h" -#include "hidabletabwidget.h" +#include "search/searchwidget.h" +#include "speedlimitdlg.h" +#include "statsdialog.h" +#include "statusbar.h" +#include "torrentcreatordlg.h" +#include "torrentmodel.h" +#include "trackerlist.h" +#include "transferlistfilterswidget.h" +#include "transferlistwidget.h" #include "ui_mainwindow.h" +#ifdef Q_OS_WIN +#include "base/net/downloadhandler.h" +#include "base/net/downloadmanager.h" +#endif #ifdef Q_OS_MAC #include "macutilities.h" #endif +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) +#include "programupdater.h" +#endif +#if LIBTORRENT_VERSION_NUM < 10100 +#include "trackerlogin.h" +#endif #ifdef Q_OS_MAC void qt_mac_set_dock_menu(QMenu *menu); diff --git a/src/gui/optionsdlg.cpp b/src/gui/optionsdlg.cpp index c4ca836c6..0f5ef88d7 100644 --- a/src/gui/optionsdlg.cpp +++ b/src/gui/optionsdlg.cpp @@ -139,7 +139,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) connect(ScanFoldersModel::instance(), &QAbstractListModel::dataChanged, this, &ThisType::enableApplyButton); connect(m_ui->scanFoldersView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ThisType::handleScanFolderViewSelectionChanged); - connect(m_ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(applySettings(QAbstractButton*))); + connect(m_ui->buttonBox, &QDialogButtonBox::clicked, this, &OptionsDialog::applySettings); // Languages supported initializeLanguageCombo(); @@ -1578,7 +1578,7 @@ void OptionsDialog::on_IpFilterRefreshBtn_clicked() session->setIPFilteringEnabled(true); session->setIPFilterFile(""); // forcing Session reload filter file session->setIPFilterFile(getFilter()); - connect(session, SIGNAL(IPFilterParsed(bool, int)), SLOT(handleIPFilterParsed(bool, int))); + connect(session, &BitTorrent::Session::IPFilterParsed, this, &OptionsDialog::handleIPFilterParsed); setCursor(QCursor(Qt::WaitCursor)); } @@ -1590,7 +1590,7 @@ void OptionsDialog::handleIPFilterParsed(bool error, int ruleCount) else QMessageBox::information(this, tr("Successfully refreshed"), tr("Successfully parsed the provided IP filter: %1 rules were applied.", "%1 is a number").arg(ruleCount)); m_refreshingIpFilter = false; - disconnect(BitTorrent::Session::instance(), SIGNAL(IPFilterParsed(bool, int)), this, SLOT(handleIPFilterParsed(bool, int))); + disconnect(BitTorrent::Session::instance(), &BitTorrent::Session::IPFilterParsed, this, &OptionsDialog::handleIPFilterParsed); } QString OptionsDialog::languageToLocalizedString(const QLocale &locale) From 52ae118e3c03d2f3b164d1ce2f8151e077352c87 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 24 Nov 2017 17:33:19 +0800 Subject: [PATCH 2/5] Tweak spacing --- src/gui/properties/propertieswidget.ui | 3 +++ src/gui/properties/speedwidget.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/src/gui/properties/propertieswidget.ui b/src/gui/properties/propertieswidget.ui index 710d60310..26c2ebe69 100644 --- a/src/gui/properties/propertieswidget.ui +++ b/src/gui/properties/propertieswidget.ui @@ -1000,6 +1000,9 @@ + + 3 + 0 diff --git a/src/gui/properties/speedwidget.cpp b/src/gui/properties/speedwidget.cpp index 3f6910c5a..fde4eb5cf 100644 --- a/src/gui/properties/speedwidget.cpp +++ b/src/gui/properties/speedwidget.cpp @@ -61,6 +61,7 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent) { m_layout = new QVBoxLayout(this); m_layout->setContentsMargins(0, 0, 0, 0); + m_layout->setSpacing(3); m_hlayout = new QHBoxLayout(); m_hlayout->setContentsMargins(0, 0, 0, 0); From aaaa67050cc69d947ab55aa1927b5855bd615959 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 24 Nov 2017 17:13:22 +0800 Subject: [PATCH 3/5] 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 --- src/base/utils/misc.cpp | 13 --- src/base/utils/misc.h | 2 - src/gui/CMakeLists.txt | 2 + src/gui/about.ui | 12 +-- src/gui/about_imp.h | 8 +- src/gui/categoryfilterwidget.cpp | 4 +- src/gui/cookiesdialog.cpp | 3 + src/gui/cookiesdialog.ui | 12 --- src/gui/deletionconfirmationdlg.h | 10 ++- src/gui/gui.pri | 2 + src/gui/lineedit/CMakeLists.txt | 6 -- src/gui/lineedit/lineedit.pri | 1 - src/gui/lineedit/resources/lineeditimages.qrc | 5 -- .../resources/lineeditimages/search.png | Bin 292 -> 0 bytes src/gui/lineedit/src/lineedit.cpp | 35 ++++---- src/gui/lineedit/src/lineedit.h | 4 +- src/gui/mainwindow.cpp | 3 +- src/gui/optionsdlg.cpp | 21 +++-- src/gui/optionsdlg.ui | 40 +-------- src/gui/properties/propertieswidget.cpp | 10 ++- src/gui/statusbar.cpp | 13 +-- src/gui/tagfilterwidget.cpp | 4 +- src/gui/transferlistfilterswidget.cpp | 5 +- src/gui/utils.cpp | 79 ++++++++++++++++++ src/gui/utils.h | 50 +++++++++++ 25 files changed, 211 insertions(+), 133 deletions(-) delete mode 100644 src/gui/lineedit/resources/lineeditimages.qrc delete mode 100644 src/gui/lineedit/resources/lineeditimages/search.png create mode 100644 src/gui/utils.cpp create mode 100644 src/gui/utils.h diff --git a/src/base/utils/misc.cpp b/src/base/utils/misc.cpp index 65d4ea85a..6fdfa0ef1 100644 --- a/src/base/utils/misc.cpp +++ b/src/base/utils/misc.cpp @@ -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() diff --git a/src/base/utils/misc.h b/src/base/utils/misc.h index cf733e9a7..157b30113 100644 --- a/src/base/utils/misc.h +++ b/src/base/utils/misc.h @@ -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 diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 44148b441..d7dfb2ca1 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -74,6 +74,7 @@ transferlistfilterswidget.h transferlistsortmodel.h transferlistwidget.h updownratiodlg.h +utils.h ) set(QBT_GUI_SOURCES @@ -119,6 +120,7 @@ transferlistfilterswidget.cpp transferlistsortmodel.cpp transferlistwidget.cpp updownratiodlg.cpp +utils.cpp ) if (APPLE) diff --git a/src/gui/about.ui b/src/gui/about.ui index 4b90eb352..27581c0ca 100644 --- a/src/gui/about.ui +++ b/src/gui/about.ui @@ -18,11 +18,7 @@ - - - :/icons/skin/qbittorrent32.png - - + @@ -57,11 +53,7 @@ - - - :/icons/skin/mascot.png - - + diff --git a/src/gui/about_imp.h b/src/gui/about_imp.h index 2ff663edc..5625813f1 100644 --- a/src/gui/about_imp.h +++ b/src/gui/about_imp.h @@ -31,10 +31,12 @@ #ifndef ABOUT_H #define ABOUT_H -#include "ui_about.h" #include + #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: lb_name->setText("

qBittorrent " QBT_VERSION " (32-bit)

"); #endif + logo->setPixmap(Utils::Gui::scaledPixmap(":/icons/skin/qbittorrent32.png", this)); + // About QString aboutText = QString( "

" @@ -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)) { diff --git a/src/gui/categoryfilterwidget.cpp b/src/gui/categoryfilterwidget.cpp index 52669d221..efba70854 100644 --- a/src/gui/categoryfilterwidget.cpp +++ b/src/gui/categoryfilterwidget.cpp @@ -35,11 +35,11 @@ #include #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) 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 diff --git a/src/gui/cookiesdialog.cpp b/src/gui/cookiesdialog.cpp index ee6004161..f67892c2d 100644 --- a/src/gui/cookiesdialog.cpp +++ b/src/gui/cookiesdialog.cpp @@ -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) 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) diff --git a/src/gui/cookiesdialog.ui b/src/gui/cookiesdialog.ui index 0f08a69d9..e9d9a768a 100644 --- a/src/gui/cookiesdialog.ui +++ b/src/gui/cookiesdialog.ui @@ -49,12 +49,6 @@ - - - 20 - 20 - - @@ -78,12 +72,6 @@ - - - 20 - 20 - - diff --git a/src/gui/deletionconfirmationdlg.h b/src/gui/deletionconfirmationdlg.h index 37e7acde1..e7029cb8e 100644 --- a/src/gui/deletionconfirmationdlg.h +++ b/src/gui/deletionconfirmationdlg.h @@ -33,11 +33,13 @@ #include #include -#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 { 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())); diff --git a/src/gui/gui.pri b/src/gui/gui.pri index e73949549..6503ada48 100644 --- a/src/gui/gui.pri +++ b/src/gui/gui.pri @@ -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 += \ $$PWD/fspathedit.cpp \ $$PWD/fspathedit_p.cpp \ $$PWD/previewselectdialog.cpp \ + $$PWD/utils.cpp \ win32|macx { HEADERS += $$PWD/programupdater.h diff --git a/src/gui/lineedit/CMakeLists.txt b/src/gui/lineedit/CMakeLists.txt index ee1f46c2f..3fdd1260e 100644 --- a/src/gui/lineedit/CMakeLists.txt +++ b/src/gui/lineedit/CMakeLists.txt @@ -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}) diff --git a/src/gui/lineedit/lineedit.pri b/src/gui/lineedit/lineedit.pri index 19c09395a..d07a720c6 100644 --- a/src/gui/lineedit/lineedit.pri +++ b/src/gui/lineedit/lineedit.pri @@ -1,4 +1,3 @@ INCLUDEPATH += $$PWD/src HEADERS += $$PWD/src/lineedit.h SOURCES += $$PWD/src/lineedit.cpp -RESOURCES += $$PWD/resources/lineeditimages.qrc diff --git a/src/gui/lineedit/resources/lineeditimages.qrc b/src/gui/lineedit/resources/lineeditimages.qrc deleted file mode 100644 index c2d0c1516..000000000 --- a/src/gui/lineedit/resources/lineeditimages.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - lineeditimages/search.png - - diff --git a/src/gui/lineedit/resources/lineeditimages/search.png b/src/gui/lineedit/resources/lineeditimages/search.png deleted file mode 100644 index fb8df709ea51e7fd7745530b154ba04763be9014..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 292 zcmV+<0o(qGP)WG{Jlhd`Z`32oX0X^tdXb0Hc9UMf$3Mw^XvwHSjGZx(O?G4 qNb!jfJ2P3v3Oz*aAC|F7oAem6SqDjo4&sRb0000 + +#include #include #include -#include + +#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); } - diff --git a/src/gui/lineedit/src/lineedit.h b/src/gui/lineedit/src/lineedit.h index 5922ce209..2d9440eb5 100644 --- a/src/gui/lineedit/src/lineedit.h +++ b/src/gui/lineedit/src/lineedit.h @@ -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 diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index f3f876215..7f53aeb3a 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -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) 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); diff --git a/src/gui/optionsdlg.cpp b/src/gui/optionsdlg.cpp index 0f5ef88d7..89c3b370a 100644 --- a/src/gui/optionsdlg.cpp +++ b/src/gui/optionsdlg.cpp @@ -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) 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::max(), 62)); + const QSize size(std::numeric_limits::max(), static_cast(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) // 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) #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; diff --git a/src/gui/optionsdlg.ui b/src/gui/optionsdlg.ui index 98a53f60f..9118a2fc4 100644 --- a/src/gui/optionsdlg.ui +++ b/src/gui/optionsdlg.ui @@ -1823,11 +1823,7 @@ - - - :/icons/slow_off.png - - + @@ -1970,11 +1966,7 @@ - - - :/icons/slow.png - - + @@ -2853,20 +2845,8 @@ Use ';' to split multiple entries. Can use wildcard '*'. - - - 22 - 22 - - - - - 22 - 22 - - - + @@ -2906,20 +2886,8 @@ Use ';' to split multiple entries. Can use wildcard '*'. - - - 22 - 22 - - - - - 22 - 22 - - - + diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 2e6fcb625..3fcd3b0f8 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -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 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 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 // 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); diff --git a/src/gui/statusbar.cpp b/src/gui/statusbar.cpp index 20927f928..e84f61ac4 100644 --- a/src/gui/statusbar.cpp +++ b/src/gui/statusbar.cpp @@ -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) // 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); diff --git a/src/gui/tagfilterwidget.cpp b/src/gui/tagfilterwidget.cpp index 4c51699fa..136938882 100644 --- a/src/gui/tagfilterwidget.cpp +++ b/src/gui/tagfilterwidget.cpp @@ -36,11 +36,11 @@ #include #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) 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 diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index 9f9b1a550..4102e4d88 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include "base/bittorrent/session.h" #include "base/bittorrent/torrenthandle.h" @@ -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 @@ #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) setUniformItemSizes(true); setSpacing(0); - setIconSize(Utils::Misc::smallIconSize()); + setIconSize(Utils::Gui::smallIconSize()); #if defined(Q_OS_MAC) setAttribute(Qt::WA_MacShowFocusRect, false); diff --git a/src/gui/utils.cpp b/src/gui/utils.cpp new file mode 100644 index 000000000..9ab3fc1a6 --- /dev/null +++ b/src/gui/utils.cpp @@ -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 +#include +#include +#include +#include +#include + +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); +} diff --git a/src/gui/utils.h b/src/gui/utils.h new file mode 100644 index 000000000..d49ff2eb4 --- /dev/null +++ b/src/gui/utils.h @@ -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 +#include +#include + +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 From 27cf98a9626ab0e76c8ef38b514168ebb5b3164f Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 3 Dec 2017 15:32:58 +0800 Subject: [PATCH 4/5] Resize dialog size on high DPI monitors --- src/base/preferences.cpp | 8 ++--- src/base/preferences.h | 4 +-- src/gui/about_imp.h | 1 + src/gui/addnewtorrentdialog.cpp | 39 ++++++++++++---------- src/gui/autoexpandabledialog.cpp | 26 +++++++-------- src/gui/banlistoptions.cpp | 3 ++ src/gui/cookiesdialog.cpp | 2 +- src/gui/deletionconfirmationdlg.h | 2 ++ src/gui/downloadfromurldlg.h | 2 ++ src/gui/ipsubnetwhitelistoptionsdialog.cpp | 3 ++ src/gui/lineedit/src/lineedit.cpp | 5 +-- src/gui/mainwindow.cpp | 2 +- src/gui/optionsdlg.cpp | 22 +++++------- src/gui/previewselectdialog.cpp | 8 ++--- src/gui/properties/propertieswidget.cpp | 4 +-- src/gui/rss/automatedrssdownloader.cpp | 5 +-- src/gui/search/pluginselectdlg.cpp | 20 ++++++----- src/gui/search/pluginsourcedlg.cpp | 3 ++ src/gui/shutdownconfirmdlg.cpp | 3 ++ src/gui/speedlimitdlg.cpp | 3 ++ src/gui/statsdialog.cpp | 2 ++ src/gui/torrentcreatordlg.cpp | 5 ++- src/gui/trackerlogin.cpp | 6 +++- src/gui/updownratiodlg.cpp | 3 ++ src/gui/utils.cpp | 8 +++++ src/gui/utils.h | 8 +++++ 26 files changed, 121 insertions(+), 76 deletions(-) diff --git a/src/base/preferences.cpp b/src/base/preferences.cpp index 88766b365..9b75601a9 100644 --- a/src/base/preferences.cpp +++ b/src/base/preferences.cpp @@ -1216,9 +1216,9 @@ void Preferences::setMainLastDir(const QString &path) setValue("MainWindowLastDir", path); } -QSize Preferences::getPrefSize(const QSize &defaultSize) const +QSize Preferences::getPrefSize() const { - return value("Preferences/State/size", defaultSize).toSize(); + return value("Preferences/State/size").toSize(); } void Preferences::setPrefSize(const QSize &size) @@ -1296,9 +1296,9 @@ void Preferences::setPropTrackerListState(const QByteArray &state) setValue("TorrentProperties/Trackers/qt5/TrackerListState", state); } -QSize Preferences::getRssGeometrySize(const QSize &defaultSize) const +QSize Preferences::getRssGeometrySize() const { - return value("RssFeedDownloader/geometrySize", defaultSize).toSize(); + return value("RssFeedDownloader/geometrySize").toSize(); } void Preferences::setRssGeometrySize(const QSize &geometry) diff --git a/src/base/preferences.h b/src/base/preferences.h index 3e5087fa4..2c7a72942 100644 --- a/src/base/preferences.h +++ b/src/base/preferences.h @@ -301,7 +301,7 @@ public: void setMainVSplitterState(const QByteArray &state); QString getMainLastDir() const; void setMainLastDir(const QString &path); - QSize getPrefSize(const QSize &defaultSize) const; + QSize getPrefSize() const; void setPrefSize(const QSize &size); QStringList getPrefHSplitterSizes() const; void setPrefHSplitterSizes(const QStringList &sizes); @@ -317,7 +317,7 @@ public: void setPropVisible(const bool visible); QByteArray getPropTrackerListState() const; void setPropTrackerListState(const QByteArray &state); - QSize getRssGeometrySize(const QSize &defaultSize) const; + QSize getRssGeometrySize() const; void setRssGeometrySize(const QSize &geometry); QByteArray getRssHSplitterSizes() const; void setRssHSplitterSizes(const QByteArray &sizes); diff --git a/src/gui/about_imp.h b/src/gui/about_imp.h index 5625813f1..07f99ba69 100644 --- a/src/gui/about_imp.h +++ b/src/gui/about_imp.h @@ -103,6 +103,7 @@ public: label_12->setText(Utils::Misc::libtorrentVersionString()); label_13->setText(Utils::Misc::boostVersionString()); + Utils::Gui::resize(this); show(); } }; diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 39f430363..4f2c7250c 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -28,36 +28,38 @@ * Contact : chris@qbittorrent.org */ +#include "addnewtorrentdialog.h" + #include -#include #include -#include -#include #include +#include #include +#include +#include +#include "autoexpandabledialog.h" +#include "base/bittorrent/magneturi.h" +#include "base/bittorrent/session.h" +#include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/torrentinfo.h" +#include "base/net/downloadhandler.h" +#include "base/net/downloadmanager.h" #include "base/preferences.h" #include "base/settingsstorage.h" #include "base/settingvalue.h" -#include "base/net/downloadmanager.h" -#include "base/net/downloadhandler.h" -#include "base/bittorrent/session.h" -#include "base/bittorrent/magneturi.h" -#include "base/bittorrent/torrentinfo.h" -#include "base/bittorrent/torrenthandle.h" +#include "base/torrentfileguard.h" +#include "base/unicodestrings.h" #include "base/utils/fs.h" #include "base/utils/misc.h" #include "base/utils/string.h" -#include "base/torrentfileguard.h" -#include "base/unicodestrings.h" #include "guiiconprovider.h" -#include "autoexpandabledialog.h" #include "messageboxraised.h" #include "proplistdelegate.h" -#include "torrentcontentmodel.h" #include "torrentcontentfiltermodel.h" +#include "torrentcontentmodel.h" #include "ui_addnewtorrentdialog.h" -#include "addnewtorrentdialog.h" +#include "utils.h" namespace { @@ -212,10 +214,11 @@ CachedSettingValue &AddNewTorrentDialog::savePathHistoryLengthSetting() void AddNewTorrentDialog::loadState() { m_headerState = settings()->loadValue(KEY_TREEHEADERSTATE).toByteArray(); - int width = settings()->loadValue(KEY_WIDTH, -1).toInt(); - QSize geo = size(); - geo.setWidth(width); - resize(geo); + + const QSize newSize = Utils::Gui::scaledSize(this, size()); + const int width = settings()->loadValue(KEY_WIDTH, newSize.width()).toInt(); + const int height = newSize.height(); + resize(width, height); ui->adv_button->setChecked(settings()->loadValue(KEY_EXPANDED).toBool()); } diff --git a/src/gui/autoexpandabledialog.cpp b/src/gui/autoexpandabledialog.cpp index 590989326..c5e975211 100644 --- a/src/gui/autoexpandabledialog.cpp +++ b/src/gui/autoexpandabledialog.cpp @@ -32,6 +32,7 @@ #include "mainwindow.h" #include "ui_autoexpandabledialog.h" +#include "utils.h" AutoExpandableDialog::AutoExpandableDialog(QWidget *parent) : QDialog(parent) @@ -68,30 +69,29 @@ QString AutoExpandableDialog::getText(QWidget *parent, const QString &title, con void AutoExpandableDialog::showEvent(QShowEvent *e) { // Overriding showEvent is required for consistent UI with fixed size under custom DPI - // Show dialog QDialog::showEvent(e); - // and resize textbox to fit the text - // NOTE: For some strange reason QFontMetrics gets more accurate - // when called from showEvent. Only 6 symbols off instead of 11 symbols off. - int textW = m_ui->textEdit->fontMetrics().width(m_ui->textEdit->text()) + 4; - int wd = textW; + // Show dialog and resize textbox to fit the text + // NOTE: For unknown reason QFontMetrics gets more accurate when called from showEvent. + int wd = m_ui->textEdit->fontMetrics().width(m_ui->textEdit->text()) + 4; if (!windowTitle().isEmpty()) { - int w = fontMetrics().width(windowTitle()); - if (w > wd) - wd = w; + // not really the font metrics in window title, so we enlarge it a bit, + // including the small icon and close button width + int w = fontMetrics().width(windowTitle()) * 1.8; + wd = std::max(wd, w); } if (!m_ui->textLabel->text().isEmpty()) { int w = m_ui->textLabel->fontMetrics().width(m_ui->textLabel->text()); - if (w > wd) - wd = w; + wd = std::max(wd, w); } // Now resize the dialog to fit the contents // max width of text from either of: label, title, textedit // If the value is less than dialog default size, default size is used - if (wd > width()) - resize(width() - m_ui->verticalLayout->sizeHint().width() + wd, height()); + if (wd > width()) { + QSize size = {width() - m_ui->verticalLayout->sizeHint().width() + wd, height()}; + Utils::Gui::resize(this, size); + } } diff --git a/src/gui/banlistoptions.cpp b/src/gui/banlistoptions.cpp index ee009e854..71a1be2dd 100644 --- a/src/gui/banlistoptions.cpp +++ b/src/gui/banlistoptions.cpp @@ -36,6 +36,7 @@ #include "base/bittorrent/session.h" #include "base/utils/net.h" #include "ui_banlistoptions.h" +#include "utils.h" BanListOptions::BanListOptions(QWidget *parent) : QDialog(parent) @@ -52,6 +53,8 @@ BanListOptions::BanListOptions(QWidget *parent) m_ui->bannedIPList->setModel(m_sortFilter); m_ui->bannedIPList->sortByColumn(0, Qt::AscendingOrder); m_ui->buttonBanIP->setEnabled(false); + + Utils::Gui::resize(this); } BanListOptions::~BanListOptions() diff --git a/src/gui/cookiesdialog.cpp b/src/gui/cookiesdialog.cpp index f67892c2d..da46fa7c8 100644 --- a/src/gui/cookiesdialog.cpp +++ b/src/gui/cookiesdialog.cpp @@ -60,7 +60,7 @@ CookiesDialog::CookiesDialog(QWidget *parent) m_cookiesModel->index(0, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); - resize(SettingsStorage::instance()->loadValue(KEY_SIZE, size()).toSize()); + Utils::Gui::resize(this, SettingsStorage::instance()->loadValue(KEY_SIZE).toSize()); m_ui->treeView->header()->restoreState( SettingsStorage::instance()->loadValue(KEY_COOKIESVIEWSTATE).toByteArray()); } diff --git a/src/gui/deletionconfirmationdlg.h b/src/gui/deletionconfirmationdlg.h index e7029cb8e..b369891e0 100644 --- a/src/gui/deletionconfirmationdlg.h +++ b/src/gui/deletionconfirmationdlg.h @@ -61,6 +61,8 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault()); connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState())); buttonBox->button(QDialogButtonBox::Cancel)->setFocus(); + + Utils::Gui::resize(this); } bool shouldDeleteLocalFiles() const { diff --git a/src/gui/downloadfromurldlg.h b/src/gui/downloadfromurldlg.h index 9adbb7936..c422b9975 100644 --- a/src/gui/downloadfromurldlg.h +++ b/src/gui/downloadfromurldlg.h @@ -40,6 +40,7 @@ #include #include "ui_downloadfromurldlg.h" +#include "utils.h" class downloadFromURL : public QDialog, private Ui::downloadFromURL { @@ -82,6 +83,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL if (clip_txt_list_cleaned.size() > 0) textUrls->setText(clip_txt_list_cleaned.join("\n")); + Utils::Gui::resize(this); show(); } diff --git a/src/gui/ipsubnetwhitelistoptionsdialog.cpp b/src/gui/ipsubnetwhitelistoptionsdialog.cpp index 0cbf9c9c4..16b5d0273 100644 --- a/src/gui/ipsubnetwhitelistoptionsdialog.cpp +++ b/src/gui/ipsubnetwhitelistoptionsdialog.cpp @@ -37,6 +37,7 @@ #include "base/preferences.h" #include "base/utils/net.h" #include "ui_ipsubnetwhitelistoptionsdialog.h" +#include "utils.h" IPSubnetWhitelistOptionsDialog::IPSubnetWhitelistOptionsDialog(QWidget *parent) : QDialog(parent) @@ -57,6 +58,8 @@ IPSubnetWhitelistOptionsDialog::IPSubnetWhitelistOptionsDialog(QWidget *parent) m_ui->whitelistedIPSubnetList->setModel(m_sortFilter); m_ui->whitelistedIPSubnetList->sortByColumn(0, Qt::AscendingOrder); m_ui->buttonWhitelistIPSubnet->setEnabled(false); + + Utils::Gui::resize(this); } IPSubnetWhitelistOptionsDialog::~IPSubnetWhitelistOptionsDialog() diff --git a/src/gui/lineedit/src/lineedit.cpp b/src/gui/lineedit/src/lineedit.cpp index e2dfb46d0..0a900c625 100644 --- a/src/gui/lineedit/src/lineedit.cpp +++ b/src/gui/lineedit/src/lineedit.cpp @@ -23,9 +23,10 @@ LineEdit::LineEdit(QWidget *parent) 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; }"); + 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 + // padding between text and widget borders + setStyleSheet(QString("QLineEdit {padding-left: %1px;}").arg(m_searchButton->sizeHint().width())); setClearButtonEnabled(true); diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 7f53aeb3a..b486d97dd 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -231,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 * Utils::Gui::screenScalingFactor(this)); + m_searchFilter->setFixedWidth(Utils::Gui::scaledSize(this, 200)); QWidget *spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); diff --git a/src/gui/optionsdlg.cpp b/src/gui/optionsdlg.cpp index 89c3b370a..a5e0b15a8 100644 --- a/src/gui/optionsdlg.cpp +++ b/src/gui/optionsdlg.cpp @@ -454,25 +454,19 @@ void OptionsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previo void OptionsDialog::loadWindowState() { - const Preferences* const pref = Preferences::instance(); - - resize(pref->getPrefSize(this->size())); + Utils::Gui::resize(this, Preferences::instance()->getPrefSize()); } void OptionsDialog::loadSplitterState() { - const Preferences* const pref = Preferences::instance(); + const QStringList sizesStr = Preferences::instance()->getPrefHSplitterSizes(); - const QStringList sizes_str = pref->getPrefHSplitterSizes(); - QList sizes; - if (sizes_str.size() == 2) { - sizes << sizes_str.first().toInt(); - sizes << sizes_str.last().toInt(); - } - else { - sizes << 116; - sizes << m_ui->hsplitter->width() - 116; - } + // width has been modified, use height as width reference instead + const int width = Utils::Gui::scaledSize(this + , (m_ui->tabSelection->item(TAB_UI)->sizeHint().height() * 2)); + QList sizes {width, (m_ui->hsplitter->width() - width)}; + if (sizesStr.size() == 2) + sizes = {sizesStr.first().toInt(), sizesStr.last().toInt()}; m_ui->hsplitter->setSizes(sizes); } diff --git a/src/gui/previewselectdialog.cpp b/src/gui/previewselectdialog.cpp index 3bd55fd86..4627d8be6 100644 --- a/src/gui/previewselectdialog.cpp +++ b/src/gui/previewselectdialog.cpp @@ -39,6 +39,7 @@ #include "base/utils/fs.h" #include "base/utils/misc.h" #include "previewlistdelegate.h" +#include "utils.h" #define SETTINGS_KEY(name) "PreviewSelectDialog/" name @@ -146,7 +147,7 @@ void PreviewSelectDialog::previewButtonClicked() void PreviewSelectDialog::saveWindowState() { // Persist dialog size - m_storeDialogSize = this->size(); + m_storeDialogSize = size(); // Persist TreeView Header state m_storeTreeHeaderState = previewList->header()->saveState(); } @@ -154,9 +155,8 @@ void PreviewSelectDialog::saveWindowState() void PreviewSelectDialog::loadWindowState() { // Restore dialog size - if (m_storeDialogSize.value().isValid()) { - resize(m_storeDialogSize); - } + Utils::Gui::resize(this, m_storeDialogSize); + // Restore TreeView Header state if (!m_storeTreeHeaderState.value().isEmpty()) { m_headerStateInitialized = previewList->header()->restoreState(m_storeTreeHeaderState); diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 3fcd3b0f8..d26f313e5 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -92,7 +92,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran // Torrent content filtering m_contentFilterLine = new LineEdit(this); m_contentFilterLine->setPlaceholderText(tr("Filter files...")); - m_contentFilterLine->setFixedWidth(300 * Utils::Gui::screenScalingFactor(this)); + m_contentFilterLine->setFixedWidth(Utils::Gui::scaledSize(this, 300)); connect(m_contentFilterLine, SIGNAL(textChanged(QString)), this, SLOT(filterText(QString))); m_ui->contentFilterLayout->insertWidget(3, m_contentFilterLine); @@ -114,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 - const int barHeight = 18 * Utils::Gui::screenScalingFactor(this); + const int barHeight = Utils::Gui::scaledSize(this, 18); // Downloaded pieces progress bar m_ui->tempProgressBarArea->setVisible(false); diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index 14676405b..a00ab4750 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -53,6 +53,7 @@ #include "guiiconprovider.h" #include "autoexpandabledialog.h" #include "ui_automatedrssdownloader.h" +#include "utils.h" const QString EXT_JSON {QStringLiteral(".json")}; const QString EXT_LEGACY {QStringLiteral(".rssrules")}; @@ -155,14 +156,14 @@ AutomatedRssDownloader::~AutomatedRssDownloader() void AutomatedRssDownloader::loadSettings() { const Preferences *const pref = Preferences::instance(); - resize(pref->getRssGeometrySize(this->size())); + Utils::Gui::resize(this, pref->getRssGeometrySize()); m_ui->hsplitter->restoreState(pref->getRssHSplitterSizes()); } void AutomatedRssDownloader::saveSettings() { Preferences *const pref = Preferences::instance(); - pref->setRssGeometrySize(this->size()); + pref->setRssGeometrySize(size()); pref->setRssHSplitterSizes(m_ui->hsplitter->saveState()); } diff --git a/src/gui/search/pluginselectdlg.cpp b/src/gui/search/pluginselectdlg.cpp index 653d75800..12a864263 100644 --- a/src/gui/search/pluginselectdlg.cpp +++ b/src/gui/search/pluginselectdlg.cpp @@ -31,25 +31,26 @@ #include "pluginselectdlg.h" +#include +#include +#include #include +#include #include #include -#include -#include #include -#include #include -#include +#include "autoexpandabledialog.h" +#include "base/net/downloadhandler.h" +#include "base/net/downloadmanager.h" #include "base/utils/fs.h" #include "base/utils/misc.h" -#include "base/net/downloadmanager.h" -#include "base/net/downloadhandler.h" -#include "searchwidget.h" -#include "pluginsourcedlg.h" #include "guiiconprovider.h" -#include "autoexpandabledialog.h" +#include "pluginsourcedlg.h" +#include "searchwidget.h" #include "ui_pluginselectdlg.h" +#include "utils.h" enum PluginColumns { @@ -99,6 +100,7 @@ PluginSelectDlg::PluginSelectDlg(SearchEngine *pluginManager, QWidget *parent) connect(m_pluginManager, &SearchEngine::checkForUpdatesFinished, this, &PluginSelectDlg::checkForUpdatesFinished); connect(m_pluginManager, &SearchEngine::checkForUpdatesFailed, this, &PluginSelectDlg::checkForUpdatesFailed); + Utils::Gui::resize(this); show(); } diff --git a/src/gui/search/pluginsourcedlg.cpp b/src/gui/search/pluginsourcedlg.cpp index 1d5844bd3..387666e42 100644 --- a/src/gui/search/pluginsourcedlg.cpp +++ b/src/gui/search/pluginsourcedlg.cpp @@ -31,6 +31,7 @@ #include "pluginsourcedlg.h" #include "ui_pluginsourcedlg.h" +#include "utils.h" PluginSourceDlg::PluginSourceDlg(QWidget *parent) : QDialog(parent) @@ -38,6 +39,8 @@ PluginSourceDlg::PluginSourceDlg(QWidget *parent) { m_ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); + + Utils::Gui::resize(this); show(); } diff --git a/src/gui/shutdownconfirmdlg.cpp b/src/gui/shutdownconfirmdlg.cpp index 63446e752..eaf3a2012 100644 --- a/src/gui/shutdownconfirmdlg.cpp +++ b/src/gui/shutdownconfirmdlg.cpp @@ -37,6 +37,7 @@ #include "base/preferences.h" #include "base/utils/misc.h" #include "ui_shutdownconfirmdlg.h" +#include "utils.h" ShutdownConfirmDlg::ShutdownConfirmDlg(QWidget *parent, const ShutdownDialogAction &action) : QDialog(parent) @@ -66,6 +67,8 @@ ShutdownConfirmDlg::ShutdownConfirmDlg(QWidget *parent, const ShutdownDialogActi m_timer.setInterval(1000); // 1sec connect(&m_timer, SIGNAL(timeout()), this, SLOT(updateSeconds())); + + Utils::Gui::resize(this); } ShutdownConfirmDlg::~ShutdownConfirmDlg() diff --git a/src/gui/speedlimitdlg.cpp b/src/gui/speedlimitdlg.cpp index 723f68ecd..916686154 100644 --- a/src/gui/speedlimitdlg.cpp +++ b/src/gui/speedlimitdlg.cpp @@ -30,6 +30,7 @@ #include "base/unicodestrings.h" #include "ui_bandwidth_limit.h" +#include "utils.h" SpeedLimitDialog::SpeedLimitDialog(QWidget *parent) : QDialog(parent) @@ -41,6 +42,8 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent) // Connect to slots connect(m_ui->bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateSpinValue(int))); connect(m_ui->spinBandwidth, SIGNAL(valueChanged(int)), this, SLOT(updateSliderValue(int))); + + Utils::Gui::resize(this); } SpeedLimitDialog::~SpeedLimitDialog() diff --git a/src/gui/statsdialog.cpp b/src/gui/statsdialog.cpp index f73d61164..5ec64edc0 100644 --- a/src/gui/statsdialog.cpp +++ b/src/gui/statsdialog.cpp @@ -35,6 +35,7 @@ #include "base/utils/misc.h" #include "base/utils/string.h" #include "ui_statsdialog.h" +#include "utils.h" StatsDialog::StatsDialog(QWidget *parent) : QDialog(parent) @@ -48,6 +49,7 @@ StatsDialog::StatsDialog(QWidget *parent) connect(BitTorrent::Session::instance(), &BitTorrent::Session::statsUpdated , this, &StatsDialog::update); + Utils::Gui::resize(this); show(); } diff --git a/src/gui/torrentcreatordlg.cpp b/src/gui/torrentcreatordlg.cpp index 0d46da91a..f074e3783 100644 --- a/src/gui/torrentcreatordlg.cpp +++ b/src/gui/torrentcreatordlg.cpp @@ -41,8 +41,8 @@ #include "base/bittorrent/torrentinfo.h" #include "base/global.h" #include "base/utils/fs.h" - #include "ui_torrentcreatordlg.h" +#include "utils.h" #define SETTINGS_KEY(name) "TorrentCreator/" name @@ -264,6 +264,5 @@ void TorrentCreatorDlg::loadSettings() m_ui->txtComment->setPlainText(m_storeComments); m_ui->lineEditSource->setText(m_storeSource); - if (m_storeDialogSize.value().isValid()) - resize(m_storeDialogSize); + Utils::Gui::resize(this, m_storeDialogSize); } diff --git a/src/gui/trackerlogin.cpp b/src/gui/trackerlogin.cpp index 7d25a93e8..717040ec8 100644 --- a/src/gui/trackerlogin.cpp +++ b/src/gui/trackerlogin.cpp @@ -30,9 +30,12 @@ #include "trackerlogin.h" -#include #include + +#include + #include "base/bittorrent/torrenthandle.h" +#include "utils.h" trackerLogin::trackerLogin(QWidget *parent, BitTorrent::TorrentHandle *const torrent) : QDialog(parent) @@ -53,6 +56,7 @@ trackerLogin::trackerLogin(QWidget *parent, BitTorrent::TorrentHandle *const tor connect(this, SIGNAL(trackerLoginCancelled(QPair)), // TODO: use Qt5 connect syntax parent, SLOT(addUnauthenticatedTracker(QPair))); + Utils::Gui::resize(this); show(); } diff --git a/src/gui/updownratiodlg.cpp b/src/gui/updownratiodlg.cpp index 3c3acfb70..f4ba4ed1c 100644 --- a/src/gui/updownratiodlg.cpp +++ b/src/gui/updownratiodlg.cpp @@ -33,6 +33,7 @@ #include "base/bittorrent/session.h" #include "ui_updownratiodlg.h" +#include "utils.h" UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialRatioValue, qreal maxRatioValue, int initialTimeValue, @@ -73,6 +74,8 @@ UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialRatioValue, connect(m_ui->checkMaxTime, SIGNAL(toggled(bool)), this, SLOT(enableTimeSpin())); handleRatioTypeChanged(); + + Utils::Gui::resize(this); } void UpDownRatioDlg::accept() diff --git a/src/gui/utils.cpp b/src/gui/utils.cpp index 9ab3fc1a6..5709810b2 100644 --- a/src/gui/utils.cpp +++ b/src/gui/utils.cpp @@ -35,6 +35,14 @@ #include #include +void Utils::Gui::resize(QWidget *widget, const QSize &newSize) +{ + if (newSize.isValid()) + widget->resize(newSize); + else // depends on screen DPI + widget->resize(widget->size() * screenScalingFactor(widget)); +} + qreal Utils::Gui::screenScalingFactor(const QWidget *widget) { #ifdef Q_OS_WIN diff --git a/src/gui/utils.h b/src/gui/utils.h index d49ff2eb4..8e44f1457 100644 --- a/src/gui/utils.h +++ b/src/gui/utils.h @@ -39,7 +39,15 @@ namespace Utils { namespace Gui { + void resize(QWidget *widget, const QSize &newSize = {}); qreal screenScalingFactor(const QWidget *widget); + + template + T scaledSize(const QWidget *widget, const T &size) + { + return (size * screenScalingFactor(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); From c2c0dd2717e1eef80f503db75fff6c2b41ba511a Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 8 Dec 2017 22:05:21 +0800 Subject: [PATCH 5/5] Fix column size too narrow on resize Instead of giving a value, just resize to the content size --- src/gui/properties/peerlistwidget.cpp | 3 +-- src/gui/properties/propertieswidget.cpp | 4 +--- src/gui/properties/trackerlist.cpp | 3 +-- src/gui/search/pluginselectdlg.cpp | 3 --- src/gui/search/searchtab.cpp | 3 +-- src/gui/transferlistwidget.cpp | 8 ++------ 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index 5dd27a7de..85ee18ed4 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -180,10 +180,9 @@ void PeerListWidget::displayToggleColumnsMenu(const QPoint &) Q_ASSERT(visibleCols > 0); if (!isColumnHidden(col) && (visibleCols == 1)) return; - qDebug("Toggling column %d visibility", col); setColumnHidden(col, !isColumnHidden(col)); if (!isColumnHidden(col) && (columnWidth(col) <= 5)) - setColumnWidth(col, 100); + resizeColumnToContents(col); saveSettings(); } } diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index d26f313e5..3c32b4898 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -371,9 +371,7 @@ void PropertiesWidget::readSettings() } const int current_tab = pref->getPropCurTab(); const bool visible = pref->getPropVisible(); - // the following will call saveSettings but shouldn't change any state - if (!m_ui->filesList->header()->restoreState(pref->getPropFileListState())) - m_ui->filesList->header()->resizeSection(0, 400); // Default + m_ui->filesList->header()->restoreState(pref->getPropFileListState()); m_tabBar->setCurrentIndex(current_tab); if (!visible) setVisibility(false); diff --git a/src/gui/properties/trackerlist.cpp b/src/gui/properties/trackerlist.cpp index b0d2d0d80..1c4e10e9c 100644 --- a/src/gui/properties/trackerlist.cpp +++ b/src/gui/properties/trackerlist.cpp @@ -627,9 +627,8 @@ void TrackerList::displayToggleColumnsMenu(const QPoint &) Q_ASSERT(visibleColumnsCount() > 0); if (!isColumnHidden(col) && (visibleColumnsCount() == 1)) return; - qDebug("Toggling column %d visibility", col); setColumnHidden(col, !isColumnHidden(col)); if (!isColumnHidden(col) && (columnWidth(col) <= 5)) - setColumnWidth(col, 100); + resizeColumnToContents(col); saveSettings(); } diff --git a/src/gui/search/pluginselectdlg.cpp b/src/gui/search/pluginselectdlg.cpp index 12a864263..dad2e0897 100644 --- a/src/gui/search/pluginselectdlg.cpp +++ b/src/gui/search/pluginselectdlg.cpp @@ -79,9 +79,6 @@ PluginSelectDlg::PluginSelectDlg(SearchEngine *pluginManager, QWidget *parent) unused.setVerticalHeader(new QHeaderView(Qt::Horizontal)); m_ui->pluginsTree->setRootIsDecorated(false); - m_ui->pluginsTree->header()->resizeSection(0, 160); - m_ui->pluginsTree->header()->resizeSection(1, 80); - m_ui->pluginsTree->header()->resizeSection(2, 200); m_ui->pluginsTree->hideColumn(PLUGIN_ID); m_ui->pluginsTree->header()->setSortIndicator(0, Qt::AscendingOrder); diff --git a/src/gui/search/searchtab.cpp b/src/gui/search/searchtab.cpp index 786da6fd5..182f53848 100644 --- a/src/gui/search/searchtab.cpp +++ b/src/gui/search/searchtab.cpp @@ -334,10 +334,9 @@ void SearchTab::displayToggleColumnsMenu(const QPoint&) Q_ASSERT(visibleCols > 0); if ((!m_ui->resultsBrowser->isColumnHidden(col)) && (visibleCols == 1)) return; - qDebug("Toggling column %d visibility", col); m_ui->resultsBrowser->setColumnHidden(col, !m_ui->resultsBrowser->isColumnHidden(col)); if ((!m_ui->resultsBrowser->isColumnHidden(col)) && (m_ui->resultsBrowser->columnWidth(col) <= 5)) - m_ui->resultsBrowser->setColumnWidth(col, 100); + m_ui->resultsBrowser->resizeColumnToContents(col); saveSettings(); } } diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index df965096b..ba5a65460 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -716,10 +716,9 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) Q_ASSERT(visibleCols > 0); if (!isColumnHidden(col) && visibleCols == 1) return; - qDebug("Toggling column %d visibility", col); setColumnHidden(col, !isColumnHidden(col)); if (!isColumnHidden(col) && columnWidth(col) <= 5) - setColumnWidth(col, 100); + resizeColumnToContents(col); saveSettings(); } } @@ -1193,10 +1192,7 @@ void TransferListWidget::saveSettings() bool TransferListWidget::loadSettings() { - bool ok = header()->restoreState(Preferences::instance()->getTransHeaderState()); - if (!ok) - header()->resizeSection(0, 200); // Default - return ok; + return header()->restoreState(Preferences::instance()->getTransHeaderState()); } void TransferListWidget::wheelEvent(QWheelEvent *event)