Skip to content

Commit e95708c

Browse files
committed
GUI - menu - add new items - scope kind visibility toggles
1 parent 9c16a83 commit e95708c

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

app/gui/qt/mainwindow.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ void MainWindow::setupWindowStructure() {
537537
connect(settingsWidget, SIGNAL(logAutoScrollChanged()), this, SLOT(updateLogAutoScroll()));
538538
connect(settingsWidget, SIGNAL(themeChanged()), this, SLOT(updateColourTheme()));
539539
connect(settingsWidget, SIGNAL(scopeChanged()), this, SLOT(scope()));
540-
connect(settingsWidget, SIGNAL(scopeChanged(QString)), this, SLOT(toggleScope(QString)));
540+
connect(settingsWidget, SIGNAL(scopeChanged(QString)), this, SLOT(changeScopeKindVisibility(QString)));
541541
connect(settingsWidget, SIGNAL(scopeLabelsChanged()), this, SLOT(changeScopeLabels()));
542542
connect(settingsWidget, SIGNAL(transparencyChanged(int)), this, SLOT(changeGUITransparency(int)));
543543

@@ -1951,8 +1951,24 @@ void MainWindow::changeSystemPreAmp(int val, int silent)
19511951
}
19521952

19531953

1954-
void MainWindow::toggleScope(QString name) {
1955-
scopeInterface->EnableScope( name, piSettings->isScopeActive(name));
1954+
void MainWindow::changeScopeKindVisibility(QString name) {
1955+
foreach (QAction *action, scopeKindVisibilityMenu->actions()) {
1956+
if (action->text() == name) {
1957+
QSignalBlocker blocker( action );
1958+
action->setChecked(piSettings->isScopeActive(name));
1959+
}
1960+
}
1961+
1962+
scopeInterface->EnableScope( name, piSettings->isScopeActive(name));
1963+
}
1964+
1965+
void MainWindow::scopeKindVisibilityMenuChanged() {
1966+
foreach (QAction *action, scopeKindVisibilityMenu->actions()) {
1967+
piSettings->setScopeState(action->text(), action->isChecked());
1968+
changeScopeKindVisibility(action->text());
1969+
}
1970+
1971+
emit settingsChanged();
19561972
}
19571973

19581974
void MainWindow::toggleLeftScope()
@@ -2716,6 +2732,7 @@ void MainWindow::createToolBar()
27162732
displayMenu = menuBar()->addMenu(tr("Visuals"));
27172733

27182734

2735+
27192736
lightThemeAct = new QAction(tr("Light"));
27202737
lightThemeAct->setCheckable(true);
27212738
lightThemeAct->setChecked(false);
@@ -2755,6 +2772,15 @@ void MainWindow::createToolBar()
27552772
displayMenu->addSeparator();
27562773
displayMenu->addAction(scopeAct);
27572774
displayMenu->addAction(showScopeLabelsAct);
2775+
scopeKindVisibilityMenu = displayMenu->addMenu(tr("Show Scope Kinds"));
2776+
2777+
for( auto name : scopeInterface->GetScopeCategories()) {
2778+
QAction *act = new QAction(name);
2779+
act->setCheckable(true);
2780+
act->setChecked(piSettings->isScopeActive(name));
2781+
connect(act, SIGNAL(triggered()), this, SLOT(scopeKindVisibilityMenuChanged()));
2782+
scopeKindVisibilityMenu->addAction(act);
2783+
}
27582784

27592785

27602786
ioMenu = menuBar()->addMenu(tr("IO"));

app/gui/qt/mainwindow.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ class MainWindow : public QMainWindow
172172
void showLogMenuChanged();
173173
void showCuesMenuChanged();
174174
void logAutoScrollMenuChanged();
175-
void toggleScope(QString name);
175+
void changeScopeKindVisibility(QString name);
176+
void scopeKindVisibilityMenuChanged();
176177
void toggleLeftScope();
177178
void toggleRightScope();
178179
void changeScopeLabels();
@@ -308,7 +309,7 @@ class MainWindow : public QMainWindow
308309

309310
void addUniversalCopyShortcuts(QTextEdit *te);
310311

311-
QMenu *liveMenu, *codeMenu, *audioMenu, *displayMenu, *viewMenu, *ioMenu, *ioMidiInMenu, *ioMidiOutMenu, *ioMidiOutChannelMenu, *localIpAddressesMenu, *themeMenu;
312+
QMenu *liveMenu, *codeMenu, *audioMenu, *displayMenu, *viewMenu, *ioMenu, *ioMidiInMenu, *ioMidiOutMenu, *ioMidiOutChannelMenu, *localIpAddressesMenu, *themeMenu, *scopeKindVisibilityMenu;
312313

313314
SonicPiSettings *piSettings;
314315

app/gui/qt/widgets/settingswidget.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,14 @@ void SettingsWidget::updateScopeNames( std::vector<QString> names ) {
485485
connect( scopeSignalMap, SIGNAL(mapped(QWidget*)), this, SLOT(toggleScope(QWidget*)));
486486
}
487487

488+
void SettingsWidget::updateScopeKindVisibility() {
489+
for (int i = 0; i < scope_box_kinds_layout->count(); ++i) {
490+
QCheckBox *cb = qobject_cast<QCheckBox*>(scope_box_kinds_layout->itemAt(i)->widget());
491+
cb->setChecked(piSettings->isScopeActive(cb->text()));
492+
}
493+
494+
}
495+
488496
void SettingsWidget::toggleScope( QWidget* qw ) {
489497
QCheckBox* cb = static_cast<QCheckBox*>(qw);
490498
//QSettings settings(QSettings::IniFormat, QSettings::UserScope, "sonic-pi.net", "gui-settings");
@@ -673,6 +681,7 @@ void SettingsWidget::updateSettings() {
673681
}
674682

675683
void SettingsWidget::settingsChanged() {
684+
676685
mixer_invert_stereo->setChecked(piSettings->mixer_invert_stereo);
677686
mixer_force_mono->setChecked(piSettings->mixer_force_mono);
678687
check_args->setChecked(piSettings->check_args);
@@ -711,6 +720,7 @@ void SettingsWidget::settingsChanged() {
711720
check_updates->setChecked(piSettings->check_updates);
712721
show_autocompletion->setChecked(piSettings->show_autocompletion);
713722
show_context->setChecked(piSettings->show_context);
723+
updateScopeKindVisibility();
714724
}
715725

716726
void SettingsWidget::connectAll() {

app/gui/qt/widgets/settingswidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ private slots:
165165
QString tooltipStrShiftMeta(char key, QString str);
166166

167167
void connectAll();
168+
void updateScopeKindVisibility();
169+
168170
};
169171

170172
#endif

0 commit comments

Comments
 (0)