summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-24 18:43:06 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-24 18:43:06 +0000
commit9079cddd832366fce51d853926cba3bad14837d4 (patch)
tree39ebef773b40647c99f961cba64edf7132058ee2
parent4146882277cdc2145c67b3340d9b3c83b9469148 (diff)
downloadrockbox-9079cddd832366fce51d853926cba3bad14837d4.tar.gz
rockbox-9079cddd832366fce51d853926cba3bad14837d4.zip
Theme Editor: Added settingsChanged() signal to DeviceState class
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27110 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--utils/themeeditor/gui/devicestate.cpp66
-rw-r--r--utils/themeeditor/gui/devicestate.h6
2 files changed, 51 insertions, 21 deletions
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) :
44 QScrollArea* currentArea; 44 QScrollArea* currentArea;
45 QHBoxLayout* subLayout; 45 QHBoxLayout* subLayout;
46 QWidget* panel; 46 QWidget* panel;
47 QWidget* temp;
48 47
49 QFile fin(":/resources/deviceoptions"); 48 QFile fin(":/resources/deviceoptions");
50 fin.open(QFile::Text | QFile::ReadOnly); 49 fin.open(QFile::Text | QFile::ReadOnly);
@@ -91,19 +90,25 @@ DeviceState::DeviceState(QWidget *parent) :
91 elements = type.split("("); 90 elements = type.split("(");
92 if(elements[0].trimmed() == "text") 91 if(elements[0].trimmed() == "text")
93 { 92 {
94 temp = new QLineEdit(defVal, currentArea); 93 QLineEdit* temp = new QLineEdit(defVal, currentArea);
95 subLayout->addWidget(temp); 94 subLayout->addWidget(temp);
96 inputs.insert(tag, QPair<InputType, QWidget*>(Text, temp)); 95 inputs.insert(tag, QPair<InputType, QWidget*>(Text, temp));
96
97 QObject::connect(temp, SIGNAL(textChanged(QString)),
98 this, SLOT(input()));
97 } 99 }
98 else if(elements[0].trimmed() == "check") 100 else if(elements[0].trimmed() == "check")
99 { 101 {
100 temp = new QCheckBox(title, currentArea); 102 QCheckBox* temp = new QCheckBox(title, currentArea);
101 subLayout->addWidget(temp); 103 subLayout->addWidget(temp);
102 if(defVal.toLower() == "true") 104 if(defVal.toLower() == "true")
103 dynamic_cast<QCheckBox*>(temp)->setChecked(true); 105 temp->setChecked(true);
104 else 106 else
105 dynamic_cast<QCheckBox*>(temp)->setChecked(false); 107 temp->setChecked(false);
106 inputs.insert(tag, QPair<InputType, QWidget*>(Check, temp)); 108 inputs.insert(tag, QPair<InputType, QWidget*>(Check, temp));
109
110 QObject::connect(temp, SIGNAL(toggled(bool)),
111 this, SLOT(input()));
107 } 112 }
108 else if(elements[0].trimmed() == "slider") 113 else if(elements[0].trimmed() == "slider")
109 { 114 {
@@ -113,12 +118,15 @@ DeviceState::DeviceState(QWidget *parent) :
113 maxS.chop(1); 118 maxS.chop(1);
114 int max = maxS.toInt(); 119 int max = maxS.toInt();
115 120
116 temp = new QSlider(Qt::Horizontal, currentArea); 121 QSlider* temp = new QSlider(Qt::Horizontal, currentArea);
117 dynamic_cast<QSlider*>(temp)->setMinimum(min); 122 temp->setMinimum(min);
118 dynamic_cast<QSlider*>(temp)->setMaximum(max); 123 temp->setMaximum(max);
119 dynamic_cast<QSlider*>(temp)->setValue(defVal.toInt()); 124 temp->setValue(defVal.toInt());
120 subLayout->addWidget(temp); 125 subLayout->addWidget(temp);
121 inputs.insert(tag, QPair<InputType, QWidget*>(Slide, temp)); 126 inputs.insert(tag, QPair<InputType, QWidget*>(Slide, temp));
127
128 QObject::connect(temp, SIGNAL(valueChanged(int)),
129 this, SLOT(input()));
122 } 130 }
123 else if(elements[0].trimmed() == "spin") 131 else if(elements[0].trimmed() == "spin")
124 { 132 {
@@ -128,12 +136,15 @@ DeviceState::DeviceState(QWidget *parent) :
128 maxS.chop(1); 136 maxS.chop(1);
129 int max = maxS.toInt(); 137 int max = maxS.toInt();
130 138
131 temp = new QSpinBox(currentArea); 139 QSpinBox* temp = new QSpinBox(currentArea);
132 dynamic_cast<QSpinBox*>(temp)->setMinimum(min); 140 temp->setMinimum(min);
133 dynamic_cast<QSpinBox*>(temp)->setMaximum(max); 141 temp->setMaximum(max);
134 dynamic_cast<QSpinBox*>(temp)->setValue(defVal.toInt()); 142 temp->setValue(defVal.toInt());
135 subLayout->addWidget(temp); 143 subLayout->addWidget(temp);
136 inputs.insert(tag, QPair<InputType, QWidget*>(Spin, temp)); 144 inputs.insert(tag, QPair<InputType, QWidget*>(Spin, temp));
145
146 QObject::connect(temp, SIGNAL(valueChanged(int)),
147 this, SLOT(input()));
137 } 148 }
138 else if(elements[0].trimmed() == "fspin") 149 else if(elements[0].trimmed() == "fspin")
139 { 150 {
@@ -143,32 +154,38 @@ DeviceState::DeviceState(QWidget *parent) :
143 maxS.chop(1); 154 maxS.chop(1);
144 int max = maxS.toDouble(); 155 int max = maxS.toDouble();
145 156
146 temp = new QDoubleSpinBox(currentArea); 157 QDoubleSpinBox* temp = new QDoubleSpinBox(currentArea);
147 dynamic_cast<QDoubleSpinBox*>(temp)->setMinimum(min); 158 temp->setMinimum(min);
148 dynamic_cast<QDoubleSpinBox*>(temp)->setMaximum(max); 159 temp->setMaximum(max);
149 dynamic_cast<QDoubleSpinBox*>(temp)->setValue(defVal.toDouble()); 160 temp->setValue(defVal.toDouble());
150 dynamic_cast<QDoubleSpinBox*>(temp)->setSingleStep(0.1); 161 temp->setSingleStep(0.1);
151 subLayout->addWidget(temp); 162 subLayout->addWidget(temp);
152 inputs.insert(tag, QPair<InputType, QWidget*>(DSpin, temp)); 163 inputs.insert(tag, QPair<InputType, QWidget*>(DSpin, temp));
164
165 QObject::connect(temp, SIGNAL(valueChanged(double)),
166 this, SLOT(input()));
153 } 167 }
154 else if(elements[0].trimmed() == "combo") 168 else if(elements[0].trimmed() == "combo")
155 { 169 {
156 elements = elements[1].trimmed().split(","); 170 elements = elements[1].trimmed().split(",");
157 171
158 int defIndex; 172 int defIndex;
159 temp = new QComboBox(currentArea); 173 QComboBox* temp = new QComboBox(currentArea);
160 for(int i = 0; i < elements.count(); i++) 174 for(int i = 0; i < elements.count(); i++)
161 { 175 {
162 QString current = elements[i].trimmed(); 176 QString current = elements[i].trimmed();
163 if(i == elements.count() - 1) 177 if(i == elements.count() - 1)
164 current.chop(1); 178 current.chop(1);
165 dynamic_cast<QComboBox*>(temp)->addItem(current, i); 179 temp->addItem(current, i);
166 if(current == defVal) 180 if(current == defVal)
167 defIndex = i; 181 defIndex = i;
168 } 182 }
169 dynamic_cast<QComboBox*>(temp)->setCurrentIndex(defIndex); 183 temp->setCurrentIndex(defIndex);
170 subLayout->addWidget(temp); 184 subLayout->addWidget(temp);
171 inputs.insert(tag, QPair<InputType, QWidget*>(Combo, temp)); 185 inputs.insert(tag, QPair<InputType, QWidget*>(Combo, temp));
186
187 QObject::connect(temp, SIGNAL(currentIndexChanged(int)),
188 this, SLOT(input()));
172 } 189 }
173 190
174 } 191 }
@@ -206,4 +223,11 @@ QVariant DeviceState::data(QString tag)
206 case Check: 223 case Check:
207 return dynamic_cast<QCheckBox*>(found.second)->isChecked(); 224 return dynamic_cast<QCheckBox*>(found.second)->isChecked();
208 } 225 }
226
227 return QVariant();
228}
229
230void DeviceState::input()
231{
232 emit settingsChanged();
209} 233}
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:
48 48
49 QVariant data(QString tag); 49 QVariant data(QString tag);
50 50
51signals:
52 void settingsChanged();
53
54private slots:
55 void input();
56
51private: 57private:
52 QMap<QString, QPair<InputType, QWidget*> > inputs; 58 QMap<QString, QPair<InputType, QWidget*> > inputs;
53 QTabWidget tabs; 59 QTabWidget tabs;