Remove QScreen usage from non-frontend classes
This commit is contained in:
@@ -1032,7 +1032,7 @@ void LayoutSaver::Placeholder::fromVariantMap(const QVariantMap &map)
|
||||
mainWindowUniqueName = map.value(QStringLiteral("mainWindowUniqueName")).toString();
|
||||
}
|
||||
|
||||
static QScreen *screenForMainWindow(Controllers::MainWindow *mw)
|
||||
static Screen::Ptr screenForMainWindow(Controllers::MainWindow *mw)
|
||||
{
|
||||
return mw->view()->screen();
|
||||
}
|
||||
@@ -1055,7 +1055,7 @@ LayoutSaver::ScalingInfo::ScalingInfo(const QString &mainWindowId, QRect savedMa
|
||||
return;
|
||||
}
|
||||
|
||||
const int currentScreenIndex = qGuiApp->screens().indexOf(screenForMainWindow(mainWindow));
|
||||
const int currentScreenIndex = Platform::instance()->screens().indexOf(screenForMainWindow(mainWindow));
|
||||
|
||||
this->mainWindowName = mainWindowId;
|
||||
this->savedMainWindowGeometry = savedMainWindowGeo;
|
||||
|
||||
@@ -143,6 +143,9 @@ public:
|
||||
/// @brief Returns whether the left mouse button is pressed
|
||||
virtual bool isLeftMouseButtonPressed() const = 0;
|
||||
|
||||
/// @brief Returns all available screens
|
||||
virtual Screen::List screens() const = 0;
|
||||
|
||||
#ifdef DOCKS_DEVELOPER_MODE
|
||||
|
||||
struct CreateViewOptions
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#include "Platform.h"
|
||||
#include "Window.h"
|
||||
|
||||
#include <QScreen>
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
|
||||
namespace KDDockWidgets {
|
||||
@@ -333,7 +331,7 @@ void View::closeRootView()
|
||||
view->close();
|
||||
}
|
||||
|
||||
QScreen *View::screen() const
|
||||
Screen::Ptr View::screen() const
|
||||
{
|
||||
if (Window::Ptr window = this->window())
|
||||
return window->screen();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "kddockwidgets/docks_export.h"
|
||||
#include "kddockwidgets/KDDockWidgets.h"
|
||||
#include "Controller.h"
|
||||
#include "Screen.h"
|
||||
|
||||
#include <QSize> // TODOm4 Remove Qt headers, introduce Size and Rect structs
|
||||
#include <QRect>
|
||||
@@ -28,7 +29,6 @@ QT_BEGIN_NAMESPACE
|
||||
class QCloseEvent;
|
||||
class QFocusEvent;
|
||||
class QSizePolicy;
|
||||
class QScreen;
|
||||
class QPainter;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace KDDockWidgets {
|
||||
|
||||
class EventFilterInterface;
|
||||
class Controller;
|
||||
class Screen;
|
||||
class Window;
|
||||
|
||||
namespace Controllers {
|
||||
@@ -219,7 +220,7 @@ public:
|
||||
bool equals(const std::shared_ptr<View> &) const;
|
||||
static bool equals(const View *one, const View *two);
|
||||
|
||||
QScreen *screen() const;
|
||||
Screen::Ptr screen() const;
|
||||
|
||||
/// @brief Returns the views's geometry, but always in global space
|
||||
QRect globalGeometry() const;
|
||||
|
||||
@@ -12,16 +12,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "View.h"
|
||||
#include "Screen.h"
|
||||
#include "KDDockWidgets_p.h"
|
||||
|
||||
#include <QVector>
|
||||
|
||||
#include "kdbindings/signal.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QScreen;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace KDDockWidgets {
|
||||
|
||||
/// @brief Represents a top-level window
|
||||
@@ -103,7 +100,7 @@ public:
|
||||
virtual QPoint mapToGlobal(QPoint localPos) const = 0;
|
||||
|
||||
/// @brief Returns the screen this window is on
|
||||
virtual QScreen *screen() const = 0;
|
||||
virtual Screen::Ptr screen() const = 0;
|
||||
|
||||
/// Deletes the underlying window. Only used during tests.
|
||||
virtual void destroy() = 0;
|
||||
|
||||
@@ -659,7 +659,7 @@ void FloatingWindow::updateSizeConstraints()
|
||||
|
||||
void FloatingWindow::ensureRectIsOnScreen(QRect &geometry)
|
||||
{
|
||||
const auto screens = qGuiApp->screens();
|
||||
const auto screens = Platform::instance()->screens();
|
||||
if (screens.empty())
|
||||
return;
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
#include "KDDockWidgets_p.h"
|
||||
#include "kddockwidgets/KDDockWidgets.h"
|
||||
#include "kddockwidgets/LayoutSaver.h"
|
||||
#include "kddockwidgets/Platform.h"
|
||||
#include "Window.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
#include <QRect>
|
||||
#include <QScreen>
|
||||
#include <QSettings>
|
||||
|
||||
#include <memory>
|
||||
@@ -260,7 +260,7 @@ public:
|
||||
{
|
||||
s_currentLayoutBeingRestored = this;
|
||||
|
||||
const QList<QScreen *> screens = qGuiApp->screens();
|
||||
const auto screens = Platform::instance()->screens();
|
||||
const int numScreens = screens.size();
|
||||
screenInfo.reserve(numScreens);
|
||||
for (int i = 0; i < numScreens; ++i) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "kddockwidgets/View.h"
|
||||
#include "kddockwidgets/Platform.h"
|
||||
|
||||
#include <QScreen>
|
||||
#include <QWindow>
|
||||
#include <QMouseEvent>
|
||||
#include <QGuiApplication>
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include <QScopedValueRollback>
|
||||
#include <QTimer>
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef Q_CC_MSVC
|
||||
@@ -2102,7 +2101,7 @@ void ItemBoxContainer::dumpLayout(int level)
|
||||
{
|
||||
if (level == 0 && hostView()) {
|
||||
|
||||
const auto screens = qGuiApp->screens();
|
||||
const auto screens = Platform::instance()->screens();
|
||||
for (auto screen : screens) {
|
||||
qDebug().noquote() << "Screen" << screen->geometry() << screen->availableGeometry()
|
||||
<< "; drp=" << screen->devicePixelRatio();
|
||||
|
||||
@@ -494,3 +494,14 @@ Platform_qt *Platform_qt::instance()
|
||||
{
|
||||
return static_cast<Platform_qt *>(Platform::instance());
|
||||
}
|
||||
|
||||
Screen::List Platform_qt::screens() const
|
||||
{
|
||||
const auto qscreens = qGuiApp->screens();
|
||||
Screen::List screens;
|
||||
screens.reserve(qscreens.size());
|
||||
for (auto qscreen : qscreens) {
|
||||
screens.push_back(std::make_shared<Screen_qt>(qscreen));
|
||||
}
|
||||
return screens;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ public:
|
||||
DisplayType displayType() const override;
|
||||
bool isLeftMouseButtonPressed() const override;
|
||||
|
||||
Screen::List screens() const override;
|
||||
|
||||
/// @brief Returns the specified QObject casted to View
|
||||
/// Nullptr if it's not a view. TODOm3: This is shared between the
|
||||
/// QtQuick and QWidgets impl, but will be remove once we started removing Qt from backend
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "kddockwidgets/Screen_qt.h"
|
||||
#include "kddockwidgets/Window_qt.h"
|
||||
|
||||
#include <QWindow>
|
||||
@@ -108,9 +109,9 @@ QPoint Window_qt::mapToGlobal(QPoint localPos) const
|
||||
return m_window->mapToGlobal(localPos);
|
||||
}
|
||||
|
||||
QScreen *Window_qt::screen() const
|
||||
Screen::Ptr Window_qt::screen() const
|
||||
{
|
||||
return m_window->screen();
|
||||
return std::make_shared<Screen_qt>(m_window->screen());
|
||||
}
|
||||
|
||||
void Window_qt::destroy()
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "kddockwidgets/Window.h"
|
||||
#include "Screen_qt.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
@@ -47,7 +48,7 @@ public:
|
||||
|
||||
QPoint mapFromGlobal(QPoint globalPos) const override;
|
||||
QPoint mapToGlobal(QPoint localPos) const override;
|
||||
QScreen *screen() const override;
|
||||
Screen_qt::Ptr screen() const override;
|
||||
void destroy() override;
|
||||
QSize minSize() const override;
|
||||
QSize maxSize() const override;
|
||||
|
||||
Reference in New Issue
Block a user