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()
|
||||
: m_browserAction(nullptr)
|
||||
, m_sideBar(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -40,6 +41,18 @@ void QmlPluginInterface::init(InitState state, const QString &settingsPath)
|
|||
args.append(state);
|
||||
args.append(settingsPath);
|
||||
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
|
||||
|
@ -56,10 +69,16 @@ void QmlPluginInterface::unload()
|
|||
|
||||
m_jsUnload.call();
|
||||
|
||||
for (BrowserWindow *window : mApp->windows()) {
|
||||
if (m_browserAction) {
|
||||
window->navigationBar()->removeToolButton(m_browserAction);
|
||||
for (BrowserWindow *window : mApp->windows()) {
|
||||
removeButton(window);
|
||||
}
|
||||
|
||||
disconnect(mApp->plugins(), &PluginProxy::mainWindowCreated, this, &QmlPluginInterface::addButton);
|
||||
}
|
||||
|
||||
if (m_sideBar) {
|
||||
SideBarManager::removeSidebar(m_sideBar);
|
||||
}
|
||||
|
||||
emit qmlPluginUnloaded();
|
||||
|
@ -119,7 +138,6 @@ QmlBrowserAction *QmlPluginInterface::browserAction() const
|
|||
void QmlPluginInterface::setBrowserAction(QmlBrowserAction *browserAction)
|
||||
{
|
||||
m_browserAction = browserAction;
|
||||
connect(m_browserAction, &QmlBrowserAction::locationChanged, this, &QmlPluginInterface::addButton);
|
||||
}
|
||||
|
||||
QmlSideBar *QmlPluginInterface::sideBar() const
|
||||
|
@ -130,38 +148,26 @@ QmlSideBar *QmlPluginInterface::sideBar() const
|
|||
void QmlPluginInterface::setSideBar(QmlSideBar *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)) {
|
||||
addToolButton();
|
||||
window->navigationBar()->addToolButton(m_browserAction);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
QmlBrowserAction *m_browserAction;
|
||||
QmlSideBar *m_sideBar;
|
||||
bool loaded;
|
||||
|
||||
QJSValue jsInit() const;
|
||||
void setJsInit(const QJSValue &init);
|
||||
|
@ -66,7 +67,6 @@ private:
|
|||
QmlSideBar *sideBar() const;
|
||||
void setSideBar(QmlSideBar *sideBar);
|
||||
|
||||
void addButton();
|
||||
void addToolButton();
|
||||
void addStatusBarButton();
|
||||
void addButton(BrowserWindow *window);
|
||||
void removeButton(BrowserWindow *window);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user