mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-15 09:43:07 -07:00
Resize dialog size on high DPI monitors
This commit is contained in:
parent
aaaa67050c
commit
27cf98a962
26 changed files with 125 additions and 80 deletions
|
@ -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)
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -103,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();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,36 +28,38 @@
|
||||||
* Contact : chris@qbittorrent.org
|
* Contact : chris@qbittorrent.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QDebug>
|
#include "addnewtorrentdialog.h"
|
||||||
#include <QString>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QUrl>
|
|
||||||
#include <QMenu>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QPushButton>
|
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QMenu>
|
||||||
|
#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());
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -60,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());
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,8 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
|
||||||
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 {
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -23,9 +23,10 @@ LineEdit::LineEdit(QWidget *parent)
|
||||||
m_searchButton = new QToolButton(this);
|
m_searchButton = new QToolButton(this);
|
||||||
m_searchButton->setIcon(GuiIconProvider::instance()->getIcon("edit-find"));
|
m_searchButton->setIcon(GuiIconProvider::instance()->getIcon("edit-find"));
|
||||||
m_searchButton->setCursor(Qt::ArrowCursor);
|
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);
|
setClearButtonEnabled(true);
|
||||||
|
|
||||||
|
|
|
@ -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 * Utils::Gui::screenScalingFactor(this));
|
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);
|
||||||
|
|
|
@ -454,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -92,7 +92,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
|
||||||
// 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->setFixedWidth(300 * Utils::Gui::screenScalingFactor(this));
|
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);
|
||||||
|
|
||||||
|
@ -114,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
|
||||||
const int barHeight = 18 * Utils::Gui::screenScalingFactor(this);
|
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);
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
{
|
{
|
||||||
|
@ -99,6 +100,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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -35,6 +35,14 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QWindow>
|
#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)
|
qreal Utils::Gui::screenScalingFactor(const QWidget *widget)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|
|
@ -39,7 +39,15 @@ namespace Utils
|
||||||
{
|
{
|
||||||
namespace Gui
|
namespace Gui
|
||||||
{
|
{
|
||||||
|
void resize(QWidget *widget, const QSize &newSize = {});
|
||||||
qreal screenScalingFactor(const QWidget *widget);
|
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);
|
QPixmap scaledPixmap(const QString &path, const QWidget *widget, const int height = 0);
|
||||||
QSize smallIconSize(const QWidget *widget = nullptr);
|
QSize smallIconSize(const QWidget *widget = nullptr);
|
||||||
QSize mediumIconSize(const QWidget *widget = nullptr);
|
QSize mediumIconSize(const QWidget *widget = nullptr);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue