Skip to content

Commit e8c7dc3

Browse files
authored
Merge pull request #338 from githubdoe/averageProfile
Average profile into master
2 parents cb4becf + 1de78b9 commit e8c7dc3

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

foucaultview.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ foucaultView::foucaultView(QWidget *parent, SurfaceManager *sm) :
4343
// Using name() and string check for robust color persistence
4444
m_gridColor = QColor(set.value("ronchiGrid/color", "#00FFFF").toString()); // Default Cyan
4545
m_textColor = QColor(set.value("ronchiGrid/textColor", "#FFFFFF").toString()); // Default White
46+
4647
}
4748

4849

@@ -118,19 +119,18 @@ void foucaultView::showGrid() {
118119
QCheckBox *textToggle = new QCheckBox("Show unit labels", &dlg);
119120
textToggle->setChecked(m_showUnitLabels);
120121

121-
// Color storage (using local temps for the dialog session)
122-
struct State { QColor grid; QColor text; } colors = { m_gridColor, m_textColor };
123-
124122
QPushButton *btnGridCol = new QPushButton("Grid Color");
125123
QPushButton *btnTextCol = new QPushButton("Text Color");
126124

127-
connect(btnGridCol, &QPushButton::clicked, [&]() {
128-
QColor c = QColorDialog::getColor(colors.grid, this);
129-
if (c.isValid()) colors.grid = c;
125+
m_temp_colors = { m_gridColor, m_textColor }; // store current values
126+
127+
connect(btnGridCol, &QPushButton::clicked, this,[this]() {
128+
QColor c = QColorDialog::getColor(m_temp_colors.grid, this);
129+
if (c.isValid()) m_temp_colors.grid = c;
130130
});
131-
connect(btnTextCol, &QPushButton::clicked, [&]() {
132-
QColor c = QColorDialog::getColor(colors.text, this);
133-
if (c.isValid()) colors.text = c;
131+
connect(btnTextCol, &QPushButton::clicked, this, [this]() {
132+
QColor c = QColorDialog::getColor(m_temp_colors.text, this);
133+
if (c.isValid()) m_temp_colors.text = c;
134134
});
135135

136136
form.addRow("Grid Units:", unitCombo);
@@ -146,13 +146,13 @@ void foucaultView::showGrid() {
146146
form.addRow(&buttonBox);
147147

148148
// Reset Logic
149-
connect(resetBtn, &QPushButton::clicked, [&]() {
149+
connect(resetBtn, &QPushButton::clicked, this, [=]() {
150150
unitCombo->setCurrentIndex(0); // None
151151
spacingSpin->setValue(10.0);
152152
widthSpin->setValue(1);
153153
textToggle->setChecked(true);
154-
colors.grid = Qt::cyan;
155-
colors.text = Qt::white;
154+
m_temp_colors.grid = Qt::cyan;
155+
m_temp_colors.text = Qt::white;
156156
});
157157

158158
connect(&buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept);
@@ -163,8 +163,8 @@ void foucaultView::showGrid() {
163163
m_gridSpacing = spacingSpin->value();
164164
m_gridLineWidth = widthSpin->value();
165165
m_showUnitLabels = textToggle->isChecked();
166-
m_gridColor = colors.grid;
167-
m_textColor = colors.text;
166+
m_gridColor = m_temp_colors.grid;
167+
m_textColor = m_temp_colors.text;
168168

169169
// Save to QSettings with "ronchiGrid" prefix
170170
QSettings set;

foucaultview.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ private slots:
109109
bool m_showUnitLabels = true;
110110
QColor m_gridColor = Qt::cyan;
111111
QColor m_textColor = Qt::white;
112+
struct State { QColor grid; QColor text; } m_temp_colors;
113+
112114

113115
void drawGridOverlay(QImage &img);
114116
explicit foucaultView(QWidget *parent = 0, SurfaceManager *sm = 0);

0 commit comments

Comments
 (0)