Skip to content
Snippets Groups Projects
Commit 3d4c827d authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

rm 'Edit structure' button (#758)

parent 6bce451b
No related branches found
No related tags found
1 merge request!2004rm 'Edit structure' button (#758)
Pipeline #114412 passed
......@@ -68,8 +68,6 @@ LayerForm::LayerForm(QWidget* parent, LayerItem* layerItem, SampleEditorControll
{
m_moveButton = new WidgetMoverButton(this, this, 1);
m_moveButton->setToolTip("Move layer up/down");
connect(m_moveButton, &WidgetMoverButton::startingToMove, ec,
&SampleEditorController::onStartingToMoveLayer);
connect(m_moveButton, &WidgetMoverButton::finishedMoving, ec,
&SampleEditorController::onStoppedToMoveLayer);
m_collapser->addWidget(m_moveButton);
......
......@@ -30,7 +30,6 @@ LayerOrientedSampleEditor::LayerOrientedSampleEditor(QWidget* parent, ProjectDoc
, m_currentSampleWidget(nullptr)
, m_undoAction(nullptr)
, m_redoAction(nullptr)
, m_showInlineEditButtonsAction(nullptr)
, m_currentSample(nullptr)
, m_document(document)
{
......@@ -39,20 +38,12 @@ LayerOrientedSampleEditor::LayerOrientedSampleEditor(QWidget* parent, ProjectDoc
m_scrollArea->setWidget(createEmptyWidget());
m_toolbar = new StyledToolbar(this);
m_toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
auto* mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->setSpacing(0);
mainLayout->addWidget(m_toolbar);
mainLayout->addWidget(m_scrollArea);
m_showInlineEditButtonsAction = new QAction(QIcon(":/images/edit.svg"), "Edit structure", this);
connect(m_showInlineEditButtonsAction, &QAction::toggled, this,
&LayerOrientedSampleEditor::onShowInlineEditButtonsToggled);
m_showInlineEditButtonsAction->setCheckable(true);
m_showInlineEditButtonsAction->setChecked(true);
m_toolbar->addAction(m_showInlineEditButtonsAction);
}
LayerOrientedSampleEditor::~LayerOrientedSampleEditor()
......@@ -105,7 +96,6 @@ void LayerOrientedSampleEditor::setCurrentSample(SampleItem* sampleItem)
ec->setSampleForm(m_currentSampleWidget);
m_currentSampleWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
m_scrollArea->setWidget(m_currentSampleWidget);
m_currentSampleWidget->showInlineEditButtons(m_showInlineEditButtonsAction->isChecked());
updateActionEnabling();
}
......@@ -119,12 +109,6 @@ void LayerOrientedSampleEditor::updateActionEnabling()
m_redoAction->setVisible(false);
}
void LayerOrientedSampleEditor::onShowInlineEditButtonsToggled(bool checked)
{
if (m_currentSampleWidget)
m_currentSampleWidget->showInlineEditButtons(checked);
}
void LayerOrientedSampleEditor::createLayerColors() // #baLayerEditor move to better place
{
if (!m_currentSample)
......
......@@ -43,7 +43,6 @@ signals:
private:
void updateActionEnabling();
void onShowInlineEditButtonsToggled(bool checked);
void createLayerColors();
......@@ -56,7 +55,6 @@ private:
QToolBar* m_toolbar;
QAction* m_undoAction; // dedicated to the current sample
QAction* m_redoAction;
QAction* m_showInlineEditButtonsAction;
SampleItem* m_currentSample = nullptr;
QMap<SampleItem*, SampleEditorController*> m_editControllers;
ProjectDocument* m_document;
......
......@@ -151,7 +151,6 @@ void SampleEditorController::removeLayerItemFromUndo(int atIndex)
emit aboutToRemoveItem(layer);
m_sampleForm->onAboutToRemoveLayer(layer);
m_sampleItem->removeLayer(layer);
m_sampleForm->updateRowVisibilities();
emit modified();
}
......@@ -384,8 +383,7 @@ void SampleEditorController::setDoubleFromUndo(double newValue, const QString& p
spinBox->setPropertyValue(newValue);
m_sampleForm->ensureVisible(spinBox);
QSignalBlocker b(spinBox);
QSignalBlocker _(spinBox);
spinBox->setBaseValue(newValue);
spinBox->setFocus();
spinBox->selectAll();
......@@ -459,17 +457,9 @@ void SampleEditorController::setDensityRelatedValue(InterferenceItem* interferen
}
}
void SampleEditorController::onStartingToMoveLayer()
{
ASSERT(m_sampleForm);
m_sampleForm->showAddLayerButtons(false);
}
void SampleEditorController::onStoppedToMoveLayer(QWidget* widgetToMove,
QWidget* moveAboveThisWidget)
{
ASSERT(m_sampleForm);
m_sampleForm->showAddLayerButtons(true);
auto* itemToMove = dynamic_cast<LayerForm*>(widgetToMove)->layerItem();
const auto* moveAboveThisLayerForm = m_sampleForm->findNextLayerForm(moveAboveThisWidget);
......
......@@ -122,7 +122,6 @@ public:
void setDensityRelatedValue(InterferenceItem* interferenceItem, double newValue,
DoubleProperty& d);
void onStartingToMoveLayer();
void onStoppedToMoveLayer(QWidget* widgetToMove, QWidget* moveAboveThisWidget);
void setSampleName(const QString& name);
......
......@@ -112,12 +112,6 @@ SampleForm::SampleForm(QWidget* parent, SampleItem* sampleItem, SampleEditorCont
m_layout->addStretch(1);
}
void SampleForm::showInlineEditButtons(bool b)
{
m_showInlineEditButtons = b;
updateRowVisibilities();
}
void SampleForm::onLayerAdded(LayerItem* layerItem)
{
const int rowInMultiLayer = m_sampleItem->layerItems().indexOf(layerItem);
......@@ -128,8 +122,6 @@ void SampleForm::onLayerAdded(LayerItem* layerItem)
// same row => button is above!
m_layout->insertWidget(rowInLayout, new AddLayerWidget(this, layerItem, m_ec));
updateRowVisibilities();
}
void SampleForm::onLayerMoved(LayerItem* layerItem)
......@@ -161,8 +153,6 @@ void SampleForm::onLayerMoved(LayerItem* layerItem)
// same row => button is above!
m_layout->insertWidget(rowInLayout, al);
updateRowVisibilities();
}
void SampleForm::onAboutToRemoveLayer(LayerItem* layerItem)
......@@ -192,42 +182,6 @@ void SampleForm::onAboutToRemoveLayer(LayerItem* layerItem)
delete addLayerWidget;
}
void SampleForm::updateRowVisibilities()
{
for (auto* c : findChildren<QWidget*>()) {
if (auto* w = dynamic_cast<LayerForm*>(c))
w->enableStructureEditing(m_showInlineEditButtons);
if (auto* w = dynamic_cast<ParticleLayoutForm*>(c))
w->enableStructureEditing(m_showInlineEditButtons);
if (auto* w = dynamic_cast<ParticleForm*>(c))
w->enableStructureEditing(m_showInlineEditButtons);
if (auto* w = dynamic_cast<CompoundForm*>(c))
w->enableStructureEditing(m_showInlineEditButtons);
if (auto* w = dynamic_cast<CoreAndShellForm*>(c))
w->enableStructureEditing(m_showInlineEditButtons);
if (auto* w = dynamic_cast<MesocrystalForm*>(c))
w->enableStructureEditing(m_showInlineEditButtons);
}
showAddLayerButtons(m_showInlineEditButtons);
for (auto* c : findChildren<LayerForm*>())
c->updateLayerPositionDependentElements();
}
void SampleForm::ensureVisible(QWidget* /*w*/)
{
// #baLayerEditor implement ensureVisible
}
void SampleForm::showAddLayerButtons(bool show)
{
for (auto* c : findChildren<QWidget*>())
if (dynamic_cast<AddLayerWidget*>(c))
c->setVisible(show);
}
LayerForm* SampleForm::findNextLayerForm(QWidget* w)
{
while (w != nullptr && dynamic_cast<LayerForm*>(w) == nullptr) {
......
......@@ -29,9 +29,6 @@ class SampleForm : public QWidget {
public:
SampleForm(QWidget* parent, SampleItem* sampleItem, SampleEditorController* ec);
//! Show or hide all buttons related to structure editing (like "add layer", "remove particle")
void showInlineEditButtons(bool b);
//! Create widgets for the new layer.
void onLayerAdded(LayerItem* layerItem);
......@@ -45,13 +42,6 @@ public:
//! Any widgets related to the item will be deleted or scheduled for later deletion.
void onAboutToRemoveLayer(LayerItem* layerItem);
void updateRowVisibilities();
void ensureVisible(QWidget* w);
//! Shows or hides the "Add Layer" buttons.
void showAddLayerButtons(bool show);
//! Search for the next LayerForm, starting from the given widget.
//!
//! The search starts with the given widget itself If it is a LayerForm, it is returned.
......@@ -62,7 +52,6 @@ private:
QVBoxLayout* m_layout;
SampleItem* m_sampleItem; //!< Ptr is borrowed, don't delete
SampleEditorController* m_ec; //!< Ptr is borrowed, don't delete
bool m_showInlineEditButtons = false;
QList<QPushButton*> m_addLayerButtons;
};
......
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