From 9079cddd832366fce51d853926cba3bad14837d4 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Thu, 24 Jun 2010 18:43:06 +0000 Subject: Theme Editor: Added settingsChanged() signal to DeviceState class git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27110 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/gui/devicestate.cpp | 66 ++++++++++++++++++++++++----------- utils/themeeditor/gui/devicestate.h | 6 ++++ 2 files changed, 51 insertions(+), 21 deletions(-) (limited to 'utils/themeeditor') diff --git a/utils/themeeditor/gui/devicestate.cpp b/utils/themeeditor/gui/devicestate.cpp index fb35e77b36..b17dcafa57 100644 --- a/utils/themeeditor/gui/devicestate.cpp +++ b/utils/themeeditor/gui/devicestate.cpp @@ -44,7 +44,6 @@ DeviceState::DeviceState(QWidget *parent) : QScrollArea* currentArea; QHBoxLayout* subLayout; QWidget* panel; - QWidget* temp; QFile fin(":/resources/deviceoptions"); fin.open(QFile::Text | QFile::ReadOnly); @@ -91,19 +90,25 @@ DeviceState::DeviceState(QWidget *parent) : elements = type.split("("); if(elements[0].trimmed() == "text") { - temp = new QLineEdit(defVal, currentArea); + QLineEdit* temp = new QLineEdit(defVal, currentArea); subLayout->addWidget(temp); inputs.insert(tag, QPair(Text, temp)); + + QObject::connect(temp, SIGNAL(textChanged(QString)), + this, SLOT(input())); } else if(elements[0].trimmed() == "check") { - temp = new QCheckBox(title, currentArea); + QCheckBox* temp = new QCheckBox(title, currentArea); subLayout->addWidget(temp); if(defVal.toLower() == "true") - dynamic_cast(temp)->setChecked(true); + temp->setChecked(true); else - dynamic_cast(temp)->setChecked(false); + temp->setChecked(false); inputs.insert(tag, QPair(Check, temp)); + + QObject::connect(temp, SIGNAL(toggled(bool)), + this, SLOT(input())); } else if(elements[0].trimmed() == "slider") { @@ -113,12 +118,15 @@ DeviceState::DeviceState(QWidget *parent) : maxS.chop(1); int max = maxS.toInt(); - temp = new QSlider(Qt::Horizontal, currentArea); - dynamic_cast(temp)->setMinimum(min); - dynamic_cast(temp)->setMaximum(max); - dynamic_cast(temp)->setValue(defVal.toInt()); + QSlider* temp = new QSlider(Qt::Horizontal, currentArea); + temp->setMinimum(min); + temp->setMaximum(max); + temp->setValue(defVal.toInt()); subLayout->addWidget(temp); inputs.insert(tag, QPair(Slide, temp)); + + QObject::connect(temp, SIGNAL(valueChanged(int)), + this, SLOT(input())); } else if(elements[0].trimmed() == "spin") { @@ -128,12 +136,15 @@ DeviceState::DeviceState(QWidget *parent) : maxS.chop(1); int max = maxS.toInt(); - temp = new QSpinBox(currentArea); - dynamic_cast(temp)->setMinimum(min); - dynamic_cast(temp)->setMaximum(max); - dynamic_cast(temp)->setValue(defVal.toInt()); + QSpinBox* temp = new QSpinBox(currentArea); + temp->setMinimum(min); + temp->setMaximum(max); + temp->setValue(defVal.toInt()); subLayout->addWidget(temp); inputs.insert(tag, QPair(Spin, temp)); + + QObject::connect(temp, SIGNAL(valueChanged(int)), + this, SLOT(input())); } else if(elements[0].trimmed() == "fspin") { @@ -143,32 +154,38 @@ DeviceState::DeviceState(QWidget *parent) : maxS.chop(1); int max = maxS.toDouble(); - temp = new QDoubleSpinBox(currentArea); - dynamic_cast(temp)->setMinimum(min); - dynamic_cast(temp)->setMaximum(max); - dynamic_cast(temp)->setValue(defVal.toDouble()); - dynamic_cast(temp)->setSingleStep(0.1); + QDoubleSpinBox* temp = new QDoubleSpinBox(currentArea); + temp->setMinimum(min); + temp->setMaximum(max); + temp->setValue(defVal.toDouble()); + temp->setSingleStep(0.1); subLayout->addWidget(temp); inputs.insert(tag, QPair(DSpin, temp)); + + QObject::connect(temp, SIGNAL(valueChanged(double)), + this, SLOT(input())); } else if(elements[0].trimmed() == "combo") { elements = elements[1].trimmed().split(","); int defIndex; - temp = new QComboBox(currentArea); + QComboBox* temp = new QComboBox(currentArea); for(int i = 0; i < elements.count(); i++) { QString current = elements[i].trimmed(); if(i == elements.count() - 1) current.chop(1); - dynamic_cast(temp)->addItem(current, i); + temp->addItem(current, i); if(current == defVal) defIndex = i; } - dynamic_cast(temp)->setCurrentIndex(defIndex); + temp->setCurrentIndex(defIndex); subLayout->addWidget(temp); inputs.insert(tag, QPair(Combo, temp)); + + QObject::connect(temp, SIGNAL(currentIndexChanged(int)), + this, SLOT(input())); } } @@ -206,4 +223,11 @@ QVariant DeviceState::data(QString tag) case Check: return dynamic_cast(found.second)->isChecked(); } + + return QVariant(); +} + +void DeviceState::input() +{ + emit settingsChanged(); } diff --git a/utils/themeeditor/gui/devicestate.h b/utils/themeeditor/gui/devicestate.h index 8938e01f29..c680e2c1ea 100644 --- a/utils/themeeditor/gui/devicestate.h +++ b/utils/themeeditor/gui/devicestate.h @@ -48,6 +48,12 @@ public: QVariant data(QString tag); +signals: + void settingsChanged(); + +private slots: + void input(); + private: QMap > inputs; QTabWidget tabs; -- cgit