Commit f2ad6bcc authored by Xaver Hugl's avatar Xaver Hugl
Browse files

move ColorManager singleton to Application

parent 9337f145
......@@ -15,17 +15,14 @@
namespace KWin
{
KWIN_SINGLETON_FACTORY(ColorManager)
class ColorManagerPrivate
{
public:
QVector<ColorDevice *> devices;
};
ColorManager::ColorManager(QObject *parent)
: QObject(parent)
, d(new ColorManagerPrivate)
ColorManager::ColorManager()
: d(std::make_unique<ColorManagerPrivate>())
{
Platform *platform = kwinApp()->platform();
Session *session = platform->session();
......@@ -40,10 +37,7 @@ ColorManager::ColorManager(QObject *parent)
connect(session, &Session::activeChanged, this, &ColorManager::handleSessionActiveChanged);
}
ColorManager::~ColorManager()
{
s_self = nullptr;
}
ColorManager::~ColorManager() = default;
QVector<ColorDevice *> ColorManager::devices() const
{
......
......@@ -9,6 +9,7 @@
#include "kwinglobals.h"
#include <QObject>
#include <memory>
namespace KWin
{
......@@ -25,6 +26,7 @@ class KWIN_EXPORT ColorManager : public QObject
Q_OBJECT
public:
ColorManager();
~ColorManager() override;
/**
......@@ -55,8 +57,7 @@ private Q_SLOTS:
void handleSessionActiveChanged(bool active);
private:
QScopedPointer<ColorManagerPrivate> d;
KWIN_SINGLETON(ColorManager)
std::unique_ptr<ColorManagerPrivate> d;
};
} // namespace KWin
......@@ -271,7 +271,7 @@ void Application::createPlugins()
void Application::createColorManager()
{
ColorManager::create(this);
m_colorManager = std::make_unique<ColorManager>();
}
void Application::createInputMethod()
......@@ -311,7 +311,7 @@ void Application::destroyPlugins()
void Application::destroyColorManager()
{
delete ColorManager::self();
m_colorManager.reset();
}
void Application::destroyInputMethod()
......@@ -572,4 +572,9 @@ InputMethod *Application::inputMethod() const
return m_inputMethod.get();
}
ColorManager *Application::colorManager() const
{
return m_colorManager.get();
}
} // namespace
......@@ -31,6 +31,7 @@ class Platform;
class X11EventFilter;
class PluginManager;
class InputMethod;
class ColorManager;
class XcbEventFilter : public QAbstractNativeEventFilter
{
......@@ -243,6 +244,7 @@ public:
PluginManager *pluginManager() const;
InputMethod *inputMethod() const;
ColorManager *colorManager() const;
Q_SIGNALS:
void x11ConnectionChanged();
......@@ -301,6 +303,7 @@ private:
QProcessEnvironment m_processEnvironment;
std::unique_ptr<PluginManager> m_pluginManager;
std::unique_ptr<InputMethod> m_inputMethod;
std::unique_ptr<ColorManager> m_colorManager;
};
inline static Application *kwinApp()
......
......@@ -54,7 +54,7 @@ void ColordDevice::updateProfile()
return;
}
ColorDevice *device = ColorManager::self()->findDevice(m_output);
ColorDevice *device = kwinApp()->colorManager()->findDevice(m_output);
if (device) {
device->setProfile(profile.filename());
}
......
......@@ -114,7 +114,7 @@ void NightColorManager::init()
KGlobalAccel::setGlobalShortcut(toggleAction, QList<QKeySequence>());
input()->registerShortcut(QKeySequence(), toggleAction, this, &NightColorManager::toggle);
connect(ColorManager::self(), &ColorManager::deviceAdded, this, &NightColorManager::hardReset);
connect(kwinApp()->colorManager(), &ColorManager::deviceAdded, this, &NightColorManager::hardReset);
connect(kwinApp()->platform()->session(), &Session::activeChanged, this, [this](bool active) {
if (active) {
......@@ -671,7 +671,7 @@ int NightColorManager::currentTargetTemp() const
void NightColorManager::commitGammaRamps(int temperature)
{
const QVector<ColorDevice *> devices = ColorManager::self()->devices();
const QVector<ColorDevice *> devices = kwinApp()->colorManager()->devices();
for (ColorDevice *device : devices) {
device->setTemperature(temperature);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment