~ubuntu-branches/ubuntu/jaunty/qterm/jaunty

« back to all changes in this revision

Viewing changes to qterm/soundconf.cpp

  • Committer: Bazaar Package Importer
  • Author(s): LI Daobing
  • Date: 2006-10-06 07:38:46 UTC
  • mfrom: (2.1.8 edgy)
  • Revision ID: james.westby@ubuntu.com-20061006073846-2je2hzmmvdyi6d69
Tags: 1:0.4.0-4
fix FTBFS on hurd-i386, Thanks Cyril Brulebois (closes: #391300)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "soundconf.h"
2
2
#include "qtermconfig.h"
 
3
#include "qtermsound.h"
3
4
#include "qterm.h"
4
5
#include <stdlib.h>
5
6
#include <qvariant.h>
28
29
fSoundConf::fSoundConf( QWidget* parent,  const char* name, bool modal, WFlags fl )
29
30
    : fSoundConfUI( parent, name, modal, fl )
30
31
{
 
32
        m_pSound = NULL;
31
33
        loadSetting();
32
34
}
33
35
 
37
39
fSoundConf::~fSoundConf()
38
40
{
39
41
    // no need to delete child widgets, Qt does it all for us
 
42
    delete m_pSound;
40
43
}
41
44
 
42
45
/*
66
69
 */
67
70
void fSoundConf::onPlayMethod( int id )
68
71
{
69
 
    if(id==3)
 
72
#ifdef _NO_ARTS_COMPILED
 
73
    if (id == 1){
 
74
        QMessageBox::critical(this, tr("No such output driver"),
 
75
            tr("ARTS is not supported by this instance of QTerm,\nCheck whether your ARTS support is enabled in compile time."),
 
76
            tr("&OK"));
 
77
        QRadioButton * tmp = static_cast<QRadioButton *>(bgMethod->find(3));
 
78
        tmp->setChecked(true);
 
79
    }
 
80
#endif
 
81
#ifdef _NO_ESD_COMPILED
 
82
    if (id == 2){
 
83
        QMessageBox::critical(this, tr("No such output driver"),
 
84
            tr("ESD is not supported by this instance of QTerm,\nCheck whether your ESD support is enabled in compile time"),
 
85
            tr("&OK"));
 
86
        QRadioButton * tmp = static_cast<QRadioButton *>(bgMethod->find(3));
 
87
        tmp->setChecked(true);
 
88
    }
 
89
#endif
 
90
    if(id == 3 || bgMethod->selectedId() == 3)
70
91
    {
71
92
        leProg->setEnabled(true);
72
93
        bpSelect->setEnabled(true);
77
98
        bpSelect->setEnabled(false);
78
99
    }
79
100
}
80
 
 
 
101
void fSoundConf::onTestPlay()
 
102
{
 
103
    if (leFile->text().isEmpty())
 
104
        QMessageBox::critical(this, tr("No sound file"),
 
105
        tr("You have to select a file to test the sound"),
 
106
        tr("&Ok"));
 
107
    switch (bgMethod->selectedId()) {
 
108
    case 0:
 
109
         m_pSound = new QTermInternalSound(leFile->text());
 
110
        break;
 
111
    case 1:
 
112
#ifndef _NO_ARTS_COMPILED
 
113
        m_pSound = new QTermArtsSound(leFile->text());
 
114
#endif
 
115
        break;
 
116
    case 2:
 
117
#ifndef _NO_ESD_COMPILED
 
118
        m_pSound = new QTermEsdSound(leFile->text());
 
119
#endif
 
120
        break;
 
121
    case 3:
 
122
        if (leProg->text().isEmpty())
 
123
            QMessageBox::critical(this, tr("No player"),
 
124
                tr("You have to specify an external player"),
 
125
                tr("&Ok"));
 
126
            else
 
127
                m_pSound = new QTermExternalSound(leProg->text(), leFile->text());
 
128
            break;
 
129
    default:
 
130
        m_pSound = NULL;
 
131
    }
 
132
    if (m_pSound)
 
133
        m_pSound->play();
 
134
    delete m_pSound;
 
135
    m_pSound = NULL;
 
136
}
 
137
            
81
138
void fSoundConf::loadSetting()
82
139
{
83
140
        QTermConfig conf(fileCfg);
84
141
 
85
142
        QString strTmp;
86
143
 
87
 
        //fprintf(stderr, "we got here\n");
88
 
 
89
144
        strTmp = conf.getItemValue("preference", "wavefile");
90
145
        if (!strTmp.isEmpty())
91
146
                leFile->setText( strTmp );
121
176
        conf.setItemValue("preference", "wavefile", leFile->text());
122
177
 
123
178
        strTmp.setNum(bgMethod->id(bgMethod->selected()));
124
 
#ifdef _NO_ARTS_COMPILED
125
 
        if (strTmp == "1"){
126
 
                QMessageBox::critical(this, tr("No such output driver"),
127
 
                        tr("ARTS is not supported by this instance of QTerm,\nCheck whether your ARTS support is enabled in compile time."),
128
 
                        tr("&OK"));
129
 
                return;
130
 
        }
131
 
#endif
132
 
#ifdef _NO_ESD_COMPILED
133
 
        if (strTmp == "2"){
134
 
                QMessageBox::critical(this, tr("No such output driver"),
135
 
                        tr("ESD is not supported by this instance of QTerm,\nCheck whether your ESD support is enabled in compile time"),
136
 
                        tr("&OK"));
137
 
                return;
138
 
        }
139
 
#endif
140
179
        conf.setItemValue("preference", "playmethod", strTmp);
141
180
 
142
181
        if (strTmp == "3")
150
189
        saveSetting();
151
190
        fSoundConfUI::accept();
152
191
}
 
192
#include <soundconf.moc>