/[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 115 by capela, Mon Jun 7 21:41:43 2004 UTC revision 255 by capela, Tue Sep 28 16:17:43 2004 UTC
# Line 54  Line 54 
54  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.  #define QSAMPLER_STATUS_SESSION 3       // Current session modification state.
55    
56    
57    // All winsock apps needs this.
58  #if defined(WIN32)  #if defined(WIN32)
59  static WSADATA _wsaData;  static WSADATA _wsaData;
60  #endif  #endif
61    
62    
63    //-------------------------------------------------------------------------
64    // qsamplerCustomEvent -- specialty for callback comunication.
65    
66    #define QSAMPLER_CUSTOM_EVENT   1000
67    
68    class qsamplerCustomEvent : public QCustomEvent
69    {
70    public:
71    
72        // Constructor.
73        qsamplerCustomEvent(lscp_event_t event, const char *pchData, int cchData)
74            : QCustomEvent(QSAMPLER_CUSTOM_EVENT)
75        {
76            m_event = event;
77            m_data.setLatin1(pchData, cchData);
78        }
79    
80        // Accessors.
81        lscp_event_t event() { return m_event; }
82        QString&     data()  { return m_data;  }
83    
84    private:
85    
86        // The proper event type.
87        lscp_event_t m_event;
88        // The event data as a string.
89        QString      m_data;
90    };
91    
92    
93  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
94  // qsamplerMainForm -- Main window form implementation.  // qsamplerMainForm -- Main window form implementation.
95    
# Line 252  void qsamplerMainForm::closeEvent ( QClo Line 284  void qsamplerMainForm::closeEvent ( QClo
284  }  }
285    
286    
287    // Window drag-n-drop event handlers.
288  void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )  void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent )
289  {  {
290      bool bAccept = false;      bool bAccept = false;
# Line 276  void qsamplerMainForm::dropEvent ( QDrop Line 309  void qsamplerMainForm::dropEvent ( QDrop
309  }  }
310    
311    
312    // Custome event handler.
313    void qsamplerMainForm::customEvent ( QCustomEvent *pCustomEvent )
314    {
315        // For the time being, just pump it to messages.
316        if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) {
317            qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent;
318            appendMessagesColor(tr("Notify event: %1 data: %2")
319                .arg(::lscp_event_to_text(pEvent->event()))
320                .arg(pEvent->data()), "#996699");
321        }
322    }
323    
324    
325    // Context menu event handler.
326    void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent )
327    {
328        stabilizeForm();
329        
330        editMenu->exec(pEvent->globalPos());
331    }
332    
333    
334  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
335  // qsamplerMainForm -- Brainless public property accessors.  // qsamplerMainForm -- Brainless public property accessors.
336    
# Line 546  bool qsamplerMainForm::saveSessionFile ( Line 601  bool qsamplerMainForm::saveSessionFile (
601          ts << "ADD CHANNEL" << endl;          ts << "ADD CHANNEL" << endl;
602          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;          ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl;
603          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;          ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl;
604      //  ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;          ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl;
605          ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl;          ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " ";
606            if (pChannel->midiChannel() > 0)
607                ts << pChannel->midiChannel();
608             else
609                ts << "ALL";
610            ts << endl;
611          ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;          ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl;
612          ts << "LOAD INSTRUMENT " << pChannel->instrumentFile() << " " << pChannel->instrumentNr() << " " << iChannelID << endl;          ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl;
613          ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;          ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl;
614          ts << endl;          ts << endl;
615          // Try to keep it snappy :)          // Try to keep it snappy :)
# Line 623  void qsamplerMainForm::fileSaveAs (void) Line 683  void qsamplerMainForm::fileSaveAs (void)
683  }  }
684    
685    
686    // Reset the sampler instance.
687    void qsamplerMainForm::fileReset (void)
688    {
689        if (m_pClient == NULL)
690            return;
691    
692        // Ask user whether he/she want's an internal sampler reset...
693        if (QMessageBox::warning(this, tr("Warning"),
694            tr("Resetting the sampler instance will close\n"
695               "all device and channel configurations.\n\n"
696               "Please note that this operation may cause\n"
697               "temporary MIDI and Audio disruption\n\n"
698               "Do you want to reset the sampler engine now?"),
699            tr("Reset"), tr("Cancel")) > 0)
700            return;
701    
702        // Just do the reset, after closing down current session...
703        if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK)
704            appendMessagesClient("lscp_reset_sampler");
705    }
706    
707    
708  // Restart the client/server instance.  // Restart the client/server instance.
709  void qsamplerMainForm::fileRestart (void)  void qsamplerMainForm::fileRestart (void)
710  {  {
# Line 745  void qsamplerMainForm::editSetupChannel Line 827  void qsamplerMainForm::editSetupChannel
827          return;          return;
828    
829      // Just invoque the channel strip procedure.      // Just invoque the channel strip procedure.
830      pChannel->channelSetup();      pChannel->channelSetup(false);
831  }  }
832    
833    
# Line 843  void qsamplerMainForm::viewOptions (void Line 925  void qsamplerMainForm::viewOptions (void
925          bool    bOldServerStart     = m_pOptions->bServerStart;          bool    bOldServerStart     = m_pOptions->bServerStart;
926          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;          QString sOldServerCmdLine   = m_pOptions->sServerCmdLine;
927          QString sOldDisplayFont     = m_pOptions->sDisplayFont;          QString sOldDisplayFont     = m_pOptions->sDisplayFont;
928            int     iOldMaxVolume       = m_pOptions->iMaxVolume;
929          QString sOldMessagesFont    = m_pOptions->sMessagesFont;          QString sOldMessagesFont    = m_pOptions->sMessagesFont;
930          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;          bool    bOldStdoutCapture   = m_pOptions->bStdoutCapture;
931          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;          int     bOldMessagesLimit   = m_pOptions->bMessagesLimit;
# Line 868  void qsamplerMainForm::viewOptions (void Line 951  void qsamplerMainForm::viewOptions (void
951                  updateRecentFilesMenu();                  updateRecentFilesMenu();
952              if (sOldDisplayFont != m_pOptions->sDisplayFont)              if (sOldDisplayFont != m_pOptions->sDisplayFont)
953                  updateDisplayFont();                  updateDisplayFont();
954                if (iOldMaxVolume != m_pOptions->iMaxVolume)
955                    updateMaxVolume();
956              if (sOldMessagesFont != m_pOptions->sMessagesFont)              if (sOldMessagesFont != m_pOptions->sMessagesFont)
957                  updateMessagesFont();                  updateMessagesFont();
958              if (( bOldMessagesLimit && !m_pOptions->bMessagesLimit) ||              if (( bOldMessagesLimit && !m_pOptions->bMessagesLimit) ||
# Line 966  void qsamplerMainForm::helpAbout (void) Line 1051  void qsamplerMainForm::helpAbout (void)
1051      sText += tr("Debugging option enabled.");      sText += tr("Debugging option enabled.");
1052      sText += "</font></small><br />";      sText += "</font></small><br />";
1053  #endif  #endif
1054    #ifndef CONFIG_LIBGIG
1055        sText += "<small><font color=\"red\">";
1056        sText += tr("GIG (libgig) file support disabled.");
1057        sText += "</font></small><br />";
1058    #endif
1059      sText += "<br />\n";      sText += "<br />\n";
1060      sText += tr("Using") + ": ";      sText += tr("Using") + ": ";
1061      sText += ::lscp_client_package();      sText += ::lscp_client_package();
# Line 1006  void qsamplerMainForm::stabilizeForm (vo Line 1096  void qsamplerMainForm::stabilizeForm (vo
1096      fileOpenAction->setEnabled(bHasClient);      fileOpenAction->setEnabled(bHasClient);
1097      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);      fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0);
1098      fileSaveAsAction->setEnabled(bHasClient);      fileSaveAsAction->setEnabled(bHasClient);
1099        fileResetAction->setEnabled(bHasClient);
1100      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);      fileRestartAction->setEnabled(bHasClient || m_pServer == NULL);
1101      editAddChannelAction->setEnabled(bHasClient);      editAddChannelAction->setEnabled(bHasClient);
1102      editRemoveChannelAction->setEnabled(bHasChannel);      editRemoveChannelAction->setEnabled(bHasChannel);
# Line 1124  void qsamplerMainForm::updateDisplayFont Line 1215  void qsamplerMainForm::updateDisplayFont
1215  }  }
1216    
1217    
1218    // Force update of the channels maximum volume setting.
1219    void qsamplerMainForm::updateMaxVolume (void)
1220    {
1221        if (m_pOptions == NULL)
1222            return;
1223    
1224        // Full channel list update...
1225        QWidgetList wlist = m_pWorkspace->windowList();
1226        if (wlist.isEmpty())
1227            return;
1228    
1229        m_pWorkspace->setUpdatesEnabled(false);
1230        for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) {
1231            qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel);
1232            pChannel->setMaxVolume(m_pOptions->iMaxVolume);
1233        }
1234        m_pWorkspace->setUpdatesEnabled(true);
1235    }
1236    
1237    
1238  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1239  // qsamplerMainForm -- Messages window form handlers.  // qsamplerMainForm -- Messages window form handlers.
1240    
# Line 1237  void qsamplerMainForm::createChannel ( i Line 1348  void qsamplerMainForm::createChannel ( i
1348      // Add a new channel itema...      // Add a new channel itema...
1349      WFlags wflags = Qt::WStyle_Customize | Qt::WStyle_Tool | Qt::WStyle_Title | Qt::WStyle_NoBorder;      WFlags wflags = Qt::WStyle_Customize | Qt::WStyle_Tool | Qt::WStyle_Title | Qt::WStyle_NoBorder;
1350      pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);      pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags);
1351        pChannel->setMaxVolume(m_pOptions->iMaxVolume);
1352      pChannel->setup(this, iChannelID);      pChannel->setup(this, iChannelID);
1353      // We'll need a display font.      // We'll need a display font.
1354      QFont font;      QFont font;
# Line 1247  void qsamplerMainForm::createChannel ( i Line 1359  void qsamplerMainForm::createChannel ( i
1359      // Before we show it up, may be we'll      // Before we show it up, may be we'll
1360      // better ask for some initial values?      // better ask for some initial values?
1361      if (bPrompt)      if (bPrompt)
1362          pChannel->channelSetup();                pChannel->channelSetup(true);
1363      // Now we show up us to the world.      // Now we show up us to the world.
1364      pChannel->show();      pChannel->show();
1365      // Only then, we'll auto-arrange...      // Only then, we'll auto-arrange...
# Line 1438  void qsamplerMainForm::stopServer (void) Line 1550  void qsamplerMainForm::stopServer (void)
1550      // And try to stop server.      // And try to stop server.
1551      if (m_pServer) {      if (m_pServer) {
1552          appendMessages(tr("Server is stopping..."));          appendMessages(tr("Server is stopping..."));
1553          if (m_pServer->isRunning()) {          if (m_pServer->isRunning())
1554              m_pServer->tryTerminate();              m_pServer->tryTerminate();
             return;  
         }  
1555       }       }
1556    
1557        // Give it some time to terminate gracefully and stabilize...
1558        QTime t;
1559        t.start();
1560        while (t.elapsed() < QSAMPLER_TIMER_MSECS)
1561            QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
1562    
1563       // Do final processing anyway.       // Do final processing anyway.
1564       processServerExit();       processServerExit();
1565  }  }
# Line 1485  void qsamplerMainForm::processServerExit Line 1601  void qsamplerMainForm::processServerExit
1601  //-------------------------------------------------------------------------  //-------------------------------------------------------------------------
1602  // qsamplerMainForm -- Client stuff.  // qsamplerMainForm -- Client stuff.
1603    
   
1604  // The LSCP client callback procedure.  // The LSCP client callback procedure.
1605  lscp_status_t qsampler_client_callback ( lscp_client_t *pClient, const char *pchBuffer, int cchBuffer, void *pvData )  lscp_status_t qsampler_client_callback ( lscp_client_t */*pClient*/, lscp_event_t event, const char *pchData, int cchData, void *pvData )
1606  {  {
1607      qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData;      qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData;
1608      if (pMainForm == NULL)      if (pMainForm == NULL)
1609          return LSCP_FAILED;          return LSCP_FAILED;
1610    
1611      char *pszBuffer = (char *) malloc(cchBuffer + 1);      // ATTN: DO NOT EVER call any GUI code here,
1612      if (pszBuffer == NULL)      // as this is run under some other thread context.
1613          return LSCP_FAILED;      // A custom event must be posted here...
1614        QApplication::postEvent(pMainForm, new qsamplerCustomEvent(event, pchData, cchData));
     memcpy(pszBuffer, pchBuffer, cchBuffer);  
     pszBuffer[cchBuffer] = (char) 0;  
     pMainForm->appendMessagesColor(pszBuffer, "#996699");  
     free(pszBuffer);  
1615    
1616      return LSCP_OK;      return LSCP_OK;
1617  }  }

Legend:
Removed from v.115  
changed lines
  Added in v.255

  ViewVC Help
Powered by ViewVC