/[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 255 - (hide annotations) (download) (as text)
Tue Sep 28 16:17:43 2004 UTC (19 years, 6 months ago) by capela
File MIME type: text/x-c++hdr
File size: 9516 byte(s)
* Sampler reset command action added to menu and toolbar.

* MIDI channel selection is now a dropdown list, allowing
  the explicit selection for "All" channels input per sampler
  channel (omni).

* Channel strip display glass effect has changed background
  color to black (was green).

* Minor configure fixes.

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 capela 176 void qsamplerChannelForm::setup ( qsamplerChannelStrip *pChannel, bool bNew )
57 capela 104 {
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 capela 145
91 capela 104 // 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 capela 145
109 capela 104 // Read proper channel information,
110     // and populate the channel form fields.
111    
112     // Engine name...
113 capela 145 QString sEngineName = pChannel->engineName();
114 capela 176 if (sEngineName.isEmpty() && bNew)
115     sEngineName = pOptions->sEngineName;
116 capela 145 if (sEngineName.isEmpty())
117     sEngineName = tr("(No engine)");
118     if (EngineNameComboBox->listBox()->findItem(sEngineName, Qt::ExactMatch) == NULL)
119     EngineNameComboBox->insertItem(sEngineName);
120     EngineNameComboBox->setCurrentText(sEngineName);
121 capela 104 // Instrument filename and index...
122 capela 145 QString sInstrumentFile = pChannel->instrumentFile();
123     if (sInstrumentFile.isEmpty())
124     sInstrumentFile = tr("(No instrument)");
125     InstrumentFileComboBox->setCurrentText(sInstrumentFile);
126 capela 104 InstrumentNrSpinBox->setValue(pChannel->instrumentNr());
127 capela 176 // MIDI input driver...
128     QString sMidiDriver = pChannel->midiDriver();
129     if (sMidiDriver.isEmpty() && bNew)
130     sMidiDriver = pOptions->sMidiDriver;
131 capela 104 if (!sMidiDriver.isEmpty()) {
132     if (MidiDriverComboBox->listBox()->findItem(sMidiDriver, Qt::ExactMatch) == NULL)
133     MidiDriverComboBox->insertItem(sMidiDriver);
134     MidiDriverComboBox->setCurrentText(sMidiDriver);
135     }
136 capela 176 // MIDI input port...
137 capela 104 MidiPortSpinBox->setValue(pChannel->midiPort());
138 capela 176 // MIDI input channel...
139     int iMidiChannel = pChannel->midiChannel();
140     if (bNew)
141     iMidiChannel = (pChannel->channelID() + 1) % 16;
142 capela 255 MidiChannelComboBox->setCurrentItem(iMidiChannel);
143 capela 176 // Audio output driver...
144     QString sAudioDriver = pChannel->audioDriver();
145     if (sAudioDriver.isEmpty() && bNew)
146     sAudioDriver = pOptions->sAudioDriver;
147 capela 104 if (!sAudioDriver.isEmpty()) {
148     if (AudioDriverComboBox->listBox()->findItem(sAudioDriver, Qt::ExactMatch) == NULL)
149     AudioDriverComboBox->insertItem(sAudioDriver);
150     AudioDriverComboBox->setCurrentText(sAudioDriver);
151     }
152     // Done.
153     m_iDirtySetup--;
154     stabilizeForm();
155     }
156    
157    
158     // Accept settings (OK button slot).
159     void qsamplerChannelForm::accept (void)
160     {
161     if (m_pChannel == NULL)
162     return;
163    
164     qsamplerOptions *pOptions = m_pChannel->options();
165     if (pOptions == NULL)
166     return;
167    
168     // We'll go for it!
169     if (m_iDirtyCount > 0) {
170     int iErrors = 0;
171 capela 115 // Audio output driver type...
172     if (!m_pChannel->setAudioDriver(AudioDriverComboBox->currentText()))
173 capela 104 iErrors++;
174     // MIDI input driver type...
175     if (!m_pChannel->setMidiDriver(MidiDriverComboBox->currentText()))
176     iErrors++;
177     // MIDI input port number...
178     if (!m_pChannel->setMidiPort(MidiPortSpinBox->value()))
179 capela 161 iErrors++;
180 capela 104 // MIDI input channel...
181 capela 255 if (!m_pChannel->setMidiChannel(MidiChannelComboBox->currentItem()))
182 capela 104 iErrors++;
183 capela 115 // Engine name...
184     if (!m_pChannel->loadEngine(EngineNameComboBox->currentText()))
185 capela 104 iErrors++;
186     // Instrument file and index...
187     if (!m_pChannel->loadInstrument(InstrumentFileComboBox->currentText(), InstrumentNrSpinBox->value()))
188     iErrors++;
189     // Show error messages?
190     if (iErrors > 0)
191     m_pChannel->appendMessagesError(tr("Some channel settings could not be set.\n\nSorry."));
192     }
193    
194 capela 176 // Save default engine name, instrument directory and history...
195 capela 104 pOptions->sInstrumentDir = QFileInfo(InstrumentFileComboBox->currentText()).dirPath(true);
196 capela 176 pOptions->sEngineName = EngineNameComboBox->currentText();
197     pOptions->sAudioDriver = AudioDriverComboBox->currentText();
198     pOptions->sMidiDriver = MidiDriverComboBox->currentText();
199 capela 104 pOptions->saveComboBoxHistory(InstrumentFileComboBox);
200    
201     // Just go with dialog acceptance.
202     QDialog::accept();
203     }
204    
205    
206     // Reject settings (Cancel button slot).
207     void qsamplerChannelForm::reject (void)
208     {
209     bool bReject = true;
210    
211     // Check if there's any pending changes...
212 capela 176 if (m_iDirtyCount > 0 && OkPushButton->isEnabled()) {
213 capela 104 switch (QMessageBox::warning(this, tr("Warning"),
214     tr("Some channel settings have been changed.\n\n"
215     "Do you want to apply the changes?"),
216     tr("Apply"), tr("Discard"), tr("Cancel"))) {
217     case 0: // Apply...
218     accept();
219     return;
220     case 1: // Discard
221     break;
222     default: // Cancel.
223     bReject = false;
224     }
225     }
226    
227     if (bReject)
228     QDialog::reject();
229     }
230    
231    
232     // Browse and open an instrument file.
233     void qsamplerChannelForm::openInstrumentFile (void)
234     {
235     qsamplerOptions *pOptions = m_pChannel->options();
236     if (pOptions == NULL)
237     return;
238    
239     // FIXME: the instrument file filters should be restricted,
240     // depending on the current engine.
241     QString sInstrumentFile = QFileDialog::getOpenFileName(
242     pOptions->sInstrumentDir, // Start here.
243     tr("Instrument files") + " (*.gig *.dls)", // Filter (GIG and DLS files)
244     this, 0, // Parent and name (none)
245     tr("Instrument files") // Caption.
246     );
247    
248     if (sInstrumentFile.isEmpty())
249     return;
250    
251     InstrumentFileComboBox->setCurrentText(sInstrumentFile);
252     }
253    
254    
255     // Refresh the actual instrument name.
256     void qsamplerChannelForm::updateInstrumentName (void)
257     {
258     // FIXME: A better idea would be to use libgig
259     // to retrieve the REAL instrument name.
260     InstrumentNameTextLabel->setText(QFileInfo(InstrumentFileComboBox->currentText()).fileName()
261     + " [" + QString::number(InstrumentNrSpinBox->value()) + "]");
262    
263     optionsChanged();
264     }
265    
266    
267    
268     // Dirty up settings.
269     void qsamplerChannelForm::optionsChanged (void)
270     {
271     if (m_iDirtySetup > 0)
272     return;
273    
274     m_iDirtyCount++;
275     stabilizeForm();
276     }
277    
278    
279     // Stabilize current form state.
280     void qsamplerChannelForm::stabilizeForm (void)
281     {
282 capela 145 const QString& sFilename = InstrumentFileComboBox->currentText();
283 capela 104 OkPushButton->setEnabled(m_iDirtyCount > 0 && !sFilename.isEmpty() && QFileInfo(sFilename).exists());
284     }
285    
286    
287     // end of qsamplerChannelForm.ui.h
288    

  ViewVC Help
Powered by ViewVC