/* SPDX-FileCopyrightText: 2023 Marco Martin SPDX-License-Identifier: LGPL-2.0-or-later */ #include "dialogbackground_p.h" #include #include #include "sharedqmlengine.h" namespace PlasmaQuick { DialogBackground::DialogBackground(QQuickItem *parent) : QQuickItem(parent) , m_sharedEngine(new SharedQmlEngine(this)) { QQmlComponent component(m_sharedEngine->engine().get(), "org.kde.plasma.core", "DialogBackground"); QVariantHash props({{QStringLiteral("parent"), QVariant::fromValue(this)}}); QObject *object = m_sharedEngine->createObjectFromComponent(&component, m_sharedEngine->rootContext(), props); m_frameSvgItem = qobject_cast(object); Q_ASSERT(m_frameSvgItem); connect(m_frameSvgItem, SIGNAL(maskChanged()), this, SIGNAL(maskChanged())); connect(m_frameSvgItem->property("fixedMargins").value(), SIGNAL(marginsChanged()), this, SIGNAL(fixedMarginsChanged())); } DialogBackground::~DialogBackground() { delete m_frameSvgItem; } QString DialogBackground::imagePath() const { return m_frameSvgItem->property("imagePath").toString(); } void DialogBackground::setImagePath(const QString &path) { m_frameSvgItem->setProperty("imagePath", path); } void DialogBackground::setEnabledBorders(const KSvg::FrameSvg::EnabledBorders borders) { m_frameSvgItem->setProperty("enabledBorders", QVariant::fromValue(borders)); } KSvg::FrameSvg::EnabledBorders DialogBackground::enabledBorders() const { return m_frameSvgItem->property("enabledBorders").value(); } QRegion DialogBackground::mask() const { return m_frameSvgItem->property("mask").value(); } qreal DialogBackground::leftMargin() const { // assume margins is valid, as we asserted it's a valid FrameSvgItem QObject *margins = m_frameSvgItem->property("fixedMargins").value(); return margins->property("left").value(); } qreal DialogBackground::topMargin() const { QObject *margins = m_frameSvgItem->property("fixedMargins").value(); return margins->property("top").value(); } qreal DialogBackground::rightMargin() const { QObject *margins = m_frameSvgItem->property("fixedMargins").value(); return margins->property("right").value(); } qreal DialogBackground::bottomMargin() const { QObject *margins = m_frameSvgItem->property("fixedMargins").value(); return margins->property("bottom").value(); } QObject *DialogBackground::fixedMargins() const { return m_frameSvgItem->property("fixedMargins").value(); } QObject *DialogBackground::inset() const { return m_frameSvgItem->property("inset").value(); } } #include "moc_dialogbackground_p.cpp"