summaryrefslogtreecommitdiff
path: root/utils
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 /utils
parentd41a6810533f5508a18ce7e02cb34b8c37e371cc (diff)
downloadrockbox-4051b34039e079c0969904887fdcabd68bcad681.tar.gz
rockbox-4051b34039e079c0969904887fdcabd68bcad681.zip
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
Diffstat (limited to 'utils')
-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 a2fc11afdf..cadc6313a9 100644
--- a/utils/themeeditor/editorwindow.cpp
+++ b/utils/themeeditor/editorwindow.cpp
@@ -106,6 +106,10 @@ void EditorWindow::newTab()
106{ 106{
107 SkinDocument* doc = new SkinDocument; 107 SkinDocument* doc = new SkinDocument;
108 ui->editorTabs->addTab(doc, doc->getTitle()); 108 ui->editorTabs->addTab(doc, doc->getTitle());
109
110 /* Connecting to title change events */
111 QObject::connect(doc, SIGNAL(titleChanged(QString)),
112 this, SLOT(tabTitleChanged(QString)));
109} 113}
110 114
111void EditorWindow::shiftTab(int index) 115void EditorWindow::shiftTab(int index)
@@ -128,6 +132,12 @@ void EditorWindow::closeTab(int index)
128 } 132 }
129} 133}
130 134
135void EditorWindow::tabTitleChanged(QString title)
136{
137 SkinDocument* sender = dynamic_cast<SkinDocument*>(QObject::sender());
138 ui->editorTabs->setTabText(ui->editorTabs->indexOf(sender), title);
139}
140
131void EditorWindow::showPanel() 141void EditorWindow::showPanel()
132{ 142{
133 if(sender() == ui->actionFile_Panel) 143 if(sender() == ui->actionFile_Panel)
diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h
index 1c02bb378d..52076b61a2 100644
--- a/utils/themeeditor/editorwindow.h
+++ b/utils/themeeditor/editorwindow.h
@@ -46,6 +46,7 @@ private slots:
46 void newTab(); 46 void newTab();
47 void shiftTab(int index); 47 void shiftTab(int index);
48 void closeTab(int index); 48 void closeTab(int index);
49 void tabTitleChanged(QString title);
49 50
50private: 51private:
51 /* Setup functions */ 52 /* Setup functions */
diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp
index 5391f9155d..2e4f6f464b 100644
--- a/utils/themeeditor/skindocument.cpp
+++ b/utils/themeeditor/skindocument.cpp
@@ -21,12 +21,18 @@
21 21
22#include "skindocument.h" 22#include "skindocument.h"
23 23
24#include <QFile>
25#include <QTimer>
26#include <QSettings>
27
24SkinDocument::SkinDocument(QWidget *parent) : 28SkinDocument::SkinDocument(QWidget *parent) :
25 QWidget(parent) 29 QWidget(parent)
26{ 30{
27 setupUI(); 31 setupUI();
28 32
29 title = "Untitled"; 33 title = "Untitled";
34 fileName = "";
35 saved = true;
30} 36}
31 37
32SkinDocument::~SkinDocument() 38SkinDocument::~SkinDocument()
@@ -65,4 +71,33 @@ void SkinDocument::setupUI()
65void SkinDocument::codeChanged() 71void SkinDocument::codeChanged()
66{ 72{
67 model->changeTree(editor->document()->toPlainText().toAscii()); 73 model->changeTree(editor->document()->toPlainText().toAscii());
74 if(saved == true)
75 {
76 saved = false;
77 title.append(tr("*"));
78 emit titleChanged(title);
79 }
80}
81
82void SkinDocument::save()
83{
84 QFile fout(fileName);
85
86 if(!fout.exists())
87 {
88 QTimer::singleShot(0, this, SLOT(saveAs()));
89 return;
90 }
91
92 fout.open(QFile::WriteOnly);
93 fout.write(editor->document()->toPlainText().toAscii());
94 fout.close();
95
96 saved = true;
97}
98
99void SkinDocument::saveAs()
100{
101 /* Determining the directory to open */
102
68} 103}
diff --git a/utils/themeeditor/skindocument.h b/utils/themeeditor/skindocument.h
index e15dd613fd..37f1443ece 100644
--- a/utils/themeeditor/skindocument.h
+++ b/utils/themeeditor/skindocument.h
@@ -42,6 +42,11 @@ public:
42 bool requestClose(); 42 bool requestClose();
43 43
44signals: 44signals:
45 void titleChanged(QString);
46
47public slots:
48 void save();
49 void saveAs();
45 50
46private slots: 51private slots:
47 void codeChanged(); 52 void codeChanged();
@@ -50,6 +55,8 @@ private:
50 void setupUI(); 55 void setupUI();
51 56
52 QString title; 57 QString title;
58 QString fileName;
59 bool saved;
53 60
54 QLayout* layout; 61 QLayout* layout;
55 QPlainTextEdit* editor; 62 QPlainTextEdit* editor;