From 4c4f5356e97cb2d62cebf6a42cfa8ce7838af882 Mon Sep 17 00:00:00 2001 From: Elias Date: Thu, 23 Jan 2020 09:48:48 +0100 Subject: [PATCH] Add refresh ability of widgets via F5 --- ScreenPlayWidget/mainWidget.qml | 15 +++++++++++++++ ScreenPlayWidget/src/widgetwindow.cpp | 5 +++++ ScreenPlayWidget/src/widgetwindow.h | 1 + 3 files changed, 21 insertions(+) diff --git a/ScreenPlayWidget/mainWidget.qml b/ScreenPlayWidget/mainWidget.qml index 41b0d30e..a9773de3 100644 --- a/ScreenPlayWidget/mainWidget.qml +++ b/ScreenPlayWidget/mainWidget.qml @@ -23,6 +23,21 @@ Item { } } + Action { + shortcut: "F5" + onTriggered: { + loader.sourceComponent = undefined + loader.source = "" + Widget.clearComponentCache() + if (Widget.type === "qmlWidget") { + loader.source = Qt.resolvedUrl(Widget.sourcePath) + } else if (Widget.type === "htmlWidget") { + loader.sourceComponent = webViewComponent + } + } + } + + OpacityAnimator { id: animFadeOut from: 1 diff --git a/ScreenPlayWidget/src/widgetwindow.cpp b/ScreenPlayWidget/src/widgetwindow.cpp index 321433f1..c4f4624a 100644 --- a/ScreenPlayWidget/src/widgetwindow.cpp +++ b/ScreenPlayWidget/src/widgetwindow.cpp @@ -90,6 +90,11 @@ void WidgetWindow::setWidgetSize(const int with, const int height) m_window.setHeight(height); } +void WidgetWindow::clearComponentCache() +{ + m_window.engine()->clearComponentCache(); +} + #ifdef Q_OS_WIN void WidgetWindow::setWindowBlur(unsigned int style) { diff --git a/ScreenPlayWidget/src/widgetwindow.h b/ScreenPlayWidget/src/widgetwindow.h index 96d784ff..ba840154 100644 --- a/ScreenPlayWidget/src/widgetwindow.h +++ b/ScreenPlayWidget/src/widgetwindow.h @@ -68,6 +68,7 @@ public slots: void setPos(int xPos, int yPos); void setClickPos(const QPoint& clickPos); void setWidgetSize(const int with, const int height); + void clearComponentCache(); void setAppID(QString appID) {