Skip to content

Commit

Permalink
Python: cleaned up the code for the WebBrowserWindow plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Oct 30, 2019
1 parent a829f58 commit 1a89a68
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 32 deletions.
Expand Up @@ -159,6 +159,17 @@ void WebBrowserWindowPlugin::handleUrl(const QUrl &pUrl)
// We don't handle this interface...
}

//==============================================================================
// Python interface
//==============================================================================

void WebBrowserWindowPlugin::registerPythonClasses(PyObject *pModule)
{
// Register our Python classes

new WebBrowserWindowPythonWrapper(pModule, this);
}

//==============================================================================
// Window interface
//==============================================================================
Expand Down Expand Up @@ -188,17 +199,6 @@ QDockWidget * WebBrowserWindowPlugin::windowWidget() const
return mWebBrowserWindowWindow;
}

//==============================================================================
// Python interface
//==============================================================================

void WebBrowserWindowPlugin::registerPythonClasses(PyObject *pModule)
{
// Register our Python classes

new WebBrowserWindowPythonWrapper(pModule, this);
}

//==============================================================================
// Plugin specific
//==============================================================================
Expand All @@ -207,18 +207,18 @@ WebBrowserWindowPlugin * WebBrowserWindowPlugin::instance()
{
// Return the 'global' instance of our plugin

static WebBrowserWindowPlugin pluginInstance;
static WebBrowserWindowPlugin instance;

return static_cast<WebBrowserWindowPlugin *>(Core::globalInstance("OpenCOR::WebBrowserWindow::WebBrowserWindowPlugin",
&pluginInstance));
return static_cast<WebBrowserWindowPlugin *>(Core::globalInstance("OpenCOR::WebBrowserWindow::WebBrowserWindowPlugin::instance()",
&instance));
}


//==============================================================================

WebBrowserWindowWidget * WebBrowserWindowPlugin::webBrowserWidget() const
WebBrowserWindowWidget * WebBrowserWindowPlugin::webBrowserWindowWidget() const
{
// Return our Web Browser widget
// Return our Web Browser window widget

return mWebBrowserWindowWidget;
}
Expand Down
Expand Up @@ -68,7 +68,7 @@ class WebBrowserWindowPlugin : public QObject, public I18nInterface,

static WebBrowserWindowPlugin * instance();

WebBrowserWindowWidget * webBrowserWidget() const;
WebBrowserWindowWidget * webBrowserWindowWidget() const;

private:
QAction *mWebBrowserWindowAction = nullptr;
Expand Down
Expand Up @@ -18,10 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/

//==============================================================================
// Python wrapper for web browser window
// Web Browser window Python wrapper
//==============================================================================

#include "pythonqtsupport.h"
#include "webbrowserwindowplugin.h"
#include "webbrowserwindowpythonwrapper.h"
#include "webbrowserwindowwidget.h"

//==============================================================================
Expand All @@ -30,11 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

//==============================================================================

#include "pythonqtsupport.h"
#include "webbrowserwindowpythonwrapper.h"

//==============================================================================

#include <array>

//==============================================================================
Expand All @@ -44,14 +41,14 @@ namespace WebBrowserWindow {

//==============================================================================

static PyObject * browserWebView(PyObject *pSelf, PyObject *pArgs)
static PyObject * webBrowserWindowWebView(PyObject *pSelf, PyObject *pArgs)
{
Q_UNUSED(pSelf)
Q_UNUSED(pArgs)

// Return a Python object to our Web browser's Web view
// Return a Python object to our Web browser window's Web view

return PythonQtSupport::wrapQObject(WebBrowserWindowPlugin::instance()->webBrowserWidget()->webView());
return PythonQtSupport::wrapQObject(WebBrowserWindowPlugin::instance()->webBrowserWindowWidget()->webView());
}
//==============================================================================

Expand All @@ -62,7 +59,7 @@ WebBrowserWindowPythonWrapper::WebBrowserWindowPythonWrapper(PyObject *pModule,
// Add some Python wrappers

static std::array<PyMethodDef, 2> PythonWebBrowserWindowMethods = {{
{ "browserWebView", browserWebView, METH_VARARGS, "browserWebView()\n\nReturn a QWebView of OpenCOR's web browser." },
{ "webBrowserWindowWebView", webBrowserWindowWebView, METH_VARARGS, "Return OpenCOR's Web Browser window's QWebView object." },
{ nullptr, nullptr, 0, nullptr }
}};

Expand Down
Expand Up @@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/

//==============================================================================
// Python wrapper for web browser window
// Web Browser window Python wrapper
//==============================================================================

#pragma once
Expand All @@ -36,9 +36,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//==============================================================================

namespace OpenCOR {

//==============================================================================

namespace WebBrowserWindow {

//==============================================================================
Expand Down
Expand Up @@ -261,7 +261,7 @@ void WebBrowserWindowWindow::saveSettings(QSettings &pSettings) const

//==============================================================================

WebBrowserWindowWidget *WebBrowserWindowWindow::widget() const
WebBrowserWindowWidget * WebBrowserWindowWindow::widget() const
{
return mWebBrowserWindowWidget;
}
Expand Down

0 comments on commit 1a89a68

Please sign in to comment.