move PluginManager singleton to Application
This commit is contained in:
parent
4121d45c42
commit
45d4677973
5 changed files with 17 additions and 13 deletions
|
@ -266,7 +266,7 @@ void Application::createOptions()
|
|||
|
||||
void Application::createPlugins()
|
||||
{
|
||||
PluginManager::create(this);
|
||||
m_pluginManager = std::make_unique<PluginManager>();
|
||||
}
|
||||
|
||||
void Application::createColorManager()
|
||||
|
@ -306,7 +306,7 @@ void Application::destroyCompositor()
|
|||
|
||||
void Application::destroyPlugins()
|
||||
{
|
||||
delete PluginManager::self();
|
||||
m_pluginManager.reset();
|
||||
}
|
||||
|
||||
void Application::destroyColorManager()
|
||||
|
@ -562,4 +562,9 @@ void Application::initPlatform(const KPluginMetaData &plugin)
|
|||
}
|
||||
}
|
||||
|
||||
PluginManager *Application::pluginManager() const
|
||||
{
|
||||
return m_pluginManager.get();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <kwinglobals.h>
|
||||
|
||||
#include <KSharedConfig>
|
||||
#include <memory>
|
||||
// Qt
|
||||
#include <QAbstractNativeEventFilter>
|
||||
#include <QApplication>
|
||||
|
@ -28,6 +29,7 @@ namespace KWin
|
|||
|
||||
class Platform;
|
||||
class X11EventFilter;
|
||||
class PluginManager;
|
||||
|
||||
class XcbEventFilter : public QAbstractNativeEventFilter
|
||||
{
|
||||
|
@ -238,6 +240,8 @@ public:
|
|||
static void setupMalloc();
|
||||
static void setupLocalizedString();
|
||||
|
||||
PluginManager *pluginManager() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void x11ConnectionChanged();
|
||||
void x11ConnectionAboutToBeDestroyed();
|
||||
|
@ -293,6 +297,7 @@ private:
|
|||
bool m_terminating = false;
|
||||
qreal m_xwaylandScale = 1;
|
||||
QProcessEnvironment m_processEnvironment;
|
||||
std::unique_ptr<PluginManager> m_pluginManager;
|
||||
};
|
||||
|
||||
inline static Application *kwinApp()
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_SINGLETON_FACTORY(PluginManager)
|
||||
|
||||
static const QString s_pluginDirectory = QStringLiteral("kwin/plugins");
|
||||
|
||||
static QJsonValue readPluginInfo(const QJsonObject &metadata, const QString &key)
|
||||
|
@ -26,8 +24,7 @@ static QJsonValue readPluginInfo(const QJsonObject &metadata, const QString &key
|
|||
return metadata.value(QLatin1String("KPlugin")).toObject().value(key);
|
||||
}
|
||||
|
||||
PluginManager::PluginManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
PluginManager::PluginManager()
|
||||
{
|
||||
const KConfigGroup config(kwinApp()->config(), QStringLiteral("Plugins"));
|
||||
|
||||
|
@ -77,10 +74,7 @@ PluginManager::PluginManager(QObject *parent)
|
|||
new PluginManagerDBusInterface(this);
|
||||
}
|
||||
|
||||
PluginManager::~PluginManager()
|
||||
{
|
||||
s_self = nullptr;
|
||||
}
|
||||
PluginManager::~PluginManager() = default;
|
||||
|
||||
QStringList PluginManager::loadedPlugins() const
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@ class KWIN_EXPORT PluginManager : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PluginManager();
|
||||
~PluginManager() override;
|
||||
|
||||
QStringList loadedPlugins() const;
|
||||
|
@ -45,7 +46,6 @@ private:
|
|||
|
||||
std::map<QString, std::unique_ptr<Plugin>> m_plugins;
|
||||
QHash<QString, QStaticPlugin> m_staticPlugins;
|
||||
KWIN_SINGLETON(PluginManager)
|
||||
};
|
||||
|
||||
} // namespace KWin
|
||||
|
|
|
@ -1724,14 +1724,14 @@ QString Workspace::supportInformation() const
|
|||
}
|
||||
support.append(QLatin1String("\nLoaded Plugins:\n"));
|
||||
support.append(QLatin1String("---------------\n"));
|
||||
QStringList loadedPlugins = PluginManager::self()->loadedPlugins();
|
||||
QStringList loadedPlugins = kwinApp()->pluginManager()->loadedPlugins();
|
||||
loadedPlugins.sort();
|
||||
for (const QString &plugin : qAsConst(loadedPlugins)) {
|
||||
support.append(plugin + QLatin1Char('\n'));
|
||||
}
|
||||
support.append(QLatin1String("\nAvailable Plugins:\n"));
|
||||
support.append(QLatin1String("------------------\n"));
|
||||
QStringList availablePlugins = PluginManager::self()->availablePlugins();
|
||||
QStringList availablePlugins = kwinApp()->pluginManager()->availablePlugins();
|
||||
availablePlugins.sort();
|
||||
for (const QString &plugin : qAsConst(availablePlugins)) {
|
||||
support.append(plugin + QLatin1Char('\n'));
|
||||
|
|
Loading…
Reference in a new issue