@@ -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;
0 commit comments