Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / editors / sc-ide / widgets / settings / dialog.cpp
blob06e3a2c43ef643f781465993b740768ada810457
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 "dialog.hpp"
22 #include "ui_settings_dialog.h"
23 #include "general_page.hpp"
24 #include "sclang_page.hpp"
25 #include "editor_page.hpp"
26 #include "shortcuts_page.hpp"
27 #include "../../core/settings/manager.hpp"
28 #include "../../core/main.hpp"
30 #include <QVBoxLayout>
31 #include <QHBoxLayout>
32 #include <QDialogButtonBox>
33 #include <QStackedWidget>
34 #include <QListWidget>
35 #include <QFile>
36 #include <QLineEdit>
37 #include <QPushButton>
39 namespace ScIDE { namespace Settings {
41 Dialog::Dialog( Manager *settings, QWidget * parent ):
42 QDialog(parent),
43 mManager(settings),
44 ui( new Ui::ConfigDialog )
46 ui->setupUi(this);
48 QWidget *w;
50 w = new GeneralPage;
51 ui->configPageStack->addWidget(w);
52 ui->configPageList->addItem (
53 new QListWidgetItem(QIcon::fromTheme("preferences-system"), "General"));
54 connect(this, SIGNAL(storeRequest(Manager*)), w, SLOT(store(Manager*)));
55 connect(this, SIGNAL(loadRequest(Manager*)), w, SLOT(load(Manager*)));
57 w = new SclangPage;
58 ui->configPageStack->addWidget(w);
59 ui->configPageList->addItem (
60 new QListWidgetItem(QIcon::fromTheme("applications-system"), "Interpreter"));
61 connect(this, SIGNAL(storeRequest(Manager*)), w, SLOT(store(Manager*)));
62 connect(this, SIGNAL(loadRequest(Manager*)), w, SLOT(load(Manager*)));
64 w = new EditorPage;
65 ui->configPageStack->addWidget(w);
66 ui->configPageList->addItem (
67 new QListWidgetItem(QIcon::fromTheme("accessories-text-editor"), "Editor"));
68 connect(this, SIGNAL(storeRequest(Manager*)), w, SLOT(store(Manager*)));
69 connect(this, SIGNAL(loadRequest(Manager*)), w, SLOT(load(Manager*)));
71 w = new ShortcutsPage;
72 ui->configPageStack->addWidget(w);
73 ui->configPageList->addItem (
74 new QListWidgetItem(QIcon::fromTheme("input-keyboard"), "Shortcuts"));
75 connect(this, SIGNAL(storeRequest(Manager*)), w, SLOT(store(Manager*)));
76 connect(this, SIGNAL(loadRequest(Manager*)), w, SLOT(load(Manager*)));
78 connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
79 connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
80 connect(ui->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
81 connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), this, SLOT(reset()));
83 reset();
86 Dialog::~Dialog()
88 delete ui;
91 void Dialog::accept()
93 Q_EMIT( storeRequest(mManager) );
95 QDialog::accept();
98 void Dialog::reject()
100 QDialog::reject();
103 void Dialog::apply()
105 Q_EMIT( storeRequest(mManager) );
106 Main::instance()->applySettings();
109 void Dialog::reset()
111 Q_EMIT( loadRequest(mManager) );
114 }} // namespace ScIDE::Settings