diff options
author | Chris Xiong <chirs241097@gmail.com> | 2020-04-19 23:36:48 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2020-04-19 23:36:48 +0800 |
commit | 6d568d07b31ba2ae39703cfd272d3003ea542018 (patch) | |
tree | 58dca1ac27ffe9dd6bb045c5a71d04644b7a2e07 /qmidiplayer-desktop/qmpdevpropdialog.cpp | |
parent | c7bf3e37e6eaed6895c797f72ef116b42c6f8a44 (diff) | |
download | QMidiPlayer-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/qmpdevpropdialog.cpp')
-rw-r--r-- | qmidiplayer-desktop/qmpdevpropdialog.cpp | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/qmidiplayer-desktop/qmpdevpropdialog.cpp b/qmidiplayer-desktop/qmpdevpropdialog.cpp index 64c385d..3b9ccc4 100644 --- a/qmidiplayer-desktop/qmpdevpropdialog.cpp +++ b/qmidiplayer-desktop/qmpdevpropdialog.cpp @@ -21,15 +21,19 @@ qmpDevPropDialog::qmpDevPropDialog(QWidget *parent) : this->ui->twProps->edit(ui->twProps->model()->index(r,c)); if(c==3) { - QString p=QFileDialog::getOpenFileUrl(this,"Select Device Initialization File",QUrl()).toLocalFile(); + QString p=QFileDialog::getOpenFileUrl(this,tr("Select Device Initialization File"),QUrl()).toLocalFile(); if(p.length())this->ui->twProps->item(r,2)->setText(p); } }); connect(ui->twProps,&QTableWidget::cellChanged,this,[this](int r,int c){ if(c!=0)return; - QString connst("Disconnected"); + QString connst(tr("Disconnected")); for(auto&ds:qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices()) - if(ui->twProps->item(r,c)->text()==QString::fromStdString(ds)){connst="Connected";break;} + if(ui->twProps->item(r,c)->text()==QString::fromStdString(ds)) + { + connst=tr("Connected"); + break; + } ui->twProps->item(r,1)->setText(connst); }); } @@ -39,16 +43,31 @@ qmpDevPropDialog::~qmpDevPropDialog() delete ui; } -void qmpDevPropDialog::launch() +void qmpDevPropDialog::load(void *data) { - QSettings *s=qmpSettingsWindow::getSettingsIntf(); + QList<QVariant> lst=static_cast<QVariant*>(data)->toList(); ui->twProps->clearContents(); ui->twProps->setRowCount(0); - s->beginGroup("DevInit"); - for(auto&k:s->allKeys()) - setupRow(k,s->value(k).toString()); - s->endGroup(); - show(); + for(auto&i:lst) + { + QPair<QString,QString> p=i.value<QPair<QString,QString>>(); + setupRow(p.first,p.second); + } +} + +void *qmpDevPropDialog::save() +{ + QList<QVariant> ret; + for(int i=0;i<ui->twProps->rowCount();++i) + { + QPair<QString,QString> p + { + ui->twProps->item(i,0)->text(), + ui->twProps->item(i,2)->text() + }; + ret.push_back(QVariant::fromValue(p)); + } + return new QVariant(ret); } void qmpDevPropDialog::on_pbAdd_clicked() @@ -74,7 +93,7 @@ void qmpDevPropDialog::setupRow(const QString&dn,const QString&din) ui->twProps->setItem(r,3,new QTableWidgetItem("...")); if(din.length())ui->twProps->item(r,2)->setText(din); cbx->setFlags(Qt::ItemFlag::ItemIsEnabled|Qt::ItemFlag::ItemIsSelectable); - cbx->setText("Disconnected"); + cbx->setText(tr("Disconnected")); ui->twProps->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents); if(dn.length()) { @@ -89,14 +108,10 @@ void qmpDevPropDialog::setupRow(const QString&dn,const QString&din) void qmpDevPropDialog::on_buttonBox_accepted() { - QSettings *s=qmpSettingsWindow::getSettingsIntf(); - s->beginGroup("DevInit"); - s->remove(""); - for(int i=0;i<ui->twProps->rowCount();++i) - { - s->setValue(ui->twProps->item(i,0)->text(), - ui->twProps->item(i,2)->text()); - } - s->endGroup(); - s->sync(); + accept(); +} + +void qmpDevPropDialog::on_buttonBox_rejected() +{ + reject(); } |