/[svn]/qsampler/trunk/src/qsamplerMainForm.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerMainForm.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1461 by schoenebeck, Sun Oct 28 23:30:36 2007 UTC revision 1475 by schoenebeck, Tue Nov 6 22:12:32 2007 UTC
# Line 1  Line 1 
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>
# Line 108  MainForm* MainForm::g_pMainForm = NULL; Line 130  MainForm* MainForm::g_pMainForm = NULL;
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    
# Line 145  MainForm::MainForm(QWidget* parent) : QM Line 163  MainForm::MainForm(QWidget* parent) : QM
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.
# Line 214  MainForm::MainForm(QWidget* parent) : QM Line 233  MainForm::MainForm(QWidget* parent) : QM
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.
# Line 348  bool MainForm::queryClose (void) Line 440  bool MainForm::queryClose (void)
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();
# Line 1344  void MainForm::viewMenubar ( bool bOn ) Line 1436  void MainForm::viewMenubar ( bool bOn )
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    
# Line 1629  void MainForm::helpAbout (void) Line 1721  void MainForm::helpAbout (void)
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.");
# Line 1710  void MainForm::stabilizeForm (void) Line 1803  void MainForm::stabilizeForm (void)
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    
# Line 1988  void MainForm::appendMessagesError( cons Line 2077  void MainForm::appendMessagesError( cons
2077      if (m_pMessages)      if (m_pMessages)
2078          m_pMessages->show();          m_pMessages->show();
2079    
2080      appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000");      appendMessagesColor(s.simplified(), "#ff0000");
2081    
2082          // Make it look responsive...:)          // Make it look responsive...:)
2083          QApplication::processEvents(QEventLoop::ExcludeUserInput);          QApplication::processEvents(QEventLoop::ExcludeUserInput);
# Line 2077  ChannelStrip* MainForm::createChannelStr Line 2166  ChannelStrip* MainForm::createChannelStr
2166      }      }
2167    
2168      // Add a new channel itema...      // Add a new channel itema...
2169      Qt::WFlags wflags = Qt::WStyle_Customize | Qt::WStyle_Tool | Qt::WStyle_Title | Qt::WStyle_NoBorder;      pChannelStrip = new ChannelStrip();
     pChannelStrip = new ChannelStrip(m_pWorkspace, wflags);  
2170      if (pChannelStrip == NULL)      if (pChannelStrip == NULL)
2171          return NULL;          return NULL;
2172    
2173        m_pWorkspace->addWindow(pChannelStrip, Qt::Tool);
2174    
2175      // Actual channel strip setup...      // Actual channel strip setup...
2176      pChannelStrip->setup(pChannel);      pChannelStrip->setup(pChannel);
2177          QObject::connect(pChannelStrip,          QObject::connect(pChannelStrip,
2178                  SIGNAL(channelChanged(qsamplerChannelStrip *)),                  SIGNAL(channelChanged(ChannelStrip*)),
2179                  SLOT(channelStripChanged(qsamplerChannelStrip *)));                  SLOT(channelStripChanged(ChannelStrip*)));
2180      // Set some initial aesthetic options...      // Set some initial aesthetic options...
2181      if (m_pOptions) {      if (m_pOptions) {
2182          // Background display effect...          // Background display effect...
# Line 2296  void MainForm::startServer (void) Line 2386  void MainForm::startServer (void)
2386                  //m_pServer->setProcessChannelMode(                  //m_pServer->setProcessChannelMode(
2387                  //      QProcess::StandardOutput);                  //      QProcess::StandardOutput);
2388                  QObject::connect(m_pServer,                  QObject::connect(m_pServer,
2389                          SIGNAL(readyReadStdout()),                          SIGNAL(readyReadStandardOutput()),
2390                          SLOT(readServerStdout()));                          SLOT(readServerStdout()));
2391                  QObject::connect(m_pServer,                  QObject::connect(m_pServer,
2392                          SIGNAL(readyReadStderr()),                          SIGNAL(readyReadStandardError()),
2393                          SLOT(readServerStdout()));                          SLOT(readServerStdout()));
2394          //      }          //      }
2395          // The unforgiveable signal communication...          // The unforgiveable signal communication...
2396          QObject::connect(m_pServer,          QObject::connect(m_pServer,
2397                  SIGNAL(processExited()),                  SIGNAL(finished(int,QProcess::ExitStatus)),
2398                  SLOT(processServerExit()));                  SLOT(processServerExit()));
2399    
2400      // Build process arguments...      // Build process arguments...
# Line 2519  void MainForm::stopClient (void) Line 2609  void MainForm::stopClient (void)
2609  }  }
2610    
2611  } // namespace QSampler  } // namespace QSampler
2612    
2613    
2614    // end of qsamplerMainForm.cpp

Legend:
Removed from v.1461  
changed lines
  Added in v.1475

  ViewVC Help
Powered by ViewVC