From 6d609e009f4836418bbe5b404be8ae03d29ef8cb Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Wed, 7 Jul 2010 09:33:47 +0000 Subject: 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 --- utils/themeeditor/gui/editorwindow.cpp | 5 +++++ utils/themeeditor/gui/skindocument.cpp | 21 +++++++++++++++++++-- utils/themeeditor/gui/skindocument.h | 6 ++++++ 3 files changed, 30 insertions(+), 2 deletions(-) (limited to 'utils/themeeditor/gui') 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 @@ #include "editorwindow.h" #include "projectmodel.h" #include "ui_editorwindow.h" +#include "rbfontcache.h" +#include "rbtextcache.h" #include #include @@ -49,6 +51,9 @@ EditorWindow::~EditorWindow() delete project; delete deviceConfig; delete deviceDock; + + RBFontCache::clearCache(); + RBTextCache::clearCache(); } 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 @@ #include +const int SkinDocument::updateInterval = 500; + SkinDocument::SkinDocument(QLabel* statusLabel, ProjectModel* project, DeviceState* device, QWidget *parent) :TabContent(parent), statusLabel(statusLabel), @@ -70,6 +72,8 @@ SkinDocument::SkinDocument(QLabel* statusLabel, QString file, /* Setting the title */ QStringList decomposed = fileName.split('/'); titleText = decomposed.last(); + + lastUpdate = QTime::currentTime(); } SkinDocument::~SkinDocument() @@ -161,6 +165,11 @@ void SkinDocument::setupUI() findReplace->hide(); settingsChanged(); + + /* Setting up a timer to check for updates */ + checkUpdate.setInterval(500); + QObject::connect(&checkUpdate, SIGNAL(timeout()), + this, SLOT(codeChanged())); } void SkinDocument::settingsChanged() @@ -273,8 +282,16 @@ void SkinDocument::codeChanged() else emit titleChanged(titleText); - model->render(project, device, &fileName); - + if(lastUpdate.msecsTo(QTime::currentTime()) >= updateInterval) + { + model->render(project, device, &fileName); + checkUpdate.stop(); + lastUpdate = QTime::currentTime(); + } + else + { + checkUpdate.start(); + } cursorChanged(); } 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 @@ #include #include #include +#include +#include #include "findreplacedialog.h" @@ -113,6 +115,10 @@ private: DeviceState* device; FindReplaceDialog* findReplace; + + QTime lastUpdate; + static const int updateInterval; + QTimer checkUpdate; }; #endif // SKINDOCUMENT_H -- cgit v1.2.3