From: Debian Multimedia Maintainers Date: Mon, 8 Jun 2020 07:17:12 +0000 (+0100) Subject: optional-qtwebengine-01-cc8201ac297ee8de90949eb0209228b0394678a0 X-Git-Tag: archive/raspbian/1%3.10.4+repack-1+rpi1~21 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9e0cc4cd1c1ad3e445e5ce3c7a129cdccf90378e;p=supercollider.git optional-qtwebengine-01-cc8201ac297ee8de90949eb0209228b0394678a0 commit cc8201ac297ee8de90949eb0209228b0394678a0 Author: Nathan Ho 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 --- diff --git a/QtCollider/CMakeLists.txt b/QtCollider/CMakeLists.txt index 4702367..0fcd017 100644 --- a/QtCollider/CMakeLists.txt +++ b/QtCollider/CMakeLists.txt @@ -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 index 0000000..2094a95 --- /dev/null +++ b/QtCollider/QcCallback.cpp @@ -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 index 0000000..31289f2 --- /dev/null +++ b/QtCollider/QcCallback.hpp @@ -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 + +namespace QtCollider { + +class QcCallback; + +class QcCallbackWeakFunctor { +public: + QcCallbackWeakFunctor(QPointer cb): _cb(cb) {} + + template void operator()(RESULT r) const; + +private: + QPointer _cb; +}; + +class QcCallback : public QObject { + Q_OBJECT + +public: + QcCallback() {} + + template void call(const CallbackT& result) { Q_EMIT(onCalled(result)); } + + QcCallbackWeakFunctor asFunctor() { return QcCallbackWeakFunctor(QPointer(this)); } + +Q_SIGNALS: + void onCalled(bool); + void onCalled(const QString&); + void onCalled(const QVariant&); + void onCalled(const QUrl&); +}; + +template void QcCallbackWeakFunctor::operator()(RESULT r) const { + if (_cb) { + _cb->call(r); + } +} + +} // namespace QtCollider + +Q_DECLARE_METATYPE(QtCollider::QcCallback*); diff --git a/QtCollider/metatype.cpp b/QtCollider/metatype.cpp index 2e45ed7..6a4873c 100644 --- a/QtCollider/metatype.cpp +++ b/QtCollider/metatype.cpp @@ -24,7 +24,7 @@ #include "Common.h" // Make sure PyrObject* is declared to QMetaType #include -#include "widgets/QcWebView.h" +#include "QcCallback.hpp" namespace QtCollider { diff --git a/QtCollider/widgets/QcWebView.cpp b/QtCollider/widgets/QcWebView.cpp index 7321255..b176ab7 100644 --- a/QtCollider/widgets/QcWebView.cpp +++ b/QtCollider/widgets/QcWebView.cpp @@ -34,7 +34,6 @@ #include QC_DECLARE_QWIDGET_FACTORY(WebView); -QC_DECLARE_QOBJECT_FACTORY(QcCallback); namespace QtCollider { diff --git a/QtCollider/widgets/QcWebView.h b/QtCollider/widgets/QcWebView.h index e286242..5174b8a 100644 --- a/QtCollider/widgets/QcWebView.h +++ b/QtCollider/widgets/QcWebView.h @@ -21,6 +21,7 @@ #pragma once +#include "../QcCallback.hpp" #include #include #include @@ -35,41 +36,6 @@ Q_DECLARE_METATYPE(QUrl) namespace QtCollider { class WebPage; -class QcCallback; - -class QcCallbackWeakFunctor { -public: - QcCallbackWeakFunctor(QPointer cb): _cb(cb) {} - - template void operator()(RESULT r) const; - -private: - QPointer _cb; -}; - -class QcCallback : public QObject { - Q_OBJECT - -public: - QcCallback() {} - - template void call(const CallbackT& result) { Q_EMIT(onCalled(result)); } - - QcCallbackWeakFunctor asFunctor() { return QcCallbackWeakFunctor(QPointer(this)); } - -Q_SIGNALS: - void onCalled(bool); - void onCalled(const QString&); - void onCalled(const QVariant&); - void onCalled(const QUrl&); -}; - -template 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*);