diff options
-rw-r--r-- | qmidiplayer-desktop/qmpdevpropdialog.cpp | 28 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpdevpropdialog.ui | 5 |
2 files changed, 16 insertions, 17 deletions
diff --git a/qmidiplayer-desktop/qmpdevpropdialog.cpp b/qmidiplayer-desktop/qmpdevpropdialog.cpp index 30f1568..82136dc 100644 --- a/qmidiplayer-desktop/qmpdevpropdialog.cpp +++ b/qmidiplayer-desktop/qmpdevpropdialog.cpp @@ -17,8 +17,13 @@ qmpDevPropDialog::qmpDevPropDialog(QWidget *parent) : ui->twProps->setItemDelegateForColumn(0,new qmpDeviceItemDelegate(true,ui->twProps)); ui->twProps->setEditTriggers(QAbstractItemView::EditTrigger::NoEditTriggers); connect(ui->twProps,&QTableWidget::cellClicked,[this](int r,int c){ - if(c!=0)return; - this->ui->twProps->edit(ui->twProps->model()->index(r,c)); + if(c==0) + this->ui->twProps->edit(ui->twProps->model()->index(r,c)); + if(c==3) + { + QString p=QFileDialog::getOpenFileUrl(this,"Select Device Initialization File",QUrl()).path(); + 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; @@ -65,18 +70,11 @@ void qmpDevPropDialog::setupRow(const QString&dn,const QString&din) ui->twProps->setItem(r,1,cbx); QTableWidgetItem *cb; ui->twProps->setItem(r,0,cb=new QTableWidgetItem); - QWidget *fw=new QWidget; - QLabel *lb;QPushButton *pb; - fw->setLayout(new QHBoxLayout); - fw->layout()->addWidget(lb=new QLabel); - lb->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); - if(din.length()){lb->setText(din);fw->setProperty("fn",din);} - fw->layout()->addWidget(pb=new QPushButton); - pb->setText("..."); - pb->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); + ui->twProps->setItem(r,2,new QTableWidgetItem); + 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"); - ui->twProps->setCellWidget(r,2,fw); ui->twProps->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents); if(dn.length()) { @@ -87,10 +85,6 @@ void qmpDevPropDialog::setupRow(const QString&dn,const QString&din) cb->setFlags(cb->flags()&(~Qt::ItemFlag::ItemIsEnabled)); else cb->setFlags(cb->flags()|Qt::ItemFlag::ItemIsEnabled); } - connect(pb,&QPushButton::clicked,this,[this,lb,fw]{ - lb->setText(QFileDialog::getOpenFileUrl(this,"Select Device Initialization File",QUrl()).path()); - fw->setProperty("fn",lb->text()); - }); } void qmpDevPropDialog::on_buttonBox_accepted() @@ -101,7 +95,7 @@ void qmpDevPropDialog::on_buttonBox_accepted() for(int i=0;i<ui->twProps->rowCount();++i) { s->setValue(ui->twProps->item(i,0)->text(), - ui->twProps->cellWidget(i,2)->property("fn").toString()); + ui->twProps->item(i,2)->text()); } s->endGroup(); s->sync(); diff --git a/qmidiplayer-desktop/qmpdevpropdialog.ui b/qmidiplayer-desktop/qmpdevpropdialog.ui index 641a511..9309bfc 100644 --- a/qmidiplayer-desktop/qmpdevpropdialog.ui +++ b/qmidiplayer-desktop/qmpdevpropdialog.ui @@ -37,6 +37,11 @@ <string>Device Initialization File</string> </property> </column> + <column> + <property name="text"> + <string/> + </property> + </column> </widget> </item> <item> |