Skip to content

Commit 310620f

Browse files
committed
GUI - menu - add new item - auto indent on run
1 parent 3e5ca03 commit 310620f

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

app/gui/qt/mainwindow.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ void MainWindow::setupWindowStructure() {
551551
connect(settingsWidget, SIGNAL(logCuesChanged()), this, SLOT(changeLogCues()));
552552
connect(settingsWidget, SIGNAL(logSynthsChanged()), this, SLOT(changeLogSynths()));
553553
connect(settingsWidget, SIGNAL(clearOutputOnRunChanged()), this, SLOT(changeClearOutputOnRun()));
554+
connect(settingsWidget, SIGNAL(autoIndentOnRunChanged()), this, SLOT(changeAutoIndentOnRun()));
554555

555556
connect(this, SIGNAL(settingsChanged()), settingsWidget, SLOT(settingsChanged()));
556557

@@ -1365,6 +1366,7 @@ void MainWindow::honourPrefs() {
13651366
changeLogSynths();
13661367
changeLogCues();
13671368
changeClearOutputOnRun();
1369+
changeAutoIndentOnRun();
13681370
}
13691371

13701372
void MainWindow::setMessageBoxStyle() {
@@ -2155,6 +2157,16 @@ void MainWindow::changeClearOutputOnRun() {
21552157
clearOutputOnRunAct->setChecked(piSettings->clear_output_on_run);
21562158
}
21572159

2160+
void MainWindow::autoIndentOnRunMenuChanged() {
2161+
piSettings->auto_indent_on_run = autoIndentOnRunAct->isChecked();
2162+
emit settingsChanged();
2163+
}
2164+
2165+
void MainWindow::changeAutoIndentOnRun() {
2166+
QSignalBlocker blocker( autoIndentOnRunAct );
2167+
autoIndentOnRunAct->setChecked(piSettings->auto_indent_on_run);
2168+
}
2169+
21582170
void MainWindow::changeMidiDefaultChannel() {
21592171
int idx = piSettings->midi_default_channel;
21602172

@@ -2578,6 +2590,11 @@ void MainWindow::createToolBar()
25782590
clearOutputOnRunAct->setChecked(piSettings->log_cues);
25792591
connect(clearOutputOnRunAct, SIGNAL(triggered()), this, SLOT(clearOutputOnRunMenuChanged()));
25802592

2593+
autoIndentOnRunAct = new QAction(tr("Auto Indent Code on Run"), this);
2594+
autoIndentOnRunAct->setCheckable(true);
2595+
autoIndentOnRunAct->setChecked(piSettings->auto_indent_on_run);
2596+
connect(autoIndentOnRunAct, SIGNAL(triggered()), this, SLOT(autoIndentOnRunMenuChanged()));
2597+
25812598
logAutoScrollAct = new QAction(tr("Auto-Scroll Log"), this);
25822599
logAutoScrollAct->setCheckable(true);
25832600
logAutoScrollAct->setChecked(piSettings->log_auto_scroll);
@@ -2610,8 +2627,7 @@ void MainWindow::createToolBar()
26102627
codeMenu->addSeparator();
26112628
codeMenu->addAction(showLineNumbersAct);
26122629
codeMenu->addAction(showAutoCompletionAct);
2613-
2614-
2630+
codeMenu->addAction(autoIndentOnRunAct);
26152631

26162632
audioMenu = menuBar()->addMenu(tr("Audio"));
26172633
audioMenu->addAction(enableExternalSynthsAct);

app/gui/qt/mainwindow.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ class MainWindow : public QMainWindow
182182
void changeLogSynths();
183183
void clearOutputOnRunMenuChanged();
184184
void changeClearOutputOnRun();
185+
void autoIndentOnRunMenuChanged();
186+
void changeAutoIndentOnRun();
185187
void cycleThemes();
186188
void updateColourTheme();
187189
void updatePrefsIcon();
@@ -355,7 +357,7 @@ class MainWindow : public QMainWindow
355357

356358
QToolBar *toolBar;
357359

358-
QAction *exitAct, *runAct, *stopAct, *saveAsAct, *loadFileAct, *recAct, *textAlignAct, *textIncAct, *textDecAct, *scopeAct, *infoAct, *helpAct, *prefsAct, *focusEditorAct, *focusLogsAct, *focusContextAct, *focusCuesAct, *focusPreferencesAct, *focusHelpListingAct, *focusHelpDetailsAct, *focusErrorsAct, *showLineNumbersAct, *showAutoCompletionAct, *showContextAct, *audioSafeAct, *audioTimingGuaranteesAct, *enableExternalSynthsAct, *mixerInvertStereoAct, *mixerForceMonoAct, *midiEnabledAct, *enableOSCServerAct, *allowRemoteOSCAct, *showLogAct, *showCuesAct, *logAutoScrollAct, *logCuesAct, *logSynthsAct, *clearOutputOnRunAct;
360+
QAction *exitAct, *runAct, *stopAct, *saveAsAct, *loadFileAct, *recAct, *textAlignAct, *textIncAct, *textDecAct, *scopeAct, *infoAct, *helpAct, *prefsAct, *focusEditorAct, *focusLogsAct, *focusContextAct, *focusCuesAct, *focusPreferencesAct, *focusHelpListingAct, *focusHelpDetailsAct, *focusErrorsAct, *showLineNumbersAct, *showAutoCompletionAct, *showContextAct, *audioSafeAct, *audioTimingGuaranteesAct, *enableExternalSynthsAct, *mixerInvertStereoAct, *mixerForceMonoAct, *midiEnabledAct, *enableOSCServerAct, *allowRemoteOSCAct, *showLogAct, *showCuesAct, *logAutoScrollAct, *logCuesAct, *logSynthsAct, *clearOutputOnRunAct, *autoIndentOnRunAct;
359361
QShortcut *runSc, *stopSc, *saveAsSc, *loadFileSc, *recSc, *textAlignSc, *textIncSc, *textDecSc, *scopeSc, *infoSc, *helpSc, *prefsSc, *focusEditorSc, *focusLogsSc, *focusContextSc, *focusCuesSc, *focusPreferencesSc, *focusHelpListingSc, *focusHelpDetailsSc, *focusErrorsSc;
360362

361363
SettingsWidget *settingsWidget;

app/gui/qt/widgets/settingswidget.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,11 @@ void SettingsWidget::clearOutputOnRun() {
617617
emit clearOutputOnRunChanged();
618618
}
619619

620+
621+
void SettingsWidget::autoIndentOnRun() {
622+
emit autoIndentOnRunChanged();
623+
}
624+
620625
void SettingsWidget::openSonicPiNet() {
621626
QDesktopServices::openUrl(QUrl("http://sonic-pi.net", QUrl::TolerantMode));
622627
}
@@ -786,4 +791,5 @@ void SettingsWidget::connectAll() {
786791
connect(log_cues, SIGNAL(clicked()), this, SLOT(logCues()));
787792
connect(log_synths, SIGNAL(clicked()), this, SLOT(logSynths()));
788793
connect(clear_output_on_run, SIGNAL(clicked()), this, SLOT(clearOutputOnRun()));
794+
connect(auto_indent_on_run, SIGNAL(clicked()), this, SLOT(autoIndentOnRun()));
789795
}

app/gui/qt/widgets/settingswidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ private slots:
6565
void logCues();
6666
void logSynths();
6767
void clearOutputOnRun();
68+
void autoIndentOnRun();
6869

6970
signals:
7071
void mixerSettingsChanged();
@@ -95,6 +96,7 @@ private slots:
9596
void logCuesChanged();
9697
void logSynthsChanged();
9798
void clearOutputOnRunChanged();
99+
void autoIndentOnRunChanged();
98100

99101
private:
100102
SonicPiSettings* piSettings;

0 commit comments

Comments
 (0)