Skip to content
Snippets Groups Projects
Commit 4832e107 authored by Matthias Puchner's avatar Matthias Puchner Committed by Wuttke, Joachim
Browse files

remove outdated sub-dialog for editing name and description of an instrument

parent 4d6b9cca
No related branches found
No related tags found
1 merge request!708Refactor and simplify UI
Pipeline #57777 passed
......@@ -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()
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment