Skip to content

Commit f9f9091

Browse files
author
etet100
committed
Use menu for view options
1 parent 7a30ecd commit f9f9091

3 files changed

Lines changed: 19 additions & 16 deletions

File tree

src/gpilot/ui/forms/partials/main/partmainprogram.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,18 @@ void PartMainProgram::setupUi()
5151
connect(ui->tblProgram, &QWidget::customContextMenuRequested, this, &PartMainProgram::onTableContextMenuRequested);
5252
ui->tblProgram->installEventFilter(this);
5353

54-
connect(ui->chkShowComments, &QCheckBox::checkStateChanged, this, [this](int state) {
55-
m_programModel.setCommentsVisible(state);
54+
auto* viewMenu = new QMenu(this);
55+
m_actionAutoScroll = viewMenu->addAction(tr("Auto scroll"));
56+
m_actionAutoScroll->setCheckable(true);
57+
m_actionShowComments = viewMenu->addAction(tr("Comments"));
58+
m_actionShowComments->setCheckable(true);
59+
m_actionShowComments->setChecked(true);
60+
61+
connect(m_actionShowComments, &QAction::toggled, this, [this](bool checked) {
62+
m_programModel.setCommentsVisible(checked);
63+
});
64+
connect(ui->btnViewOptions, &QPushButton::clicked, this, [this, viewMenu]() {
65+
viewMenu->popup(ui->btnViewOptions->mapToGlobal(QPoint(0, ui->btnViewOptions->height())));
5666
});
5767

5868
// Debounce filter input so every keystroke does not trigger a full
@@ -145,12 +155,12 @@ void PartMainProgram::refreshHeightmapSections()
145155

146156
void PartMainProgram::setAutoScroll(bool enabled)
147157
{
148-
ui->chkAutoScrollGCode->setChecked(enabled);
158+
m_actionAutoScroll->setChecked(enabled);
149159
}
150160

151161
bool PartMainProgram::isAutoScroll() const
152162
{
153-
return ui->chkAutoScrollGCode->isChecked();
163+
return m_actionAutoScroll->isChecked();
154164
}
155165

156166
void PartMainProgram::setHeightMapVisible(bool visible)

src/gpilot/ui/forms/partials/main/partmainprogram.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
class GCode;
1616
class Heightmap;
17+
class QAction;
1718

1819
namespace Ui {
1920
class PartMainProgram;
@@ -136,6 +137,8 @@ class PartMainProgram : public QWidget
136137
private:
137138
Ui::PartMainProgram* ui;
138139
QMenu* m_tableMenu;
140+
QAction* m_actionAutoScroll = nullptr;
141+
QAction* m_actionShowComments = nullptr;
139142

140143
struct SelRange {
141144
int from;

src/gpilot/ui/forms/partials/main/partmainprogram.ui

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,9 @@
146146
<number>0</number>
147147
</property>
148148
<item>
149-
<widget class="QCheckBox" name="chkAutoScrollGCode">
149+
<widget class="QPushButton" name="btnViewOptions">
150150
<property name="text">
151-
<string>Auto scroll</string>
152-
</property>
153-
</widget>
154-
</item>
155-
<item>
156-
<widget class="QCheckBox" name="chkShowComments">
157-
<property name="text">
158-
<string>Comments</string>
159-
</property>
160-
<property name="checked">
161-
<bool>true</bool>
151+
<string>View</string>
162152
</property>
163153
</widget>
164154
</item>

0 commit comments

Comments
 (0)