#include "sidebarDbusService.h"

SidebarDbusService::SidebarDbusService(QWidget *parent)
{
    m_parent = parent;
    QDBusConnection::sessionBus().unregisterService("org.ukui.Sidebar");
    QDBusConnection::sessionBus().registerService("org.ukui.Sidebar");
    //注册对象路径，导出所有此对象的插槽 ,registerObject参数：路径，interface,对象，options
    QDBusConnection::sessionBus().registerObject("/org/ukui/Sidebar",this,
                                                 QDBusConnection::ExportAllSlots|QDBusConnection::ExportAllSignals);
}

void SidebarDbusService::setPresentSidebarWidth(int width)
{
    m_PresentsidebarWidth = width;
}

int SidebarDbusService::getPresentSidebarWidth()
{
    return m_PresentsidebarWidth;
}

void SidebarDbusService::setSidebarHeight(int height)
{
    m_SidebarHeight = height;
}

void SidebarDbusService::setSidebarWidth(int width)
{
    m_SidebarWidth = width;
}

int SidebarDbusService::getSidebarHeight()
{
    return m_SidebarHeight;
}

int SidebarDbusService::getSidebarWidth()
{
    return m_SidebarWidth;
}

void SidebarDbusService::setSidebarState(bool state)
{
    m_bSidebarState = state;
}

bool SidebarDbusService::getSidebarState()
{
    return m_bSidebarState;
}

void SidebarDbusService::sidebarActive()
{
    QProcess p(0);
    p.startDetached("ukui-sidebar -state");
    p.waitForStarted();
}
