mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
Utility function for screen geometry
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <QAction>
|
||||
#include <QCloseEvent>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
@@ -290,6 +291,20 @@ namespace BlackGui
|
||||
return CGuiUtility::isUsingHighDpiScreenSupport();
|
||||
}
|
||||
|
||||
QScreen *CGuiApplication::currentScreen()
|
||||
{
|
||||
QWidget *w = CGuiApplication::mainApplicationWidget();
|
||||
const int s = QApplication::desktop()->screenNumber(w);
|
||||
if (s < QGuiApplication::screens().size()) { return QGuiApplication::screens()[s]; }
|
||||
return QGuiApplication::primaryScreen();
|
||||
}
|
||||
|
||||
QRect CGuiApplication::currentScreenGeometry()
|
||||
{
|
||||
const QScreen *s = currentScreen();
|
||||
return s->geometry();
|
||||
}
|
||||
|
||||
bool CGuiApplication::saveWindowGeometryAndState(const QMainWindow *window) const
|
||||
{
|
||||
if (!window) { return false; }
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <QDialog>
|
||||
#include <QObject>
|
||||
#include <QEvent>
|
||||
#include <QScreen>
|
||||
#include <QPixmap>
|
||||
#include <QScopedPointer>
|
||||
#include <QString>
|
||||
@@ -244,6 +245,13 @@ namespace BlackGui
|
||||
//! Uses the high DPI support?
|
||||
static bool isUsingHighDpiScreenSupport();
|
||||
|
||||
//! Current screen
|
||||
static QScreen *currentScreen();
|
||||
|
||||
//! Current screen resolution
|
||||
//! \remark logical resolution, not physical resolution
|
||||
static QRect currentScreenGeometry();
|
||||
|
||||
//! Parse scale factor if any
|
||||
static double parseScaleFactor(int argc, char *argv[]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user