optional-qtwebengine-01-cc8201ac297ee8de90949eb0209228b0394678a0
authorDebian Multimedia Maintainers <debian-multimedia@lists.debian.org>
Sat, 29 Jun 2019 01:02:25 +0000 (02:02 +0100)
committerPeter Michael Green <plugwash@raspbian.org>
Sat, 29 Jun 2019 01:02:25 +0000 (02:02 +0100)
commit cc8201ac297ee8de90949eb0209228b0394678a0
Author: Nathan Ho <nathan@snappizz.com>
Date:   Sun Jun 2 01:42:20 2019 -0700

    sclang: Refactor QcCallback declaration out of QcWebView

    This commit relocates QcCallback out of the QcWebView header. QcCallback is not specific to WebView.

    Also removes a dangerous "using" in header file.

Gbp-Pq: Name optional-qtwebengine-01-cc8201ac297ee8de90949eb0209228b0394678a0

QtCollider/CMakeLists.txt
QtCollider/QcCallback.cpp [new file with mode: 0644]
QtCollider/QcCallback.hpp [new file with mode: 0644]
QtCollider/metatype.cpp
QtCollider/widgets/QcWebView.cpp
QtCollider/widgets/QcWebView.h

index 4702367a2209c9e46037f8be37efb4c15093ee9c..0fcd01726a8096517e878616fecf105cce563712 100644 (file)
@@ -41,6 +41,7 @@ set( QT_COLLIDER_HDRS
   ${QT_COLLIDER_DIR}/QObjectProxy.h
   ${QT_COLLIDER_DIR}/QWidgetProxy.h
   ${QT_COLLIDER_DIR}/QtDownload.h
+  ${QT_COLLIDER_DIR}/QcCallback.hpp
   ${QT_COLLIDER_DIR}/widgets/BasicWidgets.h
   ${QT_COLLIDER_DIR}/widgets/QcButton.h
   ${QT_COLLIDER_DIR}/widgets/QcCheckBox.h
@@ -85,6 +86,7 @@ set( QT_COLLIDER_SRCS
   ${QT_COLLIDER_DIR}/QWidgetProxy.cpp
   ${QT_COLLIDER_DIR}/QcObjectFactory.cpp
   ${QT_COLLIDER_DIR}/QtDownload.cpp
+  ${QT_COLLIDER_DIR}/QcCallback.cpp
   ${QT_COLLIDER_DIR}/hacks/hacks_x11.cpp
   ${QT_COLLIDER_DIR}/primitives/primitives.cpp
   ${QT_COLLIDER_DIR}/primitives/prim_QObject.cpp
diff --git a/QtCollider/QcCallback.cpp b/QtCollider/QcCallback.cpp
new file mode 100644 (file)
index 0000000..2094a95
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+    SuperCollider Language
+    Copyright (c) 2018 SuperCollider Team
+    https://supercollider.github.io/
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#include "QcCallback.hpp"
+#include "QcObjectFactory.h"
+
+QC_DECLARE_QOBJECT_FACTORY(QcCallback);
diff --git a/QtCollider/QcCallback.hpp b/QtCollider/QcCallback.hpp
new file mode 100644 (file)
index 0000000..31289f2
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+    SuperCollider Language
+    Copyright (c) 2018 SuperCollider Team
+    https://supercollider.github.io/
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#pragma once
+
+#include <QPointer>
+
+namespace QtCollider {
+
+class QcCallback;
+
+class QcCallbackWeakFunctor {
+public:
+    QcCallbackWeakFunctor(QPointer<QcCallback> cb): _cb(cb) {}
+
+    template <typename RESULT> void operator()(RESULT r) const;
+
+private:
+    QPointer<QcCallback> _cb;
+};
+
+class QcCallback : public QObject {
+    Q_OBJECT
+
+public:
+    QcCallback() {}
+
+    template <typename CallbackT> void call(const CallbackT& result) { Q_EMIT(onCalled(result)); }
+
+    QcCallbackWeakFunctor asFunctor() { return QcCallbackWeakFunctor(QPointer<QcCallback>(this)); }
+
+Q_SIGNALS:
+    void onCalled(bool);
+    void onCalled(const QString&);
+    void onCalled(const QVariant&);
+    void onCalled(const QUrl&);
+};
+
+template <typename RESULT> void QcCallbackWeakFunctor::operator()(RESULT r) const {
+    if (_cb) {
+        _cb->call(r);
+    }
+}
+
+} // namespace QtCollider
+
+Q_DECLARE_METATYPE(QtCollider::QcCallback*);
index 2e45ed780a824e2c68b68e2dc9b3edab1f84f6a8..6a4873c749f8fd1b2964f3f0bf46aa47da7c32d1 100644 (file)
@@ -24,7 +24,7 @@
 #include "Common.h" // Make sure PyrObject* is declared to QMetaType
 #include <PyrKernel.h>
 
-#include "widgets/QcWebView.h"
+#include "QcCallback.hpp"
 
 namespace QtCollider {
 
index 7321255d06558b5b8b4291ac424c5e93397eef5d..b176ab795e861a2ff3dafa0205410a5ed1de0fa8 100644 (file)
@@ -34,7 +34,6 @@
 #include <QWebEngineCallback>
 
 QC_DECLARE_QWIDGET_FACTORY(WebView);
-QC_DECLARE_QOBJECT_FACTORY(QcCallback);
 
 namespace QtCollider {
 
index e28624200b622c018a2d641380eceb9ea70527bc..5174b8acd9505cd48189cc98cac24f317c59372c 100644 (file)
@@ -21,6 +21,7 @@
 
 #pragma once
 
+#include "../QcCallback.hpp"
 #include <QWebEngineView>
 #include <QWebEnginePage>
 #include <QWebEngineCallback>
@@ -35,41 +36,6 @@ Q_DECLARE_METATYPE(QUrl)
 namespace QtCollider {
 
 class WebPage;
-class QcCallback;
-
-class QcCallbackWeakFunctor {
-public:
-    QcCallbackWeakFunctor(QPointer<QcCallback> cb): _cb(cb) {}
-
-    template <typename RESULT> void operator()(RESULT r) const;
-
-private:
-    QPointer<QcCallback> _cb;
-};
-
-class QcCallback : public QObject {
-    Q_OBJECT
-
-public:
-    QcCallback() {}
-
-    template <typename CallbackT> void call(const CallbackT& result) { Q_EMIT(onCalled(result)); }
-
-    QcCallbackWeakFunctor asFunctor() { return QcCallbackWeakFunctor(QPointer<QcCallback>(this)); }
-
-Q_SIGNALS:
-    void onCalled(bool);
-    void onCalled(const QString&);
-    void onCalled(const QVariant&);
-    void onCalled(const QUrl&);
-};
-
-template <typename RESULT> void QcCallbackWeakFunctor::operator()(RESULT r) const {
-    if (_cb) {
-        _cb->call(r);
-    }
-}
-
 
 class WebView : public QWebEngineView {
     Q_OBJECT
@@ -190,6 +156,3 @@ private:
 };
 
 } // namespace QtCollider
-
-using namespace QtCollider;
-Q_DECLARE_METATYPE(QcCallback*);