#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()
{
    QProcess::startDetached("ukui-sidebar -s control");
}

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