diff --git a/app/gui/qt/mainwindow.cpp b/app/gui/qt/mainwindow.cpp index dcd894e27a..235c0e5f4a 100644 --- a/app/gui/qt/mainwindow.cpp +++ b/app/gui/qt/mainwindow.cpp @@ -543,6 +543,7 @@ void MainWindow::setupWindowStructure() { connect(settingsWidget, SIGNAL(checkUpdatesChanged()), this, SLOT(update_check_updates())); connect(settingsWidget, SIGNAL(forceCheckUpdates()), this, SLOT(check_for_updates_now())); + connect(settingsWidget, SIGNAL(showContextChanged()), this, SLOT(changeShowContext())); connect(this, SIGNAL(settingsChanged()), settingsWidget, SLOT(settingsChanged())); @@ -1296,6 +1297,7 @@ void MainWindow::honourPrefs() { toggleIcons(); scope(); changeShowAutoCompletion(); + changeShowContext(); } void MainWindow::setMessageBoxStyle() { @@ -1987,6 +1989,12 @@ void MainWindow::showAutoCompletionMenuChanged() { changeShowAutoCompletion(); } +void MainWindow::showContextMenuChanged() { + piSettings->show_context = showContextAct->isChecked(); + emit settingsChanged(); + changeShowContext(); +} + void MainWindow::changeShowLineNumbers(){ bool show = piSettings->show_line_numbers; @@ -2022,6 +2030,21 @@ void MainWindow::changeShowAutoCompletion() { showAutoCompletionAct->setChecked(piSettings->show_autocompletion); } +void MainWindow::changeShowContext() { + bool show = piSettings->show_context; + if(show) { + statusBar()->showMessage(tr("Show context on"), 2000); + contextWidget->show(); + } else { + statusBar()->showMessage(tr("Show context off"), 2000); + contextWidget->hide(); + } + + + QSignalBlocker blocker( showContextAct ); + showContextAct->setChecked(piSettings->show_context); +} + void MainWindow::togglePrefs() { if(prefsWidget->isVisible()) { prefsWidget->hide(); @@ -2296,8 +2319,13 @@ void MainWindow::createToolBar() showAutoCompletionAct->setCheckable(true); showAutoCompletionAct->setChecked(piSettings->show_autocompletion); + showContextAct = new QAction(tr("Show Code Context"), this); + showContextAct->setCheckable(true); + showContextAct->setChecked(piSettings->show_context); + connect(showLineNumbersAct, SIGNAL(triggered()), this, SLOT(showLineNumbersMenuChanged())); connect(showAutoCompletionAct, SIGNAL(triggered()), this, SLOT(showAutoCompletionMenuChanged())); + connect(showContextAct, SIGNAL(triggered()), this, SLOT(showContextMenuChanged())); toolBar->addAction(scopeAct); toolBar->addAction(infoAct); @@ -2327,6 +2355,7 @@ void MainWindow::createToolBar() displayMenu->addAction(infoAct); displayMenu->addAction(helpAct); displayMenu->addAction(prefsAct); + displayMenu->addAction(showContextAct); focusMenu = menuBar()->addMenu(tr("&Focus")); @@ -2599,8 +2628,8 @@ void MainWindow::readSettings() { piSettings->goto_buffer_shortcuts = settings.value("prefs/goto_buffer_shortcuts", false).toBool(); QString styleName = settings.value("prefs/theme", "").toString(); piSettings->themeStyle = theme->themeNameToStyle(styleName); - piSettings->show_autocompletion = settings.value("prefs/show-autocompletion", true).toBool(); + piSettings->show_context = settings.value("prefs/show-context", true).toBool(); emit settingsChanged(); } @@ -2653,6 +2682,7 @@ void MainWindow::writeSettings() settings.setValue("prefs/show-buttons", piSettings->show_buttons); settings.setValue("prefs/show-tabs", piSettings->show_tabs); settings.setValue("prefs/show-log", piSettings->show_log); + settings.setValue("prefs/show-context", piSettings->show_context); for ( auto name : piSettings->scope_names ) { settings.setValue("prefs/scope/show-"+name.toLower(), piSettings->isScopeActive(name)); diff --git a/app/gui/qt/mainwindow.h b/app/gui/qt/mainwindow.h index c4abe6e7cc..95e774b23b 100644 --- a/app/gui/qt/mainwindow.h +++ b/app/gui/qt/mainwindow.h @@ -153,6 +153,8 @@ class MainWindow : public QMainWindow void showLineNumbersMenuChanged(); void showAutoCompletionMenuChanged(); void changeShowAutoCompletion(); + void changeShowContext(); + void showContextMenuChanged(); void toggleScope(QString name); void toggleLeftScope(); void toggleRightScope(); @@ -331,7 +333,7 @@ class MainWindow : public QMainWindow QToolBar *toolBar; - QAction *exitAct, *runAct, *stopAct, *saveAsAct, *loadFileAct, *recAct, *textAlignAct, *textIncAct, *textDecAct, *scopeAct, *infoAct, *helpAct, *prefsAct, *focusEditorAct, *focusLogsAct, *focusContextAct, *focusCuesAct, *focusPreferencesAct, *focusHelpListingAct, *focusHelpDetailsAct, *focusErrorsAct, *showLineNumbersAct, *showAutoCompletionAct; + 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; QShortcut *runSc, *stopSc, *saveAsSc, *loadFileSc, *recSc, *textAlignSc, *textIncSc, *textDecSc, *scopeSc, *infoSc, *helpSc, *prefsSc, *focusEditorSc, *focusLogsSc, *focusContextSc, *focusCuesSc, *focusPreferencesSc, *focusHelpListingSc, *focusHelpDetailsSc, *focusErrorsSc; SettingsWidget *settingsWidget; diff --git a/app/gui/qt/model/settings.h b/app/gui/qt/model/settings.h index a5106864a5..a3290025b7 100644 --- a/app/gui/qt/model/settings.h +++ b/app/gui/qt/model/settings.h @@ -38,6 +38,7 @@ class SonicPiSettings { bool log_auto_scroll; int gui_transparency; bool show_autocompletion; + bool show_context; SonicPiTheme::Style themeStyle; // UpdateSettings; diff --git a/app/gui/qt/widgets/settingswidget.cpp b/app/gui/qt/widgets/settingswidget.cpp index 931b5051bf..3156451d6f 100644 --- a/app/gui/qt/widgets/settingswidget.cpp +++ b/app/gui/qt/widgets/settingswidget.cpp @@ -285,6 +285,9 @@ QGroupBox* SettingsWidget::createEditorPrefsTab() { show_autocompletion = new QCheckBox(tr("Show code completion")); show_autocompletion->setToolTip(tr("When enabled, Sonic Pi's editor will attempt to autocomplete your code with suggestions. When disabled, these suggestions will not be visible.")); + show_context = new QCheckBox(tr("Show code context")); + show_context->setToolTip(tr("When enabled, Sonic Pi's editor will show a pane which will display context-specific information for the code such as the current line and position of the cursor.")); + show_log = new QCheckBox(tr("Show log")); show_log->setToolTip(tooltipStrShiftMeta('L', tr("Toggle visibility of the log."))); show_log->setChecked(true); @@ -323,6 +326,7 @@ QGroupBox* SettingsWidget::createEditorPrefsTab() { editor_display_box_layout->addWidget(show_line_numbers); editor_display_box_layout->addWidget(show_autocompletion); + editor_display_box_layout->addWidget(show_context); editor_display_box_layout->addWidget(show_log); editor_display_box_layout->addWidget(show_cues); editor_display_box_layout->addWidget(show_buttons); @@ -533,6 +537,10 @@ void SettingsWidget::showAutoCompletion() { emit showAutoCompletionChanged(); } +void SettingsWidget::showContext() { + emit showContextChanged(); +} + void SettingsWidget::toggleLog() { emit showLogChanged(); } @@ -610,6 +618,7 @@ void SettingsWidget::updateSettings() { piSettings->auto_indent_on_run = auto_indent_on_run->isChecked(); piSettings->show_line_numbers = show_line_numbers->isChecked(); piSettings->show_autocompletion = show_autocompletion->isChecked(); + piSettings->show_context = show_context->isChecked(); piSettings->show_log = show_log->isChecked(); piSettings->show_cues = show_cues->isChecked(); piSettings->show_buttons = show_buttons->isChecked(); @@ -672,6 +681,7 @@ void SettingsWidget::settingsChanged() { check_updates->setChecked(piSettings->check_updates); show_autocompletion->setChecked(piSettings->show_autocompletion); + show_context->setChecked(piSettings->show_context); } void SettingsWidget::connectAll() { @@ -713,6 +723,7 @@ void SettingsWidget::connectAll() { connect(gui_transparency_slider, SIGNAL(valueChanged(int)), this, SLOT(updateSettings())); connect(show_autocompletion, SIGNAL(clicked()), this, SLOT(updateSettings())); + connect(show_context, SIGNAL(clicked()), this, SLOT(updateSettings())); connect(show_line_numbers, SIGNAL(clicked()), this, SLOT(toggleLineNumbers())); connect(show_log, SIGNAL(clicked()), this, SLOT(toggleLog())); @@ -739,4 +750,5 @@ void SettingsWidget::connectAll() { connect(check_updates_now, SIGNAL(clicked()), this, SLOT(checkForUpdatesNow())); connect(show_autocompletion, SIGNAL(clicked()), this, SLOT(showAutoCompletion())); + connect(show_context, SIGNAL(clicked()), this, SLOT(showContext())); } diff --git a/app/gui/qt/widgets/settingswidget.h b/app/gui/qt/widgets/settingswidget.h index 96cf759a2f..30a1c387c6 100644 --- a/app/gui/qt/widgets/settingswidget.h +++ b/app/gui/qt/widgets/settingswidget.h @@ -57,6 +57,7 @@ private slots: void updateSettings(); void updateTransparency(int t); void settingsChanged(); + void showContext(); signals: void mixerSettingsChanged(); @@ -79,6 +80,7 @@ private slots: void transparencyChanged(int t); void checkUpdatesChanged(); void forceCheckUpdates(); + void showContextChanged(); private: SonicPiSettings* piSettings; @@ -106,6 +108,7 @@ private slots: QCheckBox *check_updates; QCheckBox *studio_mode; QCheckBox *show_autocompletion; + QCheckBox *show_context; QComboBox *midi_default_channel_combo; QCheckBox *midi_enable_check;