Remove the "groupViewInMDIResize" property from DockRegistry

Moved it into the QmlHelpers, as it's QtQuick specific.
Allows to remove a asQObject() call.
This commit is contained in:
Sergio Martins
2022-06-28 21:40:12 +01:00
parent 2f12cd8f3d
commit fd4431246c
7 changed files with 33 additions and 18 deletions

View File

@@ -237,14 +237,6 @@ Controllers::Group *DockRegistry::groupInMDIResize() const
return nullptr;
}
QObject *DockRegistry::groupViewInMDIResize() const
{
if (auto group = groupInMDIResize())
return group->view()->asQObject();
return nullptr;
}
Controllers::MainWindow::List DockRegistry::mainWindowsWithAffinity(const QStringList &affinities) const
{
Controllers::MainWindow::List result;

View File

@@ -48,8 +48,7 @@ struct WindowBeingDragged;
class DOCKS_EXPORT DockRegistry : public QObject
{
Q_OBJECT
Q_PROPERTY(
QObject *groupViewInMDIResize READ groupViewInMDIResize NOTIFY groupInMDIResizeChanged)
public:
enum class DockByNameFlag
{
@@ -230,12 +229,9 @@ public:
///@brief Overload that returns the SideBar itself
Controllers::SideBar *sideBarForDockWidget(const Controllers::DockWidget *) const;
///@brief Returns the Frame which is being resized in a MDI layout. nullptr if none
///@brief Returns the Group which is being resized in a MDI layout. nullptr if none
Controllers::Group *groupInMDIResize() const;
/// Returns the Frame view, for QtQuick
QObject *groupViewInMDIResize() const;
Q_SIGNALS:
/// @brief emitted when a main window or a floating window change screen
void windowChangedScreen(std::shared_ptr<Window>);

View File

@@ -10,13 +10,30 @@
*/
#include "Helpers_p.h"
#include "DockRegistry.h"
#include "controllers/Group.h"
#include "qtcommon/View_qt.h"
#include <QQuickItem>
using namespace KDDockWidgets;
QtQuickHelpers::QtQuickHelpers()
{
connect(DockRegistry::self(), &DockRegistry::groupInMDIResizeChanged,
this, &QtQuickHelpers::groupInMDIResizeChanged);
}
qreal QtQuickHelpers::logicalDpiFactor(const QQuickItem *) const
{
return 1; // TODO: Support the actual dpi factor.
// return KDDockWidgets::logicalDpiFactor(item);
}
QObject *QtQuickHelpers::groupViewInMDIResize() const
{
if (auto group = DockRegistry::self()->groupInMDIResize())
return Views::View_qt::asObject(group->view());
return nullptr;
}

View File

@@ -22,11 +22,21 @@ namespace KDDockWidgets {
class QtQuickHelpers : public QObject
{
Q_OBJECT
Q_PROPERTY(
QObject *groupViewInMDIResize READ groupViewInMDIResize NOTIFY groupInMDIResizeChanged)
Q_SIGNALS:
/// @brief emitted when the MDI group that's being resized changed
void groupInMDIResizeChanged();
public:
using QObject::QObject;
QtQuickHelpers();
Q_INVOKABLE qreal logicalDpiFactor(const QQuickItem *item) const;
QObject *groupViewInMDIResize() const;
};
}
#endif

View File

@@ -69,7 +69,7 @@ public:
private:
void init();
QQmlEngine *m_qmlEngine = nullptr;
QtQuickHelpers *const m_qquickHelpers;
QtQuickHelpers *m_qquickHelpers = nullptr;
};
inline Platform_qtquick *plat()

View File

@@ -57,9 +57,9 @@ TestView_qtquick::~TestView_qtquick() = default;
Platform_qtquick::Platform_qtquick(int &argc, char **argv)
: Platform_qt(argc, argv)
, m_qquickHelpers(new QtQuickHelpers())
{
new QGuiApplication(argc, argv);
m_qquickHelpers = new QtQuickHelpers();
init();
}

View File

@@ -26,7 +26,7 @@ Rectangle {
property bool hasCustomMouseEventRedirector: false
property int mouseResizeMargin: 8
readonly property bool isMDI: groupCpp && groupCpp.isMDI
readonly property bool resizeAllowed: root.isMDI && !_kddwDragController.isDragging && _kddwDockRegistry && (!_kddwDockRegistry.groupViewInMDIResize || _kddwDockRegistry.groupViewInMDIResize === groupCpp)
readonly property bool resizeAllowed: root.isMDI && !_kddwDragController.isDragging && _kddwDockRegistry && (!_kddwHelpers.groupViewInMDIResize || _kddwHelpers.groupViewInMDIResize === groupCpp)
property alias tabBarHeight: tabbar.height
anchors.fill: parent