diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-07-07 09:33:47 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-07-07 09:33:47 +0000 |
commit | 6d609e009f4836418bbe5b404be8ae03d29ef8cb (patch) | |
tree | 708bc7ba7bce2c7fc01cb719b594b296e51b17d0 /utils/themeeditor/gui | |
parent | 6f06793f58f520ec7d44683f6447c0b540a265b3 (diff) | |
download | rockbox-6d609e009f4836418bbe5b404be8ae03d29ef8cb.tar.gz rockbox-6d609e009f4836418bbe5b404be8ae03d29ef8cb.zip |
Theme Editor: Implemented caching for rendered text, added profiling info to debug build, added a 500msec delay when rendering after code changes to prevent editor from hanging on large themes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27332 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/gui')
-rw-r--r-- | utils/themeeditor/gui/editorwindow.cpp | 5 | ||||
-rw-r--r-- | utils/themeeditor/gui/skindocument.cpp | 21 | ||||
-rw-r--r-- | utils/themeeditor/gui/skindocument.h | 6 |
3 files changed, 30 insertions, 2 deletions
diff --git a/utils/themeeditor/gui/editorwindow.cpp b/utils/themeeditor/gui/editorwindow.cpp index 4c073b9e0b..171e7b7019 100644 --- a/utils/themeeditor/gui/editorwindow.cpp +++ b/utils/themeeditor/gui/editorwindow.cpp | |||
@@ -22,6 +22,8 @@ | |||
22 | #include "editorwindow.h" | 22 | #include "editorwindow.h" |
23 | #include "projectmodel.h" | 23 | #include "projectmodel.h" |
24 | #include "ui_editorwindow.h" | 24 | #include "ui_editorwindow.h" |
25 | #include "rbfontcache.h" | ||
26 | #include "rbtextcache.h" | ||
25 | 27 | ||
26 | #include <QDesktopWidget> | 28 | #include <QDesktopWidget> |
27 | #include <QFileSystemModel> | 29 | #include <QFileSystemModel> |
@@ -49,6 +51,9 @@ EditorWindow::~EditorWindow() | |||
49 | delete project; | 51 | delete project; |
50 | delete deviceConfig; | 52 | delete deviceConfig; |
51 | delete deviceDock; | 53 | delete deviceDock; |
54 | |||
55 | RBFontCache::clearCache(); | ||
56 | RBTextCache::clearCache(); | ||
52 | } | 57 | } |
53 | 58 | ||
54 | void EditorWindow::loadTabFromSkinFile(QString fileName) | 59 | void EditorWindow::loadTabFromSkinFile(QString fileName) |
diff --git a/utils/themeeditor/gui/skindocument.cpp b/utils/themeeditor/gui/skindocument.cpp index 9a381a9589..f04c12d213 100644 --- a/utils/themeeditor/gui/skindocument.cpp +++ b/utils/themeeditor/gui/skindocument.cpp | |||
@@ -31,6 +31,8 @@ | |||
31 | 31 | ||
32 | #include <QDebug> | 32 | #include <QDebug> |
33 | 33 | ||
34 | const int SkinDocument::updateInterval = 500; | ||
35 | |||
34 | SkinDocument::SkinDocument(QLabel* statusLabel, ProjectModel* project, | 36 | SkinDocument::SkinDocument(QLabel* statusLabel, ProjectModel* project, |
35 | DeviceState* device, QWidget *parent) | 37 | DeviceState* device, QWidget *parent) |
36 | :TabContent(parent), statusLabel(statusLabel), | 38 | :TabContent(parent), statusLabel(statusLabel), |
@@ -70,6 +72,8 @@ SkinDocument::SkinDocument(QLabel* statusLabel, QString file, | |||
70 | /* Setting the title */ | 72 | /* Setting the title */ |
71 | QStringList decomposed = fileName.split('/'); | 73 | QStringList decomposed = fileName.split('/'); |
72 | titleText = decomposed.last(); | 74 | titleText = decomposed.last(); |
75 | |||
76 | lastUpdate = QTime::currentTime(); | ||
73 | } | 77 | } |
74 | 78 | ||
75 | SkinDocument::~SkinDocument() | 79 | SkinDocument::~SkinDocument() |
@@ -161,6 +165,11 @@ void SkinDocument::setupUI() | |||
161 | findReplace->hide(); | 165 | findReplace->hide(); |
162 | 166 | ||
163 | settingsChanged(); | 167 | settingsChanged(); |
168 | |||
169 | /* Setting up a timer to check for updates */ | ||
170 | checkUpdate.setInterval(500); | ||
171 | QObject::connect(&checkUpdate, SIGNAL(timeout()), | ||
172 | this, SLOT(codeChanged())); | ||
164 | } | 173 | } |
165 | 174 | ||
166 | void SkinDocument::settingsChanged() | 175 | void SkinDocument::settingsChanged() |
@@ -273,8 +282,16 @@ void SkinDocument::codeChanged() | |||
273 | else | 282 | else |
274 | emit titleChanged(titleText); | 283 | emit titleChanged(titleText); |
275 | 284 | ||
276 | model->render(project, device, &fileName); | 285 | if(lastUpdate.msecsTo(QTime::currentTime()) >= updateInterval) |
277 | 286 | { | |
287 | model->render(project, device, &fileName); | ||
288 | checkUpdate.stop(); | ||
289 | lastUpdate = QTime::currentTime(); | ||
290 | } | ||
291 | else | ||
292 | { | ||
293 | checkUpdate.start(); | ||
294 | } | ||
278 | cursorChanged(); | 295 | cursorChanged(); |
279 | 296 | ||
280 | } | 297 | } |
diff --git a/utils/themeeditor/gui/skindocument.h b/utils/themeeditor/gui/skindocument.h index 7563b3cb53..f7ac2bbc2c 100644 --- a/utils/themeeditor/gui/skindocument.h +++ b/utils/themeeditor/gui/skindocument.h | |||
@@ -26,6 +26,8 @@ | |||
26 | #include <QLabel> | 26 | #include <QLabel> |
27 | #include <QHBoxLayout> | 27 | #include <QHBoxLayout> |
28 | #include <QGraphicsScene> | 28 | #include <QGraphicsScene> |
29 | #include <QTime> | ||
30 | #include <QTimer> | ||
29 | 31 | ||
30 | #include "findreplacedialog.h" | 32 | #include "findreplacedialog.h" |
31 | 33 | ||
@@ -113,6 +115,10 @@ private: | |||
113 | DeviceState* device; | 115 | DeviceState* device; |
114 | 116 | ||
115 | FindReplaceDialog* findReplace; | 117 | FindReplaceDialog* findReplace; |
118 | |||
119 | QTime lastUpdate; | ||
120 | static const int updateInterval; | ||
121 | QTimer checkUpdate; | ||
116 | }; | 122 | }; |
117 | 123 | ||
118 | #endif // SKINDOCUMENT_H | 124 | #endif // SKINDOCUMENT_H |