diff --git a/GUI/View/Instrument/InstrumentLibraryEditor.cpp b/GUI/View/Instrument/InstrumentLibraryEditor.cpp index 6b44717799bb65f2b19863192c5639128df3f470..1e892ff19033616668f828d02ce6e716c904989f 100644 --- a/GUI/View/Instrument/InstrumentLibraryEditor.cpp +++ b/GUI/View/Instrument/InstrumentLibraryEditor.cpp @@ -139,9 +139,6 @@ void InstrumentLibraryEditor::execAdd(const InstrumentItem& instrumentToAdd) m_ui->treeView->setCurrentIndex(index); m_ui->treeView->scrollTo(index, QAbstractItemView::PositionAtTop); createWidgetsForCurrentInstrument(); - setModal(true); - show(); - editNameAndDescription(addedInstrument); exec(); } @@ -172,13 +169,6 @@ QList<QAction*> InstrumentLibraryEditor::getOverlayActions(const QModelIndex& in if (item == nullptr) return {}; - auto* editAction = new QAction(this); - editAction->setText("Edit name and description"); - editAction->setIcon(QIcon(":/images/edit.svg")); - editAction->setIconText("Edit"); - editAction->setToolTip("Edit name and description"); - connect(editAction, &QAction::triggered, [=]() { editNameAndDescription(item); }); - auto* removeAction = new QAction(this); removeAction->setText("Remove"); removeAction->setIcon(QIcon(":/images/delete.svg")); @@ -186,50 +176,7 @@ QList<QAction*> InstrumentLibraryEditor::getOverlayActions(const QModelIndex& in removeAction->setToolTip("Remove this instrument"); connect(removeAction, &QAction::triggered, [=]() { m_treeModel->removeItem(item); }); - return {editAction, removeAction}; -} - -void InstrumentLibraryEditor::editNameAndDescription(InstrumentItem* item) -{ - QDialog dlg(this); - dlg.setObjectName("NameAndDescriptionDialog"); - dlg.setWindowTitle("Edit name and description of instrument"); - dlg.setWindowIcon(windowIcon()); - dlg.setWindowFlag(Qt::WindowContextHelpButtonHint, false); - dlg.setProperty("stylable", true); // for stylesheet addressing - - auto* layout = new QFormLayout(&dlg); - auto* nameEdit = new QLineEdit(&dlg); - nameEdit->setText(item->instrumentName()); - nameEdit->selectAll(); - - auto* descriptionEdit = new QTextEdit(&dlg); - descriptionEdit->setMinimumWidth(200); - descriptionEdit->setAcceptRichText(false); - descriptionEdit->setTabChangesFocus(true); - descriptionEdit->setPlainText(item->description()); - - auto* buttonBox = new QDialogButtonBox(&dlg); - buttonBox->addButton(QDialogButtonBox::Ok); - buttonBox->addButton(QDialogButtonBox::Cancel); - buttonBox->button(QDialogButtonBox::Ok)->setAutoDefault(true); - buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); - - layout->addRow("Name:", nameEdit); - layout->addRow("Description:", descriptionEdit); - layout->addWidget(buttonBox); - dlg.setLayout(layout); - - connect(buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept); - connect(buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject); - - appSettings->loadWindowSizeAndPos(&dlg); - if (dlg.exec() == QDialog::Accepted) { - QModelIndex index = m_treeModel->indexForItem(item); - m_treeModel->setData(index, nameEdit->text(), Qt::EditRole); - m_treeModel->setData(index, descriptionEdit->toPlainText(), Qt::ToolTipRole); - } - appSettings->saveWindowSizeAndPos(&dlg); + return {removeAction}; } void InstrumentLibraryEditor::createWidgetsForCurrentInstrument() diff --git a/GUI/View/Instrument/InstrumentLibraryEditor.h b/GUI/View/Instrument/InstrumentLibraryEditor.h index 812ad133ffa9947deac35873f5bd0b14763f2fdf..e0bc72c2bc0ea95519e40a7f4ba25714f8efc7a1 100644 --- a/GUI/View/Instrument/InstrumentLibraryEditor.h +++ b/GUI/View/Instrument/InstrumentLibraryEditor.h @@ -48,7 +48,6 @@ private: void onItemDoubleClickedForChoose(const QModelIndex& index); void onCurrentChangedForChoose(); QList<QAction*> getOverlayActions(const QModelIndex& index, bool asHover); - void editNameAndDescription(InstrumentItem* item); void createWidgetsForCurrentInstrument(); void onInstrumentNameEdited(const QString& newName);