1
0
Fork 0
forked from len0rd/rockbox

Set svn:eol-style on several files missing it and dos2unix them.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21238 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Riebeling 2009-06-09 21:49:34 +00:00
parent 86041b1d33
commit 11cd9e4464
4 changed files with 638 additions and 638 deletions

View file

@ -1,70 +1,70 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* *
* Copyright (C) 2007 by Dominik Wenger * Copyright (C) 2007 by Dominik Wenger
* $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $ * $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include "encttssettings.h" #include "encttssettings.h"
EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current, EButton btn) : QObject(parent) EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current, EButton btn) : QObject(parent)
{ {
m_btn = btn; m_btn = btn;
m_name =name; m_name =name;
m_type =type; m_type =type;
m_currentValue = current; m_currentValue = current;
} }
EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QStringList list,EButton btn) : QObject(parent) EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QStringList list,EButton btn) : QObject(parent)
{ {
m_btn = btn; m_btn = btn;
m_name =name; m_name =name;
m_type =type; m_type =type;
m_currentValue = current; m_currentValue = current;
m_list = list; m_list = list;
} }
EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QVariant min,QVariant max, EButton btn) : QObject(parent) EncTtsSetting::EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QVariant min,QVariant max, EButton btn) : QObject(parent)
{ {
m_btn = btn; m_btn = btn;
m_name =name; m_name =name;
m_type =type; m_type =type;
m_currentValue = current; m_currentValue = current;
m_minValue = min; m_minValue = min;
m_maxValue = max; m_maxValue = max;
} }
void EncTtsSetting::setCurrent(QVariant current,bool noticeGui) void EncTtsSetting::setCurrent(QVariant current,bool noticeGui)
{ {
m_currentValue = current; m_currentValue = current;
emit dataChanged(); emit dataChanged();
if(noticeGui) emit updateGui(); if(noticeGui) emit updateGui();
} }
//! insert a setting //! insert a setting
void EncTtsSettingInterface::insertSetting(int id,EncTtsSetting* setting) void EncTtsSettingInterface::insertSetting(int id,EncTtsSetting* setting)
{ {
settingsList.insert(id,setting); settingsList.insert(id,setting);
} }
//! retrieve a specific setting //! retrieve a specific setting
EncTtsSetting* EncTtsSettingInterface::getSetting(int id) EncTtsSetting* EncTtsSettingInterface::getSetting(int id)
{ {
return settingsList.at(id); return settingsList.at(id);
} }

View file

@ -1,129 +1,129 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* *
* Copyright (C) 2007 by Dominik Wenger * Copyright (C) 2007 by Dominik Wenger
* $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $ * $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#ifndef ENCTTSSETTINGS_H #ifndef ENCTTSSETTINGS_H
#define ENCTTSSETTINGS_H #define ENCTTSSETTINGS_H
#include <QtCore> #include <QtCore>
//! \brief This class stores everything needed to display a Setting. //! \brief This class stores everything needed to display a Setting.
//! //!
class EncTtsSetting : public QObject class EncTtsSetting : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
enum ESettingType enum ESettingType
{ {
eBASE, eBASE,
eBOOL, eBOOL,
eDOUBLE, eDOUBLE,
eINT, eINT,
eSTRING, eSTRING,
eREADONLYSTRING, eREADONLYSTRING,
eSTRINGLIST, eSTRINGLIST,
}; };
enum EButton enum EButton
{ {
eNOBTN, eNOBTN,
eBROWSEBTN, eBROWSEBTN,
eREFRESHBTN eREFRESHBTN
}; };
//! constructor for a String or Bool setting //! constructor for a String or Bool setting
EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,EButton btn = eNOBTN); EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,EButton btn = eNOBTN);
//! contructor for a Stringlist setting, ie a enumeration //! contructor for a Stringlist setting, ie a enumeration
EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QStringList list,EButton btn = eNOBTN); EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QStringList list,EButton btn = eNOBTN);
//! constructor for a setting with a min-max range //! constructor for a setting with a min-max range
EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QVariant min,QVariant max,EButton = eNOBTN); EncTtsSetting(QObject* parent,ESettingType type,QString name,QVariant current,QVariant min,QVariant max,EButton = eNOBTN);
//! get currentValue //! get currentValue
QVariant current() {return m_currentValue;} QVariant current() {return m_currentValue;}
//! set currentValue //! set currentValue
void setCurrent(QVariant current,bool noticeGui=true); void setCurrent(QVariant current,bool noticeGui=true);
//! get name of the Setting //! get name of the Setting
QString name() {return m_name;} QString name() {return m_name;}
//! get the type of the setting //! get the type of the setting
ESettingType type() {return m_type;} ESettingType type() {return m_type;}
//! get what type of button this setting needs //! get what type of button this setting needs
EButton button() {return m_btn;} EButton button() {return m_btn;}
//! get the minValue (only valid for a range setting, ie eDOUBLE or eINT) //! get the minValue (only valid for a range setting, ie eDOUBLE or eINT)
QVariant min() {return m_minValue; } QVariant min() {return m_minValue; }
//! get the maxValue (only valid for a range setting, ie eDOUBLE or eINT) //! get the maxValue (only valid for a range setting, ie eDOUBLE or eINT)
QVariant max() {return m_maxValue; } QVariant max() {return m_maxValue; }
//! get the enumerationlist (only valid for eSTRINGLIST settings) //! get the enumerationlist (only valid for eSTRINGLIST settings)
QStringList list() {return m_list;} QStringList list() {return m_list;}
//! set the enumeration list //! set the enumeration list
void setList(QStringList list){m_list = list;} void setList(QStringList list){m_list = list;}
signals: signals:
//! connect to this signal if you want to get noticed when the data changes //! connect to this signal if you want to get noticed when the data changes
void dataChanged(); void dataChanged();
//! connect to this if you want to react on refresh button //! connect to this if you want to react on refresh button
void refresh(); void refresh();
//! will be emited when the gui should update this setting //! will be emited when the gui should update this setting
void updateGui(); void updateGui();
private: private:
ESettingType m_type; ESettingType m_type;
EButton m_btn; EButton m_btn;
QString m_name; QString m_name;
QVariant m_currentValue; QVariant m_currentValue;
QVariant m_minValue; QVariant m_minValue;
QVariant m_maxValue; QVariant m_maxValue;
QStringList m_list; QStringList m_list;
}; };
//! \brief this class is the Interface for Encoder and TTS engines, to display settings //! \brief this class is the Interface for Encoder and TTS engines, to display settings
//! It wraps nearly everything needed, only updateModel() and commitModel() needs to be reimplemented //! It wraps nearly everything needed, only updateModel() and commitModel() needs to be reimplemented
//! //!
class EncTtsSettingInterface : public QObject class EncTtsSettingInterface : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
EncTtsSettingInterface(QObject* parent) : QObject(parent) {} EncTtsSettingInterface(QObject* parent) : QObject(parent) {}
//! get the Settings list //! get the Settings list
QList<EncTtsSetting*> getSettings() {generateSettings(); return settingsList;} QList<EncTtsSetting*> getSettings() {generateSettings(); return settingsList;}
//! Chlid class should commit the from SettingsList to permanent storage //! Chlid class should commit the from SettingsList to permanent storage
virtual void saveSettings() = 0; virtual void saveSettings() = 0;
signals: signals:
void busy(); // emit this if a operation takes time void busy(); // emit this if a operation takes time
void busyEnd(); // emit this at the end of a busy section void busyEnd(); // emit this at the end of a busy section
protected: protected:
//! Child class should fill in the setttingsList //! Child class should fill in the setttingsList
virtual void generateSettings() = 0; virtual void generateSettings() = 0;
//! insert a setting //! insert a setting
void insertSetting(int id,EncTtsSetting* setting); void insertSetting(int id,EncTtsSetting* setting);
//! retrieve a specific setting //! retrieve a specific setting
EncTtsSetting* getSetting(int id); EncTtsSetting* getSetting(int id);
private: private:
//! The setting storage. //! The setting storage.
QList<EncTtsSetting*> settingsList; QList<EncTtsSetting*> settingsList;
}; };
#endif #endif

View file

@ -1,361 +1,361 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* *
* Copyright (C) 2007 by Dominik Wenger * Copyright (C) 2007 by Dominik Wenger
* $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $ * $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include "encttscfggui.h" #include "encttscfggui.h"
#include "browsedirtree.h" #include "browsedirtree.h"
EncTtsCfgGui::EncTtsCfgGui(QDialog* parent,EncTtsSettingInterface* interface,QString name) : QDialog(parent) EncTtsCfgGui::EncTtsCfgGui(QDialog* parent,EncTtsSettingInterface* interface,QString name) : QDialog(parent)
{ {
m_settingInterface = interface; m_settingInterface = interface;
m_busyCnt=0; m_busyCnt=0;
// create a busy Dialog // create a busy Dialog
m_busyDlg= new QProgressDialog(tr(""), tr(""), 0, 0,this); m_busyDlg= new QProgressDialog(tr(""), tr(""), 0, 0,this);
m_busyDlg->setWindowTitle(tr("Waiting for engine...")); m_busyDlg->setWindowTitle(tr("Waiting for engine..."));
m_busyDlg->setModal(true); m_busyDlg->setModal(true);
m_busyDlg->setLabel(0); m_busyDlg->setLabel(0);
m_busyDlg->setCancelButton(0); m_busyDlg->setCancelButton(0);
m_busyDlg->hide(); m_busyDlg->hide();
connect(interface,SIGNAL(busy()),this,SLOT(showBusy())); connect(interface,SIGNAL(busy()),this,SLOT(showBusy()));
connect(interface,SIGNAL(busyEnd()),this,SLOT(hideBusy())); connect(interface,SIGNAL(busyEnd()),this,SLOT(hideBusy()));
//setup the window //setup the window
setWindowTitle(name); setWindowTitle(name);
setUpWindow(); setUpWindow();
} }
void EncTtsCfgGui::setUpWindow() void EncTtsCfgGui::setUpWindow()
{ {
m_settingsList = m_settingInterface->getSettings(); m_settingsList = m_settingInterface->getSettings();
//layout //layout
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
// groupbox // groupbox
QGroupBox *groupBox = new QGroupBox(this); QGroupBox *groupBox = new QGroupBox(this);
QFormLayout *formlayout = new QFormLayout; QFormLayout *formlayout = new QFormLayout;
// setting widgets // setting widgets
for(int i = 0; i < m_settingsList.size(); i++) for(int i = 0; i < m_settingsList.size(); i++)
{ {
formlayout->addRow(m_settingsList.at(i)->name(),createWidgets(m_settingsList.at(i))); formlayout->addRow(m_settingsList.at(i)->name(),createWidgets(m_settingsList.at(i)));
} }
groupBox->setLayout(formlayout); groupBox->setLayout(formlayout);
mainLayout->addWidget(groupBox); mainLayout->addWidget(groupBox);
// connect browse btn // connect browse btn
connect(&m_browseBtnMap,SIGNAL(mapped(QObject*)),this,SLOT(browse(QObject*))); connect(&m_browseBtnMap,SIGNAL(mapped(QObject*)),this,SLOT(browse(QObject*)));
// ok - cancel buttons // ok - cancel buttons
QPushButton* okBtn = new QPushButton(tr("Ok"),this); QPushButton* okBtn = new QPushButton(tr("Ok"),this);
okBtn->setDefault(true); okBtn->setDefault(true);
okBtn->setIcon(QIcon(":icons/go-next.png")); okBtn->setIcon(QIcon(":icons/go-next.png"));
QPushButton* cancelBtn = new QPushButton(tr("Cancel"),this); QPushButton* cancelBtn = new QPushButton(tr("Cancel"),this);
cancelBtn->setIcon(QIcon(":icons/process-stop.png")); cancelBtn->setIcon(QIcon(":icons/process-stop.png"));
connect(okBtn,SIGNAL(clicked()),this,SLOT(accept())); connect(okBtn,SIGNAL(clicked()),this,SLOT(accept()));
connect(cancelBtn,SIGNAL(clicked()),this,SLOT(reject())); connect(cancelBtn,SIGNAL(clicked()),this,SLOT(reject()));
QHBoxLayout *btnbox = new QHBoxLayout; QHBoxLayout *btnbox = new QHBoxLayout;
btnbox->addWidget(okBtn); btnbox->addWidget(okBtn);
btnbox->addWidget(cancelBtn); btnbox->addWidget(cancelBtn);
btnbox->insertStretch(0,1); btnbox->insertStretch(0,1);
mainLayout->addLayout(btnbox); mainLayout->addLayout(btnbox);
this->setLayout(mainLayout); this->setLayout(mainLayout);
} }
QLayout* EncTtsCfgGui::createWidgets(EncTtsSetting* setting) QLayout* EncTtsCfgGui::createWidgets(EncTtsSetting* setting)
{ {
// value display // value display
QWidget* value = NULL; QWidget* value = NULL;
switch(setting->type()) switch(setting->type())
{ {
case EncTtsSetting::eDOUBLE: case EncTtsSetting::eDOUBLE:
{ {
QDoubleSpinBox *spinBox = new QDoubleSpinBox(this); QDoubleSpinBox *spinBox = new QDoubleSpinBox(this);
spinBox->setMinimum(setting->min().toDouble()); spinBox->setMinimum(setting->min().toDouble());
spinBox->setMaximum(setting->max().toDouble()); spinBox->setMaximum(setting->max().toDouble());
spinBox->setSingleStep(0.01); spinBox->setSingleStep(0.01);
spinBox->setValue(setting->current().toDouble()); spinBox->setValue(setting->current().toDouble());
connect(spinBox,SIGNAL(valueChanged(double)),this,SLOT(updateSetting())); connect(spinBox,SIGNAL(valueChanged(double)),this,SLOT(updateSetting()));
value = spinBox; value = spinBox;
break; break;
} }
case EncTtsSetting::eINT: case EncTtsSetting::eINT:
{ {
QSpinBox *spinBox = new QSpinBox(this); QSpinBox *spinBox = new QSpinBox(this);
spinBox->setMinimum(setting->min().toInt()); spinBox->setMinimum(setting->min().toInt());
spinBox->setMaximum(setting->max().toInt()); spinBox->setMaximum(setting->max().toInt());
spinBox->setValue(setting->current().toInt()); spinBox->setValue(setting->current().toInt());
connect(spinBox,SIGNAL(valueChanged(int)),this,SLOT(updateSetting())); connect(spinBox,SIGNAL(valueChanged(int)),this,SLOT(updateSetting()));
value = spinBox; value = spinBox;
break; break;
} }
case EncTtsSetting::eSTRING: case EncTtsSetting::eSTRING:
{ {
QLineEdit *lineEdit = new QLineEdit(this); QLineEdit *lineEdit = new QLineEdit(this);
lineEdit->setText(setting->current().toString()); lineEdit->setText(setting->current().toString());
connect(lineEdit,SIGNAL(textChanged(QString)),this,SLOT(updateSetting())); connect(lineEdit,SIGNAL(textChanged(QString)),this,SLOT(updateSetting()));
value = lineEdit; value = lineEdit;
break; break;
} }
case EncTtsSetting::eREADONLYSTRING: case EncTtsSetting::eREADONLYSTRING:
{ {
value = new QLabel(setting->current().toString(),this); value = new QLabel(setting->current().toString(),this);
break; break;
} }
case EncTtsSetting::eSTRINGLIST: case EncTtsSetting::eSTRINGLIST:
{ {
QComboBox *comboBox = new QComboBox(this); QComboBox *comboBox = new QComboBox(this);
comboBox->addItems(setting->list()); comboBox->addItems(setting->list());
int index = comboBox->findText(setting->current().toString()); int index = comboBox->findText(setting->current().toString());
comboBox->setCurrentIndex(index); comboBox->setCurrentIndex(index);
connect(comboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateSetting())); connect(comboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(updateSetting()));
value = comboBox; value = comboBox;
break; break;
} }
case EncTtsSetting::eBOOL: case EncTtsSetting::eBOOL:
{ {
QCheckBox *checkbox = new QCheckBox(this); QCheckBox *checkbox = new QCheckBox(this);
checkbox->setCheckState(setting->current().toBool() == true ? Qt::Checked : Qt::Unchecked); checkbox->setCheckState(setting->current().toBool() == true ? Qt::Checked : Qt::Unchecked);
connect(checkbox,SIGNAL(stateChanged(int)),this,SLOT(updateSetting())); connect(checkbox,SIGNAL(stateChanged(int)),this,SLOT(updateSetting()));
value = checkbox; value = checkbox;
break; break;
} }
default: default:
{ {
qDebug() << "Warning: unknown EncTTsSetting type" << setting->type(); qDebug() << "Warning: unknown EncTTsSetting type" << setting->type();
break; break;
} }
} }
// remeber widget // remeber widget
if(value != NULL) if(value != NULL)
{ {
m_settingsWidgetsMap.insert(setting,value); m_settingsWidgetsMap.insert(setting,value);
connect(setting,SIGNAL(updateGui()),this,SLOT(updateWidget())); connect(setting,SIGNAL(updateGui()),this,SLOT(updateWidget()));
} }
// buttons ? // buttons ?
QWidget* btn = createButton(setting); QWidget* btn = createButton(setting);
// add to layout // add to layout
QHBoxLayout *hbox = new QHBoxLayout; QHBoxLayout *hbox = new QHBoxLayout;
if(value != NULL)hbox->addWidget(value); if(value != NULL)hbox->addWidget(value);
if(btn != NULL) hbox->addWidget(btn); if(btn != NULL) hbox->addWidget(btn);
return hbox; return hbox;
} }
QWidget* EncTtsCfgGui::createButton(EncTtsSetting* setting) QWidget* EncTtsCfgGui::createButton(EncTtsSetting* setting)
{ {
if(setting->button() == EncTtsSetting::eBROWSEBTN) if(setting->button() == EncTtsSetting::eBROWSEBTN)
{ {
QPushButton* browsebtn = new QPushButton(tr("Browse"),this); QPushButton* browsebtn = new QPushButton(tr("Browse"),this);
browsebtn->setFixedWidth(50); //all buttons the same size, or it looks ugly browsebtn->setFixedWidth(50); //all buttons the same size, or it looks ugly
m_browseBtnMap.setMapping(browsebtn,setting); m_browseBtnMap.setMapping(browsebtn,setting);
connect(browsebtn,SIGNAL(clicked()),&m_browseBtnMap,SLOT(map())); connect(browsebtn,SIGNAL(clicked()),&m_browseBtnMap,SLOT(map()));
return browsebtn; return browsebtn;
} }
else if(setting->button() == EncTtsSetting::eREFRESHBTN) else if(setting->button() == EncTtsSetting::eREFRESHBTN)
{ {
QPushButton* refreshbtn = new QPushButton(tr("Refresh"),this); QPushButton* refreshbtn = new QPushButton(tr("Refresh"),this);
refreshbtn->setFixedWidth(50); //all buttons the same size, or it looks ugly refreshbtn->setFixedWidth(50); //all buttons the same size, or it looks ugly
connect(refreshbtn,SIGNAL(clicked()),setting,SIGNAL(refresh())); connect(refreshbtn,SIGNAL(clicked()),setting,SIGNAL(refresh()));
return refreshbtn; return refreshbtn;
} }
else else
return NULL; return NULL;
} }
void EncTtsCfgGui::updateSetting() void EncTtsCfgGui::updateSetting()
{ {
//cast and get the sender widget //cast and get the sender widget
QWidget* widget = qobject_cast<QWidget*>(QObject::sender()); QWidget* widget = qobject_cast<QWidget*>(QObject::sender());
if(widget == NULL) return; if(widget == NULL) return;
// get the corresponding setting // get the corresponding setting
EncTtsSetting* setting = m_settingsWidgetsMap.key(widget); EncTtsSetting* setting = m_settingsWidgetsMap.key(widget);
// update widget based on setting type // update widget based on setting type
switch(setting->type()) switch(setting->type())
{ {
case EncTtsSetting::eDOUBLE: case EncTtsSetting::eDOUBLE:
{ {
setting->setCurrent(((QDoubleSpinBox*)widget)->value(),false); setting->setCurrent(((QDoubleSpinBox*)widget)->value(),false);
break; break;
} }
case EncTtsSetting::eINT: case EncTtsSetting::eINT:
{ {
setting->setCurrent(((QSpinBox*)widget)->value(),false); setting->setCurrent(((QSpinBox*)widget)->value(),false);
break; break;
} }
case EncTtsSetting::eSTRING: case EncTtsSetting::eSTRING:
{ {
setting->setCurrent(((QLineEdit*)widget)->text(),false); setting->setCurrent(((QLineEdit*)widget)->text(),false);
break; break;
} }
case EncTtsSetting::eREADONLYSTRING: case EncTtsSetting::eREADONLYSTRING:
{ {
setting->setCurrent(((QLabel*)widget)->text(),false); setting->setCurrent(((QLabel*)widget)->text(),false);
break; break;
} }
case EncTtsSetting::eSTRINGLIST: case EncTtsSetting::eSTRINGLIST:
{ {
setting->setCurrent(((QComboBox*)widget)->currentText(),false); setting->setCurrent(((QComboBox*)widget)->currentText(),false);
break; break;
} }
case EncTtsSetting::eBOOL: case EncTtsSetting::eBOOL:
{ {
setting->setCurrent(((QCheckBox*)widget)->isChecked(),false); setting->setCurrent(((QCheckBox*)widget)->isChecked(),false);
} }
default: default:
{ {
qDebug() << "unknown Settingtype !!"; qDebug() << "unknown Settingtype !!";
break; break;
} }
} }
} }
void EncTtsCfgGui::updateWidget() void EncTtsCfgGui::updateWidget()
{ {
// get sender setting // get sender setting
EncTtsSetting* setting = qobject_cast<EncTtsSetting*>(QObject::sender()); EncTtsSetting* setting = qobject_cast<EncTtsSetting*>(QObject::sender());
if(setting == NULL) return; if(setting == NULL) return;
// get corresponding widget // get corresponding widget
QWidget* widget = m_settingsWidgetsMap.value(setting); QWidget* widget = m_settingsWidgetsMap.value(setting);
// update Widget based on setting type // update Widget based on setting type
switch(setting->type()) switch(setting->type())
{ {
case EncTtsSetting::eDOUBLE: case EncTtsSetting::eDOUBLE:
{ {
QDoubleSpinBox* spinbox = (QDoubleSpinBox*) widget; QDoubleSpinBox* spinbox = (QDoubleSpinBox*) widget;
spinbox->setMinimum(setting->min().toDouble()); spinbox->setMinimum(setting->min().toDouble());
spinbox->setMaximum(setting->max().toDouble()); spinbox->setMaximum(setting->max().toDouble());
spinbox->blockSignals(true); spinbox->blockSignals(true);
spinbox->setValue(setting->current().toDouble()); spinbox->setValue(setting->current().toDouble());
spinbox->blockSignals(false); spinbox->blockSignals(false);
break; break;
} }
case EncTtsSetting::eINT: case EncTtsSetting::eINT:
{ {
QSpinBox* spinbox = (QSpinBox*) widget; QSpinBox* spinbox = (QSpinBox*) widget;
spinbox->setMinimum(setting->min().toInt()); spinbox->setMinimum(setting->min().toInt());
spinbox->setMaximum(setting->max().toInt()); spinbox->setMaximum(setting->max().toInt());
spinbox->blockSignals(true); spinbox->blockSignals(true);
spinbox->setValue(setting->current().toInt()); spinbox->setValue(setting->current().toInt());
spinbox->blockSignals(false); spinbox->blockSignals(false);
break; break;
} }
case EncTtsSetting::eSTRING: case EncTtsSetting::eSTRING:
{ {
QLineEdit* lineedit = (QLineEdit*) widget; QLineEdit* lineedit = (QLineEdit*) widget;
lineedit->blockSignals(true); lineedit->blockSignals(true);
lineedit->setText(setting->current().toString()); lineedit->setText(setting->current().toString());
lineedit->blockSignals(false); lineedit->blockSignals(false);
break; break;
} }
case EncTtsSetting::eREADONLYSTRING: case EncTtsSetting::eREADONLYSTRING:
{ {
QLabel* label = (QLabel*) widget; QLabel* label = (QLabel*) widget;
label->blockSignals(true); label->blockSignals(true);
label->setText(setting->current().toString()); label->setText(setting->current().toString());
label->blockSignals(false); label->blockSignals(false);
break; break;
} }
case EncTtsSetting::eSTRINGLIST: case EncTtsSetting::eSTRINGLIST:
{ {
QComboBox* combobox = (QComboBox*) widget; QComboBox* combobox = (QComboBox*) widget;
combobox->blockSignals(true); combobox->blockSignals(true);
combobox->clear(); combobox->clear();
combobox->addItems(setting->list()); combobox->addItems(setting->list());
int index = combobox->findText(setting->current().toString()); int index = combobox->findText(setting->current().toString());
combobox->setCurrentIndex(index); combobox->setCurrentIndex(index);
combobox->blockSignals(false); combobox->blockSignals(false);
break; break;
} }
case EncTtsSetting::eBOOL: case EncTtsSetting::eBOOL:
{ {
QCheckBox* checkbox = (QCheckBox*) widget; QCheckBox* checkbox = (QCheckBox*) widget;
checkbox->blockSignals(true); checkbox->blockSignals(true);
checkbox->setCheckState(setting->current().toBool() == true ? Qt::Checked : Qt::Unchecked); checkbox->setCheckState(setting->current().toBool() == true ? Qt::Checked : Qt::Unchecked);
checkbox->blockSignals(false); checkbox->blockSignals(false);
break; break;
} }
default: default:
{ {
qDebug() << "unknown EncTTsSetting"; qDebug() << "unknown EncTTsSetting";
break; break;
} }
} }
} }
void EncTtsCfgGui::showBusy() void EncTtsCfgGui::showBusy()
{ {
if(m_busyCnt == 0) m_busyDlg->show(); if(m_busyCnt == 0) m_busyDlg->show();
m_busyCnt++; m_busyCnt++;
} }
void EncTtsCfgGui::hideBusy() void EncTtsCfgGui::hideBusy()
{ {
m_busyCnt--; m_busyCnt--;
if(m_busyCnt == 0) m_busyDlg->hide(); if(m_busyCnt == 0) m_busyDlg->hide();
} }
void EncTtsCfgGui::accept(void) void EncTtsCfgGui::accept(void)
{ {
m_settingInterface->saveSettings(); m_settingInterface->saveSettings();
this->done(0); this->done(0);
} }
void EncTtsCfgGui::reject(void) void EncTtsCfgGui::reject(void)
{ {
this->done(0); this->done(0);
} }
//! takes a QObject because of QsignalMapper //! takes a QObject because of QsignalMapper
void EncTtsCfgGui::browse(QObject* settingObj) void EncTtsCfgGui::browse(QObject* settingObj)
{ {
// cast top setting // cast top setting
EncTtsSetting* setting= qobject_cast<EncTtsSetting*>(settingObj); EncTtsSetting* setting= qobject_cast<EncTtsSetting*>(settingObj);
if(setting == NULL) return; if(setting == NULL) return;
//current path //current path
QString curPath = setting->current().toString(); QString curPath = setting->current().toString();
// show file dialog // show file dialog
QString exe = QFileDialog::getOpenFileName(this, tr("Select excutable"), curPath, "*"); QString exe = QFileDialog::getOpenFileName(this, tr("Select excutable"), curPath, "*");
if(!QFileInfo(exe).isExecutable()) if(!QFileInfo(exe).isExecutable())
return; return;
// set new value, gui will update automatically // set new value, gui will update automatically
setting->setCurrent(exe); setting->setCurrent(exe);
} }

View file

@ -1,78 +1,78 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* *
* Copyright (C) 2007 by Dominik Wenger * Copyright (C) 2007 by Dominik Wenger
* $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $ * $Id: encoders.h 17902 2008-06-30 22:09:45Z bluebrother $
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#ifndef ENCTTSCFGGUI_H #ifndef ENCTTSCFGGUI_H
#define ENCTTSCFGGUI_H #define ENCTTSCFGGUI_H
#include <QtGui> #include <QtGui>
#include "encttssettings.h" #include "encttssettings.h"
//! \brief Shows and manages a configuration gui for encoders and tts enignes //! \brief Shows and manages a configuration gui for encoders and tts enignes
//! //!
class EncTtsCfgGui: public QDialog class EncTtsCfgGui: public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
//! Creates the UI. give it a endoer or tts engine with already set config. uses show() or exec() to show it. //! Creates the UI. give it a endoer or tts engine with already set config. uses show() or exec() to show it.
EncTtsCfgGui(QDialog* parent, EncTtsSettingInterface* interface,QString name); EncTtsCfgGui(QDialog* parent, EncTtsSettingInterface* interface,QString name);
private slots: private slots:
//! accept current configuration values and close window //! accept current configuration values and close window
void accept(void); void accept(void);
//! close window and dont save configuration //! close window and dont save configuration
void reject(void); void reject(void);
//! updates the corresponding setting from the sending Widget //! updates the corresponding setting from the sending Widget
void updateSetting(); void updateSetting();
//! updates corresponding Widget from the sending Setting. //! updates corresponding Widget from the sending Setting.
void updateWidget(); void updateWidget();
//! shows a busy dialog. counts calls. //! shows a busy dialog. counts calls.
void showBusy(); void showBusy();
//! hides the busy dialog, counts calls //! hides the busy dialog, counts calls
void hideBusy(); void hideBusy();
//! used via the SignalMapper for all Browse buttons //! used via the SignalMapper for all Browse buttons
void browse(QObject*); void browse(QObject*);
private: private:
//! creates all dynamic window content //! creates all dynamic window content
void setUpWindow(); void setUpWindow();
//! creates the Widgets needed for one setting. returns a Layout with the widgets //! creates the Widgets needed for one setting. returns a Layout with the widgets
QLayout* createWidgets(EncTtsSetting* setting); QLayout* createWidgets(EncTtsSetting* setting);
//! creates a button when needed by the setting. //! creates a button when needed by the setting.
QWidget* createButton(EncTtsSetting* setting); QWidget* createButton(EncTtsSetting* setting);
//! name of the Encoder or TTS for which this UI is //! name of the Encoder or TTS for which this UI is
QString m_name; QString m_name;
//! the interface pointer to the TTS or encoder //! the interface pointer to the TTS or encoder
EncTtsSettingInterface* m_settingInterface; EncTtsSettingInterface* m_settingInterface;
//! Dialog, shown when enc or tts is busy //! Dialog, shown when enc or tts is busy
QProgressDialog* m_busyDlg; QProgressDialog* m_busyDlg;
//! List of settings from the TTS or Encoder //! List of settings from the TTS or Encoder
QList<EncTtsSetting*> m_settingsList; QList<EncTtsSetting*> m_settingsList;
//! Maps settings and the correspondig Widget //! Maps settings and the correspondig Widget
QMap<EncTtsSetting*,QWidget*> m_settingsWidgetsMap; QMap<EncTtsSetting*,QWidget*> m_settingsWidgetsMap;
//! Maps all browse buttons to the corresponding Setting //! Maps all browse buttons to the corresponding Setting
QSignalMapper m_browseBtnMap; QSignalMapper m_browseBtnMap;
//! counter how often busyShow() is called, //! counter how often busyShow() is called,
int m_busyCnt; int m_busyCnt;
}; };
#endif #endif