diff --git a/src/musredit_qt6/musrStep/PMusrStep.cpp b/src/musredit_qt6/musrStep/PMusrStep.cpp index bbe59ac6..92de1d48 100644 --- a/src/musredit_qt6/musrStep/PMusrStep.cpp +++ b/src/musredit_qt6/musrStep/PMusrStep.cpp @@ -55,27 +55,27 @@ PModSelect::PModSelect(QWidget *parent) : { setWindowTitle("Modify Selected"); - fScaleByFactor = new QPushButton("Scale by &Factor"); + fScaleByFactor = std::make_unique("Scale by &Factor"); fScaleByFactor->setWhatsThis("if pressed it will use the Factor value, and the absolut value selection to change the selected parameter steps."); - fFactorLabel = new QLabel("Factor"); - fFactorLineEdit = new QLineEdit("0.01"); + fFactorLabel = std::make_unique("Factor"); + fFactorLineEdit = std::make_unique("0.01"); fFactorLineEdit->setValidator(new QDoubleValidator); - fAbsVal = new QCheckBox("Absolute Value"); + fAbsVal = std::make_unique("Absolute Value"); fAbsVal->setWhatsThis("if checked, the factor is used as an absolut value rather than a multiplication factor for the selected steps."); QHBoxLayout *top = new QHBoxLayout; - top->addWidget(fScaleByFactor); - top->addWidget(fFactorLabel); - top->addWidget(fFactorLineEdit); - top->addWidget(fAbsVal); + top->addWidget(fScaleByFactor.get()); + top->addWidget(fFactorLabel.get()); + top->addWidget(fFactorLineEdit.get()); + top->addWidget(fAbsVal.get()); - fScaleAutomatic = new QPushButton("Scale &Automatically"); + fScaleAutomatic = std::make_unique("Scale &Automatically"); fScaleAutomatic->setWhatsThis("Will try to reset the step size of the selected items based on some crude rules"); - fCancel = new QPushButton("&Cancel"); + fCancel = std::make_unique("&Cancel"); QHBoxLayout *bottom = new QHBoxLayout; - bottom->addWidget(fScaleAutomatic); - bottom->addWidget(fCancel); + bottom->addWidget(fScaleAutomatic.get()); + bottom->addWidget(fCancel.get()); QVBoxLayout *main = new QVBoxLayout; main->addLayout(top); @@ -83,10 +83,10 @@ PModSelect::PModSelect(QWidget *parent) : setLayout(main); - connect(fAbsVal, SIGNAL(stateChanged(int)), this, SLOT(absoluteValueStateChanged(int))); - connect(fScaleAutomatic, SIGNAL(pressed()), this, SLOT(scaleAuto())); - connect(fScaleByFactor, SIGNAL(pressed()), this, SLOT(getFactor())); - connect(fCancel, SIGNAL(pressed()), this, SLOT(reject())); + connect(fAbsVal.get(), SIGNAL(stateChanged(int)), this, SLOT(absoluteValueStateChanged(int))); + connect(fScaleAutomatic.get(), SIGNAL(pressed()), this, SLOT(scaleAuto())); + connect(fScaleByFactor.get(), SIGNAL(pressed()), this, SLOT(getFactor())); + connect(fCancel.get(), SIGNAL(pressed()), this, SLOT(reject())); } //------------------------------------------------------------------------- @@ -151,7 +151,7 @@ PMusrStep::PMusrStep(const char *fln, QWidget *parent) : fValid = false; QString title = QString("%1").arg(fMsrFileName); - fTitleLabel = new QLabel(title); + fTitleLabel = std::make_unique(title); QLabel *icon = new QLabel(); if (isDarkTheme) str = QString(":/icons/musrStep-32x32-dark.svg"); @@ -160,7 +160,7 @@ PMusrStep::PMusrStep(const char *fln, QWidget *parent) : icon->setPixmap(QPixmap(str)); QHBoxLayout *titleLayout = new QHBoxLayout; - titleLayout->addWidget(fTitleLabel); + titleLayout->addWidget(fTitleLabel.get()); titleLayout->addWidget(icon); titleLayout->insertStretch(1); @@ -185,7 +185,7 @@ PMusrStep::PMusrStep(const char *fln, QWidget *parent) : setMinimumSize(400, height); // populate dialog - fParamTable = new QTableWidget(fParamVec.size(), 3); + fParamTable = std::make_unique(fParamVec.size(), 3); QStringList strL; strL << "name" << "value" << "step"; fParamTable->setHorizontalHeaderLabels(strL); @@ -202,54 +202,54 @@ PMusrStep::PMusrStep(const char *fln, QWidget *parent) : item = new QTableWidgetItem(fParamVec[i].step); fParamTable->setItem(i, 2, item); } - fCheckSpecific = new QPushButton("Check S&pecific"); + fCheckSpecific = std::make_unique("Check S&pecific"); fCheckSpecific->setWhatsThis("Allows to specify a template name which is used\nto select parameter names fitting to it."); - fCheckAll = new QPushButton("Check A&ll"); + fCheckAll = std::make_unique("Check A&ll"); fCheckAll->setWhatsThis("Select all parameter names,\nexcept the ones with step == 0"); - fUnCheckAll = new QPushButton("&Uncheck All"); + fUnCheckAll = std::make_unique("&Uncheck All"); fUnCheckAll->setWhatsThis("Unselect all parameter names"); QHBoxLayout *checkLayout = new QHBoxLayout; - checkLayout->addWidget(fCheckSpecific); - checkLayout->addWidget(fCheckAll); - checkLayout->addWidget(fUnCheckAll); + checkLayout->addWidget(fCheckSpecific.get()); + checkLayout->addWidget(fCheckAll.get()); + checkLayout->addWidget(fUnCheckAll.get()); - fModifyAuto = new QPushButton("Modify &Automatic"); + fModifyAuto = std::make_unique("Modify &Automatic"); fModifyAuto->setWhatsThis("Will try to reset the step size,\nbased on some crude rules"); fModifyAuto->setDefault(true); - fModifySelected = new QPushButton("&Modify Selected"); + fModifySelected = std::make_unique("&Modify Selected"); fModifySelected->setWhatsThis("Will call a dialog which all to specify how\nto proceed with the selected parameter steps."); QHBoxLayout *modifyLayout = new QHBoxLayout; - modifyLayout->addWidget(fModifyAuto); - modifyLayout->addWidget(fModifySelected); + modifyLayout->addWidget(fModifyAuto.get()); + modifyLayout->addWidget(fModifySelected.get()); - fSave = new QPushButton("&Save&&Quit"); - fCancel = new QPushButton("&Cancel"); + fSave = std::make_unique("&Save&&Quit"); + fCancel = std::make_unique("&Cancel"); QHBoxLayout *buttomLayout = new QHBoxLayout; - buttomLayout->addWidget(fSave); - buttomLayout->addWidget(fCancel); + buttomLayout->addWidget(fSave.get()); + buttomLayout->addWidget(fCancel.get()); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(titleLayout); - mainLayout->addWidget(fParamTable); + mainLayout->addWidget(fParamTable.get()); mainLayout->addLayout(checkLayout); mainLayout->addLayout(modifyLayout); mainLayout->addLayout(buttomLayout); setLayout(mainLayout); - connect(fParamTable, SIGNAL(cellChanged(int, int)), this, SLOT(handleCellChanged(int, int))); + connect(fParamTable.get(), SIGNAL(cellChanged(int, int)), this, SLOT(handleCellChanged(int, int))); - connect(fCheckSpecific, SIGNAL(pressed()), this, SLOT(checkSpecific())); - connect(fCheckAll, SIGNAL(pressed()), this, SLOT(checkAll())); - connect(fUnCheckAll, SIGNAL(pressed()), this, SLOT(unCheckAll())); + connect(fCheckSpecific.get(), SIGNAL(pressed()), this, SLOT(checkSpecific())); + connect(fCheckAll.get(), SIGNAL(pressed()), this, SLOT(checkAll())); + connect(fUnCheckAll.get(), SIGNAL(pressed()), this, SLOT(unCheckAll())); - connect(fModifyAuto, SIGNAL(pressed()), this, SLOT(modifyAuto())); - connect(fModifySelected, SIGNAL(pressed()), this, SLOT(modifyChecked())); - connect(fSave, SIGNAL(pressed()), this, SLOT(saveAndQuit())); - connect(fCancel, SIGNAL(pressed()), this, SLOT(reject())); + connect(fModifyAuto.get(), SIGNAL(pressed()), this, SLOT(modifyAuto())); + connect(fModifySelected.get(), SIGNAL(pressed()), this, SLOT(modifyChecked())); + connect(fSave.get(), SIGNAL(pressed()), this, SLOT(saveAndQuit())); + connect(fCancel.get(), SIGNAL(pressed()), this, SLOT(reject())); fModSelect = new PModSelect(this); connect(fModSelect, SIGNAL(scale(bool,double,bool)), this, SLOT(handleModSelect(bool,double,bool))); diff --git a/src/musredit_qt6/musrStep/PMusrStep.h b/src/musredit_qt6/musrStep/PMusrStep.h index e5c5573a..0a5091ab 100644 --- a/src/musredit_qt6/musrStep/PMusrStep.h +++ b/src/musredit_qt6/musrStep/PMusrStep.h @@ -30,6 +30,8 @@ #ifndef _PMUSRSTEP_H_ #define _PMUSRSTEP_H_ +#include + #include #include #include @@ -37,6 +39,7 @@ #include #include #include +#include struct PParam { QString number; @@ -65,12 +68,12 @@ class PModSelect : public QDialog void getFactor(); private: - QCheckBox *fAbsVal; - QLabel *fFactorLabel; - QLineEdit *fFactorLineEdit; - QPushButton *fScaleByFactor; - QPushButton *fScaleAutomatic; - QPushButton *fCancel; + std::unique_ptr fAbsVal; + std::unique_ptr fFactorLabel; + std::unique_ptr fFactorLineEdit; + std::unique_ptr fScaleByFactor; + std::unique_ptr fScaleAutomatic; + std::unique_ptr fCancel; }; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -98,15 +101,15 @@ class PMusrStep : public QDialog QVector fParamVec; - QLabel *fTitleLabel; - QTableWidget *fParamTable; - QPushButton *fCheckSpecific; - QPushButton *fCheckAll; - QPushButton *fUnCheckAll; - QPushButton *fModifyAuto; - QPushButton *fModifySelected; - QPushButton *fSave; - QPushButton *fCancel; + std::unique_ptr fTitleLabel; + std::unique_ptr fParamTable; + std::unique_ptr fCheckSpecific; + std::unique_ptr fCheckAll; + std::unique_ptr fUnCheckAll; + std::unique_ptr fModifyAuto; + std::unique_ptr fModifySelected; + std::unique_ptr fSave; + std::unique_ptr fCancel; PModSelect *fModSelect;