Linux multi-monitor fullscreen support
[ryzomcore.git] / studio / src / plugins / object_viewer / sound_settings_page.cpp
blob02815919b78d7c9c90c64e5b141d3f0755fa030a
1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2011 Dzmitry KAMIAHIN (dnk-88) <dnk-88@tut.by>
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2010 Winch Gate Property Limited
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 // Project includes
21 #include "stdpch.h"
22 #include "sound_settings_page.h"
23 #include "object_viewer_constants.h"
24 #include "../core/icore.h"
25 #include "modules.h"
27 // Qt includes
28 #include <QtCore/QSettings>
29 #include <QtGui/QWidget>
30 #include <QtGui/QFileDialog>
32 namespace NLQT
35 SoundSettingsPage::SoundSettingsPage(QObject *parent)
36 : IOptionsPage(parent),
37 m_page(0)
41 QString SoundSettingsPage::id() const
43 return QLatin1String("SoundPage");
46 QString SoundSettingsPage::trName() const
48 return tr("Sound");
51 QString SoundSettingsPage::category() const
53 return QLatin1String(Constants::OBJECT_VIEWER_SECTION);
56 QString SoundSettingsPage::trCategory() const
58 return tr("Object Viewer");
61 QIcon SoundSettingsPage::categoryIcon() const
63 return QIcon();
66 QWidget *SoundSettingsPage::createPage(QWidget *parent)
68 m_page = new QWidget(parent);
69 m_ui.setupUi(m_page);
71 QSettings *settings = Core::ICore::instance()->settings();
72 settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
74 QString soundDriver = settings->value(Constants::SOUND_DRIVER, "Auto").toString();
75 m_ui.driverSndComboBox->setCurrentIndex(m_ui.driverSndComboBox->findText(soundDriver));
77 // load settings from the config file
78 m_ui.autoLoadSampleCheckBox->setChecked(settings->value(Constants::SOUND_AUTO_LOAD_SAMPLE, true).toBool());
79 m_ui.enableOccludeObstructCheckBox->setChecked(settings->value(Constants::SOUND_ENABLE_OCCLUDE_OBSTRUCT, true).toBool());
80 m_ui.enableReverbCheckBox->setChecked(settings->value(Constants::SOUND_ENABLE_REVERB, true).toBool());
81 m_ui.manualRolloffCheckBox->setChecked(settings->value(Constants::SOUND_MANUAL_ROLL_OFF, true).toBool());
82 m_ui.forceSoftwareCheckBox->setChecked(settings->value(Constants::SOUND_FORCE_SOFTWARE, false).toBool());
83 m_ui.useADPCMCheckBox->setChecked(settings->value(Constants::SOUND_USE_ADCPM, false).toBool());
84 m_ui.maxTrackSpinBox->setValue(settings->value(Constants::SOUND_MAX_TRACK, 48).toInt());
85 m_ui.soundSamplePathLineEdit->setText(settings->value(Constants::SOUND_SAMPLE_PATH, "").toString());
86 m_ui.soundSheetPathLineEdit->setText(settings->value(Constants::SOUND_PACKED_SHEET_PATH, "").toString());
88 connect(m_ui.soundSamplePathButton, SIGNAL(clicked()), this, SLOT(setSamplePath()));
89 connect(m_ui.soundSheetPathButton, SIGNAL(clicked()), this, SLOT(setSheetPath()));
91 settings->endGroup();
92 return m_page;
95 void SoundSettingsPage::apply()
97 QSettings *settings = Core::ICore::instance()->settings();
98 settings->beginGroup(Constants::OBJECT_VIEWER_SECTION);
100 settings->setValue(Constants::SOUND_DRIVER, m_ui.driverSndComboBox->currentText());
101 settings->setValue(Constants::SOUND_AUTO_LOAD_SAMPLE, m_ui.autoLoadSampleCheckBox->isChecked());
102 settings->setValue(Constants::SOUND_ENABLE_OCCLUDE_OBSTRUCT, m_ui.enableOccludeObstructCheckBox->isChecked());
103 settings->setValue(Constants::SOUND_ENABLE_REVERB, m_ui.enableReverbCheckBox->isChecked());
104 settings->setValue(Constants::SOUND_MANUAL_ROLL_OFF, m_ui.manualRolloffCheckBox->isChecked());
105 settings->setValue(Constants::SOUND_FORCE_SOFTWARE, m_ui.forceSoftwareCheckBox->isChecked());
106 settings->setValue(Constants::SOUND_USE_ADCPM, m_ui.useADPCMCheckBox->isChecked());
107 settings->setValue(Constants::SOUND_MAX_TRACK, m_ui.maxTrackSpinBox->value());
108 settings->setValue(Constants::SOUND_SAMPLE_PATH, m_ui.soundSamplePathLineEdit->text());
109 settings->setValue(Constants::SOUND_PACKED_SHEET_PATH, m_ui.soundSheetPathLineEdit->text());
111 settings->endGroup();
112 settings->sync();
115 void SoundSettingsPage::finish()
119 void SoundSettingsPage::setSheetPath()
121 QString path = QFileDialog::getExistingDirectory();
122 if (!path.isEmpty())
124 m_ui.soundSheetPathLineEdit->setText(path);
128 void SoundSettingsPage::setSamplePath()
130 QString path = QFileDialog::getExistingDirectory();
131 if (!path.isEmpty())
133 m_ui.soundSamplePathLineEdit->setText(path);
137 } /* namespace NLQT */