Skip to content

Commit

Permalink
qmlui: begin definition editor save state and instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Apr 15, 2021
1 parent 60a4d68 commit ec62374
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 31 deletions.
16 changes: 12 additions & 4 deletions engine/src/qlcchannel.cpp
Expand Up @@ -845,17 +845,25 @@ uchar QLCChannel::defaultValue() const

void QLCChannel::setDefaultValue(uchar value)
{
if (value == m_defaultValue)
return;

m_defaultValue = value;
emit defaultValueChanged();
}

void QLCChannel::setControlByte(ControlByte byte)
QLCChannel::ControlByte QLCChannel::controlByte() const
{
m_controlByte = byte;
return m_controlByte;
}

QLCChannel::ControlByte QLCChannel::controlByte() const
void QLCChannel::setControlByte(ControlByte byte)
{
return m_controlByte;
if (byte == m_controlByte)
return;

m_controlByte = byte;
emit controlByteChanged();
}

/*****************************************************************************
Expand Down
2 changes: 0 additions & 2 deletions qmlui/app.cpp
Expand Up @@ -882,7 +882,6 @@ void App::createFixture()
if (m_fixtureEditor == nullptr)
{
m_fixtureEditor = new FixtureEditor(this, m_doc);
//setSource(QUrl("qrc:/FixtureEditor.qml")); // another fucking segfault in QtQuick
QMetaObject::invokeMethod(rootObject(), "switchToContext",
Q_ARG(QVariant, "FXEDITOR"),
Q_ARG(QVariant, "qrc:/FixtureEditor.qml"));
Expand All @@ -896,7 +895,6 @@ void App::editFixture(QString manufacturer, QString model)
if (m_fixtureEditor == nullptr)
{
m_fixtureEditor = new FixtureEditor(this, m_doc);
//setSource(QUrl("qrc:/FixtureEditor.qml"));
QMetaObject::invokeMethod(rootObject(), "switchToContext",
Q_ARG(QVariant, "FXEDITOR"),
Q_ARG(QVariant, "qrc:/FixtureEditor.qml"));
Expand Down
6 changes: 5 additions & 1 deletion qmlui/fixtureeditor/channeledit.cpp
Expand Up @@ -27,7 +27,11 @@ ChannelEdit::ChannelEdit(QLCChannel *channel, QObject *parent)
: QObject(parent)
, m_channel(channel)
{

connect(m_channel, SIGNAL(presetChanged()), this, SIGNAL(channelChanged()));
connect(m_channel, SIGNAL(groupChanged()), this, SIGNAL(channelChanged()));
connect(m_channel, SIGNAL(nameChanged()), this, SIGNAL(channelChanged()));
connect(m_channel, SIGNAL(defaultValueChanged()), this, SIGNAL(channelChanged()));
connect(m_channel, SIGNAL(controlByteChanged()), this, SIGNAL(channelChanged()));
}

ChannelEdit::~ChannelEdit()
Expand Down
1 change: 1 addition & 0 deletions qmlui/fixtureeditor/channeledit.h
Expand Up @@ -60,6 +60,7 @@ class ChannelEdit : public QObject
Q_INVOKABLE QVariant getCapabilityValueAt(int index, int vIndex);

signals:
void channelChanged();
void capabilitiesChanged();

private:
Expand Down
21 changes: 21 additions & 0 deletions qmlui/fixtureeditor/editorview.cpp
Expand Up @@ -30,6 +30,7 @@ EditorView::EditorView(QQuickView *view, QLCFixtureDef *fixtureDef, QObject *par
: QObject(parent)
, m_view(view)
, m_fixtureDef(fixtureDef)
, m_isModified(false)
, m_channelEdit(nullptr)
, m_modeEdit(nullptr)
{
Expand All @@ -45,6 +46,22 @@ EditorView::~EditorView()
delete m_modeEdit;
}

bool EditorView::isModified() const
{
return m_isModified;
}

bool EditorView::isUser() const
{
return m_fixtureDef->isUser();
}

void EditorView::setModified()
{
m_isModified = true;
emit hasChanged();
}

QString EditorView::manufacturer() const
{
return m_fixtureDef->manufacturer();
Expand All @@ -57,6 +74,7 @@ void EditorView::setManufacturer(QString manufacturer)

m_fixtureDef->setManufacturer(manufacturer);
emit manufacturerChanged(manufacturer);
setModified();
}

QString EditorView::model() const
Expand All @@ -71,6 +89,7 @@ void EditorView::setModel(QString model)

m_fixtureDef->setModel(model);
emit modelChanged(model);
setModified();
}

QString EditorView::author() const
Expand All @@ -85,6 +104,7 @@ void EditorView::setAuthor(QString author)

m_fixtureDef->setAuthor(author);
emit authorChanged(author);
setModified();
}

PhysicalEdit *EditorView::globalPhysical()
Expand Down Expand Up @@ -120,6 +140,7 @@ ChannelEdit *EditorView::requestChannelEditor(QString name)
emit channelsChanged();
}
m_channelEdit = new ChannelEdit(ch);
connect(m_channelEdit, SIGNAL(channelChanged()), this, SLOT(setModified()));
return m_channelEdit;
}

Expand Down
15 changes: 15 additions & 0 deletions qmlui/fixtureeditor/editorview.h
Expand Up @@ -31,6 +31,9 @@ class EditorView : public QObject
{
Q_OBJECT

Q_PROPERTY(bool isModified READ isModified NOTIFY hasChanged)
Q_PROPERTY(bool isUser READ isUser CONSTANT)

Q_PROPERTY(QString manufacturer READ manufacturer WRITE setManufacturer NOTIFY manufacturerChanged)
Q_PROPERTY(QString model READ model WRITE setModel NOTIFY modelChanged)
Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY authorChanged)
Expand All @@ -44,6 +47,12 @@ class EditorView : public QObject
EditorView(QQuickView *view, QLCFixtureDef *fixtureDef, QObject *parent = nullptr);
~EditorView();

/** Get the definition modification flag */
bool isModified() const;

/** Get if the definition is user or system */
bool isUser() const;

/** Get/Set the fixture manufacturer */
QString manufacturer() const;
void setManufacturer(QString manufacturer);
Expand All @@ -60,7 +69,11 @@ class EditorView : public QObject
* global physical properties */
PhysicalEdit *globalPhysical();

protected slots:
void setModified();

signals:
void hasChanged();
void manufacturerChanged(QString manufacturer);
void modelChanged(QString model);
void authorChanged(QString author);
Expand All @@ -72,6 +85,8 @@ class EditorView : public QObject
QLCFixtureDef *m_fixtureDef;
/** Reference to the global physical properties */
PhysicalEdit *m_globalPhy;
/** Definition modification flag */
bool m_isModified;

/************************************************************************
* Channels
Expand Down
5 changes: 5 additions & 0 deletions qmlui/fixtureeditor/fixtureeditor.cpp
Expand Up @@ -46,6 +46,11 @@ FixtureEditor::~FixtureEditor()

}

QString FixtureEditor::userFolder() const
{
return m_doc->fixtureDefCache()->userDefinitionDirectory().absolutePath();
}

void FixtureEditor::createDefinition()
{
m_editors[m_lastId] = new EditorView(m_view, new QLCFixtureDef());
Expand Down
6 changes: 5 additions & 1 deletion qmlui/fixtureeditor/fixtureeditor.h
Expand Up @@ -29,13 +29,17 @@ class FixtureEditor : public QObject
{
Q_OBJECT
Q_PROPERTY(QVariantList editorsList READ editorsList NOTIFY editorsListChanged)
Q_PROPERTY(QString userFolder READ userFolder CONSTANT)

public:
FixtureEditor(QQuickView *view, Doc *doc, QObject *parent = nullptr);
~FixtureEditor();

/** Return the definitions user folder absolute location */
QString userFolder() const;

/** Create a new editor and an empty fixture definition */
void createDefinition();
Q_INVOKABLE void createDefinition();

/** Edit an existing fixture definition */
void editDefinition(QString manufacturer, QString model);
Expand Down
4 changes: 2 additions & 2 deletions qmlui/qml/fixtureeditor/ChannelEditor.qml
Expand Up @@ -28,13 +28,13 @@ GridLayout
{
columns: 4

property EditorRef fixtureEditor: null
property EditorRef editorView: null
property ChannelEdit editor: null
property QLCChannel channel: null

function setItemName(name)
{
editor = fixtureEditor.requestChannelEditor(name)
editor = editorView.requestChannelEditor(name)
channel = editor.channel
nameEdit.selectAndFocus()
}
Expand Down
40 changes: 29 additions & 11 deletions qmlui/qml/fixtureeditor/EditorView.qml
Expand Up @@ -29,10 +29,28 @@ Rectangle
id: editorRoot

property int editorId
property EditorRef fixtureEditor: null
property EditorRef editorView: null
property bool isUser: true

color: "transparent"

Component.onCompleted:
{
if (isUser)
systemFixturePopup.open()
}

CustomPopupDialog
{
id: systemFixturePopup
standardButtons: Dialog.Ok
title: qsTr("!! Warning !!")
message: qsTr("You are trying to edit a bundled fixture definition.<br>" +
"If you modify it, a new file will be stored in<br><i>" +
fixtureEditor.userFolder + "</i><br>when saving, with precedence over the bundled file.")
onAccepted: systemFixturePopup.close()
}

SplitView
{
anchors.fill: parent
Expand Down Expand Up @@ -74,8 +92,8 @@ Rectangle
CustomTextEdit
{
Layout.fillWidth: true
text: fixtureEditor ? fixtureEditor.manufacturer : ""
onTextChanged: if (fixtureEditor) fixtureEditor.manufacturer = text
text: editorView ? editorView.manufacturer : ""
onTextChanged: if (editorView) editorView.manufacturer = text
}

// row 1
Expand Down Expand Up @@ -121,17 +139,17 @@ Rectangle
CustomTextEdit
{
Layout.fillWidth: true
text: fixtureEditor ? fixtureEditor.model : ""
onTextChanged: if (fixtureEditor) fixtureEditor.model = text
text: editorView ? editorView.model : ""
onTextChanged: if (editorView) editorView.model = text
}

// row 4
RobotoText { label: qsTr("Author") }
CustomTextEdit
{
Layout.fillWidth: true
text: fixtureEditor ? fixtureEditor.author : ""
onTextChanged: if (fixtureEditor) fixtureEditor.author = text
text: editorView ? editorView.author : ""
onTextChanged: if (editorView) editorView.author = text
}
}
} // SectionBox - General
Expand All @@ -146,7 +164,7 @@ Rectangle
PhysicalProperties
{
width: Math.min(editorRoot.width / 2, parent.width)
phy: fixtureEditor ? fixtureEditor.globalPhysical : null
phy: editorView ? editorView.globalPhysical : null
}
} // SectionBox - Physical

Expand Down Expand Up @@ -216,7 +234,7 @@ Rectangle

property bool dragActive: false

model: fixtureEditor ? fixtureEditor.channels : null
model: editorView ? editorView.channels : null
delegate:
Item
{
Expand Down Expand Up @@ -366,7 +384,7 @@ Rectangle
boundsBehavior: Flickable.StopAtBounds
currentIndex: -1

model: fixtureEditor ? fixtureEditor.modes : null
model: editorView ? editorView.modes : null
delegate:
Item
{
Expand Down Expand Up @@ -447,7 +465,7 @@ Rectangle
item.width = Qt.binding(function() { return sideEditor.width - 20 })
item.height = Qt.binding(function() { return sideEditor.height - 20 })

item.fixtureEditor = editorRoot.fixtureEditor
item.editorView = editorRoot.editorView
item.setItemName(itemName)
}
}
Expand Down
22 changes: 17 additions & 5 deletions qmlui/qml/fixtureeditor/FixtureEditor.qml
Expand Up @@ -26,7 +26,6 @@ import "."

Rectangle
{
id: mainView
visible: true
width: 800
height: 600
Expand Down Expand Up @@ -76,7 +75,7 @@ Rectangle
{
imgSource: "qrc:/filenew.svg"
entryText: qsTr("New definition")
//onPressed: qlcplus.closeFixtureEditor()
onPressed: fixtureEditor.createDefinition()
autoExclusive: false
checkable: false
}
Expand Down Expand Up @@ -137,22 +136,35 @@ Rectangle
property string fxManuf: modelData.cRef.manufacturer
property string fxModel: modelData.cRef.model

//width: contentItem.width + (modIcon.visible ? modIcon.width + 8 : 0)

entryText: (fxManuf ? fxManuf : qsTr("Unknown")) + " - " + (fxModel ? fxModel : qsTr("Unknown"))
imgSource: modelData.cRef.isModified ? "qrc:/filesave.svg" : ""
iconSize: height * 0.75
checkable: true
padding: 5

onClicked:
{
editorView.editorId = modelData.id
editorView.fixtureEditor = modelData.cRef
editor.editorId = modelData.id
editor.editorView = modelData.cRef
editor.isUser = modelData.cRef.isUser
checked = true
}
}
} // Repeater
Rectangle
{
Layout.fillWidth: true
height: parent.height
color: "transparent"
}
} // RowLayout
} // Rectangle

EditorView
{
id: editorView
id: editor
y: mainToolbar.height + feToolbar.height
width: parent.width
height: parent.height - (mainToolbar.height + feToolbar.height)
Expand Down
6 changes: 3 additions & 3 deletions qmlui/qml/fixtureeditor/ModeEditor.qml
Expand Up @@ -29,12 +29,12 @@ Rectangle
id: editorRoot
color: "transparent"

property EditorRef fixtureEditor: null
property EditorRef editorView: null
property ModeEdit mode: null

function setItemName(name)
{
mode = fixtureEditor.requestModeEditor(name)
mode = editorView.requestModeEditor(name)
nameEdit.selectAndFocus()
}

Expand Down Expand Up @@ -229,7 +229,7 @@ Rectangle
{
width: Math.min(editorRoot.width / 2, parent.width)
phy: globalPhyCheck.checked ?
(fixtureEditor ? fixtureEditor.globalPhysical : null) :
(editorView ? editorView.globalPhysical : null) :
(mode ? mode.physical : null)
enabled: overridePhyCheck.checked
}
Expand Down

0 comments on commit ec62374

Please sign in to comment.