/[svn]/qsampler/trunk/src/qsamplerMainForm.ui.h
ViewVC logotype

Diff of /qsampler/trunk/src/qsamplerMainForm.ui.h

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

revision 428 by capela, Mon Mar 7 17:05:55 2005 UTC revision 487 by capela, Thu Mar 31 14:17:19 2005 UTC
# Line 211  void qsamplerMainForm::setup ( qsamplerO Line 211  void qsamplerMainForm::setup ( qsamplerO
211      // We got options?      // We got options?
212      m_pOptions = pOptions;      m_pOptions = pOptions;
213    
214        // What style do we create these forms?
215        WFlags wflags = Qt::WType_TopLevel;
216        if (m_pOptions->bKeepOnTop)
217            wflags |= Qt::WStyle_Tool;
218      // Some child forms are to be created right now.      // Some child forms are to be created right now.
219      m_pMessages = new qsamplerMessages(this);      m_pMessages = new qsamplerMessages(this);
220      m_pDeviceForm = new qsamplerDeviceForm(this);      m_pDeviceForm = new qsamplerDeviceForm(this, 0, wflags);
221        m_pDeviceForm->setMainForm(this); // An important life immutable!
222      // Set message defaults...      // Set message defaults...
223      updateMessagesFont();      updateMessagesFont();
224      updateMessagesLimit();      updateMessagesLimit();
# Line 271  bool qsamplerMainForm::queryClose (void) Line 276  bool qsamplerMainForm::queryClose (void)
276          // Some windows default fonts is here on demand too.          // Some windows default fonts is here on demand too.
277          if (bQueryClose && m_pMessages)          if (bQueryClose && m_pMessages)
278              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();              m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString();
                 // Other windows just need asking if it can close gracefully...  
         if (bQueryClose && m_pDeviceForm)  
                 bQueryClose = m_pDeviceForm->queryClose();  
279          // Try to save current positioning.          // Try to save current positioning.
280          if (bQueryClose) {          if (bQueryClose) {
281              // Save decorations state.              // Save decorations state.
# Line 597  bool qsamplerMainForm::loadSessionFile ( Line 599  bool qsamplerMainForm::loadSessionFile (
599              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {
600                  appendMessagesClient("lscp_client_query");                  appendMessagesClient("lscp_client_query");
601                  iErrors++;                  iErrors++;
                 break;  
602              }              }
603          }          }
604          // Try to make it snappy :)          // Try to make it snappy :)
# Line 607  bool qsamplerMainForm::loadSessionFile ( Line 608  bool qsamplerMainForm::loadSessionFile (
608      // Ok. we've read it.      // Ok. we've read it.
609      file.close();      file.close();
610    
     // Have we any errors?  
     if (iErrors > 0)  
         appendMessagesError(tr("Session could not be loaded\nfrom \"%1\".\n\nSorry.").arg(sFilename));  
   
611          // Now we'll try to create (update) the whole GUI session.          // Now we'll try to create (update) the whole GUI session.
612          updateSession();          updateSession();
613    
614            // Have we any errors?
615            if (iErrors > 0)
616                    appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename));
617    
618      // Save as default session directory.      // Save as default session directory.
619      if (m_pOptions)      if (m_pOptions)
620          m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true);          m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true);
621      // We're not dirty anymore.          // We're not dirty anymore, if loaded without errors,
622      m_iDirtyCount = 0;          m_iDirtyCount = iErrors;
623      // Stabilize form...      // Stabilize form...
624      m_sFilename = sFilename;      m_sFilename = sFilename;
625      updateRecentFiles(sFilename);      updateRecentFiles(sFilename);
# Line 641  bool qsamplerMainForm::saveSessionFile ( Line 642  bool qsamplerMainForm::saveSessionFile (
642      }      }
643    
644      // Write the file.      // Write the file.
645      int iErrors = 0;      int  iErrors = 0;
646      QTextStream ts(&file);      QTextStream ts(&file);
647      ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl;      ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl;
648      ts << "# " << tr("Version")      ts << "# " << tr("Version")
# Line 652  bool qsamplerMainForm::saveSessionFile ( Line 653  bool qsamplerMainForm::saveSessionFile (
653      ts << "# " << tr("File")      ts << "# " << tr("File")
654         << ": " << QFileInfo(sFilename).fileName() << endl;         << ": " << QFileInfo(sFilename).fileName() << endl;
655      ts << "# " << tr("Date")      ts << "# " << tr("Date")
656         << ": " << QDate::currentDate().toString("MMMM dd yyyy")         << ": " << QDate::currentDate().toString("MMM dd yyyy")
657         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;         << " "  << QTime::currentTime().toString("hh:mm:ss") << endl;
658      ts << "#"  << endl;      ts << "#"  << endl;
659      ts << endl;      ts << endl;
660            // It is assumed that this new kind of device+session file
661            // will be loaded from a complete
662            int *piDeviceIDs;
663            int  iDevice;
664            ts << "RESET" << endl;
665            // Audio device mapping.
666            QMap<int, int> audioDeviceMap;
667            piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio);
668            for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
669                    ts << endl;
670                    qsamplerDevice device(this, qsamplerDevice::Audio, piDeviceIDs[iDevice]);
671                    // Audio device specification...
672                    ts << "# " << device.deviceTypeName() << " " << device.driverName()
673                       << " " << tr("Device") << " " << iDevice << endl;
674                    ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName();
675                    qsamplerDeviceParamMap::ConstIterator deviceParam;
676                    for (deviceParam = device.params().begin();
677                                    deviceParam != device.params().end();
678                                            ++deviceParam) {
679                            const qsamplerDeviceParam& param = deviceParam.data();
680                            if (param.value.isEmpty()) ts << "# ";
681                            ts << " " << deviceParam.key() << "='" << param.value << "'";
682                    }
683                    ts << endl;
684                    // Audio channel parameters...
685                    int iPort = 0;
686                    for (qsamplerDevicePort *pPort = device.ports().first();
687                                    pPort;
688                                            pPort = device.ports().next(), ++iPort) {
689                            qsamplerDeviceParamMap::ConstIterator portParam;
690                            for (portParam = pPort->params().begin();
691                                            portParam != pPort->params().end();
692                                                    ++portParam) {
693                                    const qsamplerDeviceParam& param = portParam.data();
694                                    if (param.fix || param.value.isEmpty()) ts << "# ";
695                                    ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice
696                                       << " " << iPort << " " << portParam.key()
697                                       << "='" << param.value << "'" << endl;
698                            }
699                    }
700                    // Audio device index/id mapping.
701                    audioDeviceMap[device.deviceID()] = iDevice;
702            // Try to keep it snappy :)
703            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
704            }
705            // MIDI device mapping.
706            QMap<int, int> midiDeviceMap;
707            piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi);
708            for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) {
709                    ts << endl;
710                    qsamplerDevice device(this, qsamplerDevice::Midi, piDeviceIDs[iDevice]);
711                    // MIDI device specification...
712            ts << "# " << device.deviceTypeName() << " " << device.driverName()
713                       << " " << tr("Device") << " " << iDevice << endl;
714                    ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName();
715                    qsamplerDeviceParamMap::ConstIterator deviceParam;
716                    for (deviceParam = device.params().begin();
717                                    deviceParam != device.params().end();
718                                            ++deviceParam) {
719                            const qsamplerDeviceParam& param = deviceParam.data();
720                            if (param.value.isEmpty()) ts << "# ";
721                            ts << " " << deviceParam.key() << "='" << param.value << "'";
722                    }
723                    ts << endl;
724                    // MIDI port parameters...
725                    int iPort = 0;
726                    for (qsamplerDevicePort *pPort = device.ports().first();
727                                    pPort;
728                                            pPort = device.ports().next(), ++iPort) {
729                            qsamplerDeviceParamMap::ConstIterator portParam;
730                            for (portParam = pPort->params().begin();
731                                            portParam != pPort->params().end();
732                                                    ++portParam) {
733                                    const qsamplerDeviceParam& param = portParam.data();
734                                    if (param.fix || param.value.isEmpty()) ts << "# ";
735                                    ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice
736                                       << " " << iPort << " " << portParam.key()
737                                       << "='" << param.value << "'" << endl;
738                            }
739                    }
740                    // MIDI device index/id mapping.
741                    midiDeviceMap[device.deviceID()] = iDevice;
742            // Try to keep it snappy :)
743            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
744            }
745            ts << endl;
746            // Sampler channel mapping.
747      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
748      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {      for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
749          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);          qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel);
750          if (pChannelStrip) {          if (pChannelStrip) {
751              qsamplerChannel *pChannel = pChannelStrip->channel();              qsamplerChannel *pChannel = pChannelStrip->channel();
752              if (pChannel) {              if (pChannel) {
753                  ts << "# Channel " << iChannel << endl;                  ts << "# " << tr("Channel") << " " << iChannel << endl;
754                  ts << "ADD CHANNEL" << endl;                  ts << "ADD CHANNEL" << endl;
755                  ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel << " " << pChannel->audioDriver() << endl;                  if (audioDeviceMap.isEmpty()) {
756                  ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel << " " << pChannel->midiDriver() << endl;                          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel
757              //  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel << " " << pChannel->midiPort() << endl;                                              << " " << pChannel->audioDriver() << endl;
758                                } else {
759                            ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannel
760                                               << " " << audioDeviceMap[pChannel->audioDevice()] << endl;
761                                    }
762                    if (midiDeviceMap.isEmpty()) {
763                            ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel
764                                           << " " << pChannel->midiDriver() << endl;
765                                } else {
766                            ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannel
767                                               << " " << midiDeviceMap[pChannel->midiDevice()] << endl;
768                                }
769                    ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel
770                                   << " " << pChannel->midiPort() << endl;
771                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " ";                  ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " ";
772                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)                  if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL)
773                      ts << "ALL";                      ts << "ALL";
# Line 704  bool qsamplerMainForm::saveSessionFile ( Line 805  bool qsamplerMainForm::saveSessionFile (
805  }  }
806    
807    
808    // Session change receiver slot.
809    void qsamplerMainForm::sessionDirty (void)
810    {
811        // Just mark the dirty form.
812        m_iDirtyCount++;
813        // and update the form status...
814        stabilizeForm();
815    }
816    
817    
818  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
819  // qsamplerMainForm -- File Action slots.  // qsamplerMainForm -- File Action slots.
820    
# Line 1035  void qsamplerMainForm::viewOptions (void Line 1146  void qsamplerMainForm::viewOptions (void
1146          bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;          bool    bOldDisplayEffect   = m_pOptions->bDisplayEffect;
1147          int     iOldMaxVolume       = m_pOptions->iMaxVolume;          int     iOldMaxVolume       = m_pOptions->iMaxVolume;
1148          QString sOldMessagesFont    = m_pOptions->sMessagesFont;          QString sOldMessagesFont    = m_pOptions->sMessagesFont;
1149            bool    bOldKeepOnTop       = m_pOptions->bKeepOnTop;
1150          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;
1151          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;
1152          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;          int     iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines;
# Line 1047  void qsamplerMainForm::viewOptions (void Line 1159  void qsamplerMainForm::viewOptions (void
1159          if (pOptionsForm->exec()) {          if (pOptionsForm->exec()) {
1160              // Warn if something will be only effective on next run.              // Warn if something will be only effective on next run.
1161              if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) ||              if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) ||
1162                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture)) {                  (!bOldStdoutCapture &&  m_pOptions->bStdoutCapture) ||
1163                    ( bOldKeepOnTop     && !m_pOptions->bKeepOnTop)     ||
1164                    (!bOldKeepOnTop     &&  m_pOptions->bKeepOnTop)) {
1165                  QMessageBox::information(this, tr("Information"),                  QMessageBox::information(this, tr("Information"),
1166                      tr("Some settings may be only effective\n"                      tr("Some settings may be only effective\n"
1167                         "next time you start this program."), tr("OK"));                         "next time you start this program."), tr("OK"));
# Line 1293  void qsamplerMainForm::updateSession (vo Line 1407  void qsamplerMainForm::updateSession (vo
1407                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1408          }          }
1409          m_pWorkspace->setUpdatesEnabled(true);          m_pWorkspace->setUpdatesEnabled(true);
1410            
1411            // Remember to refresh devices
1412            if (m_pDeviceForm)
1413                m_pDeviceForm->refreshDevices();
1414  }  }
1415    
1416    

Legend:
Removed from v.428  
changed lines
  Added in v.487

  ViewVC Help
Powered by ViewVC