button manager ui basics
This commit is contained in:
parent
be931de6d0
commit
9bb1944fd1
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/include",
|
||||
"${workspaceFolder}/Log/",
|
||||
"${workspaceFolder}/miniaudio",
|
||||
"${workspaceFolder}/QxtGlobalShortcut/src/",
|
||||
"${workspaceFolder}/ui",
|
||||
"/usr/include/x86_64-linux-gnu/qt5/**"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/g++",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef BUTTONMANAGER_H
|
||||
#define BUTTONMANAGER_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
namespace Ui {
|
||||
class ButtonManager;
|
||||
}
|
||||
|
||||
class ButtonManager : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ButtonManager(const Config& conf, QWidget *parent = nullptr);
|
||||
~ButtonManager();
|
||||
|
||||
private:
|
||||
Ui::ButtonManager *ui;
|
||||
|
||||
const Config& mainConfig;
|
||||
};
|
||||
|
||||
#endif // BUTTONMANAGER_H
|
|
@ -36,6 +36,7 @@ private slots:
|
|||
void alwaysOnTopSettingChange(int status);
|
||||
void addSample();
|
||||
void saveConfig();
|
||||
void openButtonManager();
|
||||
|
||||
signals:
|
||||
void newStatusMessage(const QString&);
|
||||
|
|
|
@ -27,6 +27,7 @@ SOURCES += \
|
|||
src/editsample.cpp \
|
||||
src/soundview.cpp \
|
||||
src/samplereader.cpp \
|
||||
src/buttonmanager.cpp \
|
||||
Log/Log.cpp
|
||||
|
||||
HEADERS += \
|
||||
|
@ -34,11 +35,12 @@ HEADERS += \
|
|||
include/sound.h \
|
||||
include/sounddevice.h \
|
||||
include/soundbutton.h \
|
||||
miniaudio/miniaudio.h \
|
||||
include/config.h \
|
||||
include/editsample.h \
|
||||
include/soundview.h \
|
||||
include/samplereader.h \
|
||||
include/buttonmanager.h \
|
||||
miniaudio/miniaudio.h \
|
||||
Log/Log.h
|
||||
|
||||
MOC_DIR = generated/
|
||||
|
@ -46,6 +48,7 @@ UI_DIR = ui/
|
|||
OBJECTS_DIR = obj/
|
||||
|
||||
FORMS += \
|
||||
ui/buttonmanager.ui \
|
||||
ui/editsample.ui \
|
||||
ui/mainwindow.ui
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
#include "buttonmanager.h"
|
||||
#include "ui_buttonmanager.h"
|
||||
|
||||
ButtonManager::ButtonManager(const Config& conf, QWidget *parent) : QDialog(parent), ui(new Ui::ButtonManager), mainConfig(conf) {
|
||||
ui->setupUi(this);
|
||||
|
||||
|
||||
QList<QTreeWidgetItem*> items;
|
||||
for(uint8_t rownr = 0; rownr < conf.rootConfig.buttons.size(); ++rownr) {
|
||||
const std::vector<Config::ButtonConfig>& btnrow = conf.rootConfig.buttons.at(rownr);
|
||||
QTreeWidgetItem* row = new QTreeWidgetItem(1000);
|
||||
row->setData(0, 0, QVariant((int) rownr+1));
|
||||
items.push_back(row);
|
||||
|
||||
// iterate buttons in a row
|
||||
for(const Config::ButtonConfig& btn : btnrow) {
|
||||
QTreeWidgetItem* qbtn = new QTreeWidgetItem(1001);
|
||||
qbtn->setData(1, 0, QVariant(QString::fromStdString(btn.name)));
|
||||
qbtn->setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable);
|
||||
row->addChild(qbtn);
|
||||
|
||||
// iterate samples in a button
|
||||
for(uint8_t samplenr = 0; samplenr < btn.samples.size(); ++samplenr) {
|
||||
const Config::SampleConfig& sample = btn.samples.at(samplenr);
|
||||
QTreeWidgetItem* qsample = new QTreeWidgetItem(1002);
|
||||
qsample->setData(2, 0, QVariant((int) samplenr+1));
|
||||
qbtn->addChild(qsample);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QStringList labels;
|
||||
labels.push_back("Row");
|
||||
labels.push_back("Button");
|
||||
labels.push_back("Sample");
|
||||
|
||||
ui->buttonTreeWidget->addTopLevelItems(items);
|
||||
ui->buttonTreeWidget->setHeaderLabels(labels);
|
||||
}
|
||||
|
||||
ButtonManager::~ButtonManager() {
|
||||
delete ui;
|
||||
}
|
|
@ -92,6 +92,7 @@ void to_json(json& j, const Config::ButtonConfig& bc) {
|
|||
|
||||
if(bc.samples.size() == 1) {
|
||||
//dont use a json array when only one sample is present (inline instead)
|
||||
if(bc.samples.at(0).isValid())
|
||||
to_json(j, bc.samples.at(0));
|
||||
} else if(!bc.samples.empty()) {
|
||||
json samples = json::array();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include "buttonmanager.h"
|
||||
#include "editsample.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
|
@ -28,6 +29,7 @@ MainWindow::MainWindow(const std::string& binary, QWidget* parent) : QMainWindow
|
|||
QObject::connect(ui->stopButton, SIGNAL( clicked() ), this, SLOT( stop() ));
|
||||
QObject::connect(ui->actionAddButton, SIGNAL( triggered() ), this, SLOT( addSample() ));
|
||||
QObject::connect(ui->actionSaveConfig, SIGNAL( triggered() ), this, SLOT( saveConfig() ));
|
||||
QObject::connect(ui->actionButtonManager, SIGNAL( triggered() ), this, SLOT( openButtonManager() ));
|
||||
QObject::connect(ui->allwaysOnTop, SIGNAL( stateChanged(int) ), this, SLOT( alwaysOnTopSettingChange(int) ));
|
||||
QObject::connect(stopGlobal, SIGNAL( activated() ), this, SLOT( stop() ));
|
||||
QObject::connect(this, SIGNAL(newStatusMessage(const QString&)), ui->statusbar, SLOT(showMessage(const QString&)));
|
||||
|
@ -37,7 +39,6 @@ MainWindow::MainWindow(const std::string& binary, QWidget* parent) : QMainWindow
|
|||
QObject::connect(left, SIGNAL( activated() ), this, SLOT( moveLeft() ));
|
||||
QObject::connect(right, SIGNAL( activated() ), this, SLOT( moveRight() ));
|
||||
QObject::connect(play, SIGNAL( activated() ), this, SLOT( playCurrent() ));
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
|
@ -164,6 +165,13 @@ void MainWindow::saveConfig() {
|
|||
config.save();
|
||||
}
|
||||
|
||||
void MainWindow::openButtonManager() {
|
||||
Log::info << "openButtonManager";
|
||||
|
||||
ButtonManager buttonManager(config, this);
|
||||
buttonManager.exec();
|
||||
}
|
||||
|
||||
void MainWindow::loadSoundFromConfig() {
|
||||
Sound& sound = Sound::instance(); // init sound
|
||||
sound.reset();
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ButtonManager</class>
|
||||
<widget class="QDialog" name="ButtonManager">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeWidget" name="buttonTreeWidget">
|
||||
<property name="columnCount">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ButtonManager</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>227</x>
|
||||
<y>278</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ButtonManager</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>295</x>
|
||||
<y>284</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -85,6 +85,7 @@
|
|||
<string>Edit</string>
|
||||
</property>
|
||||
<addaction name="actionAddButton"/>
|
||||
<addaction name="actionButtonManager"/>
|
||||
<addaction name="actionSaveConfig"/>
|
||||
</widget>
|
||||
<addaction name="menuEdit"/>
|
||||
|
@ -106,6 +107,14 @@
|
|||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionButtonManager">
|
||||
<property name="text">
|
||||
<string>ButtonManager</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+B</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
Loading…
Reference in New Issue