summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-07 01:08:25 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-07 01:08:25 +0000
commitfbfdaf5c79c664a6ec47b1c3a131577e77efbbd0 (patch)
treec6bd522c7f48f36f9efc57b52aa9de5124023f55 /utils
parent2a90375c1201ea4f7a53fb973d59ab3a8dc88faa (diff)
Theme Editor: Implemented document load functionality
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26639 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/editorwindow.cpp27
-rw-r--r--utils/themeeditor/skindocument.cpp26
-rw-r--r--utils/themeeditor/skindocument.h1
3 files changed, 50 insertions, 4 deletions
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp
index dfc4b5981e..91e099ebf7 100644
--- a/utils/themeeditor/editorwindow.cpp
+++ b/utils/themeeditor/editorwindow.cpp
@@ -117,6 +117,11 @@ void EditorWindow::setupMenus()
QObject::connect(ui->actionToolbarSave, SIGNAL(triggered()),
this, SLOT(saveCurrent()));
+ QObject::connect(ui->actionOpen_Document, SIGNAL(triggered()),
+ this, SLOT(openFile()));
+ QObject::connect(ui->actionToolbarOpen, SIGNAL(triggered()),
+ this, SLOT(openFile()));
+
}
@@ -193,6 +198,28 @@ void EditorWindow::openFile()
QString directory = settings.value("defaultDirectory", "").toString();
fileNames = QFileDialog::getOpenFileNames(this, tr("Open Files"), directory,
SkinDocument::fileFilter());
+
+ for(int i = 0; i < fileNames.count(); i++)
+ {
+ if(!QFile::exists(fileNames[i]))
+ continue;
+
+ QString current = fileNames[i];
+
+ /* Adding a new document for each file name */
+ SkinDocument* doc = new SkinDocument(current);
+ ui->editorTabs->addTab(doc, doc->getTitle());
+
+ QObject::connect(doc, SIGNAL(titleChanged(QString)),
+ this, SLOT(tabTitleChanged(QString)));
+
+ /* And setting the new default directory */
+ current.chop(current.length() - current.lastIndexOf('/') - 1);
+ settings.setValue("defaultDirectory", current);
+
+ }
+
+ settings.endGroup();
}
diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp
index 469401d07b..efb16eeae1 100644
--- a/utils/themeeditor/skindocument.cpp
+++ b/utils/themeeditor/skindocument.cpp
@@ -22,13 +22,11 @@
#include "skindocument.h"
#include <QFile>
-#include <QTimer>
#include <QSettings>
#include <QMessageBox>
#include <QFileDialog>
-SkinDocument::SkinDocument(QWidget *parent) :
- QWidget(parent)
+SkinDocument::SkinDocument(QWidget *parent) : QWidget(parent)
{
setupUI();
@@ -37,6 +35,26 @@ SkinDocument::SkinDocument(QWidget *parent) :
saved = "";
}
+SkinDocument::SkinDocument(QString file, QWidget *parent):
+ QWidget(parent), fileName(file)
+{
+ setupUI();
+
+ /* Loading the file */
+ if(QFile::exists(fileName))
+ {
+ QFile fin(fileName);
+ fin.open(QFile::ReadOnly);
+ editor->document()->setPlainText(QString(fin.readAll()));
+ saved = editor->document()->toPlainText();
+ fin.close();
+ }
+
+ /* Setting the title */
+ QStringList decomposed = fileName.split('/');
+ title = decomposed.last();
+}
+
SkinDocument::~SkinDocument()
{
delete highlighter;
@@ -126,7 +144,7 @@ void SkinDocument::save()
saved = editor->document()->toPlainText();
QStringList decompose = fileName.split('/');
- title = decompose[decompose.count() - 1];
+ title = decompose.last();
emit titleChanged(title);
}
diff --git a/utils/themeeditor/skindocument.h b/utils/themeeditor/skindocument.h
index 4546c42edb..84d12df6a9 100644
--- a/utils/themeeditor/skindocument.h
+++ b/utils/themeeditor/skindocument.h
@@ -44,6 +44,7 @@ public:
}
SkinDocument(QWidget *parent = 0);
+ SkinDocument(QString file, QWidget* parent = 0);
virtual ~SkinDocument();
ParseTreeModel* getModel(){ return model; }