Skip to content

Commit

Permalink
Implement flash properties for qml ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Wazzledi committed Oct 19, 2023
1 parent 469ed51 commit dc1e9a6
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 1 deletion.
92 changes: 92 additions & 0 deletions qmlui/qml/virtualconsole/VCProperties.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
Q Light Controller Plus
SettingsViewDMX.qml
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.
*/

import QtQuick 2.0
import QtQuick.Layouts 1.1

import org.qlcplus.classes 1.0
import "."

Rectangle
{
id: propertyRoot
width: mainView.width / 5
height: parent.height

color: UISettings.bgMedium
border.width: 1
border.color: "#222"

property bool flashOverrides: virtualConsole.flashOverrides
property bool flashForceLTP: virtualConsole.flashForceLTP

GridLayout
{
id: propertiesLayout
width: propertyRoot.width
columns: 2
columnSpacing: 5
rowSpacing: 5

// row 1
Rectangle
{
height: UISettings.listItemHeight
Layout.fillWidth: true
color: UISettings.sectionHeader
Layout.columnSpan: 2

RobotoText
{
x: 5
anchors.verticalCenter: parent.verticalCenter
label: qsTr("Virtual Console Settings")
}
}

// row 2
RobotoText
{
leftMargin: 5
label: qsTr("Flash Override Priority")
}
CustomCheckBox
{
implicitHeight: UISettings.listItemHeight
implicitWidth: implicitHeight
checked: flashOverrides
onToggled: virtualConsole.flashOverrides = checked
}


// row 2
RobotoText
{
leftMargin: 5
label: qsTr("Flash Force LTP")
}
CustomCheckBox
{
implicitHeight: UISettings.listItemHeight
implicitWidth: implicitHeight
checked: flashForceLTP
onToggled: virtualConsole.flashForceLTP = checked
}
}
}
29 changes: 28 additions & 1 deletion qmlui/qml/virtualconsole/VirtualConsole.qml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ Rectangle
pageLoader.source = "qrc:/VCPageArea.qml"
}

function showProperties(show)
{
vcProperties.visible = show
}

function enableContext(ctx, setChecked)
{
console.log("VC enable context " + ctx)
Expand Down Expand Up @@ -197,9 +202,20 @@ Rectangle
onZoomOutClicked: { virtualConsole.setPageScale(-0.1) }
onZoomInClicked: { virtualConsole.setPageScale(0.1) }
}

IconButton
{
id: settingsButton
implicitHeight: vcToolbar.height - 2
checkable: true
tooltip: qsTr("Show/hide the VC settings")
faColor: "white"
faSource: FontAwesome.fa_bars
onToggled: showProperties(checked)
}
}
}

}
Loader
{
id: pageLoader
Expand All @@ -215,8 +231,19 @@ Rectangle
pageLoader.item.page = selectedPage
}
}

VCProperties
{
id: vcProperties
visible: false
x: parent.width - width
anchors.top: vcToolbar.bottom
z: 1000
}

}


CustomPopupDialog
{
id: addMatrixPopup
Expand Down
1 change: 1 addition & 0 deletions qmlui/qmlui.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
<file alias="VCClockProperties.qml">qml/virtualconsole/VCClockProperties.qml</file>
<file alias="VCCueListItem.qml">qml/virtualconsole/VCCueListItem.qml</file>
<file alias="VCCueListProperties.qml">qml/virtualconsole/VCCueListProperties.qml</file>
<file alias="VCProperties.qml">qml/virtualconsole/VCProperties.qml</file>

<!-- Show Manager -->
<file alias="ShowManager.qml">qml/showmanager/ShowManager.qml</file>
Expand Down
67 changes: 67 additions & 0 deletions qmlui/virtualconsole/virtualconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
#define KXMLQLCVCPropertiesSizeWidth QString("Width")
#define KXMLQLCVCPropertiesSizeHeight QString("Height")

#define KXMLQLCVCPropertiesFlashProperties QString("FlashProperties")
#define KXMLQLCVCPropertiesFlashOverrides QString("FlashOverride")
#define KXMLQLCVCPropertiesFlashForceLTP QString("FlashForceLTP")

#define KXMLQLCVCPropertiesGrandMaster QString("GrandMaster")
#define KXMLQLCVCPropertiesGrandMasterVisible QString("Visible")
#define KXMLQLCVCPropertiesGrandMasterChannelMode QString("ChannelMode")
Expand Down Expand Up @@ -71,6 +75,8 @@ VirtualConsole::VirtualConsole(QQuickView *view, Doc *doc,
, m_autoDetectionKey(QKeySequence())
, m_autoDetectionKeyId(UINT_MAX)
, m_inputChannelsTree(nullptr)
, m_flashOverrides(false)
, m_flashForceLTP(false)
{
Q_ASSERT(doc != nullptr);

Expand Down Expand Up @@ -1166,6 +1172,37 @@ void VirtualConsole::slotInputValueChanged(quint32 universe, quint32 channel, uc
}
}

/*********************************************************************
* Flashing
*********************************************************************/
void VirtualConsole::setFlashOverride(bool flashOverride)
{
if(m_flashOverrides == flashOverride)
return;
m_flashOverrides = flashOverride;
emit flashOverrideChanged(flashOverride);
m_doc->setFlashOverrides(flashOverride);
}

bool VirtualConsole::flashOverrides() const
{
return m_flashOverrides;
}

void VirtualConsole::setFlashForceLTP(bool forceLTP)
{
if(m_flashForceLTP == forceLTP)
return;
m_flashForceLTP = forceLTP;
emit flashForceLTPChanged(forceLTP);
m_doc->setFlashForceLTP(forceLTP);
}

bool VirtualConsole::flashForceLTP() const
{
return m_flashForceLTP;
}

/*****************************************************************************
* Load & Save
*****************************************************************************/
Expand Down Expand Up @@ -1279,6 +1316,21 @@ bool VirtualConsole::loadPropertiesXML(QXmlStreamReader &root)
m_pages.at(0)->setGeometry(QRect(0, 0, sz.width(), sz.height()));
root.skipCurrentElement();
}
else if (root.name() == KXMLQLCVCPropertiesFlashProperties)
{
str = root.attributes().value(KXMLQLCVCPropertiesFlashOverrides).toString();
if (str.isEmpty() == false)
{
setFlashOverride((bool)str.toInt());
}

str = root.attributes().value(KXMLQLCVCPropertiesFlashForceLTP).toString();
if (str.isEmpty() == false)
{
setFlashForceLTP((bool)str.toInt());
}
root.skipCurrentElement();
}
else if (root.name() == KXMLQLCVCPropertiesGrandMaster)
{
QXmlStreamAttributes attrs = root.attributes();
Expand Down Expand Up @@ -1362,6 +1414,17 @@ bool VirtualConsole::saveXML(QXmlStreamWriter *doc)
/* Properties */
//m_properties.saveXML(doc);

/* Properties */
doc->writeStartElement(KXMLQLCVCProperties);

/* Flash Properties */
doc->writeStartElement(KXMLQLCVCPropertiesFlashProperties);
doc->writeAttribute(KXMLQLCVCPropertiesFlashOverrides, QString::number(flashOverrides()));
doc->writeAttribute(KXMLQLCVCPropertiesFlashForceLTP, QString::number(flashForceLTP()));
doc->writeEndElement();

doc->writeEndElement();

/* End the <VirtualConsole> tag */
doc->writeEndElement();

Expand All @@ -1375,6 +1438,10 @@ void VirtualConsole::postLoad()
//m_doc->inputOutputMap()->setGrandMasterValueMode(m_properties.grandMasterValueMode());
//m_doc->inputOutputMap()->setGrandMasterChannelMode(m_properties.grandMasterChannelMode());

qDebug() << "Setting m_doc attributes: " << flashOverrides() << ", " << flashForceLTP();
m_doc->setFlashOverrides(flashOverrides());
m_doc->setFlashForceLTP(flashForceLTP());

/** Go through widgets, check IDs and register widgets to the map
* This code is the same as the one in addWidgetToMap()
* We have to repeat it to limit conflicts if
Expand Down
22 changes: 22 additions & 0 deletions qmlui/virtualconsole/virtualconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class VirtualConsole : public PreviewContext
Q_PROPERTY(int selectedWidgetsCount READ selectedWidgetsCount NOTIFY selectedWidgetsCountChanged)
Q_PROPERTY(int clipboardItemsCount READ clipboardItemsCount NOTIFY clipboardItemsCountChanged)

Q_PROPERTY(bool flashOverrides READ flashOverrides WRITE setFlashOverride NOTIFY flashOverrideChanged)
Q_PROPERTY(bool flashForceLTP READ flashForceLTP WRITE setFlashForceLTP NOTIFY flashForceLTPChanged)

public:
VirtualConsole(QQuickView *view, Doc *doc, ContextManager *ctxManager, QObject *parent = 0);

Expand Down Expand Up @@ -313,6 +316,25 @@ protected slots:
/** Data model used by the QML UI to represent groups/input channels */
TreeModel *m_inputChannelsTree;

/*********************************************************************
* Flashing
*********************************************************************/
public:
void setFlashOverride(bool flashOverride);

bool flashOverrides() const;

void setFlashForceLTP(bool forceLTP);

bool flashForceLTP() const;
private:
bool m_flashOverrides;
bool m_flashForceLTP;

signals:
void flashOverrideChanged(bool override);
void flashForceLTPChanged(bool forceLTP);

/*********************************************************************
* Load & Save
*********************************************************************/
Expand Down

0 comments on commit dc1e9a6

Please sign in to comment.