root/trunk/src/gui/src/PreferencesDialog.cpp @ 2471

Revision 2471, 20.3 KB (checked in by wolke, 15 months ago)

improve driver combobox

Line 
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 *
5 * http://www.hydrogen-music.org
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (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
24#include "Skin.h"
25#include "PreferencesDialog.h"
26#include "HydrogenApp.h"
27#include "MainForm.h"
28
29#include "qmessagebox.h"
30#include "qstylefactory.h"
31
32#include <QPixmap>
33#include <QFontDialog>
34#include "widgets/midiTable.h"
35
36#include <hydrogen/midi_map.h>
37#include <hydrogen/hydrogen.h>
38#include <hydrogen/Preferences.h>
39#include <hydrogen/IO/MidiInput.h>
40#include <hydrogen/LashClient.h>
41#include <hydrogen/audio_engine.h>
42#include <hydrogen/sampler/Sampler.h>
43
44using namespace H2Core;
45
46const char* PreferencesDialog::__class_name = "PreferencesDialog";
47
48PreferencesDialog::PreferencesDialog(QWidget* parent)
49 : QDialog( parent )
50 , Object( __class_name )
51{
52        setupUi( this );
53
54        setWindowTitle( trUtf8( "Preferences" ) );
55        setWindowIcon( QPixmap( Skin::getImagePath()  + "/icon16.png" ) );
56
57        setMinimumSize( width(), height() );
58        setMaximumSize( width(), height() );
59
60        Preferences *pPref = Preferences::get_instance();
61        pPref->loadPreferences( false );        // reload user's preferences
62
63        driverComboBox->clear();
64        driverComboBox->addItem( "Auto" );
65#ifdef H2CORE_HAVE_JACK
66        driverComboBox->addItem( "JACK" );
67#endif
68#ifdef H2CORE_HAVE_ALSA
69        driverComboBox->addItem( "ALSA" );
70#endif
71#ifdef H2CORE_HAVE_OSS
72        driverComboBox->addItem( "OSS" );
73#endif
74#ifdef H2CORE_HAVE_PORTAUDIO
75        driverComboBox->addItem( "PortAudio" );
76#endif
77#ifdef H2CORE_HAVE_COREAUDIO
78        driverComboBox->addItem( "CoreAudio" );
79#endif
80
81
82        if( driverComboBox->findText(pPref->m_sAudioDriver) > -1){
83              driverComboBox->setCurrentIndex(driverComboBox->findText(pPref->m_sAudioDriver));
84        }
85        else
86        {
87               driverInfoLbl->setText("Select your Audio Driver");
88               ERRORLOG( "Unknown midi input from preferences [" + pPref->m_sAudioDriver + "]" );
89        }
90
91
92        m_pMidiDriverComboBox->clear();
93#ifdef H2CORE_HAVE_ALSA
94        m_pMidiDriverComboBox->addItem( "ALSA" );
95#endif
96#ifdef H2CORE_HAVE_PORTMIDI
97        m_pMidiDriverComboBox->addItem( "PortMidi" );
98#endif
99#ifdef H2CORE_HAVE_COREMIDI
100        m_pMidiDriverComboBox->addItem( "CoreMidi" );
101#endif
102#ifdef H2CORE_HAVE_JACK
103        m_pMidiDriverComboBox->addItem( "JackMidi" );
104#endif
105
106
107        if( m_pMidiDriverComboBox->findText(pPref->m_sMidiDriver) > -1){
108              m_pMidiDriverComboBox->setCurrentIndex(m_pMidiDriverComboBox->findText(pPref->m_sMidiDriver));
109        }
110        else
111        {
112               driverInfoLbl->setText("Select your Midi Driver");
113               ERRORLOG( "Unknown midi input from preferences [" + pPref->m_sMidiDriver + "]" );
114        }
115
116        m_pIgnoreNoteOffCheckBox->setChecked( pPref->m_bMidiNoteOffIgnore );
117
118        updateDriverInfo();
119
120
121        // metronome volume
122        uint metronomeVol = (uint)( pPref->m_fMetronomeVolume * 100.0 );
123        metronomeVolumeSpinBox->setValue(metronomeVol);
124
125        // max voices
126        maxVoicesTxt->setValue( pPref->m_nMaxNotes );
127
128        // JACK
129        trackOutsCheckBox->setChecked( pPref->m_bJackTrackOuts );
130        connect(trackOutsCheckBox, SIGNAL(toggled(bool)), this, SLOT(toggleTrackOutsCheckBox( bool )));
131
132        connectDefaultsCheckBox->setChecked( pPref->m_bJackConnectDefaults );
133        trackOutputComboBox->setCurrentIndex( pPref->m_nJackTrackOutputMode );
134        //~ JACK
135
136
137        bufferSizeSpinBox->setValue( pPref->m_nBufferSize );
138        switch ( pPref->m_nSampleRate ) {
139                case 44100:
140                        sampleRateComboBox->setCurrentIndex( 0 );
141                        break;
142                case 48000:
143                        sampleRateComboBox->setCurrentIndex( 1 );
144                        break;
145                case 88200:
146                        sampleRateComboBox->setCurrentIndex( 2 );
147                        break;
148                case 96000:
149                        sampleRateComboBox->setCurrentIndex( 3 );
150                        break;
151                default:
152                        ERRORLOG( QString("Wrong samplerate: %1").arg( pPref->m_nSampleRate ) );
153        }
154
155        resampleComboBox->setCurrentIndex( (int) AudioEngine::get_instance()->get_sampler()->getInterpolateMode() );
156
157        // Appearance tab
158        QString applicationFamily = pPref->getApplicationFontFamily();
159        int applicationPointSize = pPref->getApplicationFontPointSize();
160
161        QFont applicationFont( applicationFamily, applicationPointSize );
162        applicationFontLbl->setFont( applicationFont );
163        applicationFontLbl->setText( applicationFamily + QString("  %1").arg( applicationPointSize ) );
164
165        QString mixerFamily = pPref->getMixerFontFamily();
166        int mixerPointSize = pPref->getMixerFontPointSize();
167        QFont mixerFont( mixerFamily, mixerPointSize );
168        mixerFontLbl->setFont( mixerFont );
169        mixerFontLbl->setText( mixerFamily + QString("  %1").arg( mixerPointSize ) );
170
171
172        float falloffSpeed = pPref->getMixerFalloffSpeed();
173        if (falloffSpeed == FALLOFF_SLOW) {
174                mixerFalloffComboBox->setCurrentIndex(0);
175        }
176        else if (falloffSpeed == FALLOFF_NORMAL) {
177                mixerFalloffComboBox->setCurrentIndex(1);
178        }
179        else if (falloffSpeed == FALLOFF_FAST) {
180                mixerFalloffComboBox->setCurrentIndex(2);
181        }
182        else {
183                ERRORLOG( QString("PreferencesDialog: wrong mixerFalloff value = %1").arg(falloffSpeed) );
184        }
185
186        uiLayoutComboBox->setCurrentIndex(  pPref->getDefaultUILayout() );
187
188        // Style
189        QStringList list = QStyleFactory::keys();
190        uint i = 0;
191        for ( QStringList::Iterator it = list.begin(); it != list.end(); it++) {
192                styleComboBox->addItem( *it );
193                //INFOLOG( "QT Stile: " + *it   );
194                //string sStyle = (*it).latin1();
195                QString sStyle = (*it);
196                if (sStyle == pPref->getQTStyle() ) {
197                        styleComboBox->setCurrentIndex( i );
198                }
199                i++;
200        }
201
202
203        // midi tab
204        midiPortChannelComboBox->setEnabled( false );
205        midiPortComboBox->setEnabled( false );
206        // list midi output ports
207        midiPortComboBox->clear();
208        midiPortComboBox->addItem( "None" );
209        if ( Hydrogen::get_instance()->getMidiInput() ) {
210                std::vector<QString> midiOutList = Hydrogen::get_instance()->getMidiInput()->getOutputPortList();
211
212                if ( midiOutList.size() != 0 ) {
213                        midiPortComboBox->setEnabled( true );
214                        midiPortChannelComboBox->setEnabled( true );
215                }
216                for (uint i = 0; i < midiOutList.size(); i++) {
217                        QString sPortName = midiOutList[i];
218                        midiPortComboBox->addItem( sPortName );
219
220                        if ( sPortName == pPref->m_sMidiPortName ) {
221                                midiPortComboBox->setCurrentIndex( i + 1 );
222                        }
223                }
224        }
225
226        if ( pPref->m_nMidiChannelFilter == -1 ) {
227                midiPortChannelComboBox->setCurrentIndex( 0 );
228        }
229        else {
230                midiPortChannelComboBox->setCurrentIndex( pPref->m_nMidiChannelFilter + 1 );
231        }
232       
233
234        // General tab
235        restoreLastUsedSongCheckbox->setChecked( pPref->isRestoreLastSongEnabled() );
236        restoreLastUsedPlaylistCheckbox->setChecked( pPref->isRestoreLastPlaylistEnabled() );
237
238        //restore the right m_bsetlash value
239        if ( pPref->m_brestartLash == true ){
240                if (pPref->m_bsetLash == false ){
241                        pPref->m_bsetLash = true ;
242                        pPref->m_brestartLash = false;
243                }
244
245        }
246        useLashCheckbox->setChecked( pPref->m_bsetLash );       
247
248        sBcountOffset->setValue( pPref->m_countOffset );
249        sBstartOffset->setValue( pPref->m_startOffset );
250
251        sBmaxBars->setValue( pPref->getMaxBars() );
252
253        QString pathtoRubberband = pPref->m_rubberBandCLIexecutable;
254
255
256        rubberbandLineEdit->setText( pathtoRubberband );
257
258#ifdef H2CORE_HAVE_RUBBERBAND
259        pathToRubberbandExLable->hide();
260        rubberbandLineEdit->hide();
261#endif
262
263#ifdef H2CORE_HAVE_JACKSESSION
264        useJackSessinStoreFiles->setVisible(true);
265        useJackSessinStoreFiles->setChecked(pPref->getJackSessionUseSessionDir());
266#else
267        useJackSessinStoreFiles->setVisible(false);
268#endif
269
270        m_bNeedDriverRestart = false;
271        connect(m_pMidiDriverComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT( onMidiDriverComboBoxIndexChanged(int) ));
272}
273
274
275
276
277PreferencesDialog::~PreferencesDialog()
278{       
279        INFOLOG("~PREFERENCES_DIALOG");
280}
281
282
283
284void PreferencesDialog::on_cancelBtn_clicked()
285{
286        Preferences *preferencesMng = Preferences::get_instance();
287        preferencesMng->loadPreferences( false );       // reload old user's preferences
288
289        //restore the right m_bsetlash value
290        if ( preferencesMng->m_brestartLash == true ){
291                if (preferencesMng->m_bsetLash == false ){
292                        preferencesMng->m_bsetLash = true ;
293                        preferencesMng->m_brestartLash = false;
294                }
295
296        }
297
298        reject();
299}
300
301
302void PreferencesDialog::on_okBtn_clicked()
303{
304//      m_bNeedDriverRestart = true;
305
306        Preferences *pPref = Preferences::get_instance();
307
308        MidiMap *mM = MidiMap::get_instance();
309        mM->reset_instance();
310
311        midiTable->saveMidiTable();
312
313        // Selected audio driver
314        if (driverComboBox->currentText() == "Auto" ) {
315                pPref->m_sAudioDriver = "Auto";
316        }
317        else if (driverComboBox->currentText() == "JACK" ) {
318                pPref->m_sAudioDriver = "Jack";
319        }
320        else if (driverComboBox->currentText() == "ALSA" ) {
321                pPref->m_sAudioDriver = "Alsa";
322                pPref->m_sAlsaAudioDevice = m_pAudioDeviceTxt->text();
323        }
324        else if (driverComboBox->currentText() == "OSS" ) {
325                pPref->m_sAudioDriver = "Oss";
326                pPref->m_sOSSDevice = m_pAudioDeviceTxt->text();
327        }
328        else if (driverComboBox->currentText() == "PortAudio" ) {
329                pPref->m_sAudioDriver = "PortAudio";
330        }
331        else if (driverComboBox->currentText() == "CoreAudio" ) {
332                pPref->m_sAudioDriver = "CoreAudio";
333        }
334        else {
335                ERRORLOG( "[okBtnClicked] Invalid audio driver" );
336        }
337
338        // JACK
339        pPref->m_bJackConnectDefaults = connectDefaultsCheckBox->isChecked();
340
341       
342        if (trackOutputComboBox->currentText() == "Post-Fader")
343        {
344                pPref->m_nJackTrackOutputMode = Preferences::POST_FADER;
345        } else {
346                pPref->m_nJackTrackOutputMode = Preferences::PRE_FADER;
347        }
348        //~ JACK
349
350        pPref->m_nBufferSize = bufferSizeSpinBox->value();
351        if ( sampleRateComboBox->currentText() == "44100" ) {
352                pPref->m_nSampleRate = 44100;
353        }
354        else if ( sampleRateComboBox->currentText() == "48000" ) {
355                pPref->m_nSampleRate = 48000;
356        }
357        else if ( sampleRateComboBox->currentText() == "88200" ) {
358                pPref->m_nSampleRate = 88200;
359        }
360        else if ( sampleRateComboBox->currentText() == "96000" ) {
361                pPref->m_nSampleRate = 96000;
362        }
363
364
365        // metronome
366        pPref->m_fMetronomeVolume = (metronomeVolumeSpinBox->value()) / 100.0;
367
368        // maxVoices
369        pPref->m_nMaxNotes = maxVoicesTxt->value();
370
371        if ( m_pMidiDriverComboBox->currentText() == "ALSA" ) {
372                pPref->m_sMidiDriver = "ALSA";
373        }
374        else if ( m_pMidiDriverComboBox->currentText() == "PortMidi" ) {
375                pPref->m_sMidiDriver = "PortMidi";
376        }
377        else if ( m_pMidiDriverComboBox->currentText() == "CoreMidi" ) {
378                pPref->m_sMidiDriver = "CoreMidi";
379        }
380        else if ( m_pMidiDriverComboBox->currentText() == "JackMidi" ) {
381                pPref->m_sMidiDriver = "JackMidi";
382        }
383
384
385
386        pPref->m_bMidiNoteOffIgnore = m_pIgnoreNoteOffCheckBox->isChecked();
387
388        // Mixer falloff
389        QString falloffStr = mixerFalloffComboBox->currentText();
390        if ( falloffStr== trUtf8("Slow") ) {
391                pPref->setMixerFalloffSpeed(FALLOFF_SLOW);
392        }
393        else if ( falloffStr == trUtf8("Normal") ) {
394                pPref->setMixerFalloffSpeed(FALLOFF_NORMAL);
395        }
396        else if ( falloffStr == trUtf8("Fast") ) {
397                pPref->setMixerFalloffSpeed(FALLOFF_FAST);
398        }
399        else {
400                ERRORLOG( "[okBtnClicked] Unknown mixerFallOffSpeed: " + falloffStr );
401        }
402
403        QString sNewMidiPortName = midiPortComboBox->currentText();
404
405        if ( pPref->m_sMidiPortName != sNewMidiPortName ) {
406                pPref->m_sMidiPortName = sNewMidiPortName;
407                m_bNeedDriverRestart = true;
408        }
409
410        if ( pPref->m_nMidiChannelFilter != midiPortChannelComboBox->currentIndex() - 1 ) {
411                //m_bNeedDriverRestart = true;
412        }
413        pPref->m_nMidiChannelFilter = midiPortChannelComboBox->currentIndex() - 1;
414
415
416        // General tab
417        pPref->setRestoreLastSongEnabled( restoreLastUsedSongCheckbox->isChecked() );
418        pPref->setRestoreLastPlaylistEnabled( restoreLastUsedPlaylistCheckbox->isChecked() );
419        pPref->m_bsetLash = useLashCheckbox->isChecked(); //restore m_bsetLash after saving pref.
420
421        //path to rubberband
422        pPref-> m_rubberBandCLIexecutable = rubberbandLineEdit->text();
423
424#ifdef H2CORE_HAVE_JACKSESSION
425        pPref->setJackSessionUseSessionDir(useJackSessinStoreFiles->isChecked());
426#endif
427
428        //check preferences
429        if ( pPref->m_brestartLash == true ){
430                pPref->m_bsetLash = true ;
431        }
432
433        pPref->m_countOffset = sBcountOffset->value();
434        pPref->m_startOffset = sBstartOffset->value();
435
436        pPref->setMaxBars( sBmaxBars->value() );
437
438        Hydrogen::get_instance()->setBcOffsetAdjust();
439
440        pPref->setDefaultUILayout( uiLayoutComboBox->currentIndex() );
441
442
443        pPref->savePreferences();
444
445       
446        if (m_bNeedDriverRestart) {
447                int res = QMessageBox::information( this, "Hydrogen", tr( "Driver restart required.\n Restart driver?"), tr("&Ok"), tr("&Cancel"), 0, 1 );
448                if ( res == 0 ) {
449                        Hydrogen::get_instance()->restartDrivers();     
450                }
451        }
452        accept();
453}
454
455
456
457void PreferencesDialog::on_driverComboBox_activated( int index )
458{
459        UNUSED( index );
460        QString selectedDriver = driverComboBox->currentText();
461        updateDriverInfo();
462        m_bNeedDriverRestart = true;
463}
464
465
466void PreferencesDialog::updateDriverInfo()
467{
468        Preferences *pPref = Preferences::get_instance();
469        QString info;
470
471        bool bJack_support = false;
472        #ifdef H2CORE_HAVE_JACK
473        bJack_support = true;
474        #endif
475
476        bool bAlsa_support = false;
477        #ifdef H2CORE_HAVE_ALSA
478        bAlsa_support = true;
479        #endif
480
481        bool bOss_support = false;
482        #ifdef H2CORE_HAVE_OSS
483        bOss_support = true;
484        #endif
485
486        bool bPortAudio_support = false;
487        #ifdef H2CORE_HAVE_PORTAUDIO
488        bPortAudio_support = true;
489        #endif
490
491        bool bCoreAudio_support = false;
492        #ifdef H2CORE_HAVE_COREAUDIO
493        bCoreAudio_support = true;
494        #endif
495
496
497        if ( driverComboBox->currentText() == "Auto" ) {
498                info += trUtf8("<b>Automatic driver selection</b>");
499
500                m_pAudioDeviceTxt->setEnabled(false);
501                m_pAudioDeviceTxt->setText( "" );
502                bufferSizeSpinBox->setEnabled( false );
503                sampleRateComboBox->setEnabled( false );
504                trackOutputComboBox->setEnabled( false );
505                connectDefaultsCheckBox->setEnabled( false );
506        }
507        else if ( driverComboBox->currentText() == "OSS" ) {    // OSS
508                info += trUtf8("<b>Open Sound System</b><br>Simple audio driver [/dev/dsp]");
509                if ( !bOss_support ) {
510                        info += trUtf8("<br><b><font color=\"red\">Not compiled</font></b>");
511                }
512                m_pAudioDeviceTxt->setEnabled(true);
513                m_pAudioDeviceTxt->setText( pPref->m_sOSSDevice );
514                bufferSizeSpinBox->setEnabled(true);
515                sampleRateComboBox->setEnabled(true);
516                trackOutputComboBox->setEnabled( false );
517                trackOutsCheckBox->setEnabled( false );
518                connectDefaultsCheckBox->setEnabled(false);
519        }
520        else if ( driverComboBox->currentText() == "JACK" ) {   // JACK
521                info += trUtf8("<b>Jack Audio Connection Kit Driver</b><br>Low latency audio driver");
522                if ( !bJack_support ) {
523                        info += trUtf8("<br><b><font color=\"red\">Not compiled</font></b>");
524                }
525                m_pAudioDeviceTxt->setEnabled(false);
526                m_pAudioDeviceTxt->setText( "" );
527                bufferSizeSpinBox->setEnabled(false);
528                sampleRateComboBox->setEnabled(false);
529                trackOutputComboBox->setEnabled( true );
530                connectDefaultsCheckBox->setEnabled(true);
531                trackOutsCheckBox->setEnabled( true );
532        }
533        else if ( driverComboBox->currentText() == "ALSA" ) {   // ALSA
534                info += trUtf8("<b>ALSA Driver</b><br>");
535                if ( !bAlsa_support ) {
536                        info += trUtf8("<br><b><font color=\"red\">Not compiled</font></b>");
537                }
538                m_pAudioDeviceTxt->setEnabled(true);
539                m_pAudioDeviceTxt->setText( pPref->m_sAlsaAudioDevice );
540                bufferSizeSpinBox->setEnabled(true);
541                sampleRateComboBox->setEnabled(true);
542                trackOutputComboBox->setEnabled( false );
543                trackOutsCheckBox->setEnabled( false );
544                connectDefaultsCheckBox->setEnabled(false);
545        }
546        else if ( driverComboBox->currentText() == "PortAudio" ) {
547                info += trUtf8( "<b>PortAudio Driver</b><br>" );
548                if ( !bPortAudio_support ) {
549                        info += trUtf8("<br><b><font color=\"red\">Not compiled</font></b>");
550                }
551                m_pAudioDeviceTxt->setEnabled(false);
552                m_pAudioDeviceTxt->setText( "" );
553                bufferSizeSpinBox->setEnabled(true);
554                sampleRateComboBox->setEnabled(true);
555                trackOutsCheckBox->setEnabled( false );
556                connectDefaultsCheckBox->setEnabled(false);
557        }
558        else if ( driverComboBox->currentText() == "CoreAudio" ) {
559                info += trUtf8( "<b>CoreAudio Driver</b><br>" );
560                if ( !bCoreAudio_support ) {
561                        info += trUtf8("<br><b><font color=\"red\">Not compiled</font></b>");
562                }
563                m_pAudioDeviceTxt->setEnabled(false);
564                m_pAudioDeviceTxt->setText( "" );
565                bufferSizeSpinBox->setEnabled(true);
566                sampleRateComboBox->setEnabled(true);
567                trackOutputComboBox->setEnabled( false );
568                trackOutsCheckBox->setEnabled( false );
569                connectDefaultsCheckBox->setEnabled(false);
570        }
571        else {
572                QString selectedDriver = driverComboBox->currentText();
573                ERRORLOG( "Unknown driver = " + selectedDriver );
574        }
575
576        metronomeVolumeSpinBox->setEnabled(true);
577        bufferSizeSpinBox->setValue( pPref->m_nBufferSize );
578
579        driverInfoLbl->setText(info);
580}
581
582
583
584void PreferencesDialog::on_selectApplicationFontBtn_clicked()
585{
586        Preferences *preferencesMng = Preferences::get_instance();
587
588        QString family = preferencesMng->getApplicationFontFamily();
589        int pointSize = preferencesMng->getApplicationFontPointSize();
590
591        bool ok;
592        QFont font = QFontDialog::getFont( &ok, QFont( family, pointSize ), this );
593        if ( ok ) {
594                // font is set to the font the user selected
595                family = font.family();
596                pointSize = font.pointSize();
597                QString familyStr = family;
598                preferencesMng->setApplicationFontFamily(familyStr);
599                preferencesMng->setApplicationFontPointSize(pointSize);
600        } else {
601                // the user cancelled the dialog; font is set to the initial
602                // value, in this case Times, 12.
603        }
604
605        QFont newFont(family, pointSize);
606        applicationFontLbl->setFont(newFont);
607        applicationFontLbl->setText(family + QString("  %1").arg(pointSize));
608}
609
610
611
612
613void PreferencesDialog::on_bufferSizeSpinBox_valueChanged( int i )
614{
615        UNUSED( i );
616        m_bNeedDriverRestart = false;
617}
618
619
620
621
622void PreferencesDialog::on_sampleRateComboBox_editTextChanged( const QString&  )
623{
624        m_bNeedDriverRestart = true;
625}
626
627
628
629void PreferencesDialog::on_restartDriverBtn_clicked()
630{
631        Hydrogen::get_instance()->restartDrivers();
632        m_bNeedDriverRestart = false;
633}
634
635
636
637void PreferencesDialog::on_selectMixerFontBtn_clicked()
638{
639        Preferences *preferencesMng = Preferences::get_instance();
640
641        QString family = preferencesMng->getMixerFontFamily();
642        int pointSize = preferencesMng->getMixerFontPointSize();
643
644        bool ok;
645        QFont font = QFontDialog::getFont( &ok, QFont( family, pointSize ), this );
646        if ( ok ) {
647                // font is set to the font the user selected
648                family = font.family();
649                pointSize = font.pointSize();
650                QString familyStr = family;
651                preferencesMng->setMixerFontFamily(familyStr);
652                preferencesMng->setMixerFontPointSize(pointSize);
653        }
654        QFont newFont(family, pointSize);
655        mixerFontLbl->setFont(newFont);
656        mixerFontLbl->setText(family + QString("  %1").arg(pointSize));
657}
658
659
660
661void PreferencesDialog::on_midiPortComboBox_activated( int index )
662{
663        UNUSED( index );
664        m_bNeedDriverRestart = true;
665}
666
667
668
669void PreferencesDialog::on_styleComboBox_activated( int index )
670{
671        UNUSED( index );
672        QApplication *pQApp = (HydrogenApp::get_instance())->getMainForm()->m_pQApp;
673        QString sStyle = styleComboBox->currentText();
674        pQApp->setStyle( sStyle );
675
676        Preferences *pPref = Preferences::get_instance();
677        pPref->setQTStyle( sStyle );
678}
679
680
681
682void PreferencesDialog::on_useLashCheckbox_clicked()
683{
684        if ( useLashCheckbox->isChecked() ){
685                Preferences::get_instance()->m_brestartLash = true;
686        }
687        else
688        {
689                 Preferences::get_instance()->m_bsetLash = false ;
690        }
691        QMessageBox::information ( this, "Hydrogen", trUtf8 ( "Please restart hydrogen to enable/disable LASH support" ) );
692}
693
694
695void PreferencesDialog::on_resampleComboBox_currentIndexChanged ( int index )
696{
697        switch ( index ){
698        case 0:
699               AudioEngine::get_instance()->get_sampler()->setInterpolateMode( Sampler::LINEAR );
700               break;
701        case 1:
702               AudioEngine::get_instance()->get_sampler()->setInterpolateMode( Sampler::COSINE );
703               break;
704        case 2:
705               AudioEngine::get_instance()->get_sampler()->setInterpolateMode( Sampler::THIRD );
706               break;
707        case 3:
708               AudioEngine::get_instance()->get_sampler()->setInterpolateMode( Sampler::CUBIC );
709               break;
710        case 4:
711               AudioEngine::get_instance()->get_sampler()->setInterpolateMode( Sampler::HERMITE );
712               break;
713        }
714
715}
716
717void PreferencesDialog::onMidiDriverComboBoxIndexChanged ( int index )
718{
719    m_bNeedDriverRestart = true;
720}
721
722void PreferencesDialog::toggleTrackOutsCheckBox(bool toggled)
723{
724        Preferences::get_instance()->m_bJackTrackOuts = toggled;
725        m_bNeedDriverRestart = true;
726}
Note: See TracBrowser for help on using the browser.