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

Annotation of /qsampler/trunk/src/qsamplerChannelForm.ui.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 115 - (hide annotations) (download) (as text)
Mon Jun 7 21:41:43 2004 UTC (19 years, 9 months ago) by capela
File MIME type: text/x-c++hdr
File size: 8838 byte(s)
* Comment SET CHANNEL MIDI_INPUT_PORT command from
  saveSessionFile(), it has no effect.

* Insert a n #include <unistd.h> on qsamplerMessages.h, between

* An initial non zero value (0.8) should be set for the channel
  volume, while GET CHANNEL INFO command is pending implementation.

* The order to load/save and setup channel settings is now as
  suggested in the following lines:

    SET CHANNEL AUDIO_OUTPUT_TYPE ...
    SET CHANNEL MIDI_INPUT_TYPE ...
    SET CHANNEL MIDI_INPUT_CHANNEL ...
    LOAD ENGINE ...
    LOAD INSTRUMENT ...
    SET CHANNEL VOLUME ...

1 capela 104 // qsamplerChannelForm.ui.h
2     //
3     // ui.h extension file, included from the uic-generated form implementation.
4     /****************************************************************************
5     Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved.
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
18     along with this program; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20    
21     *****************************************************************************/
22    
23     #include <qvalidator.h>
24     #include <qmessagebox.h>
25     #include <qfiledialog.h>
26     #include <qfileinfo.h>
27     #include <qlistbox.h>
28    
29     #include "qsamplerOptions.h"
30     #include "qsamplerChannelStrip.h"
31    
32     #include "config.h"
33    
34    
35     // Kind of constructor.
36     void qsamplerChannelForm::init (void)
37     {
38     // Initialize locals.
39     m_pChannel = NULL;
40    
41     m_iDirtySetup = 0;
42     m_iDirtyCount = 0;
43    
44     // Try to restore normal window positioning.
45     adjustSize();
46     }
47    
48    
49     // Kind of destructor.
50     void qsamplerChannelForm::destroy (void)
51     {
52     }
53    
54    
55     // Channel dialog setup formal initializer.
56     void qsamplerChannelForm::setup ( qsamplerChannelStrip *pChannel )
57     {
58     m_pChannel = pChannel;
59    
60     m_iDirtySetup = 0;
61     m_iDirtyCount = 0;
62    
63     if (m_pChannel == NULL)
64     return;
65    
66     setCaption(m_pChannel->caption());
67    
68     // Check if we're up and connected.
69     if (m_pChannel->client() == NULL)
70     return;
71    
72     qsamplerOptions *pOptions = m_pChannel->options();
73     if (pOptions == NULL)
74     return;
75    
76     // Avoid nested changes.
77     m_iDirtySetup++;
78    
79     // Load combo box history...
80     pOptions->loadComboBoxHistory(InstrumentFileComboBox);
81    
82     // Populate Engines list.
83     const char **ppszEngines = ::lscp_get_available_engines(m_pChannel->client());
84     if (ppszEngines) {
85     EngineNameComboBox->clear();
86     for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)
87     EngineNameComboBox->insertItem(ppszEngines[iEngine]);
88     }
89     else m_pChannel->appendMessagesClient("lscp_get_available_engines");
90     /*
91     // Populate Audio output type list.
92     const char **ppszAudioDrivers = ::lscp_get_available_audio_drivers(m_pChannel->client());
93     if (ppszAudioDrivers) {
94     AudioDriverComboBox->clear();
95     for (int iAudioDriver = 0; ppszAudioDrivers[iAudioDriver]; iAudioDriver++)
96     AudioDriverComboBox->insertItem(ppszAudioDrivers[iAudioDriver]);
97     }
98     else m_pChannel->appendMessagesClient("lscp_get_available_audio_drivers");
99    
100     // Populate MIDI input type list.
101     const char **ppszMidiDrivers = ::lscp_get_available_midi_drivers(m_pChannel->client());
102     if (ppszMidiDrivers) {
103     MidiDriverComboBox->clear();
104     for (int iMidiDriver = 0; ppszMidiDrivers[iMidiDriver]; iMidiDriver++)
105     MidiDriverComboBox->insertItem(ppszMidiDrivers[iMidiDriver]);
106     }
107     else m_pChannel->appendMessagesClient("lscp_get_available_midi_drivers");
108     */
109     // Read proper channel information,
110     // and populate the channel form fields.
111    
112     // Engine name...
113     const QString& sEngineName = pChannel->engineName();
114     if (!sEngineName.isEmpty()) {
115     if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL)
116     EngineNameComboBox->insertItem(sEngineName);
117     EngineNameComboBox->setCurrentText(sEngineName);
118     }
119     // Instrument filename and index...
120     InstrumentFileComboBox->setCurrentText(pChannel->instrumentFile());
121     InstrumentNrSpinBox->setValue(pChannel->instrumentNr());
122     // MIDI input...
123     const QString& sMidiDriver = pChannel->midiDriver();
124     if (!sMidiDriver.isEmpty()) {
125     if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL)
126     MidiDriverComboBox->insertItem(sMidiDriver);
127     MidiDriverComboBox->setCurrentText(sMidiDriver);
128     }
129     MidiPortSpinBox->setValue(pChannel->midiPort());
130     MidiChannelSpinBox->setValue(pChannel->midiChannel());
131     // Audio output...
132     const QString& sAudioDriver = pChannel->audioDriver();
133     if (!sAudioDriver.isEmpty()) {
134     if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL)
135     AudioDriverComboBox->insertItem(sAudioDriver);
136     AudioDriverComboBox->setCurrentText(sAudioDriver);
137     }
138     // FIXME: Disable this while we don't know what to do.
139     MidiPortTextLabel->setEnabled(false);
140     MidiPortSpinBox->setEnabled(false);
141     // Done.
142     m_iDirtySetup--;
143     stabilizeForm();
144     }
145    
146    
147     // Accept settings (OK button slot).
148     void qsamplerChannelForm::accept (void)
149     {
150     if (m_pChannel == NULL)
151     return;
152    
153     qsamplerOptions *pOptions = m_pChannel->options();
154     if (pOptions == NULL)
155     return;
156    
157     // We'll go for it!
158     if (m_iDirtyCount > 0) {
159     int iErrors = 0;
160 capela 115 // Audio output driver type...
161     if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))
162 capela 104 iErrors++;
163     // MIDI input driver type...
164     if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText()))
165     iErrors++;
166     // MIDI input port number...
167     if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))
168     iErrors++;
169     // MIDI input channel...
170     if (!m_pChannel->setMidiChannel(MidiChannelSpinBox->value()))
171     iErrors++;
172 capela 115 // Engine name...
173     if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))
174 capela 104 iErrors++;
175     // Instrument file and index...
176     if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrSpinBox->value()))
177     iErrors++;
178     // Show error messages?
179     if (iErrors > 0)
180     m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry."));
181     }
182    
183     // Save default instrument directory and history...
184     pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);
185     pOptions->saveComboBoxHistory(InstrumentFileComboBox);
186    
187     // Just go with dialog acceptance.
188     QDialog::accept();
189     }
190    
191    
192     // Reject settings (Cancel button slot).
193     void qsamplerChannelForm::reject (void)
194     {
195     bool bReject = true;
196    
197     // Check if there's any pending changes...
198     if (m_iDirtyCount > 0) {
199     switch (QMessageBox::warning(this, tr("Warning"),
200     tr("Some channel settings have been changed.\n\n"
201     "Do you want to apply the changes?"),
202     tr("Apply"), tr("Discard"), tr("Cancel"))) {
203     case 0: // Apply...
204     accept();
205     return;
206     case 1: // Discard
207     break;
208     default: // Cancel.
209     bReject = false;
210     }
211     }
212    
213     if (bReject)
214     QDialog::reject();
215     }
216    
217    
218     // Browse and open an instrument file.
219     void qsamplerChannelForm::openInstrumentFile (void)
220     {
221     qsamplerOptions *pOptions = m_pChannel->options();
222     if (pOptions == NULL)
223     return;
224    
225     // FIXME: the instrument file filters should be restricted,
226     // depending on the current engine.
227     QString sInstrumentFile = QFileDialog::getOpenFileName(
228     pOptions->sInstrumentDir, // Start here.
229     tr("Instrument files") + " (*.gig *.dls)", // Filter (GIG and DLS files)
230     this, 0, // Parent and name (none)
231     tr("Instrument files") // Caption.
232     );
233    
234     if (sInstrumentFile.isEmpty())
235     return;
236    
237     InstrumentFileComboBox->setCurrentText(sInstrumentFile);
238     }
239    
240    
241     // Refresh the actual instrument name.
242     void qsamplerChannelForm::updateInstrumentName (void)
243     {
244     // FIXME: A better idea would be to use libgig
245     // to retrieve the REAL instrument name.
246     InstrumentNameTextLabel->setText(QFileInfo(InstrumentFileComboBox->currentText()).fileName()
247     + " [" + QString::number(InstrumentNrSpinBox->value()) + "]");
248    
249     optionsChanged();
250     }
251    
252    
253    
254     // Dirty up settings.
255     void qsamplerChannelForm::optionsChanged (void)
256     {
257     if (m_iDirtySetup > 0)
258     return;
259    
260     m_iDirtyCount++;
261     stabilizeForm();
262     }
263    
264    
265     // Stabilize current form state.
266     void qsamplerChannelForm::stabilizeForm (void)
267     {
268     const QString sFilename = InstrumentFileComboBox->currentText();
269     OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists());
270     }
271    
272    
273     // end of qsamplerChannelForm.ui.h
274    

  ViewVC Help
Powered by ViewVC