// 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 "CornersPropertyGroupQuick.h"

#include <QQmlEngine>

#include "QuickStyle.h"

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

CornersPropertyGroupQuick::CornersPropertyGroupQuick(QuickStyle *style)
    : QObject()
    , m_style(style)
{
    m_topLeft = std::make_unique<CornerPropertyGroupQuick>(m_style);
    m_topRight = std::make_unique<CornerPropertyGroupQuick>(m_style);
    m_bottomLeft = std::make_unique<CornerPropertyGroupQuick>(m_style);
    m_bottomRight = std::make_unique<CornerPropertyGroupQuick>(m_style);
}

void CornersPropertyGroupQuick::update(CornersPropertyGroup *newState)
{
    if (newState == m_state) {
        return;
    }

    m_state = newState;

    if (!newState) {
        m_topLeft->update(nullptr);
        m_topRight->update(nullptr);
        m_bottomLeft->update(nullptr);
        m_bottomRight->update(nullptr);
    } else {
        m_topLeft->update(newState->topLeft());
        m_topRight->update(newState->topRight());
        m_bottomLeft->update(newState->bottomLeft());
        m_bottomRight->update(newState->bottomRight());
    }

    Q_EMIT updated();
}

void CornersPropertyGroupQuick::refreshColors()
{
    m_topLeft->refreshColors();
    m_topRight->refreshColors();
    m_bottomLeft->refreshColors();
    m_bottomRight->refreshColors();
}

CornerPropertyGroupQuick *CornersPropertyGroupQuick::topLeft() const
{
    return m_topLeft.get();
}

CornerPropertyGroupQuick *CornersPropertyGroupQuick::topRight() const
{
    return m_topRight.get();
}

CornerPropertyGroupQuick *CornersPropertyGroupQuick::bottomLeft() const
{
    return m_bottomLeft.get();
}

CornerPropertyGroupQuick *CornersPropertyGroupQuick::bottomRight() const
{
    return m_bottomRight.get();
}

#include "moc_CornersPropertyGroupQuick.cpp"