Skip to content

Commit

Permalink
Let plugins get access to the note of the current window
Browse files Browse the repository at this point in the history
fixes WizTeam#636

Signed-off-by: Robin Lee <[email protected]>
  • Loading branch information
Robin Lee committed Apr 30, 2021
1 parent 7067bcf commit 9dd1971
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion share/plugins/Note.Outline/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
pluginData = window.WizPluginData;
pluginPath = pluginData.path;
objWindow = objApp.Window;
browserObject = objWindow.CurrentDocumentBrowserObject;
browserObject = window.WizDocumentBrowser;
strings = JSON.parse(pluginData.strings);
objApp.LoadStringFromFile = LoadStringFromFile;
//
Expand Down
6 changes: 4 additions & 2 deletions src/WizPlugins.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "WizPlugins.h"
#include "sync/WizToken.h"
#include "WizMainWindow.h"
#include "WizDocumentWebView.h"
#include "share/WizGlobal.h"
#include "utils/WizPathResolve.h"
#include "widgets/WizLocalProgressWebView.h"
Expand Down Expand Up @@ -321,15 +322,16 @@ void WizPluginData::initStrings()
}


WizPluginPopupWidget::WizPluginPopupWidget(WizExplorerApp& app, WizPluginData* data, QWidget* parent)
WizPluginPopupWidget::WizPluginPopupWidget(WizExplorerApp& app, WizPluginData* data, WizDocumentWebView* web, QWidget* parent)
: WizPopupWidget(parent)
, m_data(data)
{
data->initStrings();
//
WizWebEngineViewInjectObjects objects = {
{"WizPluginData", m_data},
{"WizExplorerApp", app.object()}
{"WizExplorerApp", app.object()},
{"WizDocumentBrowser", web}
};
m_web = WizWebEngineView::create(objects, this);
//
Expand Down
3 changes: 2 additions & 1 deletion src/WizPlugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class WizWebEngineView;
class WizExplorerApp;
class WizPluginPopupWidget;
class WizDocumentWebView;

class WizPluginData : public QObject
{
Expand Down Expand Up @@ -50,7 +51,7 @@ class WizPluginData : public QObject
class WizPluginPopupWidget : public WizPopupWidget
{
public:
WizPluginPopupWidget(WizExplorerApp& app, WizPluginData* data, QWidget* parent);
WizPluginPopupWidget(WizExplorerApp& app, WizPluginData* data, WizDocumentWebView* web, QWidget* parent);
public:
WizWebEngineView* web() const {return m_web; }
private:
Expand Down
4 changes: 3 additions & 1 deletion src/WizTitleBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ void WizTitleBar::onPluginButtonClicked()
auto it = m_pluginWidget.find(guid);
WizPluginPopupWidget* widget;
if (it == m_pluginWidget.end()) {
widget = new WizPluginPopupWidget(m_app, data, this);
// passing the current note
WizDocumentWebView* web = noteView()->web();
widget = new WizPluginPopupWidget(m_app, data, web, this);
m_pluginWidget.insert(std::make_pair(guid, widget));
} else {
widget = it->second;
Expand Down

0 comments on commit 9dd1971

Please sign in to comment.