@@ -127,8 +127,9 @@ MainWindow::MainWindow(QApplication& app, bool i18n, QSplashScreen* splash)
127
127
latest_version_num = 0 ;
128
128
this ->splash = splash;
129
129
this ->i18n = i18n;
130
+ QString settings_path = sonicPiConfigPath () + QDir::separator () + " gui-settings.ini" ;
130
131
131
- QSettings settings ( QSettings::IniFormat , QSettings::UserScope, " sonic-pi.net " , " gui-settings " );
132
+ gui_settings = new QSettings (settings_path , QSettings::IniFormat );
132
133
133
134
readSettings ();
134
135
initPaths ();
@@ -277,8 +278,7 @@ void MainWindow::checkForStudioMode()
277
278
278
279
void MainWindow::showWelcomeScreen ()
279
280
{
280
- QSettings settings (QSettings::IniFormat, QSettings::UserScope, " sonic-pi.net" , " gui-settings" );
281
- if (settings.value (" first_time" , 1 ).toInt () == 1 )
281
+ if (gui_settings->value (" first_time" , 1 ).toInt () == 1 )
282
282
{
283
283
QTextBrowser* startupPane = new QTextBrowser;
284
284
startupPane->setFixedSize (ScaleHeightForDPI (600 ), ScaleHeightForDPI (650 ));
@@ -1070,8 +1070,7 @@ void MainWindow::splashClose()
1070
1070
1071
1071
void MainWindow::showWindow ()
1072
1072
{
1073
- QSettings settings (QSettings::IniFormat, QSettings::UserScope, " sonic-pi.net" , " gui-settings" );
1074
- if (settings.value (" first_time" , 1 ).toInt () == 1 )
1073
+ if (gui_settings->value (" first_time" , 1 ).toInt () == 1 )
1075
1074
{
1076
1075
showMaximized ();
1077
1076
}
@@ -1324,13 +1323,12 @@ QString MainWindow::currentTabLabel()
1324
1323
bool MainWindow::loadFile ()
1325
1324
{
1326
1325
QString selfilter = QString (" %1 (*.rb *.txt)" ).arg (tr (" Buffer files" ));
1327
- QSettings settings (QSettings::IniFormat, QSettings::UserScope, " sonic-pi.net" , " gui-settings" );
1328
- QString lastDir = settings.value (" lastDir" , QDir::homePath () + " /Desktop" ).toString ();
1326
+ QString lastDir = gui_settings->value (" lastDir" , QDir::homePath () + " /Desktop" ).toString ();
1329
1327
QString fileName = QFileDialog::getOpenFileName (this , tr (" Load Sonic Pi Buffer" ), lastDir, QString (" %1 (*.rb *.txt);;%2 (*.txt);;%3 (*.rb);;%4 (*.*)" ).arg (tr (" Buffer files" )).arg (tr (" Text files" )).arg (tr (" Ruby files" )).arg (tr (" All files" )), &selfilter);
1330
1328
if (!fileName.isEmpty ())
1331
1329
{
1332
1330
QFileInfo fi = fileName;
1333
- settings. setValue (" lastDir" , fi.dir ().absolutePath ());
1331
+ gui_settings-> setValue (" lastDir" , fi.dir ().absolutePath ());
1334
1332
SonicPiScintilla* p = (SonicPiScintilla*)tabs->currentWidget ();
1335
1333
loadFile (fileName, p);
1336
1334
return true ;
@@ -1344,14 +1342,13 @@ bool MainWindow::loadFile()
1344
1342
bool MainWindow::saveAs ()
1345
1343
{
1346
1344
QString selfilter = QString (" %1 (*.rb *.txt)" ).arg (tr (" Buffer files" ));
1347
- QSettings settings (QSettings::IniFormat, QSettings::UserScope, " sonic-pi.net" , " gui-settings" );
1348
- QString lastDir = settings.value (" lastDir" , QDir::homePath () + " /Desktop" ).toString ();
1345
+ QString lastDir = gui_settings->value (" lastDir" , QDir::homePath () + " /Desktop" ).toString ();
1349
1346
QString fileName = QFileDialog::getSaveFileName (this , tr (" Save Current Buffer" ), lastDir, QString (" %1 (*.rb *.txt);;%2 (*.txt);;%3 (*.rb);;%4 (*.*)" ).arg (tr (" Buffer files" )).arg (tr (" Text files" )).arg (tr (" Ruby files" )).arg (tr (" All files" )), &selfilter);
1350
1347
1351
1348
if (!fileName.isEmpty ())
1352
1349
{
1353
1350
QFileInfo fi = fileName;
1354
- settings. setValue (" lastDir" , fi.dir ().absolutePath ());
1351
+ gui_settings-> setValue (" lastDir" , fi.dir ().absolutePath ());
1355
1352
if (!fileName.contains (QRegExp (" \\ .[a-z]+$" )))
1356
1353
{
1357
1354
fileName = fileName + " .txt" ;
@@ -2999,13 +2996,12 @@ void MainWindow::toggleRecording()
2999
2996
Message msg (" /stop-recording" );
3000
2997
msg.pushStr (guiID.toStdString ());
3001
2998
sendOSC (msg);
3002
- QSettings settings (QSettings::IniFormat, QSettings::UserScope, " sonic-pi.net" , " gui-settings" );
3003
- QString lastDir = settings.value (" lastDir" , QDir::homePath () + " /Desktop" ).toString ();
2999
+ QString lastDir = gui_settings->value (" lastDir" , QDir::homePath () + " /Desktop" ).toString ();
3004
3000
QString fileName = QFileDialog::getSaveFileName (this , tr (" Save Recording" ), lastDir, tr (" Wavefile (*.wav)" ));
3005
3001
if (!fileName.isEmpty ())
3006
3002
{
3007
3003
QFileInfo fi = fileName;
3008
- settings. setValue (" lastDir" , fi.dir ().absolutePath ());
3004
+ gui_settings-> setValue (" lastDir" , fi.dir ().absolutePath ());
3009
3005
Message msg (" /save-recording" );
3010
3006
msg.pushStr (guiID.toStdString ());
3011
3007
msg.pushStr (fileName.toStdString ());
@@ -3035,19 +3031,18 @@ void MainWindow::createStatusBar()
3035
3031
*/
3036
3032
void MainWindow::restoreWindows ()
3037
3033
{
3038
- QSettings settings (QSettings::IniFormat, QSettings::UserScope, " sonic-pi.net" , " gui-settings" );
3039
3034
QRect rec = QGuiApplication::primaryScreen ()->geometry ();
3040
- QPoint pos = settings. value (" pos" , QPoint (0 , 0 )).toPoint ();
3041
- QSize size = settings. value (" size" , QSize (rec.width (), rec.height ())).toSize ();
3035
+ QPoint pos = gui_settings-> value (" pos" , QPoint (0 , 0 )).toPoint ();
3036
+ QSize size = gui_settings-> value (" size" , QSize (rec.width (), rec.height ())).toSize ();
3042
3037
3043
- int index = settings. value (" workspace" , 0 ).toInt ();
3038
+ int index = gui_settings-> value (" workspace" , 0 ).toInt ();
3044
3039
if (index < tabs->count ())
3045
3040
tabs->setCurrentIndex (index);
3046
3041
3047
3042
for (int w = 0 ; w < workspace_max; w++)
3048
3043
{
3049
3044
// default zoom is 13
3050
- int zoom = settings. value (QString (" workspace%1zoom" ).arg (w), 2 )
3045
+ int zoom = gui_settings-> value (QString (" workspace%1zoom" ).arg (w), 2 )
3051
3046
.toInt ();
3052
3047
if (zoom < -5 )
3053
3048
zoom = -5 ;
@@ -3058,9 +3053,9 @@ void MainWindow::restoreWindows()
3058
3053
workspaces[w]->zoomTo (zoom);
3059
3054
}
3060
3055
3061
- docsplit->restoreState (settings. value (" docsplitState" ).toByteArray ());
3056
+ docsplit->restoreState (gui_settings-> value (" docsplitState" ).toByteArray ());
3062
3057
// bool visualizer = piSettings->show_scopes;
3063
- restoreState (settings. value (" windowState" ).toByteArray ());
3058
+ restoreState (gui_settings-> value (" windowState" ).toByteArray ());
3064
3059
// restoreGeometry(settings.value("windowGeom").toByteArray());
3065
3060
3066
3061
// if (visualizer != piSettings->show_scopes) {
@@ -3079,109 +3074,106 @@ void MainWindow::restoreWindows()
3079
3074
void MainWindow::readSettings ()
3080
3075
{
3081
3076
std::cout << " [GUI] - reading settings" << std::endl;
3082
- QSettings settings (QSettings::IniFormat, QSettings::UserScope, " sonic-pi.net" , " gui-settings" );
3083
3077
3084
3078
// Read in preferences from previous session
3085
- piSettings->show_buttons = settings. value (" prefs/show-buttons" , true ).toBool ();
3086
- piSettings->show_tabs = settings. value (" prefs/show-tabs" , true ).toBool ();
3087
- piSettings->show_log = settings. value (" prefs/show-log" , true ).toBool ();
3088
- piSettings->osc_public = settings. value (" prefs/osc-public" , false ).toBool ();
3089
- piSettings->osc_server_enabled = settings. value (" prefs/osc-enabled" , true ).toBool ();
3090
- piSettings->midi_enabled = settings. value (" prefs/midi-enable" , true ).toBool ();
3091
- piSettings->midi_default_channel = settings. value (" prefs/midi-default-channel" , 0 ).toInt ();
3092
- piSettings->check_args = settings. value (" prefs/check-args" , true ).toBool ();
3093
- piSettings->log_synths = settings. value (" prefs/log-synths" , true ).toBool ();
3094
- piSettings->clear_output_on_run = settings. value (" prefs/clear-output-on-run" , true ).toBool ();
3095
- piSettings->log_cues = settings. value (" prefs/log-cues" , false ).toBool ();
3096
- piSettings->log_auto_scroll = settings. value (" prefs/log-auto-scroll" , true ).toBool ();
3097
- piSettings->show_line_numbers = settings. value (" prefs/show-line-numbers" , true ).toBool ();
3098
- piSettings->enable_external_synths = settings. value (" prefs/enable-external-synths" , false ).toBool ();
3099
- piSettings->synth_trigger_timing_guarantees = settings. value (" prefs/synth-trigger-timing-guarantees" , false ).toBool ();
3100
-
3101
- piSettings->main_volume = settings. value (" prefs/system-vol" , 80 ).toInt ();
3102
- piSettings->mixer_force_mono = settings. value (" prefs/mixer-force-mono" , false ).toBool ();
3103
- piSettings->mixer_invert_stereo = settings. value (" prefs/mixer-invert-stereo" , false ).toBool ();
3104
- piSettings->check_updates = settings. value (" prefs/rp/check-updates" , true ).toBool ();
3105
- piSettings->auto_indent_on_run = settings. value (" prefs/auto-indent-on-run" , true ).toBool ();
3106
- piSettings->gui_transparency = settings. value (" prefs/gui_transparency" , 0 ).toInt ();
3107
- piSettings->show_scopes = settings. value (" prefs/scope/show-scopes" , true ).toBool ();
3108
- piSettings->show_scope_labels = settings. value (" prefs/scope/show-labels" , false ).toBool ();
3109
- piSettings->show_cues = settings. value (" prefs/show_cues" , true ).toBool ();
3110
- QString styleName = settings. value (" prefs/theme" , " " ).toString ();
3079
+ piSettings->show_buttons = gui_settings-> value (" prefs/show-buttons" , true ).toBool ();
3080
+ piSettings->show_tabs = gui_settings-> value (" prefs/show-tabs" , true ).toBool ();
3081
+ piSettings->show_log = gui_settings-> value (" prefs/show-log" , true ).toBool ();
3082
+ piSettings->osc_public = gui_settings-> value (" prefs/osc-public" , false ).toBool ();
3083
+ piSettings->osc_server_enabled = gui_settings-> value (" prefs/osc-enabled" , true ).toBool ();
3084
+ piSettings->midi_enabled = gui_settings-> value (" prefs/midi-enable" , true ).toBool ();
3085
+ piSettings->midi_default_channel = gui_settings-> value (" prefs/midi-default-channel" , 0 ).toInt ();
3086
+ piSettings->check_args = gui_settings-> value (" prefs/check-args" , true ).toBool ();
3087
+ piSettings->log_synths = gui_settings-> value (" prefs/log-synths" , true ).toBool ();
3088
+ piSettings->clear_output_on_run = gui_settings-> value (" prefs/clear-output-on-run" , true ).toBool ();
3089
+ piSettings->log_cues = gui_settings-> value (" prefs/log-cues" , false ).toBool ();
3090
+ piSettings->log_auto_scroll = gui_settings-> value (" prefs/log-auto-scroll" , true ).toBool ();
3091
+ piSettings->show_line_numbers = gui_settings-> value (" prefs/show-line-numbers" , true ).toBool ();
3092
+ piSettings->enable_external_synths = gui_settings-> value (" prefs/enable-external-synths" , false ).toBool ();
3093
+ piSettings->synth_trigger_timing_guarantees = gui_settings-> value (" prefs/synth-trigger-timing-guarantees" , false ).toBool ();
3094
+
3095
+ piSettings->main_volume = gui_settings-> value (" prefs/system-vol" , 80 ).toInt ();
3096
+ piSettings->mixer_force_mono = gui_settings-> value (" prefs/mixer-force-mono" , false ).toBool ();
3097
+ piSettings->mixer_invert_stereo = gui_settings-> value (" prefs/mixer-invert-stereo" , false ).toBool ();
3098
+ piSettings->check_updates = gui_settings-> value (" prefs/rp/check-updates" , true ).toBool ();
3099
+ piSettings->auto_indent_on_run = gui_settings-> value (" prefs/auto-indent-on-run" , true ).toBool ();
3100
+ piSettings->gui_transparency = gui_settings-> value (" prefs/gui_transparency" , 0 ).toInt ();
3101
+ piSettings->show_scopes = gui_settings-> value (" prefs/scope/show-scopes" , true ).toBool ();
3102
+ piSettings->show_scope_labels = gui_settings-> value (" prefs/scope/show-labels" , false ).toBool ();
3103
+ piSettings->show_cues = gui_settings-> value (" prefs/show_cues" , true ).toBool ();
3104
+ QString styleName = gui_settings-> value (" prefs/theme" , " " ).toString ();
3111
3105
piSettings->themeStyle = theme->themeNameToStyle (styleName);
3112
- piSettings->show_autocompletion = settings. value (" prefs/show-autocompletion" , true ).toBool ();
3113
- piSettings->show_context = settings. value (" prefs/show-context" , true ).toBool ();
3106
+ piSettings->show_autocompletion = gui_settings-> value (" prefs/show-autocompletion" , true ).toBool ();
3107
+ piSettings->show_context = gui_settings-> value (" prefs/show-context" , true ).toBool ();
3114
3108
3115
3109
emit settingsChanged ();
3116
3110
}
3117
3111
3118
3112
void MainWindow::restoreScopeState (std::vector<QString> names)
3119
3113
{
3120
3114
std::cout << " [GUI] - restoring scope states " << std::endl;
3121
- QSettings settings (QSettings::IniFormat, QSettings::UserScope, " sonic-pi.net" , " gui-settings" );
3122
3115
3123
3116
for (auto name : names)
3124
3117
{
3125
3118
bool def = (name.toLower () == " spectrum" );
3126
- piSettings->setScopeState (name, settings. value (" prefs/scope/show-" + name.toLower (), def).toBool ());
3119
+ piSettings->setScopeState (name, gui_settings-> value (" prefs/scope/show-" + name.toLower (), def).toBool ());
3127
3120
}
3128
3121
}
3129
3122
3130
3123
void MainWindow::writeSettings ()
3131
3124
{
3132
3125
std::cout << " [GUI] - writing settings" << std::endl;
3133
- QSettings settings (QSettings::IniFormat, QSettings::UserScope, " sonic-pi.net" , " gui-settings" );
3134
- settings.setValue (" pos" , pos ());
3135
- settings.setValue (" size" , size ());
3136
- settings.setValue (" first_time" , 0 );
3137
-
3138
- settings.setValue (" prefs/midi-default-channel" , piSettings->midi_default_channel );
3139
- settings.setValue (" prefs/midi-enable" , piSettings->midi_enabled );
3140
- settings.setValue (" prefs/osc-public" , piSettings->osc_public );
3141
- settings.setValue (" prefs/osc-enabled" , piSettings->osc_server_enabled );
3142
-
3143
- settings.setValue (" prefs/check-args" , piSettings->check_args );
3144
- settings.setValue (" prefs/log-synths" , piSettings->log_synths );
3145
- settings.setValue (" prefs/clear-output-on-run" , piSettings->clear_output_on_run );
3146
- settings.setValue (" prefs/log-cues" , piSettings->log_cues );
3147
- settings.setValue (" prefs/log-auto-scroll" , piSettings->log_auto_scroll );
3148
- settings.setValue (" prefs/show-line-numbers" , piSettings->show_line_numbers );
3149
- settings.setValue (" prefs/enable-external-synths" , piSettings->enable_external_synths );
3150
- settings.setValue (" prefs/synth-trigger-timing-guarantees" , piSettings->synth_trigger_timing_guarantees );
3151
- settings.setValue (" prefs/mixer-force-mono" , piSettings->mixer_force_mono );
3152
- settings.setValue (" prefs/mixer-invert-stereo" , piSettings->mixer_invert_stereo );
3153
- settings.setValue (" prefs/system-vol" , piSettings->main_volume );
3154
- settings.setValue (" prefs/rp/check-updates" , piSettings->check_updates );
3155
- settings.setValue (" prefs/auto-indent-on-run" , piSettings->auto_indent_on_run );
3156
- settings.setValue (" prefs/gui_transparency" , piSettings->gui_transparency );
3157
- settings.setValue (" prefs/scope/show-labels" , piSettings->show_scope_labels );
3158
- settings.setValue (" prefs/scope/show-scopes" , piSettings->show_scopes );
3159
- settings.setValue (" prefs/show_cues" , piSettings->show_cues );
3160
- settings.setValue (" prefs/theme" , theme->themeStyleToName (piSettings->themeStyle ));
3161
-
3162
- settings.setValue (" prefs/show-autocompletion" , piSettings->show_autocompletion );
3163
-
3164
- settings.setValue (" prefs/show-buttons" , piSettings->show_buttons );
3165
- settings.setValue (" prefs/show-tabs" , piSettings->show_tabs );
3166
- settings.setValue (" prefs/show-log" , piSettings->show_log );
3167
- settings.setValue (" prefs/show-context" , piSettings->show_context );
3126
+ gui_settings->setValue (" pos" , pos ());
3127
+ gui_settings->setValue (" size" , size ());
3128
+ gui_settings->setValue (" first_time" , 0 );
3129
+
3130
+ gui_settings->setValue (" prefs/midi-default-channel" , piSettings->midi_default_channel );
3131
+ gui_settings->setValue (" prefs/midi-enable" , piSettings->midi_enabled );
3132
+ gui_settings->setValue (" prefs/osc-public" , piSettings->osc_public );
3133
+ gui_settings->setValue (" prefs/osc-enabled" , piSettings->osc_server_enabled );
3134
+
3135
+ gui_settings->setValue (" prefs/check-args" , piSettings->check_args );
3136
+ gui_settings->setValue (" prefs/log-synths" , piSettings->log_synths );
3137
+ gui_settings->setValue (" prefs/clear-output-on-run" , piSettings->clear_output_on_run );
3138
+ gui_settings->setValue (" prefs/log-cues" , piSettings->log_cues );
3139
+ gui_settings->setValue (" prefs/log-auto-scroll" , piSettings->log_auto_scroll );
3140
+ gui_settings->setValue (" prefs/show-line-numbers" , piSettings->show_line_numbers );
3141
+ gui_settings->setValue (" prefs/enable-external-synths" , piSettings->enable_external_synths );
3142
+ gui_settings->setValue (" prefs/synth-trigger-timing-guarantees" , piSettings->synth_trigger_timing_guarantees );
3143
+ gui_settings->setValue (" prefs/mixer-force-mono" , piSettings->mixer_force_mono );
3144
+ gui_settings->setValue (" prefs/mixer-invert-stereo" , piSettings->mixer_invert_stereo );
3145
+ gui_settings->setValue (" prefs/system-vol" , piSettings->main_volume );
3146
+ gui_settings->setValue (" prefs/rp/check-updates" , piSettings->check_updates );
3147
+ gui_settings->setValue (" prefs/auto-indent-on-run" , piSettings->auto_indent_on_run );
3148
+ gui_settings->setValue (" prefs/gui_transparency" , piSettings->gui_transparency );
3149
+ gui_settings->setValue (" prefs/scope/show-labels" , piSettings->show_scope_labels );
3150
+ gui_settings->setValue (" prefs/scope/show-scopes" , piSettings->show_scopes );
3151
+ gui_settings->setValue (" prefs/show_cues" , piSettings->show_cues );
3152
+ gui_settings->setValue (" prefs/theme" , theme->themeStyleToName (piSettings->themeStyle ));
3153
+
3154
+ gui_settings->setValue (" prefs/show-autocompletion" , piSettings->show_autocompletion );
3155
+
3156
+ gui_settings->setValue (" prefs/show-buttons" , piSettings->show_buttons );
3157
+ gui_settings->setValue (" prefs/show-tabs" , piSettings->show_tabs );
3158
+ gui_settings->setValue (" prefs/show-log" , piSettings->show_log );
3159
+ gui_settings->setValue (" prefs/show-context" , piSettings->show_context );
3168
3160
3169
3161
for (auto name : piSettings->scope_names )
3170
3162
{
3171
- settings. setValue (" prefs/scope/show-" + name.toLower (), piSettings->isScopeActive (name));
3163
+ gui_settings-> setValue (" prefs/scope/show-" + name.toLower (), piSettings->isScopeActive (name));
3172
3164
}
3173
3165
3174
- settings. setValue (" workspace" , tabs->currentIndex ());
3166
+ gui_settings-> setValue (" workspace" , tabs->currentIndex ());
3175
3167
3176
3168
for (int w = 0 ; w < workspace_max; w++)
3177
3169
{
3178
- settings. setValue (QString (" workspace%1zoom" ).arg (w),
3170
+ gui_settings-> setValue (QString (" workspace%1zoom" ).arg (w),
3179
3171
workspaces[w]->property (" zoom" ));
3180
3172
}
3181
3173
3182
- settings. setValue (" docsplitState" , docsplit->saveState ());
3183
- settings. setValue (" windowState" , saveState ());
3184
- settings. setValue (" windowGeom" , saveGeometry ());
3174
+ gui_settings-> setValue (" docsplitState" , docsplit->saveState ());
3175
+ gui_settings-> setValue (" windowState" , saveState ());
3176
+ gui_settings-> setValue (" windowGeom" , saveGeometry ());
3185
3177
}
3186
3178
3187
3179
void MainWindow::loadFile (const QString& fileName, SonicPiScintilla*& text)
@@ -3646,14 +3638,19 @@ QString MainWindow::sonicPiHomePath()
3646
3638
QString path = qgetenv (" SONIC_PI_HOME" ).constData ();
3647
3639
if (path.isEmpty ())
3648
3640
{
3649
- return QDir::homePath ();
3641
+ return QDir::homePath () + QDir::separator () + " .sonic-pi " ;
3650
3642
}
3651
3643
else
3652
3644
{
3653
- return path;
3645
+ return path;
3654
3646
}
3655
3647
}
3656
3648
3649
+ QString MainWindow::sonicPiConfigPath ()
3650
+ {
3651
+ return sonicPiHomePath () + QDir::separator () + " config" ;
3652
+ }
3653
+
3657
3654
void MainWindow::zoomInLogs ()
3658
3655
{
3659
3656
outputPane->zoomIn ();
0 commit comments