mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Resize dialog size on high DPI monitors
This commit is contained in:
parent
aaaa67050c
commit
27cf98a962
@ -1216,9 +1216,9 @@ void Preferences::setMainLastDir(const QString &path)
|
||||
setValue("MainWindowLastDir", path);
|
||||
}
|
||||
|
||||
QSize Preferences::getPrefSize(const QSize &defaultSize) const
|
||||
QSize Preferences::getPrefSize() const
|
||||
{
|
||||
return value("Preferences/State/size", defaultSize).toSize();
|
||||
return value("Preferences/State/size").toSize();
|
||||
}
|
||||
|
||||
void Preferences::setPrefSize(const QSize &size)
|
||||
@ -1296,9 +1296,9 @@ void Preferences::setPropTrackerListState(const QByteArray &state)
|
||||
setValue("TorrentProperties/Trackers/qt5/TrackerListState", state);
|
||||
}
|
||||
|
||||
QSize Preferences::getRssGeometrySize(const QSize &defaultSize) const
|
||||
QSize Preferences::getRssGeometrySize() const
|
||||
{
|
||||
return value("RssFeedDownloader/geometrySize", defaultSize).toSize();
|
||||
return value("RssFeedDownloader/geometrySize").toSize();
|
||||
}
|
||||
|
||||
void Preferences::setRssGeometrySize(const QSize &geometry)
|
||||
|
@ -301,7 +301,7 @@ public:
|
||||
void setMainVSplitterState(const QByteArray &state);
|
||||
QString getMainLastDir() const;
|
||||
void setMainLastDir(const QString &path);
|
||||
QSize getPrefSize(const QSize &defaultSize) const;
|
||||
QSize getPrefSize() const;
|
||||
void setPrefSize(const QSize &size);
|
||||
QStringList getPrefHSplitterSizes() const;
|
||||
void setPrefHSplitterSizes(const QStringList &sizes);
|
||||
@ -317,7 +317,7 @@ public:
|
||||
void setPropVisible(const bool visible);
|
||||
QByteArray getPropTrackerListState() const;
|
||||
void setPropTrackerListState(const QByteArray &state);
|
||||
QSize getRssGeometrySize(const QSize &defaultSize) const;
|
||||
QSize getRssGeometrySize() const;
|
||||
void setRssGeometrySize(const QSize &geometry);
|
||||
QByteArray getRssHSplitterSizes() const;
|
||||
void setRssHSplitterSizes(const QByteArray &sizes);
|
||||
|
@ -103,6 +103,7 @@ public:
|
||||
label_12->setText(Utils::Misc::libtorrentVersionString());
|
||||
label_13->setText(Utils::Misc::boostVersionString());
|
||||
|
||||
Utils::Gui::resize(this);
|
||||
show();
|
||||
}
|
||||
};
|
||||
|
@ -28,36 +28,38 @@
|
||||
* Contact : chris@qbittorrent.org
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QUrl>
|
||||
#include <QMenu>
|
||||
#include <QFileDialog>
|
||||
#include <QPushButton>
|
||||
#include "addnewtorrentdialog.h"
|
||||
|
||||
#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/settingsstorage.h"
|
||||
#include "base/settingvalue.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/net/downloadhandler.h"
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/bittorrent/magneturi.h"
|
||||
#include "base/bittorrent/torrentinfo.h"
|
||||
#include "base/bittorrent/torrenthandle.h"
|
||||
#include "base/torrentfileguard.h"
|
||||
#include "base/unicodestrings.h"
|
||||
#include "base/utils/fs.h"
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/utils/string.h"
|
||||
#include "base/torrentfileguard.h"
|
||||
#include "base/unicodestrings.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "autoexpandabledialog.h"
|
||||
#include "messageboxraised.h"
|
||||
#include "proplistdelegate.h"
|
||||
#include "torrentcontentmodel.h"
|
||||
#include "torrentcontentfiltermodel.h"
|
||||
#include "torrentcontentmodel.h"
|
||||
#include "ui_addnewtorrentdialog.h"
|
||||
#include "addnewtorrentdialog.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -212,10 +214,11 @@ CachedSettingValue<int> &AddNewTorrentDialog::savePathHistoryLengthSetting()
|
||||
void AddNewTorrentDialog::loadState()
|
||||
{
|
||||
m_headerState = settings()->loadValue(KEY_TREEHEADERSTATE).toByteArray();
|
||||
int width = settings()->loadValue(KEY_WIDTH, -1).toInt();
|
||||
QSize geo = size();
|
||||
geo.setWidth(width);
|
||||
resize(geo);
|
||||
|
||||
const QSize newSize = Utils::Gui::scaledSize(this, size());
|
||||
const int width = settings()->loadValue(KEY_WIDTH, newSize.width()).toInt();
|
||||
const int height = newSize.height();
|
||||
resize(width, height);
|
||||
|
||||
ui->adv_button->setChecked(settings()->loadValue(KEY_EXPANDED).toBool());
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ui_autoexpandabledialog.h"
|
||||
#include "utils.h"
|
||||
|
||||
AutoExpandableDialog::AutoExpandableDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
@ -68,30 +69,29 @@ QString AutoExpandableDialog::getText(QWidget *parent, const QString &title, con
|
||||
void AutoExpandableDialog::showEvent(QShowEvent *e)
|
||||
{
|
||||
// Overriding showEvent is required for consistent UI with fixed size under custom DPI
|
||||
// Show dialog
|
||||
QDialog::showEvent(e);
|
||||
// and resize textbox to fit the text
|
||||
|
||||
// NOTE: For some strange reason QFontMetrics gets more accurate
|
||||
// when called from showEvent. Only 6 symbols off instead of 11 symbols off.
|
||||
int textW = m_ui->textEdit->fontMetrics().width(m_ui->textEdit->text()) + 4;
|
||||
int wd = textW;
|
||||
// Show dialog and resize textbox to fit the text
|
||||
// NOTE: For unknown reason QFontMetrics gets more accurate when called from showEvent.
|
||||
int wd = m_ui->textEdit->fontMetrics().width(m_ui->textEdit->text()) + 4;
|
||||
|
||||
if (!windowTitle().isEmpty()) {
|
||||
int w = fontMetrics().width(windowTitle());
|
||||
if (w > wd)
|
||||
wd = w;
|
||||
// not really the font metrics in window title, so we enlarge it a bit,
|
||||
// including the small icon and close button width
|
||||
int w = fontMetrics().width(windowTitle()) * 1.8;
|
||||
wd = std::max(wd, w);
|
||||
}
|
||||
|
||||
if (!m_ui->textLabel->text().isEmpty()) {
|
||||
int w = m_ui->textLabel->fontMetrics().width(m_ui->textLabel->text());
|
||||
if (w > wd)
|
||||
wd = w;
|
||||
wd = std::max(wd, w);
|
||||
}
|
||||
|
||||
// Now resize the dialog to fit the contents
|
||||
// max width of text from either of: label, title, textedit
|
||||
// If the value is less than dialog default size, default size is used
|
||||
if (wd > width())
|
||||
resize(width() - m_ui->verticalLayout->sizeHint().width() + wd, height());
|
||||
if (wd > width()) {
|
||||
QSize size = {width() - m_ui->verticalLayout->sizeHint().width() + wd, height()};
|
||||
Utils::Gui::resize(this, size);
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/utils/net.h"
|
||||
#include "ui_banlistoptions.h"
|
||||
#include "utils.h"
|
||||
|
||||
BanListOptions::BanListOptions(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
@ -52,6 +53,8 @@ BanListOptions::BanListOptions(QWidget *parent)
|
||||
m_ui->bannedIPList->setModel(m_sortFilter);
|
||||
m_ui->bannedIPList->sortByColumn(0, Qt::AscendingOrder);
|
||||
m_ui->buttonBanIP->setEnabled(false);
|
||||
|
||||
Utils::Gui::resize(this);
|
||||
}
|
||||
|
||||
BanListOptions::~BanListOptions()
|
||||
|
@ -60,7 +60,7 @@ CookiesDialog::CookiesDialog(QWidget *parent)
|
||||
m_cookiesModel->index(0, 0),
|
||||
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||
|
||||
resize(SettingsStorage::instance()->loadValue(KEY_SIZE, size()).toSize());
|
||||
Utils::Gui::resize(this, SettingsStorage::instance()->loadValue(KEY_SIZE).toSize());
|
||||
m_ui->treeView->header()->restoreState(
|
||||
SettingsStorage::instance()->loadValue(KEY_COOKIESVIEWSTATE).toByteArray());
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
|
||||
checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault());
|
||||
connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState()));
|
||||
buttonBox->button(QDialogButtonBox::Cancel)->setFocus();
|
||||
|
||||
Utils::Gui::resize(this);
|
||||
}
|
||||
|
||||
bool shouldDeleteLocalFiles() const {
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <QStringList>
|
||||
|
||||
#include "ui_downloadfromurldlg.h"
|
||||
#include "utils.h"
|
||||
|
||||
class downloadFromURL : public QDialog, private Ui::downloadFromURL
|
||||
{
|
||||
@ -82,6 +83,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL
|
||||
if (clip_txt_list_cleaned.size() > 0)
|
||||
textUrls->setText(clip_txt_list_cleaned.join("\n"));
|
||||
|
||||
Utils::Gui::resize(this);
|
||||
show();
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "base/preferences.h"
|
||||
#include "base/utils/net.h"
|
||||
#include "ui_ipsubnetwhitelistoptionsdialog.h"
|
||||
#include "utils.h"
|
||||
|
||||
IPSubnetWhitelistOptionsDialog::IPSubnetWhitelistOptionsDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
@ -57,6 +58,8 @@ IPSubnetWhitelistOptionsDialog::IPSubnetWhitelistOptionsDialog(QWidget *parent)
|
||||
m_ui->whitelistedIPSubnetList->setModel(m_sortFilter);
|
||||
m_ui->whitelistedIPSubnetList->sortByColumn(0, Qt::AscendingOrder);
|
||||
m_ui->buttonWhitelistIPSubnet->setEnabled(false);
|
||||
|
||||
Utils::Gui::resize(this);
|
||||
}
|
||||
|
||||
IPSubnetWhitelistOptionsDialog::~IPSubnetWhitelistOptionsDialog()
|
||||
|
@ -23,9 +23,10 @@ LineEdit::LineEdit(QWidget *parent)
|
||||
m_searchButton = new QToolButton(this);
|
||||
m_searchButton->setIcon(GuiIconProvider::instance()->getIcon("edit-find"));
|
||||
m_searchButton->setCursor(Qt::ArrowCursor);
|
||||
m_searchButton->setStyleSheet("QToolButton { border: none; padding: 2px; }");
|
||||
m_searchButton->setStyleSheet("QToolButton {border: none; padding: 2px;}");
|
||||
|
||||
setStyleSheet(QString("QLineEdit { padding-left: %1px; }").arg(m_searchButton->sizeHint().width())); // padding between text and widget borders
|
||||
// padding between text and widget borders
|
||||
setStyleSheet(QString("QLineEdit {padding-left: %1px;}").arg(m_searchButton->sizeHint().width()));
|
||||
|
||||
setClearButtonEnabled(true);
|
||||
|
||||
|
@ -231,7 +231,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
m_searchFilter = new LineEdit(this);
|
||||
m_searchFilterAction = m_ui->toolBar->insertWidget(m_ui->actionLock, m_searchFilter);
|
||||
m_searchFilter->setPlaceholderText(tr("Filter torrent list..."));
|
||||
m_searchFilter->setFixedWidth(200 * Utils::Gui::screenScalingFactor(this));
|
||||
m_searchFilter->setFixedWidth(Utils::Gui::scaledSize(this, 200));
|
||||
|
||||
QWidget *spacer = new QWidget(this);
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
@ -454,25 +454,19 @@ void OptionsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previo
|
||||
|
||||
void OptionsDialog::loadWindowState()
|
||||
{
|
||||
const Preferences* const pref = Preferences::instance();
|
||||
|
||||
resize(pref->getPrefSize(this->size()));
|
||||
Utils::Gui::resize(this, Preferences::instance()->getPrefSize());
|
||||
}
|
||||
|
||||
void OptionsDialog::loadSplitterState()
|
||||
{
|
||||
const Preferences* const pref = Preferences::instance();
|
||||
const QStringList sizesStr = Preferences::instance()->getPrefHSplitterSizes();
|
||||
|
||||
const QStringList sizes_str = pref->getPrefHSplitterSizes();
|
||||
QList<int> sizes;
|
||||
if (sizes_str.size() == 2) {
|
||||
sizes << sizes_str.first().toInt();
|
||||
sizes << sizes_str.last().toInt();
|
||||
}
|
||||
else {
|
||||
sizes << 116;
|
||||
sizes << m_ui->hsplitter->width() - 116;
|
||||
}
|
||||
// width has been modified, use height as width reference instead
|
||||
const int width = Utils::Gui::scaledSize(this
|
||||
, (m_ui->tabSelection->item(TAB_UI)->sizeHint().height() * 2));
|
||||
QList<int> sizes {width, (m_ui->hsplitter->width() - width)};
|
||||
if (sizesStr.size() == 2)
|
||||
sizes = {sizesStr.first().toInt(), sizesStr.last().toInt()};
|
||||
m_ui->hsplitter->setSizes(sizes);
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "base/utils/fs.h"
|
||||
#include "base/utils/misc.h"
|
||||
#include "previewlistdelegate.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define SETTINGS_KEY(name) "PreviewSelectDialog/" name
|
||||
|
||||
@ -146,7 +147,7 @@ void PreviewSelectDialog::previewButtonClicked()
|
||||
void PreviewSelectDialog::saveWindowState()
|
||||
{
|
||||
// Persist dialog size
|
||||
m_storeDialogSize = this->size();
|
||||
m_storeDialogSize = size();
|
||||
// Persist TreeView Header state
|
||||
m_storeTreeHeaderState = previewList->header()->saveState();
|
||||
}
|
||||
@ -154,9 +155,8 @@ void PreviewSelectDialog::saveWindowState()
|
||||
void PreviewSelectDialog::loadWindowState()
|
||||
{
|
||||
// Restore dialog size
|
||||
if (m_storeDialogSize.value().isValid()) {
|
||||
resize(m_storeDialogSize);
|
||||
}
|
||||
Utils::Gui::resize(this, m_storeDialogSize);
|
||||
|
||||
// Restore TreeView Header state
|
||||
if (!m_storeTreeHeaderState.value().isEmpty()) {
|
||||
m_headerStateInitialized = previewList->header()->restoreState(m_storeTreeHeaderState);
|
||||
|
@ -92,7 +92,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
|
||||
// Torrent content filtering
|
||||
m_contentFilterLine = new LineEdit(this);
|
||||
m_contentFilterLine->setPlaceholderText(tr("Filter files..."));
|
||||
m_contentFilterLine->setFixedWidth(300 * Utils::Gui::screenScalingFactor(this));
|
||||
m_contentFilterLine->setFixedWidth(Utils::Gui::scaledSize(this, 300));
|
||||
connect(m_contentFilterLine, SIGNAL(textChanged(QString)), this, SLOT(filterText(QString)));
|
||||
m_ui->contentFilterLayout->insertWidget(3, m_contentFilterLine);
|
||||
|
||||
@ -114,7 +114,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
|
||||
connect(m_ui->filesList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSettings()));
|
||||
|
||||
// set bar height relative to screen dpi
|
||||
const int barHeight = 18 * Utils::Gui::screenScalingFactor(this);
|
||||
const int barHeight = Utils::Gui::scaledSize(this, 18);
|
||||
|
||||
// Downloaded pieces progress bar
|
||||
m_ui->tempProgressBarArea->setVisible(false);
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "guiiconprovider.h"
|
||||
#include "autoexpandabledialog.h"
|
||||
#include "ui_automatedrssdownloader.h"
|
||||
#include "utils.h"
|
||||
|
||||
const QString EXT_JSON {QStringLiteral(".json")};
|
||||
const QString EXT_LEGACY {QStringLiteral(".rssrules")};
|
||||
@ -155,14 +156,14 @@ AutomatedRssDownloader::~AutomatedRssDownloader()
|
||||
void AutomatedRssDownloader::loadSettings()
|
||||
{
|
||||
const Preferences *const pref = Preferences::instance();
|
||||
resize(pref->getRssGeometrySize(this->size()));
|
||||
Utils::Gui::resize(this, pref->getRssGeometrySize());
|
||||
m_ui->hsplitter->restoreState(pref->getRssHSplitterSizes());
|
||||
}
|
||||
|
||||
void AutomatedRssDownloader::saveSettings()
|
||||
{
|
||||
Preferences *const pref = Preferences::instance();
|
||||
pref->setRssGeometrySize(this->size());
|
||||
pref->setRssGeometrySize(size());
|
||||
pref->setRssHSplitterSizes(m_ui->hsplitter->saveState());
|
||||
}
|
||||
|
||||
|
@ -31,25 +31,26 @@
|
||||
|
||||
#include "pluginselectdlg.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QDropEvent>
|
||||
#include <QFileDialog>
|
||||
#include <QHeaderView>
|
||||
#include <QImageReader>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QDropEvent>
|
||||
#include <QMimeData>
|
||||
#include <QClipboard>
|
||||
#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/misc.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/net/downloadhandler.h"
|
||||
#include "searchwidget.h"
|
||||
#include "pluginsourcedlg.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "autoexpandabledialog.h"
|
||||
#include "pluginsourcedlg.h"
|
||||
#include "searchwidget.h"
|
||||
#include "ui_pluginselectdlg.h"
|
||||
#include "utils.h"
|
||||
|
||||
enum PluginColumns
|
||||
{
|
||||
@ -99,6 +100,7 @@ PluginSelectDlg::PluginSelectDlg(SearchEngine *pluginManager, QWidget *parent)
|
||||
connect(m_pluginManager, &SearchEngine::checkForUpdatesFinished, this, &PluginSelectDlg::checkForUpdatesFinished);
|
||||
connect(m_pluginManager, &SearchEngine::checkForUpdatesFailed, this, &PluginSelectDlg::checkForUpdatesFailed);
|
||||
|
||||
Utils::Gui::resize(this);
|
||||
show();
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "pluginsourcedlg.h"
|
||||
|
||||
#include "ui_pluginsourcedlg.h"
|
||||
#include "utils.h"
|
||||
|
||||
PluginSourceDlg::PluginSourceDlg(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
@ -38,6 +39,8 @@ PluginSourceDlg::PluginSourceDlg(QWidget *parent)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
Utils::Gui::resize(this);
|
||||
show();
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "base/preferences.h"
|
||||
#include "base/utils/misc.h"
|
||||
#include "ui_shutdownconfirmdlg.h"
|
||||
#include "utils.h"
|
||||
|
||||
ShutdownConfirmDlg::ShutdownConfirmDlg(QWidget *parent, const ShutdownDialogAction &action)
|
||||
: QDialog(parent)
|
||||
@ -66,6 +67,8 @@ ShutdownConfirmDlg::ShutdownConfirmDlg(QWidget *parent, const ShutdownDialogActi
|
||||
|
||||
m_timer.setInterval(1000); // 1sec
|
||||
connect(&m_timer, SIGNAL(timeout()), this, SLOT(updateSeconds()));
|
||||
|
||||
Utils::Gui::resize(this);
|
||||
}
|
||||
|
||||
ShutdownConfirmDlg::~ShutdownConfirmDlg()
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "base/unicodestrings.h"
|
||||
#include "ui_bandwidth_limit.h"
|
||||
#include "utils.h"
|
||||
|
||||
SpeedLimitDialog::SpeedLimitDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
@ -41,6 +42,8 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent)
|
||||
// Connect to slots
|
||||
connect(m_ui->bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateSpinValue(int)));
|
||||
connect(m_ui->spinBandwidth, SIGNAL(valueChanged(int)), this, SLOT(updateSliderValue(int)));
|
||||
|
||||
Utils::Gui::resize(this);
|
||||
}
|
||||
|
||||
SpeedLimitDialog::~SpeedLimitDialog()
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/utils/string.h"
|
||||
#include "ui_statsdialog.h"
|
||||
#include "utils.h"
|
||||
|
||||
StatsDialog::StatsDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
@ -48,6 +49,7 @@ StatsDialog::StatsDialog(QWidget *parent)
|
||||
connect(BitTorrent::Session::instance(), &BitTorrent::Session::statsUpdated
|
||||
, this, &StatsDialog::update);
|
||||
|
||||
Utils::Gui::resize(this);
|
||||
show();
|
||||
}
|
||||
|
||||
|
@ -41,8 +41,8 @@
|
||||
#include "base/bittorrent/torrentinfo.h"
|
||||
#include "base/global.h"
|
||||
#include "base/utils/fs.h"
|
||||
|
||||
#include "ui_torrentcreatordlg.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define SETTINGS_KEY(name) "TorrentCreator/" name
|
||||
|
||||
@ -264,6 +264,5 @@ void TorrentCreatorDlg::loadSettings()
|
||||
m_ui->txtComment->setPlainText(m_storeComments);
|
||||
m_ui->lineEditSource->setText(m_storeSource);
|
||||
|
||||
if (m_storeDialogSize.value().isValid())
|
||||
resize(m_storeDialogSize);
|
||||
Utils::Gui::resize(this, m_storeDialogSize);
|
||||
}
|
||||
|
@ -30,9 +30,12 @@
|
||||
|
||||
#include "trackerlogin.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <libtorrent/version.hpp>
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
#include "base/bittorrent/torrenthandle.h"
|
||||
#include "utils.h"
|
||||
|
||||
trackerLogin::trackerLogin(QWidget *parent, BitTorrent::TorrentHandle *const torrent)
|
||||
: QDialog(parent)
|
||||
@ -53,6 +56,7 @@ trackerLogin::trackerLogin(QWidget *parent, BitTorrent::TorrentHandle *const tor
|
||||
connect(this, SIGNAL(trackerLoginCancelled(QPair<BitTorrent::TorrentHandle*, QString>)), // TODO: use Qt5 connect syntax
|
||||
parent, SLOT(addUnauthenticatedTracker(QPair<BitTorrent::TorrentHandle*, QString>)));
|
||||
|
||||
Utils::Gui::resize(this);
|
||||
show();
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "ui_updownratiodlg.h"
|
||||
#include "utils.h"
|
||||
|
||||
UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialRatioValue,
|
||||
qreal maxRatioValue, int initialTimeValue,
|
||||
@ -73,6 +74,8 @@ UpDownRatioDlg::UpDownRatioDlg(bool useDefault, qreal initialRatioValue,
|
||||
connect(m_ui->checkMaxTime, SIGNAL(toggled(bool)), this, SLOT(enableTimeSpin()));
|
||||
|
||||
handleRatioTypeChanged();
|
||||
|
||||
Utils::Gui::resize(this);
|
||||
}
|
||||
|
||||
void UpDownRatioDlg::accept()
|
||||
|
@ -35,6 +35,14 @@
|
||||
#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
|
||||
|
@ -39,7 +39,15 @@ 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);
|
||||
|
Loading…
Reference in New Issue
Block a user