mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 13:18:06 -06:00
Merge pull request #3858 from Chocobo1/screen_center
Fix dialogs didn't position on the correct screen
This commit is contained in:
@@ -1127,7 +1127,6 @@ void Preferences::setMainLastDir(const QString &path)
|
||||
setValue("MainWindowLastDir", path);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
QSize Preferences::getPrefSize(const QSize& defaultSize) const
|
||||
{
|
||||
return value("Preferences/State/size", defaultSize).toSize();
|
||||
@@ -1137,17 +1136,6 @@ void Preferences::setPrefSize(const QSize &size)
|
||||
{
|
||||
setValue("Preferences/State/size", size);
|
||||
}
|
||||
#endif
|
||||
|
||||
QPoint Preferences::getPrefPos() const
|
||||
{
|
||||
return value("Preferences/State/pos").toPoint();
|
||||
}
|
||||
|
||||
void Preferences::setPrefPos(const QPoint &pos)
|
||||
{
|
||||
setValue("Preferences/State/pos", pos);
|
||||
}
|
||||
|
||||
QStringList Preferences::getPrefHSplitterSizes() const
|
||||
{
|
||||
@@ -1219,14 +1207,14 @@ void Preferences::setPropTrackerListState(const QByteArray &state)
|
||||
setValue("TorrentProperties/Trackers/qt5/TrackerListState", state);
|
||||
}
|
||||
|
||||
QByteArray Preferences::getRssGeometry() const
|
||||
QSize Preferences::getRssGeometrySize(const QSize &defaultSize) const
|
||||
{
|
||||
return value("RssFeedDownloader/geometry").toByteArray();
|
||||
return value("RssFeedDownloader/geometrySize", defaultSize).toSize();
|
||||
}
|
||||
|
||||
void Preferences::setRssGeometry(const QByteArray &geometry)
|
||||
void Preferences::setRssGeometrySize(const QSize &geometry)
|
||||
{
|
||||
setValue("RssFeedDownloader/geometry", geometry);
|
||||
setValue("RssFeedDownloader/geometrySize", geometry);
|
||||
}
|
||||
|
||||
QByteArray Preferences::getRssHSplitterSizes() const
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QTime>
|
||||
#include <QDateTime>
|
||||
#include <QList>
|
||||
#include <QSize>
|
||||
#include <QTimer>
|
||||
#include <QReadWriteLock>
|
||||
#include <QNetworkCookie>
|
||||
@@ -274,12 +275,8 @@ public:
|
||||
void setMainVSplitterState(const QByteArray &state);
|
||||
QString getMainLastDir() const;
|
||||
void setMainLastDir(const QString &path);
|
||||
#ifndef DISABLE_GUI
|
||||
QSize getPrefSize(const QSize &defaultSize) const;
|
||||
void setPrefSize(const QSize &size);
|
||||
#endif
|
||||
QPoint getPrefPos() const;
|
||||
void setPrefPos(const QPoint &pos);
|
||||
QStringList getPrefHSplitterSizes() const;
|
||||
void setPrefHSplitterSizes(const QStringList &sizes);
|
||||
QByteArray getPeerListState() const;
|
||||
@@ -294,8 +291,8 @@ public:
|
||||
void setPropVisible(const bool visible);
|
||||
QByteArray getPropTrackerListState() const;
|
||||
void setPropTrackerListState(const QByteArray &state);
|
||||
QByteArray getRssGeometry() const;
|
||||
void setRssGeometry(const QByteArray &geometry);
|
||||
QSize getRssGeometrySize(const QSize &defaultSize) const;
|
||||
void setRssGeometrySize(const QSize &geometry);
|
||||
QByteArray getRssHSplitterSizes() const;
|
||||
void setRssHSplitterSizes(const QByteArray &sizes);
|
||||
QStringList getRssOpenFolders() const;
|
||||
|
||||
@@ -219,21 +219,15 @@ void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action)
|
||||
}
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
// Get screen center
|
||||
QPoint Utils::Misc::screenCenter(QWidget *win)
|
||||
QPoint Utils::Misc::screenCenter(const QWidget *w)
|
||||
{
|
||||
int scrn = 0;
|
||||
const QWidget *w = win->window();
|
||||
// Returns the QPoint which the widget will be placed center on screen (where parent resides)
|
||||
|
||||
if (w)
|
||||
scrn = QApplication::desktop()->screenNumber(w);
|
||||
else if (QApplication::desktop()->isVirtualDesktop())
|
||||
scrn = QApplication::desktop()->screenNumber(QCursor::pos());
|
||||
else
|
||||
scrn = QApplication::desktop()->screenNumber(win);
|
||||
|
||||
QRect desk(QApplication::desktop()->availableGeometry(scrn));
|
||||
return QPoint((desk.width() - win->frameGeometry().width()) / 2, (desk.height() - win->frameGeometry().height()) / 2);
|
||||
QWidget *parent = w->parentWidget();
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
int scrn = desktop->screenNumber(parent); // fallback to `primaryScreen` when parent is invalid
|
||||
QRect r = desktop->availableGeometry(scrn);
|
||||
return QPoint(r.x() + (r.width() - w->frameSize().width()) / 2, r.y() + (r.height() - w->frameSize().height()) / 2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Utils
|
||||
void openPath(const QString& absolutePath);
|
||||
void openFolderSelect(const QString& absolutePath);
|
||||
|
||||
QPoint screenCenter(QWidget *win);
|
||||
QPoint screenCenter(const QWidget *w);
|
||||
QSize smallIconSize();
|
||||
QSize largeIconSize();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user