/*
 * Copyright 2022 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with thi1s program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#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();
}
