#include <QDBusConnection>
#include <QProcess>
#include <QDebug>
#include "sidebarstate.h"

SidebarState::SidebarState(QObject *parent) : QObject(parent)
{
    //sidebar
    QDBusConnection::sessionBus().connect(QString("org.ukui.Sidebar"),
                                          QString("/org/ukui/Sidebar"),
                                          QString("org.ukui.Sidebar"),
                                          QString("sidebarStateChange"), this, SLOT(setSidebarState(QString)));

}

bool SidebarState::sidebarState()
{
    return sidebarValue;
}

void SidebarState::setSidebarShow()
{
    if (!sidebarValue) {
        QProcess::startDetached("ukui-sidebar -state");
    }
}

void SidebarState::setSidebarState(QString state)
{
    if (state == "show") {
        sidebarValue = true;
    }
    if (state == "hide") {
        sidebarValue = false;
    }
}
