Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 52 additions & 22 deletions src/commandline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,34 +466,14 @@ void EditableLCDNumber::keyPressEvent(QKeyEvent * event)
if (event->keyCombination()
== Preferences::Instance().getKeyShortcut(KeyShortcutTarget::SHORTCUT_CHANNELCHECK_NEXT))
{
if (intValue() < MAX_DMX_ADDRESS)
{
buf = intValue() + 1;
display(buf);
emit valueChanged(buf);
}
else
{
display(1);
emit valueChanged(1);
}
increment();
return;
}

if (event->keyCombination()
== Preferences::Instance().getKeyShortcut(KeyShortcutTarget::SHORTCUT_CHANNELCHECK_PREV))
{
if (intValue() - 1 > 0)
{
buf = intValue() - 1;
display(buf);
emit valueChanged(buf);
}
else
{
display(MAX_DMX_ADDRESS);
emit valueChanged(MAX_DMX_ADDRESS);
}
decrement();
return;
}

Expand Down Expand Up @@ -530,3 +510,53 @@ void EditableLCDNumber::keyPressEvent(QKeyEvent * event)
default: break;
}
}

void EditableLCDNumber::focusInEvent(QFocusEvent* event)
{
setStyleSheet("background-color:rgb(0, 0, 0);\ncolor: rgb(255, 85, 0);");
}

void EditableLCDNumber::focusOutEvent(QFocusEvent* event)
{
setStyleSheet("background-color:rgb(0, 0, 0);\ncolor: rgb(24, 24, 24);");
}

void EditableLCDNumber::increment()
{
auto value = intValue();
if (value + m_offset <= MAX_DMX_ADDRESS)
{
value += m_offset;
display(value);
emit valueChanged(value);
}
else
{
display(1);
emit valueChanged(1);
}
}

void EditableLCDNumber::decrement()
{
auto value = intValue();
if (value - m_offset > 0)
{
value -= m_offset;
display(value);
emit valueChanged(value);
}
else
{
display(MAX_DMX_ADDRESS);
emit valueChanged(MAX_DMX_ADDRESS);
}
}

void EditableLCDNumber::setOffset(int offset)
{
if (offset > 1)
{
m_offset = offset;
}
}
11 changes: 10 additions & 1 deletion src/commandline.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,18 @@ class EditableLCDNumber : public QLCDNumber
void valueChanged(int);
void toggleOff();

protected:
public slots:
void increment();
void decrement();
void setOffset(int offset);

protected:
virtual void keyPressEvent(QKeyEvent * event);
virtual void focusInEvent(QFocusEvent* event);
virtual void focusOutEvent(QFocusEvent* event);

private:
int m_offset = 1;
};

#endif // COMMANDLINE_H
57 changes: 20 additions & 37 deletions src/ui/transmitwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ transmitwindow::transmitwindow(int universe, QWidget * parent)
m_slotCount = MAX_DMX_ADDRESS;
ui->sbSlotCount->setValue(m_slotCount);
ui->sbSlotCount->setWrapping(true);

ui->sbFadeRangeEnd->setMinimum(MIN_DMX_ADDRESS);
ui->sbFadeRangeEnd->setMaximum(m_slotCount);
ui->sbFadeRangeEnd->setValue(m_slotCount);
Expand Down Expand Up @@ -162,7 +162,9 @@ transmitwindow::transmitwindow(int universe, QWidget * parent)
ui->slChannelCheck->setMinimum(0);
ui->slChannelCheck->setMaximum(MAX_SACN_LEVEL);
ui->slChannelCheck->setValue(MAX_SACN_LEVEL);

ui->lcdNumber->display(1);
connect(ui->sbOffset, &QSpinBox::valueChanged, ui->lcdNumber, &EditableLCDNumber::setOffset);

m_blinkTimer = new QTimer(this);
m_blinkTimer->setInterval(BLINK_TIME);
Expand Down Expand Up @@ -532,40 +534,12 @@ void transmitwindow::on_cbPriorityMode_currentIndexChanged(int index)

void transmitwindow::on_btnCcNext_pressed()
{
int value = ui->lcdNumber->value();

if (++value > m_slotCount) value = MIN_DMX_ADDRESS;

ui->lcdNumber->display(value);

if (m_sender)
{
// Update levels.
m_sender->setLevelRange(MIN_DMX_ADDRESS - 1, m_slotCount - 1, 0);
m_sender->setLevel(value - 1, ui->slChannelCheck->value());

// Update priorities if requested.
updateChanCheckPap(value - 1);
}
ui->lcdNumber->increment();
}

void transmitwindow::on_btnCcPrev_pressed()
{
int value = ui->lcdNumber->value();

if (--value < MIN_DMX_ADDRESS) value = m_slotCount;

ui->lcdNumber->display(value);

if (m_sender)
{
// Update levels.
m_sender->setLevelRange(MIN_DMX_ADDRESS - 1, m_slotCount - 1, 0);
m_sender->setLevel(value - 1, ui->slChannelCheck->value());

// Update priorities if requested.
updateChanCheckPap(value - 1);
}
ui->lcdNumber->decrement();
}

void transmitwindow::on_cbCcPap_toggled(bool checked)
Expand All @@ -577,7 +551,7 @@ void transmitwindow::on_cbCcPap_toggled(bool checked)

if (checked)
{
updateChanCheckPap(ui->lcdNumber->value() - 1);
updateChanCheckPap(ui->lcdNumber->value() - 1, ui->sbGrouping->value());
}
else
{
Expand All @@ -590,11 +564,17 @@ void transmitwindow::on_lcdNumber_valueChanged(int value)
if (m_sender)
{
// Update levels.
const auto grouping = ui->sbGrouping->value();
const uint16_t maxAddress = value - 1 + grouping;

m_sender->setLevelRange(0, m_slotCount - 1, 0);
m_sender->setLevel(value - 1, ui->slChannelCheck->value());
for (auto channel = value - 1; channel < std::min(MAX_DMX_ADDRESS, maxAddress); channel++)
{
m_sender->setLevel(channel, ui->slChannelCheck->value());
}

// Update priorities if requested.
updateChanCheckPap(value - 1);
updateChanCheckPap(value - 1, grouping);
}
}

Expand Down Expand Up @@ -672,7 +652,7 @@ void transmitwindow::on_tabWidget_currentChanged(int index)
{
auto address = ui->lcdNumber->value() - 1;
m_sender->setLevel(address, ui->slChannelCheck->value());
updateChanCheckPap(address);
updateChanCheckPap(address, ui->sbGrouping->value());

ui->lcdNumber->setFocus();
break;
Expand Down Expand Up @@ -1008,7 +988,7 @@ void transmitwindow::on_sbMaxFPS_editingFinished()
if (ui->sbMaxFPS->value() < ui->sbMinFPS->value()) ui->sbMaxFPS->setValue(ui->sbMinFPS->value());
}

void transmitwindow::updateChanCheckPap(int address)
void transmitwindow::updateChanCheckPap(int address, int length)
{
Q_ASSERT(address < DMX_SLOT_MAX);
if (address >= m_slotCount)
Expand All @@ -1023,7 +1003,10 @@ void transmitwindow::updateChanCheckPap(int address)
}

std::array<quint8, MAX_DMX_ADDRESS> ccPap{0};
ccPap[address] = m_perAddressPriorities[address];
for (int i = address; i < std::min(address+length, DMX_SLOT_MAX); i++)
{
ccPap[i] = m_perAddressPriorities[i];
}
m_sender->setPerChannelPriorities(ccPap.data());
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/transmitwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private slots:
void updateTitle();
void setLevel(int address, int value);
void updatePerChanPriorityButton();
void updateChanCheckPap(int address);
void updateChanCheckPap(int address, int length);
void updateFadeRangePap();
Ui::transmitwindow * ui = nullptr;
ConfigurePerChanPrioDlg * m_perChannelDialog = nullptr;
Expand Down
92 changes: 91 additions & 1 deletion ui/transmitwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ border-radius: 4px;
<enum>Qt::FocusPolicy::NoFocus</enum>
</property>
<property name="currentIndex">
<number>2</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabFaders">
<attribute name="title">
Expand Down Expand Up @@ -1302,6 +1302,75 @@ color: rgb(255, 85, 0);</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Offset</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbOffset">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string>Grouping</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbGrouping">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
Expand Down Expand Up @@ -2001,6 +2070,27 @@ color: rgb(255, 85, 0);</string>
<header>commandline.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>rbPathwaySecure</tabstop>
<tabstop>lePathwaySecurePassword</tabstop>
<tabstop>sbSlotCount</tabstop>
<tabstop>sbMinFPS</tabstop>
<tabstop>sbMaxFPS</tabstop>
<tabstop>teCommandline</tabstop>
<tabstop>lcdNumber</tabstop>
<tabstop>sbOffset</tabstop>
<tabstop>sbGrouping</tabstop>
<tabstop>cbCcPap</tabstop>
<tabstop>cbFadeRangePap</tabstop>
<tabstop>rbChaseSnap</tabstop>
<tabstop>rbChaseSine</tabstop>
<tabstop>rbChaseRamp</tabstop>
<tabstop>rbVerticalBars</tabstop>
<tabstop>rbHorizBars</tabstop>
<tabstop>rbUsDate</tabstop>
<tabstop>leScrollText</tabstop>
<tabstop>rbEuDate</tabstop>
</tabstops>
<resources>
<include location="../res/resources.qrc"/>
</resources>
Expand Down
Loading