Current event type are preselected when edited

Added splitter to separate the preset list and its the parameters table more evenly
Cleaned unused functions
master
Yohann Dedy 2017-02-28 23:20:46 +01:00
parent c5dabe49ee
commit c0ca86dd41
4 changed files with 96 additions and 37 deletions

View File

@ -3,7 +3,6 @@
eventWindow::eventWindow(QWidget *parent) : eventWindow::eventWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
//_eventsList(new QStringList),
_eventsTable(new QTableWidget) _eventsTable(new QTableWidget)
{ {
QWidget *mainWidget = new QWidget(this); QWidget *mainWidget = new QWidget(this);
@ -29,6 +28,12 @@ eventWindow::eventWindow(QWidget *parent) :
for(int c=0; c<4; c++){ for(int c=0; c<4; c++){
QString nom = _eventsList.at(32*c+r); QString nom = _eventsList.at(32*c+r);
_eventsTable->setItem(r,c,new QTableWidgetItem(nom)); _eventsTable->setItem(r,c,new QTableWidgetItem(nom));
if(nom.isEmpty())
{
// TO DO SET GREY COLOR TO DISABLED CELLS
// _eventsTable->item(r,c)->setBackgroundColor(QColor().black());
_eventsTable->item(r,c)->setFlags(Qt::ItemIsEnabled);
}
} }
} }
@ -38,7 +43,6 @@ eventWindow::eventWindow(QWidget *parent) :
mainWidget->setLayout(mainLayout); mainWidget->setLayout(mainLayout);
this->setCentralWidget(mainWidget); this->setCentralWidget(mainWidget);
//connect(_eventsTable,SIGNAL(cellDoubleClicked(int,int)),this,SLOT(updatePreset(int, int)));
connect(_eventsTable,SIGNAL(cellDoubleClicked(int,int)),parent,SLOT(updateEventCell(int,int))); connect(_eventsTable,SIGNAL(cellDoubleClicked(int,int)),parent,SLOT(updateEventCell(int,int)));
} }
@ -46,13 +50,3 @@ eventWindow::~eventWindow()
{ {
} }
void eventWindow::updatePreset(int r, int c)
{
int presetNum = c*32 + r;
//emit this->updateMainWindow(_eventsList.at(presetNum));
qDebug() << "Event #" << presetNum;
qDebug() << "Event name" << _eventsList.at(presetNum);
}

View File

@ -18,7 +18,6 @@ public:
signals: signals:
public slots: public slots:
void updatePreset(int row, int col);
}; };
#endif // EVENTWINDOW_H #endif // EVENTWINDOW_H

View File

@ -20,6 +20,13 @@ mainWindow::mainWindow(QWidget *parent) :
_midiIn(new QMidiIn(this)), _midiIn(new QMidiIn(this)),
_midiOut(new QMidiOut(this)) _midiOut(new QMidiOut(this))
{ {
for(int i=0; i<8; i++){
_presetSlider.append(new QSlider());
if(i==7) _presetSlider.at(7)->setDisabled(true);
connect(_presetSlider.at(i),SIGNAL(valueChanged(int)),this,SLOT(updateSelectedPreset()));
}
this->setFixedSize(1024,768); this->setFixedSize(1024,768);
_prefixPocketC = {0xF0,0x00,0x20,0x20,0x14,0x00}; _prefixPocketC = {0xF0,0x00,0x20,0x20,0x14,0x00};
_midiIn->setIgnoreTypes(false, false, false); _midiIn->setIgnoreTypes(false, false, false);
@ -37,7 +44,7 @@ mainWindow::mainWindow(QWidget *parent) :
QWidget *mainWidget = new QWidget(this); QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget); QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
QHBoxLayout *tableLayout = new QHBoxLayout; QSplitter *presetSplitter = new QSplitter(mainWidget);
// Menu Bar // Menu Bar
@ -61,18 +68,37 @@ mainWindow::mainWindow(QWidget *parent) :
_menuBar->addMenu(mainMenu); _menuBar->addMenu(mainMenu);
mainLayout->addWidget(_menuBar); mainLayout->addWidget(_menuBar);
QHBoxLayout *toolBar = new QHBoxLayout;
QPushButton *getPresetButton = new QPushButton; QPushButton *getPresetButton = new QPushButton;
getPresetButton->setText("Get preset"); getPresetButton->setText("Get preset");
mainLayout->addWidget(getPresetButton);
connect(getPresetButton, SIGNAL(clicked(bool)),this,SLOT(sendSingleDumpRequest())); connect(getPresetButton, SIGNAL(clicked(bool)),this,SLOT(sendSingleDumpRequest()));
QHBoxLayout *presetPins = new QHBoxLayout;
for(int i=0; i<8; i++)
{
_presetSlider.at(i)->setMaximum(1);
_presetSlider.at(i)->setFixedHeight(50);
_presetSlider.at(i)->setFixedWidth(20);
_presetSlider.at(i)->setInvertedAppearance(true);
presetPins->addWidget(_presetSlider.at(i));
}
toolBar->addWidget(getPresetButton);
toolBar->addLayout(presetPins);
mainLayout->addLayout(toolBar);
// Table // Table
for(int i=0; i<128; i++){ for(int i=0; i<128; i++){
QString defaultCelString = QString("Preset #%1").arg(i+1); QString defaultCelString = QString("Preset #%1").arg(i+1);
_presetsList->addItem(defaultCelString); _presetsList->addItem(defaultCelString);
} }
connect(_presetsList,SIGNAL(itemSelectionChanged()),this,SLOT(updateTable())); //connect(_presetsList,SIGNAL(itemSelectionChanged()),this,SLOT(updateTable()));
connect(_presetsList,SIGNAL(itemSelectionChanged()),this,SLOT(updateSliders()));
QStringList settingsList; QStringList settingsList;
settingsList << "Channel" << "Type" << "Parameter" << "Description" ; settingsList << "Channel" << "Type" << "Parameter" << "Description" ;
@ -82,15 +108,14 @@ mainWindow::mainWindow(QWidget *parent) :
_presetSettingsTable->setSelectionMode(QAbstractItemView::SingleSelection); _presetSettingsTable->setSelectionMode(QAbstractItemView::SingleSelection);
_presetSettingsTable->setHorizontalHeaderLabels(settingsList); _presetSettingsTable->setHorizontalHeaderLabels(settingsList);
tableLayout->addWidget(_presetsList); presetSplitter->addWidget(_presetsList);
tableLayout->addWidget(_presetSettingsTable); presetSplitter->addWidget(_presetSettingsTable);
presetSplitter->setStretchFactor(1,1);
mainLayout->addLayout(tableLayout); mainLayout->addWidget(presetSplitter);
mainWidget->setLayout(mainLayout); mainWidget->setLayout(mainLayout);
setCentralWidget(mainWidget); setCentralWidget(mainWidget);
connect(_midiIn, SIGNAL(midiMessageReceived(QMidiMessage*)), this, SLOT(onMidiMessageReceive(QMidiMessage*))); connect(_midiIn, SIGNAL(midiMessageReceived(QMidiMessage*)), this, SLOT(onMidiMessageReceive(QMidiMessage*)));
connect(_presetSettingsTable, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(presetCellClicked(int,int))); connect(_presetSettingsTable, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(presetCellClicked(int,int)));
connect(settings, SIGNAL(triggered(bool)), this, SLOT(openSettingsWindow())); connect(settings, SIGNAL(triggered(bool)), this, SLOT(openSettingsWindow()));
@ -131,8 +156,6 @@ void mainWindow::onMidiMessageReceive(QMidiMessage *message)
} }
} }
} }
//qDebug() << "BYTE #7 : " << rawMessage.at(6) ; // DEBUG
} }
void mainWindow::presetCellClicked(int row, int column) void mainWindow::presetCellClicked(int row, int column)
@ -144,13 +167,23 @@ void mainWindow::presetCellClicked(int row, int column)
_eventWindow->setWindowTitle("Event"); _eventWindow->setWindowTitle("Event");
if(column == 1) if(column == 1)
{ {
// TODO : Preselect currently used preset int presetNum = _presetsList->currentRow();
// QModelIndex newIndex = _presetSettingsTable->_eventsTable->model()->index(10,3); int eventNum = _preset[presetNum][1][row];
// _eventWindow->_eventsTable->setCurrentIndex(newIndex);
// _eventWindow->_eventsTable->setFocus(); int r = eventNum % 32;
int c = (eventNum - r) / 32;
QModelIndex currentEvent = _eventWindow->_eventsTable->model()->index(r,c);
_eventWindow->_eventsTable->setCurrentIndex(currentEvent);
_eventWindow->_eventsTable->setFocus();
_eventWindow->show(); _eventWindow->show();
} }
if(column == 2) _paramWindow->show();
if(column == 2)
{
// TODO : CREATE A PARAM WINDOW
_paramWindow->show();
}
} }
void mainWindow::openSettingsWindow() void mainWindow::openSettingsWindow()
@ -191,8 +224,10 @@ void mainWindow::updatePreset(QMidiMessage *message)
void mainWindow::updateTable() void mainWindow::updateTable()
{ {
for(int i=0; i<3; i++){ for(int i=0; i<3; i++)
for(int j=0; j<16; j++){ {
for(int j=0; j<16; j++)
{
QString value = QString::number(_preset[_presetsList->currentRow()][i][j]); QString value = QString::number(_preset[_presetsList->currentRow()][i][j]);
if(i==1) value = _eventWindow->_eventsList.at(_preset[_presetsList->currentRow()][i][j]); if(i==1) value = _eventWindow->_eventsList.at(_preset[_presetsList->currentRow()][i][j]);
_presetSettingsTable->setItem(j,i,new QTableWidgetItem(value)); _presetSettingsTable->setItem(j,i,new QTableWidgetItem(value));
@ -212,20 +247,45 @@ void mainWindow::updateEventCell(int r, int c)
_eventWindow->close(); _eventWindow->close();
} }
void mainWindow::openMidiPorts(){ void mainWindow::updateSelectedPreset()
{
std::bitset<8> presetNum;
for(int i=0; i<8; i++)
{
presetNum.set(i,_presetSlider.at(i)->value());
}
_presetsList->setCurrentRow(presetNum.to_ulong());
updateTable();
}
void mainWindow::updateSliders()
{
std::bitset<8> presetNum (_presetsList->currentRow());
for(int i=0; i<8; i++)
{
_presetSlider.at(i)->setValue(presetNum.test(i));
}
updateTable();
}
void mainWindow::openMidiPorts()
{
_midiIn->closePort(); _midiIn->closePort();
_midiOut->closePort(); _midiOut->closePort();
if(_settingsWindow->_inPortComboBox->currentText() != "None"){ if(_settingsWindow->_inPortComboBox->currentText() != "None")
{
qDebug()<< "Selected MIDI IN : " <<_settingsWindow->_inPortComboBox->currentText(); qDebug()<< "Selected MIDI IN : " <<_settingsWindow->_inPortComboBox->currentText();
_midiIn->openPort(_settingsWindow->_inPortComboBox->currentIndex()); _midiIn->openPort(_settingsWindow->_inPortComboBox->currentIndex());
} }
if(_settingsWindow->_outPortComboBox->currentText() != "None"){ if(_settingsWindow->_outPortComboBox->currentText() != "None")
{
qDebug()<< "Selected MIDI OUT : " <<_settingsWindow->_outPortComboBox->currentText(); qDebug()<< "Selected MIDI OUT : " <<_settingsWindow->_outPortComboBox->currentText();
_midiOut->openPort(_settingsWindow->_outPortComboBox->currentIndex()); _midiOut->openPort(_settingsWindow->_outPortComboBox->currentIndex());
} }
} }
void mainWindow::sendThruMasterChnRequest(){ void mainWindow::sendThruMasterChnRequest()
{
std::vector<unsigned char> rawRequest; std::vector<unsigned char> rawRequest;
rawRequest = _prefixPocketC; rawRequest = _prefixPocketC;
rawRequest.push_back(0x56); rawRequest.push_back(0x56);
@ -235,7 +295,8 @@ void mainWindow::sendThruMasterChnRequest(){
if(_midiOut->isPortOpen()) _midiOut->sendRawMessage(rawRequest); if(_midiOut->isPortOpen()) _midiOut->sendRawMessage(rawRequest);
} }
void mainWindow::sendSingleDumpRequest(){ void mainWindow::sendSingleDumpRequest()
{
std::vector<unsigned char> rawRequest; std::vector<unsigned char> rawRequest;
rawRequest = _prefixPocketC; rawRequest = _prefixPocketC;
rawRequest.push_back(0x26); rawRequest.push_back(0x26);
@ -245,7 +306,8 @@ void mainWindow::sendSingleDumpRequest(){
if(_midiOut->isPortOpen()) _midiOut->sendRawMessage(rawRequest); if(_midiOut->isPortOpen()) _midiOut->sendRawMessage(rawRequest);
} }
void mainWindow::sendAllDumpRequest(){ void mainWindow::sendAllDumpRequest()
{
_presetsList->setCurrentRow(0); _presetsList->setCurrentRow(0);
for(int i=0; i<_presetsList->count(); i++){ for(int i=0; i<_presetsList->count(); i++){
_presetsList->setCurrentRow(i); _presetsList->setCurrentRow(i);
@ -255,7 +317,8 @@ void mainWindow::sendAllDumpRequest(){
} }
void mainWindow::sendSingleDump(){ void mainWindow::sendSingleDump()
{
std::vector<unsigned char> rawRequest; std::vector<unsigned char> rawRequest;
rawRequest = _prefixPocketC; rawRequest = _prefixPocketC;
rawRequest.push_back(0x20); rawRequest.push_back(0x20);

View File

@ -38,6 +38,7 @@ public:
QListWidget* _presetsList; QListWidget* _presetsList;
QTableWidget* _presetSettingsTable; QTableWidget* _presetSettingsTable;
QMenuBar* _menuBar; QMenuBar* _menuBar;
QList<QSlider*> _presetSlider;
~mainWindow(); ~mainWindow();
@ -65,6 +66,8 @@ public slots:
void updatePreset(QMidiMessage* message); void updatePreset(QMidiMessage* message);
void updateTable(); void updateTable();
void updateEventCell(int row, int col); void updateEventCell(int row, int col);
void updateSelectedPreset();
void updateSliders();
private slots: private slots:
void openMidiPorts(); void openMidiPorts();