Skip to content

Commit 0e7b7e2

Browse files
committed
feat: hide depth field when a laser tool is selected
1 parent f7ff0f1 commit 0e7b7e2

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

src/model/application.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ bool Application::selectTool(const QString &toolName)
168168
if (tool) {
169169
if (m_openedDocument) {
170170
m_openedDocument->setToolConfig(*tool);
171+
emit toolChanged();
171172
}
172173
m_defaultToolConfig = tool;
173174

src/model/application.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class Application : public QObject
123123
void documentRestoredFromHistory(Document *newDocument);
124124
void titleChanged(QString title);
125125
void configChanged(config::Config &config);
126+
void toolChanged();
126127
void errorRaised(const QString& message) const;
127128
void fileSaved(const QString &fileName);
128129
};

src/view/task/path.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "model/application.h"
12
#include <path.h>
23

34
namespace view::task
@@ -27,6 +28,8 @@ Path::Path(model::Application &app)
2728
m_app(app)
2829
{
2930
setupUi(this);
31+
connect(&m_app, &model::Application::toolChanged, this, &Path::toolChanged);
32+
connect(&m_app, &model::Application::configChanged, this, &Path::configChanged);
3033
}
3134

3235
void Path::selectionChanged(bool empty)
@@ -44,4 +47,21 @@ void Path::selectionChanged(bool empty)
4447
}
4548
}
4649

50+
void Path::toolChanged()
51+
{
52+
updateFieldVisibility(document()->toolConfig());
53+
}
54+
55+
void Path::configChanged()
56+
{
57+
updateFieldVisibility(document()->toolConfig());
58+
}
59+
60+
void Path::updateFieldVisibility(const config::Tools::Tool& tool)
61+
{
62+
const bool toolHasDepth = !tool.general().laser();
63+
Ui::Path::depth->setVisible(toolHasDepth);
64+
depthLabel->setVisible(toolHasDepth);
65+
}
66+
4767
}

src/view/task/path.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ class Path : public model::DocumentModelObserver<QWidget>, private Ui::Path
1919
std::unique_ptr<model::PathGroupSettings> m_groupSettings;
2020

2121
void selectionChanged(bool empty);
22+
void toolChanged();
23+
void configChanged();
24+
25+
void updateFieldVisibility(const config::Tools::Tool& tool);
2226

2327
template <typename ValueType, class Field>
2428
void connectOnFieldChanged(Field *field, std::function<void (ValueType)> &&func)

template/uic/path.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
</widget>
8383
</item>
8484
<item row="3" column="0">
85-
<widget class="QLabel" name="label_2">
85+
<widget class="QLabel" name="depthLabel">
8686
<property name="text">
8787
<string>Depth</string>
8888
</property>

0 commit comments

Comments
 (0)