File: maskmanager.cpp

package info (click to toggle)
plasma-mobile 6.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,412 kB
  • sloc: xml: 38,474; cpp: 18,529; javascript: 139; sh: 82; makefile: 5
file content (43 lines) | stat: -rw-r--r-- 1,078 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-FileCopyrightText: 2025 Micah Stanley <stanleymicah@proton.me>
// SPDX-License-Identifier: GPL-2.0-or-later

#include "maskmanager.h"
#include "masklayer.h"

MaskManager::MaskManager(QQuickItem *parent)
: QQuickItem(parent),
m_maskLayer(new MaskLayer(this))
{
}

MaskManager::~MaskManager() = default;

void MaskManager::componentComplete() {
    QQuickItem::componentComplete();
    // ensure the mask layers fill the dimensions
    m_maskLayer->setX(0);
    m_maskLayer->setY(0);
    m_maskLayer->setWidth(width());
    m_maskLayer->setHeight(height());
    m_maskLayer->setZ(z());

    connect(this, &QQuickItem::widthChanged, this, [this]() {
        m_maskLayer->setWidth(width());
    });
    connect(this, &QQuickItem::heightChanged, this, [this]() {
        m_maskLayer->setHeight(height());
    });
}

QQuickItem* MaskManager::maskLayer() const {
    return m_maskLayer;
}

void MaskManager::assignToMask(QQuickItem* item) {
    if (!item) {
        qWarning() << "Cannot assign a null item to a mask.";
        return;
    }

    m_maskLayer->addItem(item);
}