From f3491e97d0d96f8df8a3c5a16efdef19c0796770 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Sun, 6 Jun 2010 03:35:40 +0000 Subject: Theme Editor: Began working on open document functionality (still incomplete), fixed a nested conditional parsing bug in the parser, and fixed segfault-on-codegen-from-empty-tree bug git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26609 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/editorwindow.cpp | 12 ++++++++++++ utils/themeeditor/editorwindow.h | 1 + utils/themeeditor/parsetreemodel.cpp | 5 ++++- utils/themeeditor/skin_parser.c | 8 +++++++- utils/themeeditor/skindocument.cpp | 9 ++------- utils/themeeditor/skindocument.h | 11 +++++++++-- 6 files changed, 35 insertions(+), 11 deletions(-) (limited to 'utils/themeeditor') diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp index bc66fec425..dfc4b5981e 100644 --- a/utils/themeeditor/editorwindow.cpp +++ b/utils/themeeditor/editorwindow.cpp @@ -25,6 +25,7 @@ #include #include #include +#include EditorWindow::EditorWindow(QWidget *parent) : QMainWindow(parent), @@ -183,6 +184,17 @@ void EditorWindow::saveCurrentAs() dynamic_cast(ui->editorTabs->currentWidget())->saveAs(); } +void EditorWindow::openFile() +{ + QStringList fileNames; + QSettings settings; + + settings.beginGroup("SkinDocument"); + QString directory = settings.value("defaultDirectory", "").toString(); + fileNames = QFileDialog::getOpenFileNames(this, tr("Open Files"), directory, + SkinDocument::fileFilter()); +} + void EditorWindow::tabTitleChanged(QString title) { diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h index bf1228acec..e7fd96a548 100644 --- a/utils/themeeditor/editorwindow.h +++ b/utils/themeeditor/editorwindow.h @@ -49,6 +49,7 @@ private slots: void closeCurrent(); void saveCurrent(); void saveCurrentAs(); + void openFile(); void tabTitleChanged(QString title); void updateCurrent(); /* Generates code in the current tab */ diff --git a/utils/themeeditor/parsetreemodel.cpp b/utils/themeeditor/parsetreemodel.cpp index eecdc98334..8da0c26ef3 100644 --- a/utils/themeeditor/parsetreemodel.cpp +++ b/utils/themeeditor/parsetreemodel.cpp @@ -49,7 +49,10 @@ ParseTreeModel::~ParseTreeModel() QString ParseTreeModel::genCode() { - return root->genCode(); + if(root) + return root->genCode(); + else + return ""; } bool ParseTreeModel::changeTree(const char *document) diff --git a/utils/themeeditor/skin_parser.c b/utils/themeeditor/skin_parser.c index a771fe7584..c7df7af0c0 100644 --- a/utils/themeeditor/skin_parser.c +++ b/utils/themeeditor/skin_parser.c @@ -685,9 +685,15 @@ int skin_parse_conditional(struct skin_element* element, char** document) while(nested) { if(*cursor == ENUMLISTOPENSYM) + { nested++; - if(*cursor == ENUMLISTCLOSESYM) + break; + } + else if(*cursor == ENUMLISTCLOSESYM) + { nested--; + break; + } cursor++; } } diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp index aada24daac..469401d07b 100644 --- a/utils/themeeditor/skindocument.cpp +++ b/utils/themeeditor/skindocument.cpp @@ -28,12 +28,7 @@ #include SkinDocument::SkinDocument(QWidget *parent) : - QWidget(parent), fileFilter(tr("WPS Files (*.wps *.rwps);;" - "SBS Files (*.sbs *.rsbs);;" - "FMS Files (*.fms *.rfms);;" - "All Skin Files (*.wps *.rwps *.sbs " - "*.rsbs *.fms *.rfms);;" - "All Files (*.*)")) + QWidget(parent) { setupUI(); @@ -147,7 +142,7 @@ void SkinDocument::saveAs() directory = settings.value("defaultDirectory", "").toString(); fileName = QFileDialog::getSaveFileName(this, tr("Save Document"), - directory, fileFilter); + directory, fileFilter()); directory = fileName; if(fileName == "") return; diff --git a/utils/themeeditor/skindocument.h b/utils/themeeditor/skindocument.h index f222543522..4546c42edb 100644 --- a/utils/themeeditor/skindocument.h +++ b/utils/themeeditor/skindocument.h @@ -33,8 +33,15 @@ class SkinDocument : public QWidget { Q_OBJECT public: - const QString fileFilter; - + static QString fileFilter() + { + return tr("WPS Files (*.wps *.rwps);;" + "SBS Files (*.sbs *.rsbs);;" + "FMS Files (*.fms *.rfms);;" + "All Skin Files (*.wps *.rwps *.sbs " + "*.rsbs *.fms *.rfms);;" + "All Files (*.*)"); + } SkinDocument(QWidget *parent = 0); virtual ~SkinDocument(); -- cgit v1.2.3