mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
SideBarManager: Remove interfaces by pointer not id
This commit is contained in:
parent
791c9f6b1d
commit
abd30880a5
@ -137,8 +137,13 @@ void SideBarManager::addSidebar(const QString &id, SideBarInterface* interface)
|
||||
s_sidebars[id] = interface;
|
||||
}
|
||||
|
||||
void SideBarManager::removeSidebar(const QString &id)
|
||||
void SideBarManager::removeSidebar(SideBarInterface *interface)
|
||||
{
|
||||
const QString id = s_sidebars.key(interface);
|
||||
if (id.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
s_sidebars.remove(id);
|
||||
|
||||
foreach (BrowserWindow* window, mApp->windows()) {
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
void closeSideBar();
|
||||
|
||||
static void addSidebar(const QString &id, SideBarInterface* interface);
|
||||
static void removeSidebar(const QString &id);
|
||||
static void removeSidebar(SideBarInterface *interface);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotShowSideBar();
|
||||
|
@ -163,7 +163,7 @@ void TabManagerPlugin::setTabBarVisible(bool visible)
|
||||
void TabManagerPlugin::removeManagerWidget()
|
||||
{
|
||||
if (viewType() == ShowAsSideBar) {
|
||||
SideBarManager::removeSidebar("TabManager");
|
||||
SideBarManager::removeSidebar(m_controller);
|
||||
}
|
||||
else if (viewType() == ShowAsWindow) {
|
||||
// remove statusbar icon
|
||||
|
@ -68,7 +68,8 @@ void TestPlugin::init(InitState state, const QString &settingsPath)
|
||||
mApp->plugins()->registerAppEventHandler(PluginProxy::MousePressHandler, this);
|
||||
|
||||
// Adding new sidebar into application
|
||||
SideBarManager::addSidebar("testplugin-sidebar", new TestPlugin_Sidebar(this));
|
||||
m_sideBar = new TestPlugin_Sidebar(this);
|
||||
SideBarManager::addSidebar("testplugin-sidebar", m_sideBar);
|
||||
}
|
||||
|
||||
void TestPlugin::unload()
|
||||
@ -79,7 +80,8 @@ void TestPlugin::unload()
|
||||
// it will be also called if we return false from testPlugin()
|
||||
|
||||
// Removing sidebar from application
|
||||
SideBarManager::removeSidebar("testplugin-sidebar");
|
||||
SideBarManager::removeSidebar(m_sideBar);
|
||||
delete m_sideBar;
|
||||
|
||||
// Deleting settings dialog if opened
|
||||
delete m_settings.data();
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QPointer>
|
||||
|
||||
class TestPlugin_Sidebar;
|
||||
|
||||
class TestPlugin : public QObject, public PluginInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -53,6 +55,7 @@ private:
|
||||
|
||||
WebView* m_view;
|
||||
QString m_settingsPath;
|
||||
TestPlugin_Sidebar *m_sideBar = nullptr;
|
||||
};
|
||||
|
||||
#endif // TESTPLUGIN_H
|
||||
|
@ -80,7 +80,7 @@ void VerticalTabsPlugin::unload()
|
||||
{
|
||||
setTabBarVisible(true);
|
||||
|
||||
SideBarManager::removeSidebar(QSL("VerticalTabs"));
|
||||
SideBarManager::removeSidebar(m_controller);
|
||||
delete m_controller;
|
||||
m_controller = nullptr;
|
||||
|
||||
|
@ -41,7 +41,7 @@ class HelloPlugin(Falkon.PluginInterface, QtCore.QObject):
|
||||
def unload(self):
|
||||
print("unload")
|
||||
|
||||
Falkon.SideBarManager.removeSidebar("hellopython-sidebar")
|
||||
Falkon.SideBarManager.removeSidebar(self.sidebar)
|
||||
|
||||
for window in Falkon.MainApplication.instance().windows():
|
||||
self.mainWindowDeleted(window)
|
||||
|
Loading…
Reference in New Issue
Block a user