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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
/*
Q Light Controller Plus
vcsoloframe.cpp
Copyright (c) Massimo Callegari
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "vcsoloframe.h"
VCSoloFrame::VCSoloFrame(Doc *doc, VirtualConsole *vc, QObject *parent)
: VCFrame(doc, vc, parent)
{
setType(VCWidget::SoloFrameWidget);
}
VCSoloFrame::~VCSoloFrame()
{
}
QString VCSoloFrame::defaultCaption()
{
return tr("Solo Frame %1").arg(id() + 1);
}
void VCSoloFrame::render(QQuickView *view, QQuickItem *parent)
{
if (view == nullptr || parent == nullptr)
return;
QQmlComponent *component = new QQmlComponent(view->engine(), QUrl("qrc:/VCFrameItem.qml"));
if (component->isError())
{
qDebug() << component->errors();
return;
}
QQuickItem *item = qobject_cast<QQuickItem*>(component->create());
item->setParentItem(parent);
item->setProperty("isSolo", true);
item->setProperty("frameObj", QVariant::fromValue(this));
if (m_pagesMap.count() > 0)
{
QString chName = QString("frameDropArea%1").arg(id());
QQuickItem *childrenArea = qobject_cast<QQuickItem*>(item->findChild<QObject *>(chName));
foreach (VCWidget *child, m_pagesMap.keys())
child->render(view, childrenArea);
}
}
VCWidget *VCSoloFrame::createCopy(VCWidget *parent)
{
Q_ASSERT(parent != nullptr);
VCSoloFrame *frame = new VCSoloFrame(m_doc, m_vc, parent);
if (frame->copyFrom(this) == false)
{
delete frame;
frame = nullptr;
}
return frame;
}
bool VCSoloFrame::copyFrom(const VCWidget *widget)
{
const VCSoloFrame *frame = qobject_cast<const VCSoloFrame*> (widget);
if (frame == nullptr)
return false;
// setSoloframeMixing(frame->soloframeMixing()); // TODO
return VCFrame::copyFrom(widget);
}
/*********************************************************************
* Widget Function
*********************************************************************/
void VCSoloFrame::slotFunctionStarting(VCWidget *widget, quint32 fid, qreal intensity)
{
qDebug() << "[VCSoloFrame] requested to start a Function with ID:" << fid << intensity << widget->caption();
foreach (VCWidget *child, children(true))
{
if (child != widget)
child->notifyFunctionStarting(widget, fid, intensity);
}
widget->notifyFunctionStarting(widget, fid, intensity);
}
/*****************************************************************************
* Load & Save
*****************************************************************************/
QString VCSoloFrame::xmlTagName() const
{
return KXMLQLCVCSoloFrame;
}
|