#include "global-settings.h"
#include "screen-monitor.h"

namespace Sidebar {

GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
{
}

GlobalSettings *GlobalSettings::globalInstance(QObject *parent)
{
    static GlobalSettings settings(parent);
    return &settings;
}

QVariant GlobalSettings::getValue(const QString &key) const
{
    return m_values.value(key);
}

void GlobalSettings::setValue(const QString &key, const QVariant &value)
{
    if (m_values.value(key) == value) {
        return;
    }
    m_values.insert(key, value);
    Q_EMIT valueChanged(key);
}

ScreenMonitor::ScreenMonitor(QObject *parent) : QObject(parent)
{
}

ScreenMonitor *ScreenMonitor::getInstance()
{
    static ScreenMonitor monitor;
    return &monitor;
}

bool ScreenMonitor::getScreenLockState() const
{
    return m_screenLockState;
}

bool ScreenMonitor::getSessionToolsState() const
{
    return m_sessionToolsState;
}

void ScreenMonitor::setScreenLockState(bool state)
{
    if (m_screenLockState == state) {
        return;
    }
    m_screenLockState = state;
    Q_EMIT screenLockStateChanged(state);
}

void ScreenMonitor::setSessionToolsState(bool state)
{
    if (m_sessionToolsState == state) {
        return;
    }
    m_sessionToolsState = state;
    Q_EMIT sessionToolsStateChanged(state);
}

} // namespace Sidebar
