Skip to content

Commit 9eb6ace

Browse files
committed
GUI - fix indent toggle
initially indention only happened on run, but more recently it also became part of hitting enter. Unfortunately the toggle wasn't updated to take into account this change. This commit fixes this and also communicates that auto-indent isn't just on run, but on hitting enter too.
1 parent e137972 commit 9eb6ace

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

app/gui/qt/mainwindow.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2411,6 +2411,17 @@ void MainWindow::autoIndentOnRunMenuChanged()
24112411
void MainWindow::changeAutoIndentOnRun()
24122412
{
24132413
QSignalBlocker blocker(autoIndentOnRunAct);
2414+
if(piSettings->auto_indent_on_run) {
2415+
statusBar()->showMessage(tr("Auto Indent mode enabled"), 2000);
2416+
} else {
2417+
statusBar()->showMessage(tr("Auto Indent mode disabled"), 2000);
2418+
}
2419+
2420+
for (int i = 0; i < editorTabWidget->count(); i++) {
2421+
SonicPiScintilla* ws = ((SonicPiEditor*)editorTabWidget->widget(i))->getWorkspace();
2422+
ws->setAutoIndentEnabled(piSettings->auto_indent_on_run);
2423+
}
2424+
24142425
autoIndentOnRunAct->setChecked(piSettings->auto_indent_on_run);
24152426
}
24162427

@@ -2881,7 +2892,7 @@ void MainWindow::createToolBar()
28812892
clearOutputOnRunAct->setChecked(piSettings->log_cues);
28822893
connect(clearOutputOnRunAct, SIGNAL(triggered()), this, SLOT(clearOutputOnRunMenuChanged()));
28832894

2884-
autoIndentOnRunAct = new QAction(tr("Auto Indent Code Buffer on Run"), this);
2895+
autoIndentOnRunAct = new QAction(tr("Auto Indent Code Buffer"), this);
28852896
autoIndentOnRunAct->setCheckable(true);
28862897
autoIndentOnRunAct->setChecked(piSettings->auto_indent_on_run);
28872898
connect(autoIndentOnRunAct, SIGNAL(triggered()), this, SLOT(autoIndentOnRunMenuChanged()));

app/gui/qt/widgets/settingswidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ QGroupBox* SettingsWidget::createEditorPrefsTab() {
290290
automation_box->setToolTip(tr("Configure automation and other features."));
291291

292292
auto_indent_on_run = new QCheckBox(tr("Auto-align"));
293-
auto_indent_on_run->setToolTip(tr("Automatically align code on Run"));
293+
auto_indent_on_run->setToolTip(tr("Automatically align code on Enter or Run "));
294294

295295
show_line_numbers = new QCheckBox(tr("Show line numbers"));
296296
show_line_numbers->setToolTip(tr("Toggle line number visibility."));

app/gui/qt/widgets/sonicpiscintilla.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,3 +684,7 @@ void SonicPiScintilla::showAutoCompletion(bool val) {
684684
void SonicPiScintilla::setText(const QString &text) {
685685
SendScintilla(SCI_SETTEXT, ScintillaBytesConstData(textAsBytes(text)));
686686
}
687+
688+
void SonicPiScintilla::setAutoIndentEnabled(bool enabled) {
689+
this->autoIndent = enabled;
690+
}

app/gui/qt/widgets/sonicpiscintilla.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class SonicPiScintilla : public QsciScintilla
7777
void replaceBuffer(QString content, int line, int index, int first_line);
7878
void newlineAndIndent();
7979
void completeListOrNewlineAndIndent();
80+
void setAutoIndentEnabled(bool enabled);
8081

8182
void sp_paste();
8283
void sp_cut();

0 commit comments

Comments
 (0)