summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-05 08:22:30 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-05 08:22:30 +0000
commit4051b34039e079c0969904887fdcabd68bcad681 (patch)
tree3f3ff866ec2d284aafb7b9c5a51006438cc8cb6d
parentd41a6810533f5508a18ce7e02cb34b8c37e371cc (diff)
downloadrockbox-4051b34039e079c0969904887fdcabd68bcad681.zip
rockbox-4051b34039e079c0969904887fdcabd68bcad681.tar.gz
rockbox-4051b34039e079c0969904887fdcabd68bcad681.tar.bz2
rockbox-4051b34039e079c0969904887fdcabd68bcad681.tar.xz
Theme Editor: Got document title change signal working, beginning work on save function
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26567 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--utils/themeeditor/editorwindow.cpp10
-rw-r--r--utils/themeeditor/editorwindow.h1
-rw-r--r--utils/themeeditor/skindocument.cpp35
-rw-r--r--utils/themeeditor/skindocument.h7
4 files changed, 53 insertions, 0 deletions
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp
index a2fc11a..cadc631 100644
--- a/utils/themeeditor/editorwindow.cpp
+++ b/utils/themeeditor/editorwindow.cpp
@@ -106,6 +106,10 @@ void EditorWindow::newTab()
{
SkinDocument* doc = new SkinDocument;
ui->editorTabs->addTab(doc, doc->getTitle());
+
+ /* Connecting to title change events */
+ QObject::connect(doc, SIGNAL(titleChanged(QString)),
+ this, SLOT(tabTitleChanged(QString)));
}
void EditorWindow::shiftTab(int index)
@@ -128,6 +132,12 @@ void EditorWindow::closeTab(int index)
}
}
+void EditorWindow::tabTitleChanged(QString title)
+{
+ SkinDocument* sender = dynamic_cast<SkinDocument*>(QObject::sender());
+ ui->editorTabs->setTabText(ui->editorTabs->indexOf(sender), title);
+}
+
void EditorWindow::showPanel()
{
if(sender() == ui->actionFile_Panel)
diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h
index 1c02bb3..52076b6 100644
--- a/utils/themeeditor/editorwindow.h
+++ b/utils/themeeditor/editorwindow.h
@@ -46,6 +46,7 @@ private slots:
void newTab();
void shiftTab(int index);
void closeTab(int index);
+ void tabTitleChanged(QString title);
private:
/* Setup functions */
diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp
index 5391f91..2e4f6f4 100644
--- a/utils/themeeditor/skindocument.cpp
+++ b/utils/themeeditor/skindocument.cpp
@@ -21,12 +21,18 @@
#include "skindocument.h"
+#include <QFile>
+#include <QTimer>
+#include <QSettings>
+
SkinDocument::SkinDocument(QWidget *parent) :
QWidget(parent)
{
setupUI();
title = "Untitled";
+ fileName = "";
+ saved = true;
}
SkinDocument::~SkinDocument()
@@ -65,4 +71,33 @@ void SkinDocument::setupUI()
void SkinDocument::codeChanged()
{
model->changeTree(editor->document()->toPlainText().toAscii());
+ if(saved == true)
+ {
+ saved = false;
+ title.append(tr("*"));
+ emit titleChanged(title);
+ }
+}
+
+void SkinDocument::save()
+{
+ QFile fout(fileName);
+
+ if(!fout.exists())
+ {
+ QTimer::singleShot(0, this, SLOT(saveAs()));
+ return;
+ }
+
+ fout.open(QFile::WriteOnly);
+ fout.write(editor->document()->toPlainText().toAscii());
+ fout.close();
+
+ saved = true;
+}
+
+void SkinDocument::saveAs()
+{
+ /* Determining the directory to open */
+
}
diff --git a/utils/themeeditor/skindocument.h b/utils/themeeditor/skindocument.h
index e15dd61..37f1443 100644
--- a/utils/themeeditor/skindocument.h
+++ b/utils/themeeditor/skindocument.h
@@ -42,6 +42,11 @@ public:
bool requestClose();
signals:
+ void titleChanged(QString);
+
+public slots:
+ void save();
+ void saveAs();
private slots:
void codeChanged();
@@ -50,6 +55,8 @@ private:
void setupUI();
QString title;
+ QString fileName;
+ bool saved;
QLayout* layout;
QPlainTextEdit* editor;