// SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
// SPDX-FileCopyrightText: 2024 Arjen Hiemstra <ahiemstra@heimr.nl>
//
// This file is automatically generated from qml_group.cpp.j2.
// To regenerate, run `tools/propertygenerator/generate_properties.py`.

#include "BorderPropertyGroupQuick.h"

#include <QQmlEngine>

#include "QuickStyle.h"

using namespace Union::Properties;
using namespace Union::Quick;
using namespace Qt::StringLiterals;

BorderPropertyGroupQuick::BorderPropertyGroupQuick(QuickStyle *style)
    : QObject()
    , m_style(style)
{
    m_left = std::make_unique<LinePropertyGroupQuick>(m_style);
    m_right = std::make_unique<LinePropertyGroupQuick>(m_style);
    m_top = std::make_unique<LinePropertyGroupQuick>(m_style);
    m_bottom = std::make_unique<LinePropertyGroupQuick>(m_style);
}

void BorderPropertyGroupQuick::update(BorderPropertyGroup *newState)
{
    if (newState == m_state) {
        return;
    }

    m_state = newState;

    if (!newState) {
        m_left->update(nullptr);
        m_right->update(nullptr);
        m_top->update(nullptr);
        m_bottom->update(nullptr);
    } else {
        m_left->update(newState->left());
        m_right->update(newState->right());
        m_top->update(newState->top());
        m_bottom->update(newState->bottom());
    }

    Q_EMIT updated();
}

void BorderPropertyGroupQuick::refreshColors()
{
    m_left->refreshColors();
    m_right->refreshColors();
    m_top->refreshColors();
    m_bottom->refreshColors();
}

LinePropertyGroupQuick *BorderPropertyGroupQuick::left() const
{
    return m_left.get();
}

LinePropertyGroupQuick *BorderPropertyGroupQuick::right() const
{
    return m_right.get();
}

LinePropertyGroupQuick *BorderPropertyGroupQuick::top() const
{
    return m_top.get();
}

LinePropertyGroupQuick *BorderPropertyGroupQuick::bottom() const
{
    return m_bottom.get();
}

#include "moc_BorderPropertyGroupQuick.cpp"