mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
Fixed bug in init-unloading of plugins with gui
This commit is contained in:
parent
a19f23435f
commit
e626690761
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
QmlPluginInterface::QmlPluginInterface()
|
QmlPluginInterface::QmlPluginInterface()
|
||||||
: m_browserAction(nullptr)
|
: m_browserAction(nullptr)
|
||||||
|
, m_sideBar(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +41,18 @@ void QmlPluginInterface::init(InitState state, const QString &settingsPath)
|
||||||
args.append(state);
|
args.append(state);
|
||||||
args.append(settingsPath);
|
args.append(settingsPath);
|
||||||
m_jsInit.call(args);
|
m_jsInit.call(args);
|
||||||
|
|
||||||
|
if (m_browserAction) {
|
||||||
|
for (BrowserWindow *window : mApp->windows()) {
|
||||||
|
addButton(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(mApp->plugins(), &PluginProxy::mainWindowCreated, this, &QmlPluginInterface::addButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_sideBar) {
|
||||||
|
SideBarManager::addSidebar(m_sideBar->name(), m_sideBar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DesktopFile QmlPluginInterface::metaData() const
|
DesktopFile QmlPluginInterface::metaData() const
|
||||||
|
@ -56,10 +69,16 @@ void QmlPluginInterface::unload()
|
||||||
|
|
||||||
m_jsUnload.call();
|
m_jsUnload.call();
|
||||||
|
|
||||||
for (BrowserWindow *window : mApp->windows()) {
|
if (m_browserAction) {
|
||||||
if (m_browserAction) {
|
for (BrowserWindow *window : mApp->windows()) {
|
||||||
window->navigationBar()->removeToolButton(m_browserAction);
|
removeButton(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disconnect(mApp->plugins(), &PluginProxy::mainWindowCreated, this, &QmlPluginInterface::addButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_sideBar) {
|
||||||
|
SideBarManager::removeSidebar(m_sideBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit qmlPluginUnloaded();
|
emit qmlPluginUnloaded();
|
||||||
|
@ -119,7 +138,6 @@ QmlBrowserAction *QmlPluginInterface::browserAction() const
|
||||||
void QmlPluginInterface::setBrowserAction(QmlBrowserAction *browserAction)
|
void QmlPluginInterface::setBrowserAction(QmlBrowserAction *browserAction)
|
||||||
{
|
{
|
||||||
m_browserAction = browserAction;
|
m_browserAction = browserAction;
|
||||||
connect(m_browserAction, &QmlBrowserAction::locationChanged, this, &QmlPluginInterface::addButton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlSideBar *QmlPluginInterface::sideBar() const
|
QmlSideBar *QmlPluginInterface::sideBar() const
|
||||||
|
@ -130,38 +148,26 @@ QmlSideBar *QmlPluginInterface::sideBar() const
|
||||||
void QmlPluginInterface::setSideBar(QmlSideBar *sideBar)
|
void QmlPluginInterface::setSideBar(QmlSideBar *sideBar)
|
||||||
{
|
{
|
||||||
m_sideBar = sideBar;
|
m_sideBar = sideBar;
|
||||||
SideBarManager::addSidebar(m_sideBar->name(), m_sideBar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlPluginInterface::addButton()
|
void QmlPluginInterface::addButton(BrowserWindow *window)
|
||||||
{
|
{
|
||||||
if (m_browserAction->location().testFlag(QmlBrowserAction::NavigationToolBar)) {
|
if (m_browserAction->location().testFlag(QmlBrowserAction::NavigationToolBar)) {
|
||||||
addToolButton();
|
window->navigationBar()->addToolButton(m_browserAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_browserAction->location().testFlag(QmlBrowserAction::StatusBar)) {
|
if (m_browserAction->location().testFlag(QmlBrowserAction::StatusBar)) {
|
||||||
addStatusBarButton();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlPluginInterface::addToolButton()
|
|
||||||
{
|
|
||||||
for (BrowserWindow *window : mApp->windows()) {
|
|
||||||
window->navigationBar()->addToolButton(m_browserAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(mApp->plugins(), &PluginProxy::mainWindowCreated, this, [this](BrowserWindow *window){
|
|
||||||
window->navigationBar()->addToolButton(m_browserAction);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlPluginInterface::addStatusBarButton()
|
|
||||||
{
|
|
||||||
for (BrowserWindow *window : mApp->windows()) {
|
|
||||||
window->statusBar()->addButton(m_browserAction);
|
window->statusBar()->addButton(m_browserAction);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
connect(mApp->plugins(), &PluginProxy::mainWindowCreated, this, [this](BrowserWindow *window){
|
|
||||||
window->statusBar()->addButton(m_browserAction);
|
void QmlPluginInterface::removeButton(BrowserWindow *window)
|
||||||
});
|
{
|
||||||
|
if (m_browserAction->location().testFlag(QmlBrowserAction::NavigationToolBar)) {
|
||||||
|
window->navigationBar()->removeToolButton(m_browserAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_browserAction->location().testFlag(QmlBrowserAction::StatusBar)) {
|
||||||
|
window->statusBar()->removeButton(m_browserAction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ private:
|
||||||
QJSValue m_jsTestPlugin;
|
QJSValue m_jsTestPlugin;
|
||||||
QmlBrowserAction *m_browserAction;
|
QmlBrowserAction *m_browserAction;
|
||||||
QmlSideBar *m_sideBar;
|
QmlSideBar *m_sideBar;
|
||||||
|
bool loaded;
|
||||||
|
|
||||||
QJSValue jsInit() const;
|
QJSValue jsInit() const;
|
||||||
void setJsInit(const QJSValue &init);
|
void setJsInit(const QJSValue &init);
|
||||||
|
@ -66,7 +67,6 @@ private:
|
||||||
QmlSideBar *sideBar() const;
|
QmlSideBar *sideBar() const;
|
||||||
void setSideBar(QmlSideBar *sideBar);
|
void setSideBar(QmlSideBar *sideBar);
|
||||||
|
|
||||||
void addButton();
|
void addButton(BrowserWindow *window);
|
||||||
void addToolButton();
|
void removeButton(BrowserWindow *window);
|
||||||
void addStatusBarButton();
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user