diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2008-02-13 18:11:09 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2008-02-13 18:11:09 +0000 |
commit | 8f0c7908b01f67cf96058387d5f5b6e73268361b (patch) | |
tree | d02ec13ee7bfd354ef46f1cadd4a96070af30c01 | |
parent | 22a5c60af32fee67bd6f55b6d42fdbf1710cdbd1 (diff) | |
download | rockbox-8f0c7908b01f67cf96058387d5f5b6e73268361b.tar.gz rockbox-8f0c7908b01f67cf96058387d5f5b6e73268361b.zip |
Make encoder name conversion functions static to the base class.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16305 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 8 | ||||
-rw-r--r-- | rbutil/rbutilqt/createvoicewindow.cpp | 4 | ||||
-rw-r--r-- | rbutil/rbutilqt/encoders.cpp | 13 | ||||
-rw-r--r-- | rbutil/rbutilqt/encoders.h | 53 | ||||
-rw-r--r-- | rbutil/rbutilqt/installtalkwindow.cpp | 4 | ||||
-rw-r--r-- | rbutil/rbutilqt/talkfile.cpp | 2 | ||||
-rw-r--r-- | rbutil/rbutilqt/voicefile.cpp | 2 |
7 files changed, 42 insertions, 44 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index ec4bd188e5..25fc675ca5 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp | |||
@@ -289,9 +289,9 @@ void Config::setDevices() | |||
289 | 289 | ||
290 | //encoders | 290 | //encoders |
291 | int index; | 291 | int index; |
292 | QStringList encoders = getEncoderList(); | 292 | QStringList encoders = EncBase::getEncoderList(); |
293 | for(int a = 0; a < encoders.size(); a++) | 293 | for(int a = 0; a < encoders.size(); a++) |
294 | ui.comboEncoder->addItem(getEncoderName(encoders.at(a)), encoders.at(a)); | 294 | ui.comboEncoder->addItem(EncBase::getEncoderName(encoders.at(a)), encoders.at(a)); |
295 | //update index of combobox | 295 | //update index of combobox |
296 | index = ui.comboEncoder->findData(settings->curEncoder()); | 296 | index = ui.comboEncoder->findData(settings->curEncoder()); |
297 | if(index < 0) index = 0; | 297 | if(index < 0) index = 0; |
@@ -332,7 +332,7 @@ void Config::updateTtsState(int index) | |||
332 | void Config::updateEncState(int index) | 332 | void Config::updateEncState(int index) |
333 | { | 333 | { |
334 | QString encoder = ui.comboEncoder->itemData(index).toString(); | 334 | QString encoder = ui.comboEncoder->itemData(index).toString(); |
335 | EncBase* enc = getEncoder(encoder); | 335 | EncBase* enc = EncBase::getEncoder(encoder); |
336 | enc->setCfg(settings); | 336 | enc->setCfg(settings); |
337 | 337 | ||
338 | if(enc->configOk()) | 338 | if(enc->configOk()) |
@@ -599,7 +599,7 @@ void Config::configTts() | |||
599 | void Config::configEnc() | 599 | void Config::configEnc() |
600 | { | 600 | { |
601 | int index = ui.comboEncoder->currentIndex(); | 601 | int index = ui.comboEncoder->currentIndex(); |
602 | EncBase* enc = getEncoder(ui.comboEncoder->itemData(index).toString()); | 602 | EncBase* enc = EncBase::getEncoder(ui.comboEncoder->itemData(index).toString()); |
603 | 603 | ||
604 | enc->setCfg(settings); | 604 | enc->setCfg(settings); |
605 | enc->showCfg(); | 605 | enc->showCfg(); |
diff --git a/rbutil/rbutilqt/createvoicewindow.cpp b/rbutil/rbutilqt/createvoicewindow.cpp index 768b1ae117..843041fde7 100644 --- a/rbutil/rbutilqt/createvoicewindow.cpp +++ b/rbutil/rbutilqt/createvoicewindow.cpp | |||
@@ -100,11 +100,11 @@ void CreateVoiceWindow::setSettings(RbSettings* sett) | |||
100 | 100 | ||
101 | QString encoder = settings->curEncoder(); | 101 | QString encoder = settings->curEncoder(); |
102 | // only proceed if encoder setting is set | 102 | // only proceed if encoder setting is set |
103 | EncBase* enc = getEncoder(encoder); | 103 | EncBase* enc = EncBase::getEncoder(encoder); |
104 | if(enc != NULL) { | 104 | if(enc != NULL) { |
105 | enc->setCfg(settings); | 105 | enc->setCfg(settings); |
106 | if(enc->configOk()) | 106 | if(enc->configOk()) |
107 | ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(getEncoderName(encoder))); | 107 | ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(EncBase::getEncoderName(encoder))); |
108 | else | 108 | else |
109 | ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!")); | 109 | ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!")); |
110 | } | 110 | } |
diff --git a/rbutil/rbutilqt/encoders.cpp b/rbutil/rbutilqt/encoders.cpp index 0077263df0..acc7e4ef9c 100644 --- a/rbutil/rbutilqt/encoders.cpp +++ b/rbutil/rbutilqt/encoders.cpp | |||
@@ -26,12 +26,13 @@ | |||
26 | #include "encodersguicli.h" | 26 | #include "encodersguicli.h" |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | static QMap<QString,QString> encoderList; | 29 | |
30 | static QMap<QString,EncBase*> encoderCache; | 30 | QMap<QString,QString> EncBase::encoderList; |
31 | QMap<QString,EncBase*> EncBase::encoderCache; | ||
31 | 32 | ||
32 | 33 | ||
33 | // initialize list of encoders | 34 | // initialize list of encoders |
34 | void initEncodernamesList() | 35 | void EncBase::initEncodernamesList() |
35 | { | 36 | { |
36 | encoderList["rbspeex"] = "Rockbox Speex Encoder"; | 37 | encoderList["rbspeex"] = "Rockbox Speex Encoder"; |
37 | encoderList["lame"] = "Lame Mp3 Encoder"; | 38 | encoderList["lame"] = "Lame Mp3 Encoder"; |
@@ -39,7 +40,7 @@ void initEncodernamesList() | |||
39 | 40 | ||
40 | 41 | ||
41 | // get nice name for a specific encoder | 42 | // get nice name for a specific encoder |
42 | QString getEncoderName(QString encoder) | 43 | QString EncBase::getEncoderName(QString encoder) |
43 | { | 44 | { |
44 | if(encoderList.isEmpty()) | 45 | if(encoderList.isEmpty()) |
45 | initEncodernamesList(); | 46 | initEncodernamesList(); |
@@ -48,7 +49,7 @@ QString getEncoderName(QString encoder) | |||
48 | 49 | ||
49 | 50 | ||
50 | // get a specific encoder object | 51 | // get a specific encoder object |
51 | EncBase* getEncoder(QString encoder) | 52 | EncBase* EncBase::getEncoder(QString encoder) |
52 | { | 53 | { |
53 | // check cache | 54 | // check cache |
54 | if(encoderCache.contains(encoder)) | 55 | if(encoderCache.contains(encoder)) |
@@ -70,7 +71,7 @@ EncBase* getEncoder(QString encoder) | |||
70 | } | 71 | } |
71 | 72 | ||
72 | 73 | ||
73 | QStringList getEncoderList() | 74 | QStringList EncBase::getEncoderList() |
74 | { | 75 | { |
75 | if(encoderList.isEmpty()) | 76 | if(encoderList.isEmpty()) |
76 | initEncodernamesList(); | 77 | initEncodernamesList(); |
diff --git a/rbutil/rbutilqt/encoders.h b/rbutil/rbutilqt/encoders.h index 8e91e6e149..b5460de3ab 100644 --- a/rbutil/rbutilqt/encoders.h +++ b/rbutil/rbutilqt/encoders.h | |||
@@ -29,40 +29,37 @@ extern "C" | |||
29 | #include "rbspeex.h" | 29 | #include "rbspeex.h" |
30 | } | 30 | } |
31 | 31 | ||
32 | class EncBase; | ||
33 | |||
34 | //inits the encoder List | ||
35 | void initEncodernamesList(void); | ||
36 | // function to get a specific encoder | ||
37 | EncBase* getEncoder(QString encname); | ||
38 | // get the list of encoders, nice names | ||
39 | QString getEncoderName(QString encoder); | ||
40 | QStringList getEncoderList(void); | ||
41 | |||
42 | 32 | ||
43 | class EncBase : public QObject | 33 | class EncBase : public QObject |
44 | { | 34 | { |
45 | Q_OBJECT | 35 | Q_OBJECT |
46 | public: | 36 | public: |
47 | EncBase(QObject *parent ); | 37 | EncBase(QObject *parent ); |
48 | 38 | ||
49 | virtual bool encode(QString input,QString output) | 39 | virtual bool encode(QString input,QString output) |
50 | {(void)input; (void)output; return false;} | 40 | {(void)input; (void)output; return false;} |
51 | virtual bool start(){return false;} | 41 | virtual bool start(){return false;} |
52 | virtual bool stop(){return false;} | 42 | virtual bool stop(){return false;} |
53 | virtual void showCfg(){} | 43 | virtual void showCfg(){} |
54 | virtual bool configOk(){return false;} | 44 | virtual bool configOk(){return false;} |
45 | |||
46 | void setCfg(RbSettings *sett){settings = sett;} | ||
47 | static QString getEncoderName(QString); | ||
48 | static EncBase* getEncoder(QString); | ||
49 | static QStringList getEncoderList(void); | ||
50 | |||
51 | public slots: | ||
52 | virtual void accept(void){} | ||
53 | virtual void reject(void){} | ||
54 | virtual void reset(void){} | ||
55 | private: | ||
56 | static void initEncodernamesList(void); | ||
55 | 57 | ||
56 | void setCfg(RbSettings *sett){settings = sett;} | 58 | protected: |
57 | 59 | RbSettings* settings; | |
58 | public slots: | ||
59 | virtual void accept(void){} | ||
60 | virtual void reject(void){} | ||
61 | virtual void reset(void){} | ||
62 | 60 | ||
63 | protected: | 61 | static QMap<QString,QString> encoderList; |
64 | 62 | static QMap<QString,EncBase*> encoderCache; | |
65 | RbSettings* settings; | ||
66 | }; | 63 | }; |
67 | 64 | ||
68 | 65 | ||
diff --git a/rbutil/rbutilqt/installtalkwindow.cpp b/rbutil/rbutilqt/installtalkwindow.cpp index 539374a07e..59ec12fa11 100644 --- a/rbutil/rbutilqt/installtalkwindow.cpp +++ b/rbutil/rbutilqt/installtalkwindow.cpp | |||
@@ -119,11 +119,11 @@ void InstallTalkWindow::setSettings(RbSettings* sett) | |||
119 | ui.labelTtsProfile->setText(tr("Selected TTS Engine: <b>%1</b>").arg("Invalid TTS configuration!")); | 119 | ui.labelTtsProfile->setText(tr("Selected TTS Engine: <b>%1</b>").arg("Invalid TTS configuration!")); |
120 | 120 | ||
121 | QString encoder = settings->curEncoder(); | 121 | QString encoder = settings->curEncoder(); |
122 | EncBase* enc = getEncoder(encoder); | 122 | EncBase* enc = EncBase::getEncoder(encoder); |
123 | if(enc != NULL) { | 123 | if(enc != NULL) { |
124 | enc->setCfg(settings); | 124 | enc->setCfg(settings); |
125 | if(enc->configOk()) | 125 | if(enc->configOk()) |
126 | ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(getEncoderName(encoder))); | 126 | ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg(EncBase::getEncoderName(encoder))); |
127 | else | 127 | else |
128 | ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!")); | 128 | ui.labelEncProfile->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!")); |
129 | } | 129 | } |
diff --git a/rbutil/rbutilqt/talkfile.cpp b/rbutil/rbutilqt/talkfile.cpp index 4390c430b9..7e5b6a2a0c 100644 --- a/rbutil/rbutilqt/talkfile.cpp +++ b/rbutil/rbutilqt/talkfile.cpp | |||
@@ -44,7 +44,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger) | |||
44 | } | 44 | } |
45 | 45 | ||
46 | // Encoder | 46 | // Encoder |
47 | m_enc = getEncoder(settings->curEncoder()); | 47 | m_enc = EncBase::getEncoder(settings->curEncoder()); |
48 | m_enc->setCfg(settings); | 48 | m_enc->setCfg(settings); |
49 | 49 | ||
50 | if(!m_enc->start()) | 50 | if(!m_enc->start()) |
diff --git a/rbutil/rbutilqt/voicefile.cpp b/rbutil/rbutilqt/voicefile.cpp index 208e134274..e2944eb79d 100644 --- a/rbutil/rbutilqt/voicefile.cpp +++ b/rbutil/rbutilqt/voicefile.cpp | |||
@@ -155,7 +155,7 @@ void VoiceFileCreator::downloadDone(bool error) | |||
155 | } | 155 | } |
156 | 156 | ||
157 | // Encoder | 157 | // Encoder |
158 | m_enc = getEncoder(settings->curEncoder()); | 158 | m_enc = EncBase::getEncoder(settings->curEncoder()); |
159 | m_enc->setCfg(settings); | 159 | m_enc->setCfg(settings); |
160 | 160 | ||
161 | if(!m_enc->start()) | 161 | if(!m_enc->start()) |