Skip to content
Merged
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
19 changes: 19 additions & 0 deletions frame/dsqmlglobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@

#include <QLoggingCategory>
#include <QCoreApplication>
#include <QQueue>

Check warning on line 13 in frame/dsqmlglobal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QQueue> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWindow>

Check warning on line 14 in frame/dsqmlglobal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QGuiApplication>

Check warning on line 15 in frame/dsqmlglobal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGuiApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QTimer>

Check warning on line 16 in frame/dsqmlglobal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTimer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QQmlEngine>

Check warning on line 17 in frame/dsqmlglobal.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QQmlEngine> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#ifdef BUILD_WITH_X11
#include "private/utility_x11_p.h"
Expand Down Expand Up @@ -85,6 +87,23 @@
return DPluginLoader::instance()->rootApplet();
}

void DQmlGlobal::singleShot(int msec, QJSValue callback)
{
if (!callback.isCallable()) {
qCWarning(dsLog) << "singleShot: callback is not callable";
return;
}

QTimer::singleShot(msec, this, [callback]() {
if (callback.isCallable()) {
QJSValue result = callback.call();
if (result.isError()) {
qCWarning(dsLog) << "singleShot callback error:" << result.toString();
}
}
});
}

DQmlGlobal *DQmlGlobal::instance()
{
static DQmlGlobal *gInstance = nullptr;
Expand Down
2 changes: 2 additions & 0 deletions frame/private/dsqmlglobal_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

#include "dsglobal.h"

#include <QObject>

Check warning on line 9 in frame/private/dsqmlglobal_p.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DObject>

Check warning on line 10 in frame/private/dsqmlglobal_p.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QJSValue>

Check warning on line 11 in frame/private/dsqmlglobal_p.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QJSValue> not found. Please note: Cppcheck does not need standard library headers to get proper results.

QT_BEGIN_NAMESPACE
class QWindow;
Expand All @@ -32,6 +33,7 @@
Q_INVOKABLE static void closeChildrenWindows(QWindow *target);
Q_INVOKABLE bool grabKeyboard(QWindow *target, bool grab = true);
Q_INVOKABLE bool grabMouse(QWindow *target, bool grab = true);
Q_INVOKABLE void singleShot(int msec, QJSValue callback);

DApplet *rootApplet() const;

Expand Down
19 changes: 9 additions & 10 deletions frame/qml/PanelPopupWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,16 @@ PopupWindow {
D.DWindow.shadowOffset: Qt.point(0, 25)
D.DWindow.shadowColor: D.DTK.themeType === D.ApplicationHelper.DarkType ? Qt.rgba(0, 0, 0, 0.5) : Qt.rgba(0, 0, 0, 0.2)
D.ColorSelector.family: D.Palette.CrystalColor

color: "transparent"
onVisibleChanged: function (arg) {
if (!arg) {
currentItem = null
root.width = 10
root.height = 10
}
if (!arg)
DS.closeChildrenWindows(root)
}

onVisibleChanged: DS.singleShot(200, (function () {
if(root.visible)
return
currentItem = null
root.width = 10
root.height = 10
DS.closeChildrenWindows(root)
}))

Connections {
target: root.transientParent
Expand Down