aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/qmpdeviceprioritydialog.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2020-04-19 23:36:48 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2020-04-19 23:36:48 +0800
commit6d568d07b31ba2ae39703cfd272d3003ea542018 (patch)
tree58dca1ac27ffe9dd6bb045c5a71d04644b7a2e07 /qmidiplayer-desktop/qmpdeviceprioritydialog.cpp
parentc7bf3e37e6eaed6895c797f72ef116b42c6f8a44 (diff)
downloadQMidiPlayer-6d568d07b31ba2ae39703cfd272d3003ea542018.tar.xz
Legacy code massacre!
Complete reconstruction of the settings infrastructure. All options are now registered using a revamped option API. Legacy configuration files are no longer compatible. Please make a backup.
Diffstat (limited to 'qmidiplayer-desktop/qmpdeviceprioritydialog.cpp')
-rw-r--r--qmidiplayer-desktop/qmpdeviceprioritydialog.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/qmidiplayer-desktop/qmpdeviceprioritydialog.cpp b/qmidiplayer-desktop/qmpdeviceprioritydialog.cpp
index d26fb45..bf358d8 100644
--- a/qmidiplayer-desktop/qmpdeviceprioritydialog.cpp
+++ b/qmidiplayer-desktop/qmpdeviceprioritydialog.cpp
@@ -16,7 +16,6 @@ qmpDevicePriorityDialog::qmpDevicePriorityDialog(QWidget *parent) :
ui->tvDevices->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
ui->tvDevices->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
model->setHorizontalHeaderLabels({"E","Device","Connected?"});
- setdevs=qmpSettingsWindow::getSettingsIntf()->value("Midi/DevicePriority",QList<QVariant>{"Internal FluidSynth"}).toList();
}
qmpDevicePriorityDialog::~qmpDevicePriorityDialog()
@@ -30,6 +29,7 @@ void qmpDevicePriorityDialog::setupRegisteredDevices()
auto conndevs=CMidiPlayer::getInstance()->getMidiOutDevices();
for(auto dev:conndevs)
sconn.insert(dev);
+ model->removeRows(0,model->rowCount());
for(auto dev:setdevs)
{
QStandardItem *e=new QStandardItem;
@@ -60,6 +60,21 @@ void qmpDevicePriorityDialog::setupRegisteredDevices()
}
}
+void qmpDevicePriorityDialog::load(void *data)
+{
+ setdevs=static_cast<QVariant*>(data)->toList();
+ setupRegisteredDevices();
+}
+
+void *qmpDevicePriorityDialog::save()
+{
+ QList<QVariant> ret;
+ for(int i=0;i<model->rowCount();++i)
+ if(model->item(i,0)->checkState()==Qt::CheckState::Checked)
+ ret.push_back(model->item(i,1)->text());
+ return new QVariant(ret);
+}
+
void qmpDevicePriorityDialog::on_pbUp_clicked()
{
const QModelIndex &idx=ui->tvDevices->selectionModel()->currentIndex();
@@ -88,9 +103,10 @@ void qmpDevicePriorityDialog::on_pbDown_clicked()
void qmpDevicePriorityDialog::on_buttonBox_accepted()
{
- QList<QVariant> setdevs;
- for(int i=0;i<model->rowCount();++i)
- if(model->item(i,0)->checkState()==Qt::CheckState::Checked)
- setdevs.push_back(model->item(i,1)->text());
- qmpSettingsWindow::getSettingsIntf()->setValue("Midi/DevicePriority",setdevs);
+ accept();
+}
+
+void qmpDevicePriorityDialog::on_buttonBox_rejected()
+{
+ reject();
}