/*
 * SPDX-FileCopyrightText: 2024 Paul A McAuley <kde@paulmcauley.com>
 *
 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
 */

#ifndef BREEZE_DBUSMESSAGES_H
#define BREEZE_DBUSMESSAGES_H

#include <QDBusConnection>
#include <QDBusMessage>

namespace Breeze
{

class DBusMessages
{
public:
    static void kwinReloadConfig()
    {
        // needed to tell Decoration::reconfigure to reload when running from external kcmshell
        QDBusMessage message(QDBusMessage::createSignal(QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig")));
        QDBusConnection::sessionBus().send(message);
    }

    static void kstyleReloadDecorationConfig()
    {
        // needed for lingmo application style to reload shadows
        QDBusMessage message(
            QDBusMessage::createSignal(QStringLiteral("/LingmoDecoration"), QStringLiteral("org.kde.Lingmo.Style"), QStringLiteral("reparseConfiguration")));
        QDBusConnection::sessionBus().send(message);
    }

    static void kstyleReloadConfig()
    {
        QDBusMessage message(
            QDBusMessage::createSignal(QStringLiteral("/LingmoStyle"), QStringLiteral("org.kde.Lingmo.Style"), QStringLiteral("reparseConfiguration")));
        QDBusConnection::sessionBus().send(message);
    }

    static void updateDecorationColorCache()
    {
        QDBusMessage message(QDBusMessage::createSignal(QStringLiteral("/LingmoDecoration"),
                                                        QStringLiteral("org.kde.Lingmo.Style"),
                                                        QStringLiteral("updateDecorationColorCache")));
        QDBusConnection::sessionBus().send(message);
    }

    static void setGtkTheme(QString themeName)
    {
        QDBusMessage message(QDBusMessage::createMethodCall(QStringLiteral("org.kde.GtkConfig"),
                                                            QStringLiteral("/GtkConfig"),
                                                            QStringLiteral("org.kde.GtkConfig"),
                                                            QStringLiteral("setGtkTheme")));
        message.setArguments(QList{QVariant(themeName)});
        QDBusConnection::sessionBus().send(message);
    }
};

}

#endif
