diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/themeeditor/editorwindow.cpp | 10 | ||||
-rw-r--r-- | utils/themeeditor/editorwindow.h | 1 | ||||
-rw-r--r-- | utils/themeeditor/skindocument.cpp | 35 | ||||
-rw-r--r-- | utils/themeeditor/skindocument.h | 7 |
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 | ||
111 | void EditorWindow::shiftTab(int index) | 115 | void EditorWindow::shiftTab(int index) |
@@ -128,6 +132,12 @@ void EditorWindow::closeTab(int index) | |||
128 | } | 132 | } |
129 | } | 133 | } |
130 | 134 | ||
135 | void EditorWindow::tabTitleChanged(QString title) | ||
136 | { | ||
137 | SkinDocument* sender = dynamic_cast<SkinDocument*>(QObject::sender()); | ||
138 | ui->editorTabs->setTabText(ui->editorTabs->indexOf(sender), title); | ||
139 | } | ||
140 | |||
131 | void EditorWindow::showPanel() | 141 | void 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 | ||
50 | private: | 51 | private: |
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 | |||
24 | SkinDocument::SkinDocument(QWidget *parent) : | 28 | SkinDocument::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 | ||
32 | SkinDocument::~SkinDocument() | 38 | SkinDocument::~SkinDocument() |
@@ -65,4 +71,33 @@ void SkinDocument::setupUI() | |||
65 | void SkinDocument::codeChanged() | 71 | void 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 | |||
82 | void 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 | |||
99 | void 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 | ||
44 | signals: | 44 | signals: |
45 | void titleChanged(QString); | ||
46 | |||
47 | public slots: | ||
48 | void save(); | ||
49 | void saveAs(); | ||
45 | 50 | ||
46 | private slots: | 51 | private 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; |