1 |
|
// qsamplerMainForm.cpp |
2 |
|
// |
3 |
|
/**************************************************************************** |
4 |
|
Copyright (C) 2004-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
Copyright (C) 2007, Christian Schoenebeck |
6 |
|
|
7 |
|
This program is free software; you can redistribute it and/or |
8 |
|
modify it under the terms of the GNU General Public License |
9 |
|
as published by the Free Software Foundation; either version 2 |
10 |
|
of the License, or (at your option) any later version. |
11 |
|
|
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 General Public License for more details. |
16 |
|
|
17 |
|
You should have received a copy of the GNU General Public License along |
18 |
|
with this program; if not, write to the Free Software Foundation, Inc., |
19 |
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
|
|
21 |
|
*****************************************************************************/ |
22 |
|
|
23 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
24 |
|
|
25 |
#include <qapplication.h> |
#include <qapplication.h> |
130 |
MainForm::MainForm(QWidget* parent) : QMainWindow(parent) { |
MainForm::MainForm(QWidget* parent) : QMainWindow(parent) { |
131 |
ui.setupUi(this); |
ui.setupUi(this); |
132 |
|
|
|
fileToolbar = addToolBar(tr("File")); |
|
|
editToolbar = addToolBar(tr("Edit")); |
|
|
channelsToolbar = addToolBar(tr("Channels")); |
|
|
|
|
133 |
// Pseudo-singleton reference setup. |
// Pseudo-singleton reference setup. |
134 |
g_pMainForm = this; |
g_pMainForm = this; |
135 |
|
|
163 |
const QString& sVolumeText = tr("Master volume"); |
const QString& sVolumeText = tr("Master volume"); |
164 |
m_iVolumeChanging = 0; |
m_iVolumeChanging = 0; |
165 |
// Volume slider... |
// Volume slider... |
166 |
channelsToolbar->addSeparator(); |
ui.channelsToolbar->addSeparator(); |
167 |
m_pVolumeSlider = new QSlider(Qt::Horizontal, channelsToolbar); |
m_pVolumeSlider = new QSlider(Qt::Horizontal, ui.channelsToolbar); |
168 |
m_pVolumeSlider->setTickmarks(QSlider::Below); |
m_pVolumeSlider->setTickmarks(QSlider::Below); |
169 |
m_pVolumeSlider->setTickInterval(10); |
m_pVolumeSlider->setTickInterval(10); |
170 |
m_pVolumeSlider->setPageStep(10); |
m_pVolumeSlider->setPageStep(10); |
171 |
m_pVolumeSlider->setRange(0, 100); |
m_pVolumeSlider->setRange(0, 100); |
172 |
m_pVolumeSlider->setMaximumHeight(22); |
m_pVolumeSlider->setMaximumHeight(26); |
173 |
m_pVolumeSlider->setMinimumWidth(160); |
m_pVolumeSlider->setMinimumWidth(160); |
174 |
QToolTip::add(m_pVolumeSlider, sVolumeText); |
QToolTip::add(m_pVolumeSlider, sVolumeText); |
175 |
QObject::connect(m_pVolumeSlider, |
QObject::connect(m_pVolumeSlider, |
176 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
177 |
SLOT(volumeChanged(int))); |
SLOT(volumeChanged(int))); |
178 |
//channelsToolbar->setHorizontallyStretchable(true); |
//ui.channelsToolbar->setHorizontallyStretchable(true); |
179 |
//channelsToolbar->setStretchableWidget(m_pVolumeSlider); |
//ui.channelsToolbar->setStretchableWidget(m_pVolumeSlider); |
180 |
channelsToolbar->addWidget(m_pVolumeSlider); |
ui.channelsToolbar->addWidget(m_pVolumeSlider); |
181 |
// Volume spin-box |
// Volume spin-box |
182 |
channelsToolbar->addSeparator(); |
ui.channelsToolbar->addSeparator(); |
183 |
m_pVolumeSpinBox = new QSpinBox(channelsToolbar); |
m_pVolumeSpinBox = new QSpinBox(ui.channelsToolbar); |
184 |
m_pVolumeSpinBox->setSuffix(" %"); |
m_pVolumeSpinBox->setSuffix(" %"); |
185 |
m_pVolumeSpinBox->setRange(0, 100); |
m_pVolumeSpinBox->setRange(0, 100); |
186 |
QToolTip::add(m_pVolumeSpinBox, sVolumeText); |
QToolTip::add(m_pVolumeSpinBox, sVolumeText); |
187 |
QObject::connect(m_pVolumeSpinBox, |
QObject::connect(m_pVolumeSpinBox, |
188 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
189 |
SLOT(volumeChanged(int))); |
SLOT(volumeChanged(int))); |
190 |
|
ui.channelsToolbar->addWidget(m_pVolumeSpinBox); |
191 |
#endif |
#endif |
192 |
|
|
193 |
// Make it an MDI workspace. |
// Make it an MDI workspace. |
233 |
#if defined(WIN32) |
#if defined(WIN32) |
234 |
WSAStartup(MAKEWORD(1, 1), &_wsaData); |
WSAStartup(MAKEWORD(1, 1), &_wsaData); |
235 |
#endif |
#endif |
236 |
|
|
237 |
|
QObject::connect(ui.fileNewAction, |
238 |
|
SIGNAL(activated()), |
239 |
|
SLOT(fileNew())); |
240 |
|
QObject::connect(ui.fileOpenAction, |
241 |
|
SIGNAL(activated()), |
242 |
|
SLOT(fileOpen())); |
243 |
|
QObject::connect(ui.fileSaveAction, |
244 |
|
SIGNAL(activated()), |
245 |
|
SLOT(fileSave())); |
246 |
|
QObject::connect(ui.fileSaveAsAction, |
247 |
|
SIGNAL(activated()), |
248 |
|
SLOT(fileSaveAs())); |
249 |
|
QObject::connect(ui.fileResetAction, |
250 |
|
SIGNAL(activated()), |
251 |
|
SLOT(fileReset())); |
252 |
|
QObject::connect(ui.fileRestartAction, |
253 |
|
SIGNAL(activated()), |
254 |
|
SLOT(fileRestart())); |
255 |
|
QObject::connect(ui.fileExitAction, |
256 |
|
SIGNAL(activated()), |
257 |
|
SLOT(fileExit())); |
258 |
|
QObject::connect(ui.editAddChannelAction, |
259 |
|
SIGNAL(activated()), |
260 |
|
SLOT(editAddChannel())); |
261 |
|
QObject::connect(ui.editRemoveChannelAction, |
262 |
|
SIGNAL(activated()), |
263 |
|
SLOT(editRemoveChannel())); |
264 |
|
QObject::connect(ui.editSetupChannelAction, |
265 |
|
SIGNAL(activated()), |
266 |
|
SLOT(editSetupChannel())); |
267 |
|
QObject::connect(ui.editEditChannelAction, |
268 |
|
SIGNAL(activated()), |
269 |
|
SLOT(editEditChannel())); |
270 |
|
QObject::connect(ui.editResetChannelAction, |
271 |
|
SIGNAL(activated()), |
272 |
|
SLOT(editResetChannel())); |
273 |
|
QObject::connect(ui.editResetAllChannelsAction, |
274 |
|
SIGNAL(activated()), |
275 |
|
SLOT(editResetAllChannels())); |
276 |
|
QObject::connect(ui.viewMenubarAction, |
277 |
|
SIGNAL(toggled(bool)), |
278 |
|
SLOT(viewMenubar(bool))); |
279 |
|
QObject::connect(ui.viewToolbarAction, |
280 |
|
SIGNAL(toggled(bool)), |
281 |
|
SLOT(viewToolbar(bool))); |
282 |
|
QObject::connect(ui.viewStatusbarAction, |
283 |
|
SIGNAL(toggled(bool)), |
284 |
|
SLOT(viewStatusbar(bool))); |
285 |
|
QObject::connect(ui.viewMessagesAction, |
286 |
|
SIGNAL(toggled(bool)), |
287 |
|
SLOT(viewMessages(bool))); |
288 |
|
QObject::connect(ui.viewInstrumentsAction, |
289 |
|
SIGNAL(activated()), |
290 |
|
SLOT(viewInstruments())); |
291 |
|
QObject::connect(ui.viewDevicesAction, |
292 |
|
SIGNAL(activated()), |
293 |
|
SLOT(viewDevices())); |
294 |
|
QObject::connect(ui.viewOptionsAction, |
295 |
|
SIGNAL(activated()), |
296 |
|
SLOT(viewOptions())); |
297 |
|
QObject::connect(ui.channelsArrangeAction, |
298 |
|
SIGNAL(activated()), |
299 |
|
SLOT(channelsArrange())); |
300 |
|
QObject::connect(ui.channelsAutoArrangeAction, |
301 |
|
SIGNAL(toggled(bool)), |
302 |
|
SLOT(channelsAutoArrange(bool))); |
303 |
|
QObject::connect(ui.helpAboutAction, |
304 |
|
SIGNAL(activated()), |
305 |
|
SLOT(helpAbout())); |
306 |
|
QObject::connect(ui.helpAboutQtAction, |
307 |
|
SIGNAL(activated()), |
308 |
|
SLOT(helpAboutQt())); |
309 |
} |
} |
310 |
|
|
311 |
// Destructor. |
// Destructor. |
440 |
if (bQueryClose) { |
if (bQueryClose) { |
441 |
// Save decorations state. |
// Save decorations state. |
442 |
m_pOptions->bMenubar = ui.MenuBar->isVisible(); |
m_pOptions->bMenubar = ui.MenuBar->isVisible(); |
443 |
m_pOptions->bToolbar = (fileToolbar->isVisible() || editToolbar->isVisible() || channelsToolbar->isVisible()); |
m_pOptions->bToolbar = (ui.fileToolbar->isVisible() || ui.editToolbar->isVisible() || ui.channelsToolbar->isVisible()); |
444 |
m_pOptions->bStatusbar = statusBar()->isVisible(); |
m_pOptions->bStatusbar = statusBar()->isVisible(); |
445 |
// Save the dock windows state. |
// Save the dock windows state. |
446 |
const QString sDockables = saveState().toBase64().data(); |
const QString sDockables = saveState().toBase64().data(); |
1436 |
void MainForm::viewToolbar ( bool bOn ) |
void MainForm::viewToolbar ( bool bOn ) |
1437 |
{ |
{ |
1438 |
if (bOn) { |
if (bOn) { |
1439 |
fileToolbar->show(); |
ui.fileToolbar->show(); |
1440 |
editToolbar->show(); |
ui.editToolbar->show(); |
1441 |
channelsToolbar->show(); |
ui.channelsToolbar->show(); |
1442 |
} else { |
} else { |
1443 |
fileToolbar->hide(); |
ui.fileToolbar->hide(); |
1444 |
editToolbar->hide(); |
ui.editToolbar->hide(); |
1445 |
channelsToolbar->hide(); |
ui.channelsToolbar->hide(); |
1446 |
} |
} |
1447 |
} |
} |
1448 |
|
|
1721 |
sText += "<br />\n"; |
sText += "<br />\n"; |
1722 |
sText += "<small>"; |
sText += "<small>"; |
1723 |
sText += QSAMPLER_COPYRIGHT "<br />\n"; |
sText += QSAMPLER_COPYRIGHT "<br />\n"; |
1724 |
|
sText += QSAMPLER_COPYRIGHT2 "<br />\n"; |
1725 |
sText += "<br />\n"; |
sText += "<br />\n"; |
1726 |
sText += tr("This program is free software; you can redistribute it and/or modify it") + "<br />\n"; |
sText += tr("This program is free software; you can redistribute it and/or modify it") + "<br />\n"; |
1727 |
sText += tr("under the terms of the GNU General Public License version 2 or later."); |
sText += tr("under the terms of the GNU General Public License version 2 or later."); |
1803 |
|
|
1804 |
// Recent files menu. |
// Recent files menu. |
1805 |
m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0); |
m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0); |
|
|
|
|
// Always make the latest message visible. |
|
|
if (m_pMessages) |
|
|
m_pMessages->scrollToBottom(); |
|
1806 |
} |
} |
1807 |
|
|
1808 |
|
|
2608 |
} |
} |
2609 |
|
|
2610 |
} // namespace QSampler |
} // namespace QSampler |
2611 |
|
|
2612 |
|
|
2613 |
|
// end of qsamplerMainForm.cpp |