summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/editorwindow.cpp13
-rw-r--r--utils/themeeditor/editorwindow.h6
-rw-r--r--utils/themeeditor/editorwindow.ui3
-rw-r--r--utils/themeeditor/main.cpp14
-rw-r--r--utils/themeeditor/skindocument.cpp63
-rw-r--r--utils/themeeditor/skindocument.h59
-rw-r--r--utils/themeeditor/themeeditor.pro6
7 files changed, 136 insertions, 28 deletions
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp
index c19178a51a..92d400cf78 100644
--- a/utils/themeeditor/editorwindow.cpp
+++ b/utils/themeeditor/editorwindow.cpp
@@ -60,6 +60,7 @@ void EditorWindow::setupUI()
60 /* Connecting the buttons */ 60 /* Connecting the buttons */
61 QObject::connect(ui->fromTree, SIGNAL(pressed()), 61 QObject::connect(ui->fromTree, SIGNAL(pressed()),
62 this, SLOT(updateCode())); 62 this, SLOT(updateCode()));
63
63} 64}
64 65
65void EditorWindow::setupMenus() 66void EditorWindow::setupMenus()
@@ -71,15 +72,17 @@ void EditorWindow::setupMenus()
71 this, SLOT(showPanel())); 72 this, SLOT(showPanel()));
72 QObject::connect(ui->actionPreview_Panel, SIGNAL(triggered()), 73 QObject::connect(ui->actionPreview_Panel, SIGNAL(triggered()),
73 this, SLOT(showPanel())); 74 this, SLOT(showPanel()));
74}
75 75
76void EditorWindow::codeChanged() 76 /* Connecting the document opening/closing actions */
77{ 77 QObject::connect(ui->actionNew_Document, SIGNAL(triggered()),
78 ui->parseTree->expandAll(); 78 this, SLOT(newTab()));
79} 79}
80 80
81void EditorWindow::updateCode() 81
82void EditorWindow::newTab()
82{ 83{
84 SkinDocument* doc = new SkinDocument;
85 ui->editorTabs->addTab(doc, doc->getTitle());
83} 86}
84 87
85void EditorWindow::showPanel() 88void EditorWindow::showPanel()
diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h
index 8cbfd99ede..2b64bde793 100644
--- a/utils/themeeditor/editorwindow.h
+++ b/utils/themeeditor/editorwindow.h
@@ -26,6 +26,7 @@
26 26
27#include "parsetreemodel.h" 27#include "parsetreemodel.h"
28#include "skinhighlighter.h" 28#include "skinhighlighter.h"
29#include "skindocument.h"
29 30
30namespace Ui { 31namespace Ui {
31 class EditorWindow; 32 class EditorWindow;
@@ -41,9 +42,8 @@ protected:
41 virtual void closeEvent(QCloseEvent* event); 42 virtual void closeEvent(QCloseEvent* event);
42 43
43private slots: 44private slots:
44 void updateCode();
45 void codeChanged();
46 void showPanel(); 45 void showPanel();
46 void newTab();
47 47
48private: 48private:
49 /* Setup functions */ 49 /* Setup functions */
@@ -52,8 +52,6 @@ private:
52 void setupMenus(); 52 void setupMenus();
53 53
54 Ui::EditorWindow *ui; 54 Ui::EditorWindow *ui;
55 SkinHighlighter* highlighter;
56
57}; 55};
58 56
59#endif // EDITORWINDOW_H 57#endif // EDITORWINDOW_H
diff --git a/utils/themeeditor/editorwindow.ui b/utils/themeeditor/editorwindow.ui
index c7e89a4a0e..0f6062d7f9 100644
--- a/utils/themeeditor/editorwindow.ui
+++ b/utils/themeeditor/editorwindow.ui
@@ -21,9 +21,6 @@
21 <layout class="QVBoxLayout" name="verticalLayout"> 21 <layout class="QVBoxLayout" name="verticalLayout">
22 <item> 22 <item>
23 <widget class="QTabWidget" name="editorTabs"> 23 <widget class="QTabWidget" name="editorTabs">
24 <property name="tabPosition">
25 <enum>QTabWidget::North</enum>
26 </property>
27 <property name="currentIndex"> 24 <property name="currentIndex">
28 <number>-1</number> 25 <number>-1</number>
29 </property> 26 </property>
diff --git a/utils/themeeditor/main.cpp b/utils/themeeditor/main.cpp
index 3f7379e0dd..152f780a43 100644
--- a/utils/themeeditor/main.cpp
+++ b/utils/themeeditor/main.cpp
@@ -41,19 +41,5 @@ int main(int argc, char* argv[])
41 41
42 return app.exec(); 42 return app.exec();
43 43
44 /*
45 struct skin_element* test = skin_parse(doc);
46
47 ParseTreeModel tree(doc);
48 std::cout << "----" << std::endl;
49 if(std::string(doc) == tree.genCode().toStdString())
50 std::cout << "Code in/out matches" << std::endl;
51 else
52 std::cout << "Match error" << std::endl;
53
54
55 skin_free_tree(test);
56 */
57
58} 44}
59 45
diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp
new file mode 100644
index 0000000000..380f16fa7d
--- /dev/null
+++ b/utils/themeeditor/skindocument.cpp
@@ -0,0 +1,63 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "skindocument.h"
23
24SkinDocument::SkinDocument(QWidget *parent) :
25 QWidget(parent)
26{
27 setupUI();
28
29 title = "Untitled";
30}
31
32SkinDocument::~SkinDocument()
33{
34 delete highlighter;
35 delete model;
36}
37
38void SkinDocument::setupUI()
39{
40 /* Setting up the text edit */
41 layout = new QHBoxLayout;
42 editor = new QPlainTextEdit(this);
43 layout->addWidget(editor);
44
45 setLayout(layout);
46
47 /* Attaching the syntax highlighter */
48 highlighter = new SkinHighlighter(QColor(0,180,0), QColor(255,0,0),
49 QColor(0,0,255), QColor(120,120,120),
50 editor->document());
51
52 /* Setting up the model */
53 model = new ParseTreeModel("");
54
55 /* Connecting the editor's signal */
56 QObject::connect(editor, SIGNAL(textChanged()),
57 this, SLOT(codeChanged()));
58}
59
60void SkinDocument::codeChanged()
61{
62 model->changeTree(editor->document()->toPlainText().toAscii());
63}
diff --git a/utils/themeeditor/skindocument.h b/utils/themeeditor/skindocument.h
new file mode 100644
index 0000000000..5f25d8e292
--- /dev/null
+++ b/utils/themeeditor/skindocument.h
@@ -0,0 +1,59 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef SKINDOCUMENT_H
23#define SKINDOCUMENT_H
24
25#include <QWidget>
26#include <QHBoxLayout>
27#include <QPlainTextEdit>
28
29#include "skinhighlighter.h"
30#include "parsetreemodel.h"
31
32class SkinDocument : public QWidget
33{
34Q_OBJECT
35public:
36 SkinDocument(QWidget *parent = 0);
37 virtual ~SkinDocument();
38
39 ParseTreeModel* getModel(){ return model; }
40 QString getTitle(){ return title; }
41
42signals:
43
44private slots:
45 void codeChanged();
46
47private:
48 void setupUI();
49
50 QString title;
51
52 QLayout* layout;
53 QPlainTextEdit* editor;
54
55 SkinHighlighter* highlighter;
56 ParseTreeModel* model;
57};
58
59#endif // SKINDOCUMENT_H
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro
index 15615004b1..19d9205d7b 100644
--- a/utils/themeeditor/themeeditor.pro
+++ b/utils/themeeditor/themeeditor.pro
@@ -12,7 +12,8 @@ HEADERS += tag_table.h \
12 parsetreemodel.h \ 12 parsetreemodel.h \
13 parsetreenode.h \ 13 parsetreenode.h \
14 editorwindow.h \ 14 editorwindow.h \
15 skinhighlighter.h 15 skinhighlighter.h \
16 skindocument.h
16SOURCES += tag_table.c \ 17SOURCES += tag_table.c \
17 skin_parser.c \ 18 skin_parser.c \
18 skin_scan.c \ 19 skin_scan.c \
@@ -21,7 +22,8 @@ SOURCES += tag_table.c \
21 parsetreemodel.cpp \ 22 parsetreemodel.cpp \
22 parsetreenode.cpp \ 23 parsetreenode.cpp \
23 editorwindow.cpp \ 24 editorwindow.cpp \
24 skinhighlighter.cpp 25 skinhighlighter.cpp \
26 skindocument.cpp
25OTHER_FILES += README \ 27OTHER_FILES += README \
26 resources/windowicon.png \ 28 resources/windowicon.png \
27 resources/appicon.xcf 29 resources/appicon.xcf