summaryrefslogtreecommitdiff
path: root/utils/themeeditor
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-07-16 20:47:23 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-07-16 20:47:23 +0000
commit025147effbee00db8bae931b3ef3df25052e0d96 (patch)
treedb2df79d33b48f115fa35ffd9ae24f97c2bdc28b /utils/themeeditor
parent1c1d10b9fdfc2b78c5aeba4c352cd7dbc0717edc (diff)
downloadrockbox-025147effbee00db8bae931b3ef3df25052e0d96.tar.gz
rockbox-025147effbee00db8bae931b3ef3df25052e0d96.zip
Theme Editor: Added target database, now populates combo box in new project dialog but otherwise not used yet
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27450 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor')
-rw-r--r--utils/themeeditor/gui/editorwindow.h1
-rw-r--r--utils/themeeditor/gui/newprojectdialog.cpp11
-rw-r--r--utils/themeeditor/gui/newprojectdialog.h3
-rw-r--r--utils/themeeditor/gui/newprojectdialog.ui10
-rw-r--r--utils/themeeditor/models/targetdata.cpp245
-rw-r--r--utils/themeeditor/models/targetdata.h80
-rw-r--r--utils/themeeditor/resources.qrc3
-rw-r--r--utils/themeeditor/resources/targetdb73
-rw-r--r--utils/themeeditor/themeeditor.pro9
9 files changed, 424 insertions, 11 deletions
diff --git a/utils/themeeditor/gui/editorwindow.h b/utils/themeeditor/gui/editorwindow.h
index 5bfa795714..55e18732d0 100644
--- a/utils/themeeditor/gui/editorwindow.h
+++ b/utils/themeeditor/gui/editorwindow.h
@@ -35,6 +35,7 @@
35#include "skinviewer.h" 35#include "skinviewer.h"
36#include "devicestate.h" 36#include "devicestate.h"
37#include "skintimer.h" 37#include "skintimer.h"
38#include "targetdata.h"
38 39
39class ProjectModel; 40class ProjectModel;
40class TabContent; 41class TabContent;
diff --git a/utils/themeeditor/gui/newprojectdialog.cpp b/utils/themeeditor/gui/newprojectdialog.cpp
index 50a8bc4631..0df3250c5b 100644
--- a/utils/themeeditor/gui/newprojectdialog.cpp
+++ b/utils/themeeditor/gui/newprojectdialog.cpp
@@ -21,6 +21,7 @@
21 21
22#include "newprojectdialog.h" 22#include "newprojectdialog.h"
23#include "ui_newprojectdialog.h" 23#include "ui_newprojectdialog.h"
24#include "targetdata.h"
24 25
25#include <QSettings> 26#include <QSettings>
26#include <QFileDialog> 27#include <QFileDialog>
@@ -42,6 +43,13 @@ NewProjectDialog::NewProjectDialog(QWidget *parent) :
42 43
43 settings.endGroup(); 44 settings.endGroup();
44 45
46 /* Populating the target box */
47 TargetData targets;
48 for(int i = 0; i < targets.count(); i++)
49 {
50 ui->targetBox->insertItem(i, QIcon(), targets.name(i), targets.id(i));
51 }
52
45 /* Connecting the browse button */ 53 /* Connecting the browse button */
46 QObject::connect(ui->browseButton, SIGNAL(clicked()), 54 QObject::connect(ui->browseButton, SIGNAL(clicked()),
47 this, SLOT(browse())); 55 this, SLOT(browse()));
@@ -56,6 +64,8 @@ void NewProjectDialog::accept()
56{ 64{
57 status.name = ui->nameBox->text(); 65 status.name = ui->nameBox->text();
58 status.path = ui->locationBox->text(); 66 status.path = ui->locationBox->text();
67 status.target = ui->targetBox->itemData(ui->targetBox->currentIndex())
68 .toString();
59 status.sbs = ui->sbsBox->isChecked(); 69 status.sbs = ui->sbsBox->isChecked();
60 status.wps = ui->wpsBox->isChecked(); 70 status.wps = ui->wpsBox->isChecked();
61 status.fms = ui->fmsBox->isChecked(); 71 status.fms = ui->fmsBox->isChecked();
@@ -77,6 +87,7 @@ void NewProjectDialog::reject()
77{ 87{
78 ui->nameBox->setText(status.name); 88 ui->nameBox->setText(status.name);
79 ui->locationBox->setText(status.path); 89 ui->locationBox->setText(status.path);
90 ui->targetBox->setCurrentIndex(0);
80 ui->sbsBox->setChecked(status.sbs); 91 ui->sbsBox->setChecked(status.sbs);
81 ui->wpsBox->setChecked(status.wps); 92 ui->wpsBox->setChecked(status.wps);
82 ui->fmsBox->setChecked(status.fms); 93 ui->fmsBox->setChecked(status.fms);
diff --git a/utils/themeeditor/gui/newprojectdialog.h b/utils/themeeditor/gui/newprojectdialog.h
index c59607c53f..6a54a133bc 100644
--- a/utils/themeeditor/gui/newprojectdialog.h
+++ b/utils/themeeditor/gui/newprojectdialog.h
@@ -35,6 +35,7 @@ public:
35 { 35 {
36 QString name; 36 QString name;
37 QString path; 37 QString path;
38 QString target;
38 bool sbs; 39 bool sbs;
39 bool wps; 40 bool wps;
40 bool fms; 41 bool fms;
@@ -46,6 +47,7 @@ public:
46 { 47 {
47 name = ""; 48 name = "";
48 path = ""; 49 path = "";
50 target = "";
49 sbs = true; 51 sbs = true;
50 wps = true; 52 wps = true;
51 fms = false; 53 fms = false;
@@ -63,6 +65,7 @@ public:
63 { 65 {
64 name = other.name; 66 name = other.name;
65 path = other.path; 67 path = other.path;
68 target = other.target;
66 sbs = other.sbs; 69 sbs = other.sbs;
67 wps = other.wps; 70 wps = other.wps;
68 fms = other.fms; 71 fms = other.fms;
diff --git a/utils/themeeditor/gui/newprojectdialog.ui b/utils/themeeditor/gui/newprojectdialog.ui
index f6e2dcc139..86292119c7 100644
--- a/utils/themeeditor/gui/newprojectdialog.ui
+++ b/utils/themeeditor/gui/newprojectdialog.ui
@@ -63,18 +63,12 @@
63 <string>Target:</string> 63 <string>Target:</string>
64 </property> 64 </property>
65 <property name="buddy"> 65 <property name="buddy">
66 <cstring>comboBox</cstring> 66 <cstring>targetBox</cstring>
67 </property> 67 </property>
68 </widget> 68 </widget>
69 </item> 69 </item>
70 <item row="2" column="1"> 70 <item row="2" column="1">
71 <widget class="QComboBox" name="comboBox"> 71 <widget class="QComboBox" name="targetBox"/>
72 <item>
73 <property name="text">
74 <string>Not Yet Available</string>
75 </property>
76 </item>
77 </widget>
78 </item> 72 </item>
79 <item row="4" column="0" colspan="2"> 73 <item row="4" column="0" colspan="2">
80 <widget class="QGroupBox" name="groupBox"> 74 <widget class="QGroupBox" name="groupBox">
diff --git a/utils/themeeditor/models/targetdata.cpp b/utils/themeeditor/models/targetdata.cpp
new file mode 100644
index 0000000000..a20a4cf18f
--- /dev/null
+++ b/utils/themeeditor/models/targetdata.cpp
@@ -0,0 +1,245 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "targetdata.h"
23
24#include <QStringList>
25
26const QString TargetData::reserved = "{}:#\n";
27
28TargetData::TargetData(QString file)
29{
30 if(!QFile::exists(file))
31 file = ":/targets/targetdb";
32
33 QFile fin(file);
34 fin.open(QFile::ReadOnly | QFile::Text);
35
36 /* Reading the database */
37 QString data = QString(fin.readAll());
38
39 fin.close();
40
41 int cursor = 0;
42 int index = 0;
43 while(cursor < data.count())
44 {
45 QString id = scanString(data, cursor);
46 QString name = "";
47 QRect size(0, 0, 0, 0);
48 ScreenDepth depth = None;
49 QRect rSize(0, 0, 0, 0);
50 ScreenDepth rDepth = None;
51 bool fm = false;
52
53 if(id == "")
54 break;
55
56 if(!require('{', data, cursor))
57 break;
58
59 /* Now we have to parse each of the arguments */
60 while(cursor < data.count())
61 {
62 QString key = scanString(data, cursor);
63 if(key == "")
64 {
65 break;
66 }
67 else
68 {
69 if(!require(':', data, cursor))
70 break;
71
72 if(key.toLower() == "name")
73 {
74 name = scanString(data, cursor);
75 }
76 else if(key.toLower() == "screen")
77 {
78 QString s = scanString(data, cursor);
79 if(s[0].toLower() != 'n')
80 {
81 int subCursor = 0;
82 int width = scanInt(s, subCursor);
83
84 if(!require('x', s, subCursor))
85 break;
86
87 int height = scanInt(s, subCursor);
88
89 if(!require('@', s, subCursor))
90 break;
91
92 size = QRect(0, 0, width, height);
93 depth = scanDepth(s, subCursor);
94 }
95 }
96 else if(key.toLower() == "remote")
97 {
98 QString s = scanString(data, cursor);
99 if(s[0].toLower() != 'n')
100 {
101 int subCursor = 0;
102 int width = scanInt(s, subCursor);
103
104 if(!require('x', s, subCursor))
105 break;
106
107 int height = scanInt(s, subCursor);
108
109 if(!require('@', s, subCursor))
110 break;
111
112 rSize = QRect(0, 0, width, height);
113 rDepth = scanDepth(s, subCursor);
114 }
115 }
116 else if(key.toLower() == "fm")
117 {
118 QString s = scanString(data, cursor);
119 if(s.toLower() == "yes")
120 fm = true;
121 }
122 }
123 }
124
125 /* Checking for the closing '}' and adding the entry */
126 if(require('}', data, cursor))
127 {
128 entries.append(Entry(name, size, depth, rSize, rDepth, fm));
129 indices.insert(id, index);
130 index++;
131 }
132 else
133 {
134 break;
135 }
136 }
137}
138
139TargetData::~TargetData()
140{
141}
142
143QString TargetData::scanString(QString data, int &index)
144{
145 QString retval;
146
147 /* Skipping whitespace and comments */
148 while(index < data.count() && (data[index].isSpace() || data[index] == '#'))
149 {
150 if(data[index] == '#')
151 skipComment(data, index);
152 else
153 index++;
154 }
155
156 while(index < data.count() && !reserved.contains(data[index]))
157 {
158 if(data[index] == '%')
159 {
160 retval.append(data[index + 1]);
161 index += 2;
162 }
163 else
164 {
165 retval.append(data[index]);
166 index++;
167 }
168 }
169
170 return retval.trimmed();
171}
172
173int TargetData::scanInt(QString data, int &index)
174{
175 /* Skipping whitespace and comments */
176 while(index < data.count() && (data[index].isSpace() || data[index] == '#'))
177 {
178 if(data[index] == '#')
179 skipComment(data, index);
180 else
181 index++;
182 }
183
184 QString number;
185 while(index < data.count() && data[index].isDigit())
186 number.append(data[index++]);
187
188 return number.toInt();
189}
190
191TargetData::ScreenDepth TargetData::scanDepth(QString data, int &index)
192{
193 QString depth = scanString(data, index);
194
195 if(depth.toLower() == "grey")
196 return Grey;
197 else if(depth.toLower() == "rgb")
198 return RGB;
199 else if(depth.toLower() == "mono")
200 return Mono;
201 else
202 return None;
203}
204
205void TargetData::skipComment(QString data, int &index)
206{
207 if(data[index] != '#')
208 return;
209
210 while(index < data.count() && data[index] != '\n')
211 index++;
212
213 if(index < data.count())
214 index++;
215}
216
217bool TargetData::require(QChar required, QString data, int &index)
218{
219 /* Skipping whitespace and comments */
220 while(index < data.count() && (data[index].isSpace() || data[index] == '#'))
221 {
222 if(data[index] == '#')
223 skipComment(data, index);
224 else
225 index++;
226 }
227
228 if(index == data.count())
229 {
230 return false;
231 }
232 else
233 {
234 if(data[index] == required)
235 {
236 index++;
237 return true;
238 }
239 else
240 {
241 return false;
242 }
243 }
244
245}
diff --git a/utils/themeeditor/models/targetdata.h b/utils/themeeditor/models/targetdata.h
new file mode 100644
index 0000000000..6178509514
--- /dev/null
+++ b/utils/themeeditor/models/targetdata.h
@@ -0,0 +1,80 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef TARGETDATA_H
23#define TARGETDATA_H
24
25#include <QFile>
26#include <QString>
27#include <QHash>
28#include <QRect>
29
30class TargetData
31{
32
33public:
34 enum ScreenDepth
35 {
36 RGB,
37 Grey,
38 Mono,
39 None
40 };
41
42 TargetData(QString file = "");
43 virtual ~TargetData();
44
45 int count(){ return indices.count(); }
46 int index(QString id){ return indices.value(id, -1); }
47
48 QString id(int index){ return indices.key(index, ""); }
49 QString name(int index){ return entries[index].name; }
50
51private:
52 struct Entry
53 {
54 Entry(QString name, QRect size, ScreenDepth depth, QRect rSize,
55 ScreenDepth rDepth, bool fm)
56 : name(name), size(size), depth(depth), rSize(rSize),
57 rDepth(rDepth), fm(fm){ }
58
59 QString name;
60 QRect size;
61 ScreenDepth depth;
62 QRect rSize;
63 ScreenDepth rDepth;
64 bool fm;
65 };
66
67 static const QString reserved;
68
69 QString scanString(QString data, int& index);
70 int scanInt(QString data, int& index);
71 ScreenDepth scanDepth(QString data, int& index);
72 void skipComment(QString data, int& index);
73 bool require(QChar required, QString data, int& index);
74
75 QHash<QString, int> indices;
76 QList<Entry> entries;
77
78};
79
80#endif // TARGETDATA_H
diff --git a/utils/themeeditor/resources.qrc b/utils/themeeditor/resources.qrc
index bad8edcb20..9674595834 100644
--- a/utils/themeeditor/resources.qrc
+++ b/utils/themeeditor/resources.qrc
@@ -24,4 +24,7 @@
24 <qresource prefix="/fonts"> 24 <qresource prefix="/fonts">
25 <file alias="08-Schumacher-Clean.fnt">resources/fonts/08-Schumacher-Clean.fnt</file> 25 <file alias="08-Schumacher-Clean.fnt">resources/fonts/08-Schumacher-Clean.fnt</file>
26 </qresource> 26 </qresource>
27 <qresource prefix="/targets">
28 <file alias="targetdb">resources/targetdb</file>
29 </qresource>
27</RCC> 30</RCC>
diff --git a/utils/themeeditor/resources/targetdb b/utils/themeeditor/resources/targetdb
new file mode 100644
index 0000000000..414e8f03f3
--- /dev/null
+++ b/utils/themeeditor/resources/targetdb
@@ -0,0 +1,73 @@
1ipod12
2{
3 name : iPod 1st/2nd Gen
4 screen : 160 x 128 @ grey
5 fm : no
6 remote : no
7}
8
9ipod3
10{
11 name : iPod 3rd Gen
12 screen : 160 x 128 @ grey
13 fm : no
14 remote : no
15}
16
17ipod4
18{
19 name : iPod 4th Gen
20 screen : 160 x 128 @ grey
21 fm : no
22 remote : no
23}
24
25ipodmini12
26{
27 name : iPod Mini 1st/2nd Gen
28 screen : 138 x 110 @ grey
29 fm : no
30 remote : no
31}
32
33ipodcolor
34{
35 name : iPod Color/Photo
36 screen : 220 x 176 @ rgb
37 fm : no
38 remote : no
39}
40
41ipodnano1
42{
43 name : iPod Nano 1st Gen
44 screen : 176 x 132 @ rgb
45 fm : no
46 remote : no
47}
48
49ipodvideo
50{
51 name : iPod Video
52 screen : 320 x 240 @ rgb
53 fm : no
54 remote : no
55}
56
57# Olympus units
58
59mrobe100
60{
61 name : m%:robe 100
62 screen : 160 x 128 @ mono
63 fm : no
64 remote : 79 x 16 @ mono
65}
66
67mrobe500
68{
69 name : m%:robe 500
70 screen : 640 x 480 @ rgb
71 fm : no
72 remote : 79 x 16 @ mono
73}
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro
index 75bad8373b..48c9f8c24d 100644
--- a/utils/themeeditor/themeeditor.pro
+++ b/utils/themeeditor/themeeditor.pro
@@ -55,7 +55,8 @@ HEADERS += models/parsetreemodel.h \
55 graphics/rbtextcache.h \ 55 graphics/rbtextcache.h \
56 gui/skintimer.h \ 56 gui/skintimer.h \
57 graphics/rbtoucharea.h \ 57 graphics/rbtoucharea.h \
58 gui/newprojectdialog.h 58 gui/newprojectdialog.h \
59 models/targetdata.h
59SOURCES += main.cpp \ 60SOURCES += main.cpp \
60 models/parsetreemodel.cpp \ 61 models/parsetreemodel.cpp \
61 models/parsetreenode.cpp \ 62 models/parsetreenode.cpp \
@@ -81,7 +82,8 @@ SOURCES += main.cpp \
81 graphics/rbtextcache.cpp \ 82 graphics/rbtextcache.cpp \
82 gui/skintimer.cpp \ 83 gui/skintimer.cpp \
83 graphics/rbtoucharea.cpp \ 84 graphics/rbtoucharea.cpp \
84 gui/newprojectdialog.cpp 85 gui/newprojectdialog.cpp \
86 models/targetdata.cpp
85OTHER_FILES += README \ 87OTHER_FILES += README \
86 resources/windowicon.png \ 88 resources/windowicon.png \
87 resources/appicon.xcf \ 89 resources/appicon.xcf \
@@ -102,7 +104,8 @@ OTHER_FILES += README \
102 resources/lines.xcf \ 104 resources/lines.xcf \
103 resources/lines.png \ 105 resources/lines.png \
104 resources/cursor.xcf \ 106 resources/cursor.xcf \
105 resources/cursor.png 107 resources/cursor.png \
108 resources/targetdb
106FORMS += gui/editorwindow.ui \ 109FORMS += gui/editorwindow.ui \
107 gui/preferencesdialog.ui \ 110 gui/preferencesdialog.ui \
108 gui/configdocument.ui \ 111 gui/configdocument.ui \