Skip to content

Commit

Permalink
feat: Add QtQuick::IndicatorWindow::setQuickWindowCreationCallback
Browse files Browse the repository at this point in the history
For task #556
  • Loading branch information
iamsergio committed Dec 20, 2024
1 parent b12469d commit 7339a62
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* v2.3.0
- qtquick: Add QtQuick::IndicatorWindow::setQuickWindowCreationCallback

* v2.2.0
- qtquick: Add support for MainWindowOption_HasCentralWidget
- qtquick: Add QtQuick::FloatingWindow::setQuickWindowCreationCallback
Expand Down
11 changes: 11 additions & 0 deletions src/qtquick/views/ClassicIndicatorsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
using namespace KDDockWidgets;
using namespace KDDockWidgets::QtQuick;

IndicatorWindowCreationCallback KDDockWidgets::QtQuick::IndicatorWindow::s_quickWindowCreationCallback = {};

namespace KDDockWidgets {

static QString iconName(DropLocation loc, bool active)
Expand Down Expand Up @@ -202,6 +204,9 @@ IndicatorWindow::IndicatorWindow()
{
setFlags(flags() | Qt::FramelessWindowHint | Qt::BypassWindowManagerHint | Qt::Tool);
setColor(Qt::transparent);

if (s_quickWindowCreationCallback)
s_quickWindowCreationCallback(this);
}

IndicatorWindow::~IndicatorWindow() = default;
Expand Down Expand Up @@ -230,6 +235,12 @@ void IndicatorWindow::init(const QUrl &rootQml)
}
}

/** static */
void IndicatorWindow::setQuickWindowCreationCallback(const IndicatorWindowCreationCallback &callback)
{
s_quickWindowCreationCallback = callback;
}

QUrl ClassicDropIndicatorOverlay::qmlSouceUrl() const
{
return QUrl(QStringLiteral("qrc:/kddockwidgets/qtquick/views/qml/ClassicIndicatorsOverlay.qml"));
Expand Down
7 changes: 7 additions & 0 deletions src/qtquick/views/ClassicIndicatorsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class View;

namespace QtQuick {

using IndicatorWindowCreationCallback = std::function<void(QQuickView *window)>;
class ClassicDropIndicatorOverlay;

class IndicatorWindow : public QQuickView
Expand All @@ -35,7 +36,13 @@ class IndicatorWindow : public QQuickView
explicit IndicatorWindow();
~IndicatorWindow() override;

/// Set a callback if you want to be notified of a QQuickView being created
static void setQuickWindowCreationCallback(const IndicatorWindowCreationCallback &);

void init(const QUrl &rootQml);

private:
static IndicatorWindowCreationCallback s_quickWindowCreationCallback;
};

class ClassicDropIndicatorOverlay : public QObject, public Core::ClassicIndicatorWindowViewInterface
Expand Down

0 comments on commit 7339a62

Please sign in to comment.