add format options to the menubar
This commit is contained in:
parent
f484c2c8bd
commit
4417a8888f
|
@ -3,6 +3,7 @@
|
|||
#include "universemodel.h"
|
||||
#include "statusindicatorwidget.h"
|
||||
|
||||
#include <QActionGroup>
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
#include <QMetaEnum>
|
||||
|
@ -22,20 +23,58 @@ UniverseWindow::UniverseWindow(QWidget *parent, QSacnUniverse *universe)
|
|||
ui->tableView->setModel(model);
|
||||
|
||||
// update the status bar whenever the universe refreshes
|
||||
connect(model, &UniverseModel::dataChanged,
|
||||
this, [this](){update_status_();});
|
||||
connect(model, &UniverseModel::dataChanged, this, [this]() {
|
||||
update_status_();
|
||||
});
|
||||
|
||||
// add data format combobox to toolbar
|
||||
auto formatLabel = new QLabel(ui->toolBar);
|
||||
auto formatLabel = new QLabel(ui->toolBarDMX);
|
||||
ui->toolBarDMX->addWidget(formatLabel);
|
||||
formatLabel->setText(tr("Data Format") + ": ");
|
||||
ui->toolBar->addWidget(formatLabel);
|
||||
auto dataModes = new QComboBox(ui->toolBar);
|
||||
|
||||
auto dataModes = new QComboBox(ui->toolBarDMX);
|
||||
ui->toolBarDMX->addWidget(dataModes);
|
||||
const QMetaEnum types = QMetaEnum::fromType<UniverseModel::data_modes>();
|
||||
for (int i=0; i < types.keyCount(); ++i)
|
||||
dataModes->addItem(types.key(i));
|
||||
|
||||
auto formatGroup = new QActionGroup(ui->centralwidget);
|
||||
formatGroup->addAction(ui->actionViewDecimal);
|
||||
formatGroup->addAction(ui->actionViewHex);
|
||||
formatGroup->addAction(ui->actionViewPercent);
|
||||
|
||||
connect(dataModes, &QComboBox::currentTextChanged,
|
||||
model, &UniverseModel::setDataMode);
|
||||
ui->toolBar->addWidget(dataModes);
|
||||
this, [this, model, types, formatGroup](QString mode) {
|
||||
auto data_mode = static_cast<UniverseModel::data_modes>(types.keyToValue(mode.toLocal8Bit()));
|
||||
model->setDataMode(data_mode);
|
||||
formatGroup->blockSignals(true);
|
||||
switch (data_mode) {
|
||||
case UniverseModel::Decimal:
|
||||
ui->actionViewDecimal->setChecked(true);
|
||||
break;
|
||||
case UniverseModel::Hex:
|
||||
ui->actionViewHex->setChecked(true);
|
||||
break;
|
||||
case UniverseModel::Percent:
|
||||
ui->actionViewPercent->setChecked(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
formatGroup->blockSignals(false);
|
||||
});
|
||||
connect(ui->actionViewDecimal, &QAction::toggled, this, [dataModes](bool state) {
|
||||
if (state)
|
||||
dataModes->setCurrentIndex((int)UniverseModel::Decimal);
|
||||
});
|
||||
connect(ui->actionViewHex, &QAction::toggled, this, [dataModes](bool state) {
|
||||
if (state)
|
||||
dataModes->setCurrentIndex((int)UniverseModel::Hex);
|
||||
});
|
||||
connect(ui->actionViewPercent, &QAction::toggled, this, [dataModes](bool state) {
|
||||
if (state)
|
||||
dataModes->setCurrentIndex((int)UniverseModel::Percent);
|
||||
});
|
||||
|
||||
// status indicator
|
||||
auto indicator = new StatusIndicatorWidget(this, mUniverse);
|
||||
|
|
|
@ -48,9 +48,43 @@
|
|||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="nativeMenuBar">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuView">
|
||||
<property name="title">
|
||||
<string>View</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuToolbars">
|
||||
<property name="title">
|
||||
<string>Toolbars</string>
|
||||
</property>
|
||||
<addaction name="actionToolbarDMX"/>
|
||||
</widget>
|
||||
<addaction name="menuToolbars"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuDMX">
|
||||
<property name="title">
|
||||
<string>DMX</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuData_Format">
|
||||
<property name="title">
|
||||
<string>Data Format</string>
|
||||
</property>
|
||||
<addaction name="actionViewDecimal"/>
|
||||
<addaction name="actionViewHex"/>
|
||||
<addaction name="actionViewPercent"/>
|
||||
</widget>
|
||||
<addaction name="menuData_Format"/>
|
||||
</widget>
|
||||
<addaction name="menuDMX"/>
|
||||
<addaction name="menuView"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<widget class="QToolBar" name="toolBarDMX">
|
||||
<property name="windowTitle">
|
||||
<string>DMX</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
|
@ -58,7 +92,78 @@
|
|||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<action name="actionViewHex">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hex</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewDecimal">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Decimal</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewPercent">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Percent</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionToolbarDMX">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>DMX</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>actionToolbarDMX</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>toolBarDMX</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>199</x>
|
||||
<y>33</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>toolBarDMX</sender>
|
||||
<signal>visibilityChanged(bool)</signal>
|
||||
<receiver>actionToolbarDMX</receiver>
|
||||
<slot>setChecked(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>199</x>
|
||||
<y>33</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
Loading…
Reference in New Issue