-
-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecde343
commit 3e141f6
Showing
9 changed files
with
598 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
/* | ||
Q Light Controller Plus | ||
channeledit.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 "qlcfixturedef.h" | ||
#include "qlccapability.h" | ||
#include "qlcchannel.h" | ||
|
||
#include "channeledit.h" | ||
|
||
ChannelEdit::ChannelEdit(QLCChannel *channel, QObject *parent) | ||
: QObject(parent) | ||
, m_channel(channel) | ||
{ | ||
|
||
} | ||
|
||
ChannelEdit::~ChannelEdit() | ||
{ | ||
|
||
} | ||
|
||
QVariantList ChannelEdit::channelPresetList() const | ||
{ | ||
QVariantList list; | ||
|
||
QVariantMap custom; | ||
custom.insert("mIcon", "qrc:/edit.svg"); | ||
custom.insert("mLabel", tr("Custom")); | ||
custom.insert("mValue", 0); | ||
list.append(custom); | ||
|
||
for (int i = QLCChannel::Custom + 1; i < QLCChannel::LastPreset; i++) | ||
{ | ||
QLCChannel ch; | ||
ch.setPreset(QLCChannel::Preset(i)); | ||
QVariantMap chMap; | ||
chMap.insert("mIcon", ch.getIconNameFromGroup(ch.group(), true)); | ||
chMap.insert("mLabel", ch.name() + " (" + ch.presetToString(QLCChannel::Preset(i)) + ")"); | ||
custom.insert("mValue", i); | ||
list.append(chMap); | ||
} | ||
|
||
return list; | ||
} | ||
|
||
QVariantList ChannelEdit::channelTypeList() const | ||
{ | ||
QVariantList list; | ||
|
||
for (QString grp : QLCChannel::groupList()) | ||
{ | ||
QLCChannel ch; | ||
ch.setGroup(QLCChannel::stringToGroup(grp)); | ||
|
||
QVariantMap chMap; | ||
chMap.insert("mIcon", ch.getIconNameFromGroup(ch.group(), true)); | ||
chMap.insert("mLabel", ch.groupToString(ch.group())); | ||
chMap.insert("mValue", ch.group()); | ||
list.append(chMap); | ||
|
||
if (ch.group() == QLCChannel::Intensity) | ||
{ | ||
for (QString color : QLCChannel::colourList()) | ||
{ | ||
QLCChannel cc; | ||
cc.setGroup(QLCChannel::Intensity); | ||
cc.setColour(QLCChannel::stringToColour(color)); | ||
|
||
QVariantMap chMap; | ||
chMap.insert("mIcon", cc.getIconNameFromGroup(ch.group(), true)); | ||
chMap.insert("mLabel", cc.colourToString(cc.colour())); | ||
chMap.insert("mValue", cc.colour()); | ||
list.append(chMap); | ||
} | ||
} | ||
} | ||
|
||
return list; | ||
} | ||
|
||
QString ChannelEdit::name() const | ||
{ | ||
return m_channel->name(); | ||
} | ||
|
||
void ChannelEdit::setName(QString name) | ||
{ | ||
if (name == m_channel->name()) | ||
return; | ||
|
||
m_channel->setName(name); | ||
emit nameChanged(); | ||
} | ||
|
||
int ChannelEdit::preset() const | ||
{ | ||
return int(m_channel->preset()); | ||
} | ||
|
||
void ChannelEdit::setPreset(int index) | ||
{ | ||
if (index == int(m_channel->preset())) | ||
return; | ||
|
||
m_channel->setPreset(QLCChannel::Preset(index)); | ||
emit presetChanged(); | ||
if (index) | ||
{ | ||
emit groupChanged(); | ||
emit controlByteChanged(); | ||
} | ||
} | ||
|
||
int ChannelEdit::group() const | ||
{ | ||
if (m_channel->group() == QLCChannel::Intensity && | ||
m_channel->colour() != QLCChannel::NoColour) | ||
return m_channel->colour(); | ||
|
||
return m_channel->group(); | ||
} | ||
|
||
void ChannelEdit::setGroup(int group) | ||
{ | ||
Q_UNUSED(group) | ||
} | ||
|
||
int ChannelEdit::controlByte() const | ||
{ | ||
return m_channel->controlByte(); | ||
} | ||
|
||
void ChannelEdit::setControlByte(int byte) | ||
{ | ||
if (byte == m_channel->controlByte()) | ||
return; | ||
|
||
m_channel->setControlByte(QLCChannel::ControlByte(byte)); | ||
emit controlByteChanged(); | ||
} | ||
|
||
int ChannelEdit::defaultValue() const | ||
{ | ||
return m_channel->defaultValue(); | ||
} | ||
|
||
void ChannelEdit::setDefaultValue(int value) | ||
{ | ||
if (value == m_channel->defaultValue()) | ||
return; | ||
|
||
m_channel->setDefaultValue(uchar(value)); | ||
emit defaultValueChanged(); | ||
} | ||
|
||
QVariantList ChannelEdit::capabilities() const | ||
{ | ||
QVariantList list; | ||
|
||
for (QLCCapability *cap : m_channel->capabilities()) | ||
{ | ||
QVariantMap capMap; | ||
capMap.insert("iMin", cap->min()); | ||
capMap.insert("iMax", cap->max()); | ||
capMap.insert("sDesc", cap->name()); | ||
list.append(capMap); | ||
} | ||
|
||
return list; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
Q Light Controller Plus | ||
channeledit.h | ||
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. | ||
*/ | ||
|
||
#ifndef CHANNELEDIT_H | ||
#define CHANNELEDIT_H | ||
|
||
#include <QQuickView> | ||
|
||
class QLCChannel; | ||
|
||
class ChannelEdit : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
Q_PROPERTY(QVariantList channelPresetList READ channelPresetList CONSTANT) | ||
Q_PROPERTY(QVariantList channelTypeList READ channelTypeList CONSTANT) | ||
|
||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) | ||
Q_PROPERTY(int preset READ preset WRITE setPreset NOTIFY presetChanged) | ||
Q_PROPERTY(int group READ group WRITE setGroup NOTIFY groupChanged) | ||
|
||
Q_PROPERTY(int controlByte READ controlByte WRITE setControlByte NOTIFY controlByteChanged) | ||
Q_PROPERTY(int defaultValue READ defaultValue WRITE setDefaultValue NOTIFY defaultValueChanged) | ||
|
||
Q_PROPERTY(QVariantList capabilities READ capabilities CONSTANT) | ||
|
||
public: | ||
ChannelEdit(QLCChannel *channel, QObject *parent = nullptr); | ||
~ChannelEdit(); | ||
|
||
QVariantList channelPresetList() const; | ||
QVariantList channelTypeList() const; | ||
|
||
/** Get/Set the name of the channel being edited */ | ||
QString name() const; | ||
void setName(QString name); | ||
|
||
/** Get/Set the preset of the channel being edited */ | ||
int preset() const; | ||
void setPreset(int index); | ||
|
||
/** Get/Set the group of the channel being edited */ | ||
int group() const; | ||
void setGroup(int group); | ||
|
||
/** Get/Set the byte role of the channel being edited */ | ||
int controlByte() const; | ||
void setControlByte(int byte); | ||
|
||
/** Get/Set the default value of the channel being edited */ | ||
int defaultValue() const; | ||
void setDefaultValue(int value); | ||
|
||
QVariantList capabilities() const; | ||
|
||
signals: | ||
void nameChanged(); | ||
void presetChanged(); | ||
void groupChanged(); | ||
void controlByteChanged(); | ||
void defaultValueChanged(); | ||
|
||
private: | ||
/** Reference to the channel being edited */ | ||
QLCChannel *m_channel; | ||
}; | ||
|
||
#endif // CHANNELEDIT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.