/[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 986 by capela, Mon Dec 18 16:51:50 2006 UTC revision 1000 by capela, Fri Dec 22 01:31:28 2006 UTC
# Line 404  void qsamplerMainForm::dropEvent ( QDrop Line 404  void qsamplerMainForm::dropEvent ( QDrop
404                          m_iDirtyCount++;                          m_iDirtyCount++;
405                          stabilizeForm();                          stabilizeForm();
406                  }   // Otherwise, load an usual session file (LSCP script)...                  }   // Otherwise, load an usual session file (LSCP script)...
407                  else if (closeSession(true))                  else if (closeSession(true)) {
408                          loadSessionFile(sPath);                          loadSessionFile(sPath);
409                            break;
410                    }
411                  // Make it look responsive...:)                  // Make it look responsive...:)
412                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
413          }          }
# Line 623  bool qsamplerMainForm::closeSession ( bo Line 625  bool qsamplerMainForm::closeSession ( bo
625  }  }
626    
627    
628    // Reset current session.
629    bool qsamplerMainForm::resetSession (void)
630    {
631    #ifdef CONFIG_MIDI_INSTRUMENT
632            // Reset all MIDI instrument mapping, if any.
633            int *piMaps = ::lscp_list_midi_instrument_maps(m_pClient);
634            for (int iMap = 0; piMaps && piMaps[iMap] >= 0; ++iMap) {
635                    int iMidiMap = piMaps[iMap];
636                    if (::lscp_clear_midi_instruments(m_pClient, iMidiMap) != LSCP_OK)
637                            appendMessagesClient("lscp_clear_midi_instruments");
638                    if (::lscp_remove_midi_instrument_map(m_pClient, iMidiMap) != LSCP_OK)
639                            appendMessagesClient("lscp_remove_midi_instrument_map");
640            }
641            // Check for errors...
642            if (piMaps == NULL && ::lscp_client_get_errno(m_pClient))
643                    appendMessagesClient("lscp_list_midi_instrument_maps");
644    #endif  // CONFIG_MIDI_INSTRUMENT
645    
646            // Do the actual sampler reset...
647            if (::lscp_reset_sampler(m_pClient) != LSCP_OK) {
648                    appendMessagesClient("lscp_reset_sampler");
649                    appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));
650                    return false;
651            }
652    
653            // Done.
654            return true;
655    }
656    
657    
658  // Load a session from specific file path.  // Load a session from specific file path.
659  bool qsamplerMainForm::loadSessionFile ( const QString& sFilename )  bool qsamplerMainForm::loadSessionFile ( const QString& sFilename )
660  {  {
# Line 636  bool qsamplerMainForm::loadSessionFile ( Line 668  bool qsamplerMainForm::loadSessionFile (
668          return false;          return false;
669      }      }
670    
671            // Tell the world we'll take some time...
672            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
673    
674      // Read the file.      // Read the file.
675            int iLine = 0;
676      int iErrors = 0;      int iErrors = 0;
677      QTextStream ts(&file);      QTextStream ts(&file);
678      while (!ts.atEnd()) {      while (!ts.atEnd()) {
679          // Read the line.          // Read the line.
680          QString sCommand = ts.readLine().stripWhiteSpace();          QString sCommand = ts.readLine().stripWhiteSpace();
681                    iLine++;
682          // If not empty, nor a comment, call the server...          // If not empty, nor a comment, call the server...
683          if (!sCommand.isEmpty() && sCommand[0] != '#') {          if (!sCommand.isEmpty() && sCommand[0] != '#') {
684              appendMessagesColor(sCommand, "#996633");                          // HACK: A very special trap for the global RESET command...
685              // Remember that, no matter what,                          if (sCommand == "RESET") {
686              // all LSCP commands are CR/LF terminated.                                  // Do our own reset...
687              sCommand += "\r\n";                                  if (!resetSession())
688              if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {                                          iErrors++;
689                  appendMessagesClient("lscp_client_query");                          } else {
690                  iErrors++;                                  // Remember that, no matter what,
691              }                                  // all LSCP commands are CR/LF terminated.
692                                    sCommand += "\r\n";
693                                    if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) {
694                                            appendMessagesColor(QString("%1(%2): %3")
695                                                    .arg(QFileInfo(sFilename).fileName()).arg(iLine)
696                                                    .arg(sCommand.simplifyWhiteSpace()), "#996633");
697                                            appendMessagesClient("lscp_client_query");
698                                            iErrors++;
699                                    }
700                            }
701          }          }
702          // Try to make it snappy :)          // Try to make it snappy :)
703          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
# Line 663  bool qsamplerMainForm::loadSessionFile ( Line 709  bool qsamplerMainForm::loadSessionFile (
709          // Now we'll try to create (update) the whole GUI session.          // Now we'll try to create (update) the whole GUI session.
710          updateSession();          updateSession();
711    
712            // We're fornerly done.
713            QApplication::restoreOverrideCursor();
714    
715          // Have we any errors?          // Have we any errors?
716          if (iErrors > 0)          if (iErrors > 0)
717                  appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename));                  appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename));
# Line 702  bool qsamplerMainForm::saveSessionFile ( Line 751  bool qsamplerMainForm::saveSessionFile (
751          return false;          return false;
752      }      }
753    
754            // Tell the world we'll take some time...
755            QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
756    
757      // Write the file.      // Write the file.
758      int  iErrors = 0;      int  iErrors = 0;
759      QTextStream ts(&file);      QTextStream ts(&file);
# Line 855  bool qsamplerMainForm::saveSessionFile ( Line 907  bool qsamplerMainForm::saveSessionFile (
907                                  if (pInstrInfo->name)                                  if (pInstrInfo->name)
908                                          ts << " '" << pInstrInfo->name << "'";                                          ts << " '" << pInstrInfo->name << "'";
909                                  ts << endl;                                  ts << endl;
910                            }       // Check for errors...
911                            else if (::lscp_client_get_errno(m_pClient)) {
912                                    appendMessagesClient("lscp_get_midi_instrument_info");
913                                    iErrors++;
914                          }                          }
                         // MIDI device index/id mapping.  
                         midiInstrumentMap[iMidiMap] = iMap;  
915                          // Try to keep it snappy :)                          // Try to keep it snappy :)
916                          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);                          QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
917                  }                  }
918                    // Check for errors...
919                  if (pInstrs)                  if (pInstrs)
920                          ts << endl;                          ts << endl;
921                    else if (::lscp_client_get_errno(m_pClient)) {
922                            appendMessagesClient("lscp_list_midi_instruments");
923                            iErrors++;
924                    }
925                    // MIDI strument index/id mapping.
926                    midiInstrumentMap[iMidiMap] = iMap;
927          }          }
928  #endif //  CONFIG_MIDI_INSTRUMENT          // Check for errors...
929            if (piMaps == NULL && ::lscp_client_get_errno(m_pClient)) {
930                    appendMessagesClient("lscp_list_midi_instrument_maps");
931                    iErrors++;
932            }
933    #endif  // CONFIG_MIDI_INSTRUMENT
934    
935          // Sampler channel mapping.          // Sampler channel mapping.
936      QWidgetList wlist = m_pWorkspace->windowList();      QWidgetList wlist = m_pWorkspace->windowList();
# Line 931  bool qsamplerMainForm::saveSessionFile ( Line 997  bool qsamplerMainForm::saveSessionFile (
997      // Ok. we've wrote it.      // Ok. we've wrote it.
998      file.close();      file.close();
999    
1000            // We're fornerly done.
1001            QApplication::restoreOverrideCursor();
1002    
1003      // Have we any errors?      // Have we any errors?
1004      if (iErrors > 0)      if (iErrors > 0)
1005          appendMessagesError(tr("Some settings could not be saved\nto \"%1\" session file.\n\nSorry.").arg(sFilename));          appendMessagesError(tr("Some settings could not be saved\nto \"%1\" session file.\n\nSorry.").arg(sFilename));
# Line 1022  void qsamplerMainForm::fileReset (void) Line 1091  void qsamplerMainForm::fileReset (void)
1091          tr("Reset"), tr("Cancel")) > 0)          tr("Reset"), tr("Cancel")) > 0)
1092          return;          return;
1093    
1094            // Trye closing the current session, first...
1095            if (!closeSession(true))
1096                    return;
1097    
1098      // Just do the reset, after closing down current session...      // Just do the reset, after closing down current session...
1099      if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) {          if (!resetSession())
1100          appendMessagesClient("lscp_reset_sampler");                  return;
         appendMessagesError(tr("Could not reset sampler instance.\n\nSorry."));  
         return;  
     }  
1101    
1102      // Log this.      // Log this.
1103      appendMessages(tr("Sampler reset."));      appendMessages(tr("Sampler reset."));
# Line 1595  void qsamplerMainForm::updateSession (vo Line 1665  void qsamplerMainForm::updateSession (vo
1665                          appendMessagesClient("lscp_list_channels");                          appendMessagesClient("lscp_list_channels");
1666                          appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));                          appendMessagesError(tr("Could not get current list of channels.\n\nSorry."));
1667                  }                  }
1668                  return;          } else {
1669                    // Try to (re)create each channel.
1670                    m_pWorkspace->setUpdatesEnabled(false);
1671                    for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {
1672                            // Check if theres already a channel strip for this one...
1673                            if (!channelStrip(piChannelIDs[iChannel]))
1674                                    createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel]));
1675                    }
1676                    m_pWorkspace->setUpdatesEnabled(true);
1677          }          }
1678    
1679          // Try to (re)create each channel.      // Do we auto-arrange?
1680          m_pWorkspace->setUpdatesEnabled(false);      if (m_pOptions && m_pOptions->bAutoArrange)
1681          for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) {          channelsArrange();
                 // Check if theres already a channel strip for this one...  
                 if (!channelStrip(piChannelIDs[iChannel]))  
                         createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel]));  
                 // Make it visibly responsive...  
                 QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);  
         }  
         m_pWorkspace->setUpdatesEnabled(true);  
1682    
1683          // Remember to refresh devices and instruments...          // Remember to refresh devices and instruments...
1684          if (m_pInstrumentListForm)          if (m_pInstrumentListForm)
# Line 1784  void qsamplerMainForm::appendMessagesErr Line 1855  void qsamplerMainForm::appendMessagesErr
1855    
1856      appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000");      appendMessagesColor(s.simplifyWhiteSpace(), "#ff0000");
1857    
1858            // Make it look responsive...:)
1859            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1860    
1861      QMessageBox::critical(this,      QMessageBox::critical(this,
1862                  QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel"));                  QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel"));
1863  }  }
# Line 1798  void qsamplerMainForm::appendMessagesCli Line 1872  void qsamplerMainForm::appendMessagesCli
1872      appendMessagesColor(s + QString(": %1 (errno=%2)")      appendMessagesColor(s + QString(": %1 (errno=%2)")
1873          .arg(::lscp_client_get_result(m_pClient))          .arg(::lscp_client_get_result(m_pClient))
1874          .arg(::lscp_client_get_errno(m_pClient)), "#996666");          .arg(::lscp_client_get_errno(m_pClient)), "#996666");
1875    
1876            // Make it look responsive...:)
1877            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1878  }  }
1879    
1880    

Legend:
Removed from v.986  
changed lines
  Added in v.1000

  ViewVC Help
Powered by ViewVC