Browse Source

Merge pull request #7876 from Chocobo1/optionIcons

Fix gui issues on high DPI monitor
adaptive-webui-19844
Mike Tzou 7 years ago committed by GitHub
parent
commit
267362a7a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/base/preferences.cpp
  2. 4
      src/base/preferences.h
  3. 13
      src/base/utils/misc.cpp
  4. 2
      src/base/utils/misc.h
  5. 2
      src/gui/CMakeLists.txt
  6. 12
      src/gui/about.ui
  7. 9
      src/gui/about_imp.h
  8. 39
      src/gui/addnewtorrentdialog.cpp
  9. 26
      src/gui/autoexpandabledialog.cpp
  10. 3
      src/gui/banlistoptions.cpp
  11. 4
      src/gui/categoryfilterwidget.cpp
  12. 5
      src/gui/cookiesdialog.cpp
  13. 12
      src/gui/cookiesdialog.ui
  14. 12
      src/gui/deletionconfirmationdlg.h
  15. 2
      src/gui/downloadfromurldlg.h
  16. 2
      src/gui/gui.pri
  17. 3
      src/gui/ipsubnetwhitelistoptionsdialog.cpp
  18. 6
      src/gui/lineedit/CMakeLists.txt
  19. 1
      src/gui/lineedit/lineedit.pri
  20. 5
      src/gui/lineedit/resources/lineeditimages.qrc
  21. BIN
      src/gui/lineedit/resources/lineeditimages/search.png
  22. 36
      src/gui/lineedit/src/lineedit.cpp
  23. 4
      src/gui/lineedit/src/lineedit.h
  24. 110
      src/gui/mainwindow.cpp
  25. 49
      src/gui/optionsdlg.cpp
  26. 40
      src/gui/optionsdlg.ui
  27. 8
      src/gui/previewselectdialog.cpp
  28. 3
      src/gui/properties/peerlistwidget.cpp
  29. 14
      src/gui/properties/propertieswidget.cpp
  30. 3
      src/gui/properties/propertieswidget.ui
  31. 1
      src/gui/properties/speedwidget.cpp
  32. 3
      src/gui/properties/trackerlist.cpp
  33. 5
      src/gui/rss/automatedrssdownloader.cpp
  34. 23
      src/gui/search/pluginselectdlg.cpp
  35. 3
      src/gui/search/pluginsourcedlg.cpp
  36. 3
      src/gui/search/searchtab.cpp
  37. 3
      src/gui/shutdownconfirmdlg.cpp
  38. 3
      src/gui/speedlimitdlg.cpp
  39. 2
      src/gui/statsdialog.cpp
  40. 13
      src/gui/statusbar.cpp
  41. 4
      src/gui/tagfilterwidget.cpp
  42. 5
      src/gui/torrentcreatordlg.cpp
  43. 6
      src/gui/trackerlogin.cpp
  44. 5
      src/gui/transferlistfilterswidget.cpp
  45. 8
      src/gui/transferlistwidget.cpp
  46. 3
      src/gui/updownratiodlg.cpp
  47. 87
      src/gui/utils.cpp
  48. 58
      src/gui/utils.h

8
src/base/preferences.cpp

@ -1216,9 +1216,9 @@ void Preferences::setMainLastDir(const QString &path)
setValue("MainWindowLastDir", 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) void Preferences::setPrefSize(const QSize &size)
@ -1296,9 +1296,9 @@ void Preferences::setPropTrackerListState(const QByteArray &state)
setValue("TorrentProperties/Trackers/qt5/TrackerListState", 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) void Preferences::setRssGeometrySize(const QSize &geometry)

4
src/base/preferences.h

@ -301,7 +301,7 @@ public:
void setMainVSplitterState(const QByteArray &state); void setMainVSplitterState(const QByteArray &state);
QString getMainLastDir() const; QString getMainLastDir() const;
void setMainLastDir(const QString &path); void setMainLastDir(const QString &path);
QSize getPrefSize(const QSize &defaultSize) const; QSize getPrefSize() const;
void setPrefSize(const QSize &size); void setPrefSize(const QSize &size);
QStringList getPrefHSplitterSizes() const; QStringList getPrefHSplitterSizes() const;
void setPrefHSplitterSizes(const QStringList &sizes); void setPrefHSplitterSizes(const QStringList &sizes);
@ -317,7 +317,7 @@ public:
void setPropVisible(const bool visible); void setPropVisible(const bool visible);
QByteArray getPropTrackerListState() const; QByteArray getPropTrackerListState() const;
void setPropTrackerListState(const QByteArray &state); void setPropTrackerListState(const QByteArray &state);
QSize getRssGeometrySize(const QSize &defaultSize) const; QSize getRssGeometrySize() const;
void setRssGeometrySize(const QSize &geometry); void setRssGeometrySize(const QSize &geometry);
QByteArray getRssHSplitterSizes() const; QByteArray getRssHSplitterSizes() const;
void setRssHSplitterSizes(const QByteArray &sizes); void setRssHSplitterSizes(const QByteArray &sizes);

13
src/base/utils/misc.cpp

@ -632,19 +632,6 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath)
#endif #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 #endif // DISABLE_GUI
QString Utils::Misc::osName() QString Utils::Misc::osName()

2
src/base/utils/misc.h

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

2
src/gui/CMakeLists.txt

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

12
src/gui/about.ui

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

9
src/gui/about_imp.h

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

39
src/gui/addnewtorrentdialog.cpp

@ -28,36 +28,38 @@
* Contact : chris@qbittorrent.org * Contact : chris@qbittorrent.org
*/ */
#include "addnewtorrentdialog.h"
#include <QDebug> #include <QDebug>
#include <QString>
#include <QFile> #include <QFile>
#include <QUrl>
#include <QMenu>
#include <QFileDialog> #include <QFileDialog>
#include <QMenu>
#include <QPushButton> #include <QPushButton>
#include <QString>
#include <QUrl>
#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/preferences.h"
#include "base/settingsstorage.h" #include "base/settingsstorage.h"
#include "base/settingvalue.h" #include "base/settingvalue.h"
#include "base/net/downloadmanager.h" #include "base/torrentfileguard.h"
#include "base/net/downloadhandler.h" #include "base/unicodestrings.h"
#include "base/bittorrent/session.h"
#include "base/bittorrent/magneturi.h"
#include "base/bittorrent/torrentinfo.h"
#include "base/bittorrent/torrenthandle.h"
#include "base/utils/fs.h" #include "base/utils/fs.h"
#include "base/utils/misc.h" #include "base/utils/misc.h"
#include "base/utils/string.h" #include "base/utils/string.h"
#include "base/torrentfileguard.h"
#include "base/unicodestrings.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "autoexpandabledialog.h"
#include "messageboxraised.h" #include "messageboxraised.h"
#include "proplistdelegate.h" #include "proplistdelegate.h"
#include "torrentcontentmodel.h"
#include "torrentcontentfiltermodel.h" #include "torrentcontentfiltermodel.h"
#include "torrentcontentmodel.h"
#include "ui_addnewtorrentdialog.h" #include "ui_addnewtorrentdialog.h"
#include "addnewtorrentdialog.h" #include "utils.h"
namespace namespace
{ {
@ -212,10 +214,11 @@ CachedSettingValue<int> &AddNewTorrentDialog::savePathHistoryLengthSetting()
void AddNewTorrentDialog::loadState() void AddNewTorrentDialog::loadState()
{ {
m_headerState = settings()->loadValue(KEY_TREEHEADERSTATE).toByteArray(); m_headerState = settings()->loadValue(KEY_TREEHEADERSTATE).toByteArray();
int width = settings()->loadValue(KEY_WIDTH, -1).toInt();
QSize geo = size(); const QSize newSize = Utils::Gui::scaledSize(this, size());
geo.setWidth(width); const int width = settings()->loadValue(KEY_WIDTH, newSize.width()).toInt();
resize(geo); const int height = newSize.height();
resize(width, height);
ui->adv_button->setChecked(settings()->loadValue(KEY_EXPANDED).toBool()); ui->adv_button->setChecked(settings()->loadValue(KEY_EXPANDED).toBool());
} }

26
src/gui/autoexpandabledialog.cpp

@ -32,6 +32,7 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_autoexpandabledialog.h" #include "ui_autoexpandabledialog.h"
#include "utils.h"
AutoExpandableDialog::AutoExpandableDialog(QWidget *parent) AutoExpandableDialog::AutoExpandableDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)
@ -68,30 +69,29 @@ QString AutoExpandableDialog::getText(QWidget *parent, const QString &title, con
void AutoExpandableDialog::showEvent(QShowEvent *e) void AutoExpandableDialog::showEvent(QShowEvent *e)
{ {
// Overriding showEvent is required for consistent UI with fixed size under custom DPI // Overriding showEvent is required for consistent UI with fixed size under custom DPI
// Show dialog
QDialog::showEvent(e); QDialog::showEvent(e);
// and resize textbox to fit the text
// NOTE: For some strange reason QFontMetrics gets more accurate // Show dialog and resize textbox to fit the text
// when called from showEvent. Only 6 symbols off instead of 11 symbols off. // NOTE: For unknown reason QFontMetrics gets more accurate when called from showEvent.
int textW = m_ui->textEdit->fontMetrics().width(m_ui->textEdit->text()) + 4; int wd = m_ui->textEdit->fontMetrics().width(m_ui->textEdit->text()) + 4;
int wd = textW;
if (!windowTitle().isEmpty()) { if (!windowTitle().isEmpty()) {
int w = fontMetrics().width(windowTitle()); // not really the font metrics in window title, so we enlarge it a bit,
if (w > wd) // including the small icon and close button width
wd = w; int w = fontMetrics().width(windowTitle()) * 1.8;
wd = std::max(wd, w);
} }
if (!m_ui->textLabel->text().isEmpty()) { if (!m_ui->textLabel->text().isEmpty()) {
int w = m_ui->textLabel->fontMetrics().width(m_ui->textLabel->text()); int w = m_ui->textLabel->fontMetrics().width(m_ui->textLabel->text());
if (w > wd) wd = std::max(wd, w);
wd = w;
} }
// Now resize the dialog to fit the contents // Now resize the dialog to fit the contents
// max width of text from either of: label, title, textedit // max width of text from either of: label, title, textedit
// If the value is less than dialog default size, default size is used // If the value is less than dialog default size, default size is used
if (wd > width()) if (wd > width()) {
resize(width() - m_ui->verticalLayout->sizeHint().width() + wd, height()); QSize size = {width() - m_ui->verticalLayout->sizeHint().width() + wd, height()};
Utils::Gui::resize(this, size);
}
} }

3
src/gui/banlistoptions.cpp

@ -36,6 +36,7 @@
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "base/utils/net.h" #include "base/utils/net.h"
#include "ui_banlistoptions.h" #include "ui_banlistoptions.h"
#include "utils.h"
BanListOptions::BanListOptions(QWidget *parent) BanListOptions::BanListOptions(QWidget *parent)
: QDialog(parent) : QDialog(parent)
@ -52,6 +53,8 @@ BanListOptions::BanListOptions(QWidget *parent)
m_ui->bannedIPList->setModel(m_sortFilter); m_ui->bannedIPList->setModel(m_sortFilter);
m_ui->bannedIPList->sortByColumn(0, Qt::AscendingOrder); m_ui->bannedIPList->sortByColumn(0, Qt::AscendingOrder);
m_ui->buttonBanIP->setEnabled(false); m_ui->buttonBanIP->setEnabled(false);
Utils::Gui::resize(this);
} }
BanListOptions::~BanListOptions() BanListOptions::~BanListOptions()

4
src/gui/categoryfilterwidget.cpp

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

5
src/gui/cookiesdialog.cpp

@ -35,6 +35,7 @@
#include "cookiesmodel.h" #include "cookiesmodel.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "ui_cookiesdialog.h" #include "ui_cookiesdialog.h"
#include "utils.h"
#define SETTINGS_KEY(name) "CookiesDialog/" name #define SETTINGS_KEY(name) "CookiesDialog/" name
const QString KEY_SIZE = SETTINGS_KEY("Size"); const QString KEY_SIZE = SETTINGS_KEY("Size");
@ -50,6 +51,8 @@ CookiesDialog::CookiesDialog(QWidget *parent)
setWindowIcon(GuiIconProvider::instance()->getIcon("preferences-web-browser-cookies")); setWindowIcon(GuiIconProvider::instance()->getIcon("preferences-web-browser-cookies"));
m_ui->buttonAdd->setIcon(GuiIconProvider::instance()->getIcon("list-add")); m_ui->buttonAdd->setIcon(GuiIconProvider::instance()->getIcon("list-add"));
m_ui->buttonDelete->setIcon(GuiIconProvider::instance()->getIcon("list-remove")); 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); m_ui->treeView->setModel(m_cookiesModel);
if (m_cookiesModel->rowCount() > 0) if (m_cookiesModel->rowCount() > 0)
@ -57,7 +60,7 @@ CookiesDialog::CookiesDialog(QWidget *parent)
m_cookiesModel->index(0, 0), m_cookiesModel->index(0, 0),
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); 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( m_ui->treeView->header()->restoreState(
SettingsStorage::instance()->loadValue(KEY_COOKIESVIEWSTATE).toByteArray()); SettingsStorage::instance()->loadValue(KEY_COOKIESVIEWSTATE).toByteArray());
} }

12
src/gui/cookiesdialog.ui

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

12
src/gui/deletionconfirmationdlg.h

@ -33,11 +33,13 @@
#include <QDialog> #include <QDialog>
#include <QPushButton> #include <QPushButton>
#include "ui_confirmdeletiondlg.h"
#include "base/preferences.h" #include "base/preferences.h"
#include "base/utils/misc.h" #include "base/utils/misc.h"
#include "base/utils/string.h" #include "base/utils/string.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "ui_confirmdeletiondlg.h"
#include "utils.h"
class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
Q_OBJECT Q_OBJECT
@ -50,13 +52,17 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
else 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))); 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 // Icons
lbl_warn->setPixmap(GuiIconProvider::instance()->getIcon("dialog-warning").pixmap(lbl_warn->height())); const QSize iconSize = Utils::Gui::largeIconSize();
lbl_warn->setFixedWidth(lbl_warn->height()); lbl_warn->setPixmap(GuiIconProvider::instance()->getIcon("dialog-warning").pixmap(iconSize));
lbl_warn->setFixedWidth(iconSize.width());
rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked")); rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked"));
rememberBtn->setIconSize(Utils::Gui::mediumIconSize());
checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault()); checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault());
connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState())); connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState()));
buttonBox->button(QDialogButtonBox::Cancel)->setFocus(); buttonBox->button(QDialogButtonBox::Cancel)->setFocus();
Utils::Gui::resize(this);
} }
bool shouldDeleteLocalFiles() const { bool shouldDeleteLocalFiles() const {

2
src/gui/downloadfromurldlg.h

@ -40,6 +40,7 @@
#include <QStringList> #include <QStringList>
#include "ui_downloadfromurldlg.h" #include "ui_downloadfromurldlg.h"
#include "utils.h"
class downloadFromURL : public QDialog, private Ui::downloadFromURL 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) if (clip_txt_list_cleaned.size() > 0)
textUrls->setText(clip_txt_list_cleaned.join("\n")); textUrls->setText(clip_txt_list_cleaned.join("\n"));
Utils::Gui::resize(this);
show(); show();
} }

2
src/gui/gui.pri

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

3
src/gui/ipsubnetwhitelistoptionsdialog.cpp

@ -37,6 +37,7 @@
#include "base/preferences.h" #include "base/preferences.h"
#include "base/utils/net.h" #include "base/utils/net.h"
#include "ui_ipsubnetwhitelistoptionsdialog.h" #include "ui_ipsubnetwhitelistoptionsdialog.h"
#include "utils.h"
IPSubnetWhitelistOptionsDialog::IPSubnetWhitelistOptionsDialog(QWidget *parent) IPSubnetWhitelistOptionsDialog::IPSubnetWhitelistOptionsDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)
@ -57,6 +58,8 @@ IPSubnetWhitelistOptionsDialog::IPSubnetWhitelistOptionsDialog(QWidget *parent)
m_ui->whitelistedIPSubnetList->setModel(m_sortFilter); m_ui->whitelistedIPSubnetList->setModel(m_sortFilter);
m_ui->whitelistedIPSubnetList->sortByColumn(0, Qt::AscendingOrder); m_ui->whitelistedIPSubnetList->sortByColumn(0, Qt::AscendingOrder);
m_ui->buttonWhitelistIPSubnet->setEnabled(false); m_ui->buttonWhitelistIPSubnet->setEnabled(false);
Utils::Gui::resize(this);
} }
IPSubnetWhitelistOptionsDialog::~IPSubnetWhitelistOptionsDialog() IPSubnetWhitelistOptionsDialog::~IPSubnetWhitelistOptionsDialog()

6
src/gui/lineedit/CMakeLists.txt

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

1
src/gui/lineedit/lineedit.pri

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

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

@ -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

36
src/gui/lineedit/src/lineedit.cpp

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

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

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

110
src/gui/mainwindow.cpp

@ -30,84 +30,84 @@
#include "mainwindow.h" #include "mainwindow.h"
#ifdef Q_OS_MAC #include <QClipboard>
#include <QtMacExtras> #include <QCloseEvent>
#include <QtMac> #include <QCryptographicHash>
#endif
#include <QtGlobal>
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
#include <QDBusConnection>
#include "notifications.h"
#endif
#include <QDebug> #include <QDebug>
#include <QDesktopServices>
#include <QFileDialog> #include <QFileDialog>
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
#include <QMessageBox> #include <QMessageBox>
#include <QTimer> #include <QMimeData>
#include <QDesktopServices> #include <QProcess>
#include <QStatusBar>
#include <QClipboard>
#include <QCloseEvent>
#include <QShortcut>
#include <QScrollBar> #include <QScrollBar>
#include <QShortcut>
#include <QSplitter> #include <QSplitter>
#include <QStatusBar>
#include <QSysInfo> #include <QSysInfo>
#include <QMimeData> #include <QtGlobal>
#include <QCryptographicHash> #include <QTimer>
#include <QProcess>
#include "base/preferences.h" #ifdef Q_OS_MAC
#include "base/settingsstorage.h" #include <QtMac>
#include "base/logger.h" #include <QtMacExtras>
#include "base/utils/misc.h"
#include "base/utils/fs.h"
#ifdef Q_OS_WIN
#include "base/net/downloadmanager.h"
#include "base/net/downloadhandler.h"
#endif #endif
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
#include <QDBusConnection>
#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/session.h"
#include "base/bittorrent/sessionstatus.h" #include "base/bittorrent/sessionstatus.h"
#include "base/bittorrent/torrenthandle.h" #include "base/bittorrent/torrenthandle.h"
#include "base/global.h" #include "base/global.h"
#include "base/logger.h"
#include "base/preferences.h"
#include "base/rss/rss_folder.h" #include "base/rss/rss_folder.h"
#include "base/rss/rss_session.h" #include "base/rss/rss_session.h"
#include "base/settingsstorage.h"
#include "application.h" #include "base/utils/fs.h"
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) #include "base/utils/misc.h"
#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 "cookiesdialog.h" #include "cookiesdialog.h"
#include "speedlimitdlg.h" #include "downloadfromurldlg.h"
#include "transferlistwidget.h" #include "executionlog.h"
#include "search/searchwidget.h" #include "guiiconprovider.h"
#include "trackerlist.h" #include "hidabletabwidget.h"
#include "lineedit.h"
#include "optionsdlg.h"
#include "peerlistwidget.h" #include "peerlistwidget.h"
#include "transferlistfilterswidget.h" #include "powermanagement.h"
#include "propertieswidget.h" #include "propertieswidget.h"
#include "statusbar.h"
#include "rss/rsswidget.h" #include "rss/rsswidget.h"
#include "about_imp.h" #include "search/searchwidget.h"
#include "optionsdlg.h" #include "speedlimitdlg.h"
#if LIBTORRENT_VERSION_NUM < 10100 #include "statsdialog.h"
#include "trackerlogin.h" #include "statusbar.h"
#endif #include "torrentcreatordlg.h"
#include "lineedit.h" #include "torrentmodel.h"
#include "executionlog.h" #include "trackerlist.h"
#include "hidabletabwidget.h" #include "transferlistfilterswidget.h"
#include "transferlistwidget.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "utils.h"
#ifdef Q_OS_WIN
#include "base/net/downloadhandler.h"
#include "base/net/downloadmanager.h"
#endif
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
#include "macutilities.h" #include "macutilities.h"
#endif #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 #ifdef Q_OS_MAC
void qt_mac_set_dock_menu(QMenu *menu); void qt_mac_set_dock_menu(QMenu *menu);
@ -231,7 +231,7 @@ MainWindow::MainWindow(QWidget *parent)
m_searchFilter = new LineEdit(this); m_searchFilter = new LineEdit(this);
m_searchFilterAction = m_ui->toolBar->insertWidget(m_ui->actionLock, m_searchFilter); m_searchFilterAction = m_ui->toolBar->insertWidget(m_ui->actionLock, m_searchFilter);
m_searchFilter->setPlaceholderText(tr("Filter torrent list...")); m_searchFilter->setPlaceholderText(tr("Filter torrent list..."));
m_searchFilter->setFixedWidth(200); m_searchFilter->setFixedWidth(Utils::Gui::scaledSize(this, 200));
QWidget *spacer = new QWidget(this); QWidget *spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

49
src/gui/optionsdlg.cpp

@ -68,6 +68,7 @@
#include "ipsubnetwhitelistoptionsdialog.h" #include "ipsubnetwhitelistoptionsdialog.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "scanfoldersdelegate.h" #include "scanfoldersdelegate.h"
#include "utils.h"
#include "ui_optionsdlg.h" #include "ui_optionsdlg.h"
@ -99,13 +100,21 @@ OptionsDialog::OptionsDialog(QWidget *parent)
m_ui->tabSelection->item(TAB_WEBUI)->setHidden(true); m_ui->tabSelection->item(TAB_WEBUI)->setHidden(true);
#endif #endif
m_ui->tabSelection->item(TAB_ADVANCED)->setIcon(GuiIconProvider::instance()->getIcon("preferences-other")); 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) { for (int i = 0; i < m_ui->tabSelection->count(); ++i) {
// uniform size for all icons const QSize size(std::numeric_limits<int>::max(), static_cast<int>(maxHeight * 1.2));
m_ui->tabSelection->item(i)->setSizeHint(QSize(std::numeric_limits<int>::max(), 62)); m_ui->tabSelection->item(i)->setSizeHint(size);
} }
m_ui->IpFilterRefreshBtn->setIcon(GuiIconProvider::instance()->getIcon("view-refresh")); 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->setPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical).pixmap(16, 16));
m_ui->deleteTorrentWarningIcon->hide(); m_ui->deleteTorrentWarningIcon->hide();
m_ui->deleteTorrentWarningLabel->hide(); m_ui->deleteTorrentWarningLabel->hide();
@ -139,7 +148,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
connect(ScanFoldersModel::instance(), &QAbstractListModel::dataChanged, this, &ThisType::enableApplyButton); connect(ScanFoldersModel::instance(), &QAbstractListModel::dataChanged, this, &ThisType::enableApplyButton);
connect(m_ui->scanFoldersView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &ThisType::handleScanFolderViewSelectionChanged); 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 // Languages supported
initializeLanguageCombo(); initializeLanguageCombo();
@ -445,25 +454,19 @@ void OptionsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previo
void OptionsDialog::loadWindowState() void OptionsDialog::loadWindowState()
{ {
const Preferences* const pref = Preferences::instance(); Utils::Gui::resize(this, Preferences::instance()->getPrefSize());
resize(pref->getPrefSize(this->size()));
} }
void OptionsDialog::loadSplitterState() void OptionsDialog::loadSplitterState()
{ {
const Preferences* const pref = Preferences::instance(); const QStringList sizesStr = Preferences::instance()->getPrefHSplitterSizes();
const QStringList sizes_str = pref->getPrefHSplitterSizes(); // width has been modified, use height as width reference instead
QList<int> sizes; const int width = Utils::Gui::scaledSize(this
if (sizes_str.size() == 2) { , (m_ui->tabSelection->item(TAB_UI)->sizeHint().height() * 2));
sizes << sizes_str.first().toInt(); QList<int> sizes {width, (m_ui->hsplitter->width() - width)};
sizes << sizes_str.last().toInt(); if (sizesStr.size() == 2)
} sizes = {sizesStr.first().toInt(), sizesStr.last().toInt()};
else {
sizes << 116;
sizes << m_ui->hsplitter->width() - 116;
}
m_ui->hsplitter->setSizes(sizes); m_ui->hsplitter->setSizes(sizes);
} }
@ -1578,7 +1581,7 @@ void OptionsDialog::on_IpFilterRefreshBtn_clicked()
session->setIPFilteringEnabled(true); session->setIPFilteringEnabled(true);
session->setIPFilterFile(""); // forcing Session reload filter file session->setIPFilterFile(""); // forcing Session reload filter file
session->setIPFilterFile(getFilter()); 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)); setCursor(QCursor(Qt::WaitCursor));
} }
@ -1590,7 +1593,7 @@ void OptionsDialog::handleIPFilterParsed(bool error, int ruleCount)
else else
QMessageBox::information(this, tr("Successfully refreshed"), tr("Successfully parsed the provided IP filter: %1 rules were applied.", "%1 is a number").arg(ruleCount)); 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; 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) QString OptionsDialog::languageToLocalizedString(const QLocale &locale)
@ -1675,11 +1678,11 @@ bool OptionsDialog::setSslKey(const QByteArray &key)
// try different formats // try different formats
const bool isKeyValid = (!QSslKey(key, QSsl::Rsa).isNull() || !QSslKey(key, QSsl::Ec).isNull()); const bool isKeyValid = (!QSslKey(key, QSsl::Rsa).isNull() || !QSslKey(key, QSsl::Ec).isNull());
if (isKeyValid) { 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; m_sslKey = key;
} }
else { 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(); m_sslKey.clear();
} }
return isKeyValid; return isKeyValid;
@ -1694,11 +1697,11 @@ bool OptionsDialog::setSslCertificate(const QByteArray &cert)
#ifndef QT_NO_OPENSSL #ifndef QT_NO_OPENSSL
const bool isCertValid = !QSslCertificate(cert).isNull(); const bool isCertValid = !QSslCertificate(cert).isNull();
if (isCertValid) { 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; m_sslCert = cert;
} }
else { 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(); m_sslCert.clear();
} }
return isCertValid; return isCertValid;

40
src/gui/optionsdlg.ui

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

8
src/gui/previewselectdialog.cpp

@ -39,6 +39,7 @@
#include "base/utils/fs.h" #include "base/utils/fs.h"
#include "base/utils/misc.h" #include "base/utils/misc.h"
#include "previewlistdelegate.h" #include "previewlistdelegate.h"
#include "utils.h"
#define SETTINGS_KEY(name) "PreviewSelectDialog/" name #define SETTINGS_KEY(name) "PreviewSelectDialog/" name
@ -146,7 +147,7 @@ void PreviewSelectDialog::previewButtonClicked()
void PreviewSelectDialog::saveWindowState() void PreviewSelectDialog::saveWindowState()
{ {
// Persist dialog size // Persist dialog size
m_storeDialogSize = this->size(); m_storeDialogSize = size();
// Persist TreeView Header state // Persist TreeView Header state
m_storeTreeHeaderState = previewList->header()->saveState(); m_storeTreeHeaderState = previewList->header()->saveState();
} }
@ -154,9 +155,8 @@ void PreviewSelectDialog::saveWindowState()
void PreviewSelectDialog::loadWindowState() void PreviewSelectDialog::loadWindowState()
{ {
// Restore dialog size // Restore dialog size
if (m_storeDialogSize.value().isValid()) { Utils::Gui::resize(this, m_storeDialogSize);
resize(m_storeDialogSize);
}
// Restore TreeView Header state // Restore TreeView Header state
if (!m_storeTreeHeaderState.value().isEmpty()) { if (!m_storeTreeHeaderState.value().isEmpty()) {
m_headerStateInitialized = previewList->header()->restoreState(m_storeTreeHeaderState); m_headerStateInitialized = previewList->header()->restoreState(m_storeTreeHeaderState);

3
src/gui/properties/peerlistwidget.cpp

@ -180,10 +180,9 @@ void PeerListWidget::displayToggleColumnsMenu(const QPoint &)
Q_ASSERT(visibleCols > 0); Q_ASSERT(visibleCols > 0);
if (!isColumnHidden(col) && (visibleCols == 1)) if (!isColumnHidden(col) && (visibleCols == 1))
return; return;
qDebug("Toggling column %d visibility", col);
setColumnHidden(col, !isColumnHidden(col)); setColumnHidden(col, !isColumnHidden(col));
if (!isColumnHidden(col) && (columnWidth(col) <= 5)) if (!isColumnHidden(col) && (columnWidth(col) <= 5))
setColumnWidth(col, 100); resizeColumnToContents(col);
saveSettings(); saveSettings();
} }
} }

14
src/gui/properties/propertieswidget.cpp

@ -62,6 +62,7 @@
#include "torrentcontentmodel.h" #include "torrentcontentmodel.h"
#include "trackerlist.h" #include "trackerlist.h"
#include "transferlistwidget.h" #include "transferlistwidget.h"
#include "utils.h"
#include "ui_propertieswidget.h" #include "ui_propertieswidget.h"
@ -87,10 +88,11 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
m_propListDelegate = new PropListDelegate(this); m_propListDelegate = new PropListDelegate(this);
m_ui->filesList->setItemDelegate(m_propListDelegate); m_ui->filesList->setItemDelegate(m_propListDelegate);
m_ui->filesList->setSortingEnabled(true); m_ui->filesList->setSortingEnabled(true);
// Torrent content filtering // Torrent content filtering
m_contentFilterLine = new LineEdit(this); m_contentFilterLine = new LineEdit(this);
m_contentFilterLine->setPlaceholderText(tr("Filter files...")); m_contentFilterLine->setPlaceholderText(tr("Filter files..."));
m_contentFilterLine->setMaximumSize(300, m_contentFilterLine->size().height()); m_contentFilterLine->setFixedWidth(Utils::Gui::scaledSize(this, 300));
connect(m_contentFilterLine, SIGNAL(textChanged(QString)), this, SLOT(filterText(QString))); connect(m_contentFilterLine, SIGNAL(textChanged(QString)), this, SLOT(filterText(QString)));
m_ui->contentFilterLayout->insertWidget(3, m_contentFilterLine); 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())); connect(m_ui->filesList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSettings()));
// set bar height relative to screen dpi // set bar height relative to screen dpi
int barHeight = devicePixelRatio() * 18; const int barHeight = Utils::Gui::scaledSize(this, 18);
// Downloaded pieces progress bar // Downloaded pieces progress bar
m_ui->tempProgressBarArea->setVisible(false); m_ui->tempProgressBarArea->setVisible(false);
@ -131,9 +133,9 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
// Tracker list // Tracker list
m_trackerList = new TrackerList(this); m_trackerList = new TrackerList(this);
m_ui->trackerUpButton->setIcon(GuiIconProvider::instance()->getIcon("go-up")); 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->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->trackerUpButton, SIGNAL(clicked()), m_trackerList, SLOT(moveSelectionUp()));
connect(m_ui->trackerDownButton, SIGNAL(clicked()), m_trackerList, SLOT(moveSelectionDown())); connect(m_ui->trackerDownButton, SIGNAL(clicked()), m_trackerList, SLOT(moveSelectionDown()));
m_ui->horizontalLayout_trackers->insertWidget(0, m_trackerList); m_ui->horizontalLayout_trackers->insertWidget(0, m_trackerList);
@ -369,9 +371,7 @@ void PropertiesWidget::readSettings()
} }
const int current_tab = pref->getPropCurTab(); const int current_tab = pref->getPropCurTab();
const bool visible = pref->getPropVisible(); const bool visible = pref->getPropVisible();
// the following will call saveSettings but shouldn't change any state m_ui->filesList->header()->restoreState(pref->getPropFileListState());
if (!m_ui->filesList->header()->restoreState(pref->getPropFileListState()))
m_ui->filesList->header()->resizeSection(0, 400); // Default
m_tabBar->setCurrentIndex(current_tab); m_tabBar->setCurrentIndex(current_tab);
if (!visible) if (!visible)
setVisibility(false); setVisibility(false);

3
src/gui/properties/propertieswidget.ui

@ -1000,6 +1000,9 @@
</widget> </widget>
<widget class="QWidget" name="pageContents"> <widget class="QWidget" name="pageContents">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>

1
src/gui/properties/speedwidget.cpp

@ -61,6 +61,7 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent)
{ {
m_layout = new QVBoxLayout(this); m_layout = new QVBoxLayout(this);
m_layout->setContentsMargins(0, 0, 0, 0); m_layout->setContentsMargins(0, 0, 0, 0);
m_layout->setSpacing(3);
m_hlayout = new QHBoxLayout(); m_hlayout = new QHBoxLayout();
m_hlayout->setContentsMargins(0, 0, 0, 0); m_hlayout->setContentsMargins(0, 0, 0, 0);

3
src/gui/properties/trackerlist.cpp

@ -627,9 +627,8 @@ void TrackerList::displayToggleColumnsMenu(const QPoint &)
Q_ASSERT(visibleColumnsCount() > 0); Q_ASSERT(visibleColumnsCount() > 0);
if (!isColumnHidden(col) && (visibleColumnsCount() == 1)) if (!isColumnHidden(col) && (visibleColumnsCount() == 1))
return; return;
qDebug("Toggling column %d visibility", col);
setColumnHidden(col, !isColumnHidden(col)); setColumnHidden(col, !isColumnHidden(col));
if (!isColumnHidden(col) && (columnWidth(col) <= 5)) if (!isColumnHidden(col) && (columnWidth(col) <= 5))
setColumnWidth(col, 100); resizeColumnToContents(col);
saveSettings(); saveSettings();
} }

5
src/gui/rss/automatedrssdownloader.cpp

@ -53,6 +53,7 @@
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "autoexpandabledialog.h" #include "autoexpandabledialog.h"
#include "ui_automatedrssdownloader.h" #include "ui_automatedrssdownloader.h"
#include "utils.h"
const QString EXT_JSON {QStringLiteral(".json")}; const QString EXT_JSON {QStringLiteral(".json")};
const QString EXT_LEGACY {QStringLiteral(".rssrules")}; const QString EXT_LEGACY {QStringLiteral(".rssrules")};
@ -155,14 +156,14 @@ AutomatedRssDownloader::~AutomatedRssDownloader()
void AutomatedRssDownloader::loadSettings() void AutomatedRssDownloader::loadSettings()
{ {
const Preferences *const pref = Preferences::instance(); const Preferences *const pref = Preferences::instance();
resize(pref->getRssGeometrySize(this->size())); Utils::Gui::resize(this, pref->getRssGeometrySize());
m_ui->hsplitter->restoreState(pref->getRssHSplitterSizes()); m_ui->hsplitter->restoreState(pref->getRssHSplitterSizes());
} }
void AutomatedRssDownloader::saveSettings() void AutomatedRssDownloader::saveSettings()
{ {
Preferences *const pref = Preferences::instance(); Preferences *const pref = Preferences::instance();
pref->setRssGeometrySize(this->size()); pref->setRssGeometrySize(size());
pref->setRssHSplitterSizes(m_ui->hsplitter->saveState()); pref->setRssHSplitterSizes(m_ui->hsplitter->saveState());
} }

23
src/gui/search/pluginselectdlg.cpp

@ -31,25 +31,26 @@
#include "pluginselectdlg.h" #include "pluginselectdlg.h"
#include <QClipboard>
#include <QDropEvent>
#include <QFileDialog>
#include <QHeaderView> #include <QHeaderView>
#include <QImageReader>
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QFileDialog>
#include <QDropEvent>
#include <QMimeData> #include <QMimeData>
#include <QClipboard>
#include <QTableView> #include <QTableView>
#include <QImageReader>
#include "autoexpandabledialog.h"
#include "base/net/downloadhandler.h"
#include "base/net/downloadmanager.h"
#include "base/utils/fs.h" #include "base/utils/fs.h"
#include "base/utils/misc.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 "guiiconprovider.h"
#include "autoexpandabledialog.h" #include "pluginsourcedlg.h"
#include "searchwidget.h"
#include "ui_pluginselectdlg.h" #include "ui_pluginselectdlg.h"
#include "utils.h"
enum PluginColumns enum PluginColumns
{ {
@ -78,9 +79,6 @@ PluginSelectDlg::PluginSelectDlg(SearchEngine *pluginManager, QWidget *parent)
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal)); unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
m_ui->pluginsTree->setRootIsDecorated(false); 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->hideColumn(PLUGIN_ID);
m_ui->pluginsTree->header()->setSortIndicator(0, Qt::AscendingOrder); m_ui->pluginsTree->header()->setSortIndicator(0, Qt::AscendingOrder);
@ -99,6 +97,7 @@ PluginSelectDlg::PluginSelectDlg(SearchEngine *pluginManager, QWidget *parent)
connect(m_pluginManager, &SearchEngine::checkForUpdatesFinished, this, &PluginSelectDlg::checkForUpdatesFinished); connect(m_pluginManager, &SearchEngine::checkForUpdatesFinished, this, &PluginSelectDlg::checkForUpdatesFinished);
connect(m_pluginManager, &SearchEngine::checkForUpdatesFailed, this, &PluginSelectDlg::checkForUpdatesFailed); connect(m_pluginManager, &SearchEngine::checkForUpdatesFailed, this, &PluginSelectDlg::checkForUpdatesFailed);
Utils::Gui::resize(this);
show(); show();
} }

3
src/gui/search/pluginsourcedlg.cpp

@ -31,6 +31,7 @@
#include "pluginsourcedlg.h" #include "pluginsourcedlg.h"
#include "ui_pluginsourcedlg.h" #include "ui_pluginsourcedlg.h"
#include "utils.h"
PluginSourceDlg::PluginSourceDlg(QWidget *parent) PluginSourceDlg::PluginSourceDlg(QWidget *parent)
: QDialog(parent) : QDialog(parent)
@ -38,6 +39,8 @@ PluginSourceDlg::PluginSourceDlg(QWidget *parent)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
Utils::Gui::resize(this);
show(); show();
} }

3
src/gui/search/searchtab.cpp

@ -334,10 +334,9 @@ void SearchTab::displayToggleColumnsMenu(const QPoint&)
Q_ASSERT(visibleCols > 0); Q_ASSERT(visibleCols > 0);
if ((!m_ui->resultsBrowser->isColumnHidden(col)) && (visibleCols == 1)) if ((!m_ui->resultsBrowser->isColumnHidden(col)) && (visibleCols == 1))
return; return;
qDebug("Toggling column %d visibility", col);
m_ui->resultsBrowser->setColumnHidden(col, !m_ui->resultsBrowser->isColumnHidden(col)); m_ui->resultsBrowser->setColumnHidden(col, !m_ui->resultsBrowser->isColumnHidden(col));
if ((!m_ui->resultsBrowser->isColumnHidden(col)) && (m_ui->resultsBrowser->columnWidth(col) <= 5)) if ((!m_ui->resultsBrowser->isColumnHidden(col)) && (m_ui->resultsBrowser->columnWidth(col) <= 5))
m_ui->resultsBrowser->setColumnWidth(col, 100); m_ui->resultsBrowser->resizeColumnToContents(col);
saveSettings(); saveSettings();
} }
} }

3
src/gui/shutdownconfirmdlg.cpp

@ -37,6 +37,7 @@
#include "base/preferences.h" #include "base/preferences.h"
#include "base/utils/misc.h" #include "base/utils/misc.h"
#include "ui_shutdownconfirmdlg.h" #include "ui_shutdownconfirmdlg.h"
#include "utils.h"
ShutdownConfirmDlg::ShutdownConfirmDlg(QWidget *parent, const ShutdownDialogAction &action) ShutdownConfirmDlg::ShutdownConfirmDlg(QWidget *parent, const ShutdownDialogAction &action)
: QDialog(parent) : QDialog(parent)
@ -66,6 +67,8 @@ ShutdownConfirmDlg::ShutdownConfirmDlg(QWidget *parent, const ShutdownDialogActi
m_timer.setInterval(1000); // 1sec m_timer.setInterval(1000); // 1sec
connect(&m_timer, SIGNAL(timeout()), this, SLOT(updateSeconds())); connect(&m_timer, SIGNAL(timeout()), this, SLOT(updateSeconds()));
Utils::Gui::resize(this);
} }
ShutdownConfirmDlg::~ShutdownConfirmDlg() ShutdownConfirmDlg::~ShutdownConfirmDlg()

3
src/gui/speedlimitdlg.cpp

@ -30,6 +30,7 @@
#include "base/unicodestrings.h" #include "base/unicodestrings.h"
#include "ui_bandwidth_limit.h" #include "ui_bandwidth_limit.h"
#include "utils.h"
SpeedLimitDialog::SpeedLimitDialog(QWidget *parent) SpeedLimitDialog::SpeedLimitDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)
@ -41,6 +42,8 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent)
// Connect to slots // Connect to slots
connect(m_ui->bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateSpinValue(int))); connect(m_ui->bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateSpinValue(int)));
connect(m_ui->spinBandwidth, SIGNAL(valueChanged(int)), this, SLOT(updateSliderValue(int))); connect(m_ui->spinBandwidth, SIGNAL(valueChanged(int)), this, SLOT(updateSliderValue(int)));
Utils::Gui::resize(this);
} }
SpeedLimitDialog::~SpeedLimitDialog() SpeedLimitDialog::~SpeedLimitDialog()

2
src/gui/statsdialog.cpp

@ -35,6 +35,7 @@
#include "base/utils/misc.h" #include "base/utils/misc.h"
#include "base/utils/string.h" #include "base/utils/string.h"
#include "ui_statsdialog.h" #include "ui_statsdialog.h"
#include "utils.h"
StatsDialog::StatsDialog(QWidget *parent) StatsDialog::StatsDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)
@ -48,6 +49,7 @@ StatsDialog::StatsDialog(QWidget *parent)
connect(BitTorrent::Session::instance(), &BitTorrent::Session::statsUpdated connect(BitTorrent::Session::instance(), &BitTorrent::Session::statsUpdated
, this, &StatsDialog::update); , this, &StatsDialog::update);
Utils::Gui::resize(this);
show(); show();
} }

13
src/gui/statusbar.cpp

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

4
src/gui/tagfilterwidget.cpp

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

5
src/gui/torrentcreatordlg.cpp

@ -41,8 +41,8 @@
#include "base/bittorrent/torrentinfo.h" #include "base/bittorrent/torrentinfo.h"
#include "base/global.h" #include "base/global.h"
#include "base/utils/fs.h" #include "base/utils/fs.h"
#include "ui_torrentcreatordlg.h" #include "ui_torrentcreatordlg.h"
#include "utils.h"
#define SETTINGS_KEY(name) "TorrentCreator/" name #define SETTINGS_KEY(name) "TorrentCreator/" name
@ -264,6 +264,5 @@ void TorrentCreatorDlg::loadSettings()
m_ui->txtComment->setPlainText(m_storeComments); m_ui->txtComment->setPlainText(m_storeComments);
m_ui->lineEditSource->setText(m_storeSource); m_ui->lineEditSource->setText(m_storeSource);
if (m_storeDialogSize.value().isValid()) Utils::Gui::resize(this, m_storeDialogSize);
resize(m_storeDialogSize);
} }

6
src/gui/trackerlogin.cpp

@ -30,9 +30,12 @@
#include "trackerlogin.h" #include "trackerlogin.h"
#include <QPushButton>
#include <libtorrent/version.hpp> #include <libtorrent/version.hpp>
#include <QPushButton>
#include "base/bittorrent/torrenthandle.h" #include "base/bittorrent/torrenthandle.h"
#include "utils.h"
trackerLogin::trackerLogin(QWidget *parent, BitTorrent::TorrentHandle *const torrent) trackerLogin::trackerLogin(QWidget *parent, BitTorrent::TorrentHandle *const torrent)
: QDialog(parent) : QDialog(parent)
@ -53,6 +56,7 @@ trackerLogin::trackerLogin(QWidget *parent, BitTorrent::TorrentHandle *const tor
connect(this, SIGNAL(trackerLoginCancelled(QPair<BitTorrent::TorrentHandle*, QString>)), // TODO: use Qt5 connect syntax connect(this, SIGNAL(trackerLoginCancelled(QPair<BitTorrent::TorrentHandle*, QString>)), // TODO: use Qt5 connect syntax
parent, SLOT(addUnauthenticatedTracker(QPair<BitTorrent::TorrentHandle*, QString>))); parent, SLOT(addUnauthenticatedTracker(QPair<BitTorrent::TorrentHandle*, QString>)));
Utils::Gui::resize(this);
show(); show();
} }

5
src/gui/transferlistfilterswidget.cpp

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

8
src/gui/transferlistwidget.cpp

@ -716,10 +716,9 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&)
Q_ASSERT(visibleCols > 0); Q_ASSERT(visibleCols > 0);
if (!isColumnHidden(col) && visibleCols == 1) if (!isColumnHidden(col) && visibleCols == 1)
return; return;
qDebug("Toggling column %d visibility", col);
setColumnHidden(col, !isColumnHidden(col)); setColumnHidden(col, !isColumnHidden(col));
if (!isColumnHidden(col) && columnWidth(col) <= 5) if (!isColumnHidden(col) && columnWidth(col) <= 5)
setColumnWidth(col, 100); resizeColumnToContents(col);
saveSettings(); saveSettings();
} }
} }
@ -1193,10 +1192,7 @@ void TransferListWidget::saveSettings()
bool TransferListWidget::loadSettings() bool TransferListWidget::loadSettings()
{ {
bool ok = header()->restoreState(Preferences::instance()->getTransHeaderState()); return header()->restoreState(Preferences::instance()->getTransHeaderState());
if (!ok)
header()->resizeSection(0, 200); // Default
return ok;
} }
void TransferListWidget::wheelEvent(QWheelEvent *event) void TransferListWidget::wheelEvent(QWheelEvent *event)

3
src/gui/updownratiodlg.cpp

@ -33,6 +33,7 @@
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "ui_updownratiodlg.h" #include "ui_updownratiodlg.h"
#include "utils.h"
UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialRatioValue, UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialRatioValue,
qreal maxRatioValue, int initialTimeValue, qreal maxRatioValue, int initialTimeValue,
@ -73,6 +74,8 @@ UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialRatioValue,
connect(m_ui->checkMaxTime, SIGNAL(toggled(bool)), this, SLOT(enableTimeSpin())); connect(m_ui->checkMaxTime, SIGNAL(toggled(bool)), this, SLOT(enableTimeSpin()));
handleRatioTypeChanged(); handleRatioTypeChanged();
Utils::Gui::resize(this);
} }
void UpDownRatioDlg::accept() void UpDownRatioDlg::accept()

87
src/gui/utils.cpp

@ -0,0 +1,87 @@
/*
* 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>
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
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);
}

58
src/gui/utils.h

@ -0,0 +1,58 @@
/*
* 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
{
void resize(QWidget *widget, const QSize &newSize = {});
qreal screenScalingFactor(const QWidget *widget);
template <typename T>
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);
QSize largeIconSize(const QWidget *widget = nullptr);
}
}
#endif // UTILS_GUI_H
Loading…
Cancel
Save