Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / editors / sc-ide / widgets / settings / general_page.cpp
blob190c1cc01f7b6f24f4807954472d3fad129eec05
1 /*
2 SuperCollider Qt IDE
3 Copyright (c) 2012 Jakob Leben & Tim Blechmann
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "general_page.hpp"
22 #include "ui_settings_general.h"
23 #include "../../core/settings/manager.hpp"
25 Q_DECLARE_METATYPE(QAction*);
26 Q_DECLARE_METATYPE(QKeySequence);
28 namespace ScIDE { namespace Settings {
30 GeneralPage::GeneralPage(QWidget *parent) :
31 QWidget(parent),
32 ui( new Ui::GeneralConfigPage )
34 ui->setupUi(this);
36 connect( ui->startSessionName, SIGNAL(textChanged(QString)),
37 this, SLOT(onStartSessionNameChanged(QString)) );
40 GeneralPage::~GeneralPage()
42 delete ui;
45 void GeneralPage::load( Manager *settings )
47 QString startSessionName = settings->value("IDE/startWithSession").toString();
48 if (startSessionName.isEmpty())
49 ui->startNewSessionOption->setChecked(true);
50 else if (startSessionName == "last")
51 ui->startLastSessionOption->setChecked(true);
52 else {
53 ui->startNamedSessionOption->setChecked(true);
54 ui->startSessionName->setText(startSessionName);
58 void GeneralPage::store( Manager *settings )
60 settings->beginGroup("IDE");
62 QWidget *checkedOption = ui->startSessionOptions->checkedButton();
64 if (checkedOption == ui->startLastSessionOption) {
65 settings->setValue("startWithSession", "last");
67 else if (checkedOption == ui->startNamedSessionOption &&
68 !ui->startSessionName->text().isEmpty())
70 settings->setValue("startWithSession", ui->startSessionName->text());
72 else {
73 settings->setValue("startWithSession", "");
76 settings->endGroup();
79 void GeneralPage::onStartSessionNameChanged( const QString & text )
81 if (!text.isEmpty())
82 ui->startNamedSessionOption->setChecked(true);
85 }} // namespace ScIDE::Settings