Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions examples/qml-inspect/Example_Popup.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand Down Expand Up @@ -68,12 +68,6 @@ Column {
}
}
}
Button {
text: "handle forceWindowMode"
onClicked: {
popupWindow.PopupHandle.forceWindowMode = !popupWindow.PopupHandle.forceWindowMode
}
}

Popup {
id: popupWindow; objectName: "pupup window"
Expand All @@ -85,10 +79,25 @@ Column {
// width: 300
// height: 300
// margins: 100
PopupHandle.forceWindowMode: true
PopupHandle.delegate: PopupWindow {
blurControl: popupWindow
}

// Test window properties in Qt6
// popupType: Popup.Window
// PopupHandle.windowRadius: 18
// PopupHandle.borderWidth: 2
// PopupHandle.borderColor: "red"
// PopupHandle.shadowRadius: 30
// PopupHandle.shadowOffset: Qt.point(0, 4)
// PopupHandle.shadowColor: Qt.rgba(0, 0, 0, 0.5)
// PopupHandle.translucentBackground: true
// PopupHandle.enableBlurWindow: true

// Component.onCompleted: {
// console.log("=== Popup Properties ===")
// console.log("windowRadius:", PopupHandle.windowRadius)
// console.log("borderWidth:", PopupHandle.borderWidth)
// console.log("borderColor:", PopupHandle.borderColor)
// console.log("translucentBackground:", PopupHandle.translucentBackground)
// }
contentItem: Column {
spacing: 10
Text {
Expand Down Expand Up @@ -125,8 +134,6 @@ Column {
Menu {
id: menuPopup
MenuItem { text: "Text" }

PopupHandle.forceWindowMode: true
}
ArrowShapePopup {
id: arrow
Expand Down
2 changes: 0 additions & 2 deletions qmlplugin/qmlplugin_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "private/dquickiconlabel_p.h"
#include "private/dsettingscontainer_p.h"
#include "private/dmessagemanager_p.h"
#include "private/dpopupwindowhandle_p.h"
#include "private/dobjectmodelproxy_p.h"
#include "private/dquickwaterprogressattribute_p.h"
#include "private/dquickarrowboxpath_p.h"
Expand Down Expand Up @@ -208,7 +207,6 @@ void QmlpluginPlugin::registerTypes(const char *uri)
QStringLiteral("ColorSelector is only available as an attached property."));
dtkRegisterUncreatableType<DColor>(uri, implUri, 1, 0, "Color",
QStringLiteral("Color is only available as enums."));
dtkRegisterUncreatableType<DPopupWindowHandle>(uri, implUri, 1, 0, "PopupHandle", "PopupWindow Attached");
dtkRegisterUncreatableType<DPlatformHandle>(uri, implUri, 1, 0, "PlatformHandle", "PlatformHandle");

qRegisterMetaType<DQUICK_NAMESPACE::DQuickDciIcon>();
Expand Down
5 changes: 1 addition & 4 deletions qt6/src/qml/Menu.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand Down Expand Up @@ -39,9 +39,6 @@ T.Menu {

delegate: MenuItem { }

D.PopupHandle.delegate: PopupWindow {
blurControl: control
}

contentItem: FocusScope {
// QTBUG-99897 focus doesn't be clear.
Expand Down
46 changes: 45 additions & 1 deletion src/dquickwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ DQuickWindowAttached *DQuickWindow::qmlAttachedProperties(QObject *object)
if (window) {
return new DQuickWindowAttached(window);
}

// Support QQuickPopup with popupType == Window
if (object && object->inherits("QQuickPopup")) {
return new DQuickWindowAttached(object);
}

return nullptr;
}
Expand Down Expand Up @@ -131,6 +136,10 @@ bool DQuickWindowAttachedPrivate::ensurePlatformHandle()
if (handle)
return true;

if (!window) {
return false;
}

if (!DPlatformHandle::setEnabledNoTitlebarForWindow(window, true)) {
qWarning() << "Failed to enable NoTitlebar for the window:" << window;
return false;
Expand Down Expand Up @@ -179,10 +188,32 @@ void DQuickWindowAttachedPrivate::destoryPlatformHandle()
handle = nullptr;
}

void DQuickWindowAttachedPrivate::setWindow(QWindow *newWindow)
{
Q_Q(DQuickWindowAttached);

if (window == newWindow)
return;

window = newWindow;

if (newWindow) {
newWindow->installEventFilter(q);
QObject::connect(DWindowManagerHelper::instance(), SIGNAL(windowMotifWMHintsChanged(quint32)),
q, SLOT(_q_onWindowMotifHintsChanged(quint32)), Qt::UniqueConnection);

if (explicitEnable == True) {
ensurePlatformHandle();
}
}
}

void DQuickWindowAttachedPrivate::_q_onWindowMotifHintsChanged(quint32 winId)
{
D_Q(DQuickWindowAttached);

if (!q->window())
return;
if (q->window()->winId() != winId)
return;

Expand Down Expand Up @@ -339,9 +370,22 @@ DQuickWindowAttached::DQuickWindowAttached(QWindow *window)
this, SLOT(_q_onWindowMotifHintsChanged(quint32)));
}

DQuickWindowAttached::DQuickWindowAttached(QObject *popupObject)
: QObject(popupObject)
, DObject(*new DQuickWindowAttachedPrivate(nullptr, this))
{
}

QQuickWindow *DQuickWindowAttached::window() const
{
return qobject_cast<QQuickWindow *>(parent());
D_DC(DQuickWindowAttached);
return qobject_cast<QQuickWindow *>(d->window);
}

void DQuickWindowAttached::setWindow(QQuickWindow *window)
{
D_D(DQuickWindowAttached);
d->setWindow(window);
}

/*!
Expand Down
4 changes: 3 additions & 1 deletion src/dquickwindow.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2020 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later

Expand Down Expand Up @@ -80,8 +80,10 @@ class DQuickWindowAttached : public QObject, public DTK_CORE_NAMESPACE::DObject

public:
explicit DQuickWindowAttached(QWindow *window);
explicit DQuickWindowAttached(QObject *popupObject);

QQuickWindow *window() const;
void setWindow(QQuickWindow *window);
bool isEnabled() const;

int windowRadius() const;
Expand Down
Loading
Loading