mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 02:55:44 +08:00
Utility function for screen geometry
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QDesktopWidget>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -290,6 +291,20 @@ namespace BlackGui
|
|||||||
return CGuiUtility::isUsingHighDpiScreenSupport();
|
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
|
bool CGuiApplication::saveWindowGeometryAndState(const QMainWindow *window) const
|
||||||
{
|
{
|
||||||
if (!window) { return false; }
|
if (!window) { return false; }
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
#include <QScreen>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -244,6 +245,13 @@ namespace BlackGui
|
|||||||
//! Uses the high DPI support?
|
//! Uses the high DPI support?
|
||||||
static bool isUsingHighDpiScreenSupport();
|
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
|
//! Parse scale factor if any
|
||||||
static double parseScaleFactor(int argc, char *argv[]);
|
static double parseScaleFactor(int argc, char *argv[]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user