diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/themeeditor/editorwindow.cpp | 63 | ||||
-rw-r--r-- | utils/themeeditor/editorwindow.h | 49 | ||||
-rw-r--r-- | utils/themeeditor/editorwindow.ui | 87 | ||||
-rw-r--r-- | utils/themeeditor/main.cpp | 14 | ||||
-rw-r--r-- | utils/themeeditor/parsetreemodel.cpp | 2 | ||||
-rw-r--r-- | utils/themeeditor/parsetreemodel.h | 2 | ||||
-rw-r--r-- | utils/themeeditor/parsetreenode.cpp | 5 | ||||
-rw-r--r-- | utils/themeeditor/skin_parser.c | 16 | ||||
-rw-r--r-- | utils/themeeditor/skin_parser.h | 2 | ||||
-rw-r--r-- | utils/themeeditor/themeeditor.pro | 7 |
10 files changed, 219 insertions, 28 deletions
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp new file mode 100644 index 0000000000..42ca22cec2 --- /dev/null +++ b/utils/themeeditor/editorwindow.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 "editorwindow.h" | ||
23 | #include "ui_editorwindow.h" | ||
24 | |||
25 | #include <iostream> | ||
26 | |||
27 | EditorWindow::EditorWindow(QWidget *parent) : | ||
28 | QMainWindow(parent), | ||
29 | ui(new Ui::EditorWindow) | ||
30 | { | ||
31 | ui->setupUi(this); | ||
32 | |||
33 | tree = 0; | ||
34 | |||
35 | /* Connecting the buttons */ | ||
36 | QObject::connect(ui->code, SIGNAL(cursorPositionChanged()), | ||
37 | this, SLOT(updateTree())); | ||
38 | QObject::connect(ui->fromTree, SIGNAL(pressed()), | ||
39 | this, SLOT(updateCode())); | ||
40 | } | ||
41 | |||
42 | void EditorWindow::updateTree() | ||
43 | { | ||
44 | if(tree) | ||
45 | delete tree; | ||
46 | |||
47 | tree = new ParseTreeModel(ui->code->document()->toPlainText().toAscii()); | ||
48 | ui->parseTree->setModel(tree); | ||
49 | ui->parseTree->expandAll(); | ||
50 | } | ||
51 | |||
52 | void EditorWindow::updateCode() | ||
53 | { | ||
54 | tree->genCode(); | ||
55 | ui->code->setDocument(new QTextDocument(tree->genCode())); | ||
56 | } | ||
57 | |||
58 | EditorWindow::~EditorWindow() | ||
59 | { | ||
60 | delete ui; | ||
61 | if(tree) | ||
62 | delete tree; | ||
63 | } | ||
diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h new file mode 100644 index 0000000000..03cdf66caf --- /dev/null +++ b/utils/themeeditor/editorwindow.h | |||
@@ -0,0 +1,49 @@ | |||
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 EDITORWINDOW_H | ||
23 | #define EDITORWINDOW_H | ||
24 | |||
25 | #include <QMainWindow> | ||
26 | |||
27 | #include "parsetreemodel.h" | ||
28 | |||
29 | namespace Ui { | ||
30 | class EditorWindow; | ||
31 | } | ||
32 | |||
33 | class EditorWindow : public QMainWindow { | ||
34 | Q_OBJECT | ||
35 | public: | ||
36 | EditorWindow(QWidget *parent = 0); | ||
37 | ~EditorWindow(); | ||
38 | |||
39 | private slots: | ||
40 | void updateCode(); | ||
41 | void updateTree(); | ||
42 | |||
43 | private: | ||
44 | Ui::EditorWindow *ui; | ||
45 | ParseTreeModel* tree; | ||
46 | |||
47 | }; | ||
48 | |||
49 | #endif // EDITORWINDOW_H | ||
diff --git a/utils/themeeditor/editorwindow.ui b/utils/themeeditor/editorwindow.ui new file mode 100644 index 0000000000..35ff3738c9 --- /dev/null +++ b/utils/themeeditor/editorwindow.ui | |||
@@ -0,0 +1,87 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ui version="4.0"> | ||
3 | <class>EditorWindow</class> | ||
4 | <widget class="QMainWindow" name="EditorWindow"> | ||
5 | <property name="geometry"> | ||
6 | <rect> | ||
7 | <x>0</x> | ||
8 | <y>0</y> | ||
9 | <width>800</width> | ||
10 | <height>400</height> | ||
11 | </rect> | ||
12 | </property> | ||
13 | <property name="windowTitle"> | ||
14 | <string>MainWindow</string> | ||
15 | </property> | ||
16 | <widget class="QWidget" name="centralwidget"> | ||
17 | <layout class="QHBoxLayout" name="horizontalLayout"> | ||
18 | <item> | ||
19 | <layout class="QVBoxLayout" name="verticalLayout_2"> | ||
20 | <item> | ||
21 | <widget class="QTreeView" name="parseTree"/> | ||
22 | </item> | ||
23 | <item> | ||
24 | <widget class="QPushButton" name="fromTree"> | ||
25 | <property name="text"> | ||
26 | <string>Update Code</string> | ||
27 | </property> | ||
28 | </widget> | ||
29 | </item> | ||
30 | </layout> | ||
31 | </item> | ||
32 | <item> | ||
33 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
34 | <item> | ||
35 | <widget class="QTextEdit" name="code"/> | ||
36 | </item> | ||
37 | </layout> | ||
38 | </item> | ||
39 | </layout> | ||
40 | </widget> | ||
41 | <widget class="QMenuBar" name="menubar"> | ||
42 | <property name="geometry"> | ||
43 | <rect> | ||
44 | <x>0</x> | ||
45 | <y>0</y> | ||
46 | <width>800</width> | ||
47 | <height>25</height> | ||
48 | </rect> | ||
49 | </property> | ||
50 | <widget class="QMenu" name="menuFile"> | ||
51 | <property name="title"> | ||
52 | <string>File</string> | ||
53 | </property> | ||
54 | <addaction name="actionQuit"/> | ||
55 | </widget> | ||
56 | <addaction name="menuFile"/> | ||
57 | </widget> | ||
58 | <widget class="QStatusBar" name="statusbar"/> | ||
59 | <action name="actionQuit"> | ||
60 | <property name="text"> | ||
61 | <string>Quit</string> | ||
62 | </property> | ||
63 | <property name="shortcut"> | ||
64 | <string>Ctrl+Q</string> | ||
65 | </property> | ||
66 | </action> | ||
67 | </widget> | ||
68 | <resources/> | ||
69 | <connections> | ||
70 | <connection> | ||
71 | <sender>actionQuit</sender> | ||
72 | <signal>activated()</signal> | ||
73 | <receiver>EditorWindow</receiver> | ||
74 | <slot>close()</slot> | ||
75 | <hints> | ||
76 | <hint type="sourcelabel"> | ||
77 | <x>65</x> | ||
78 | <y>57</y> | ||
79 | </hint> | ||
80 | <hint type="destinationlabel"> | ||
81 | <x>299</x> | ||
82 | <y>199</y> | ||
83 | </hint> | ||
84 | </hints> | ||
85 | </connection> | ||
86 | </connections> | ||
87 | </ui> | ||
diff --git a/utils/themeeditor/main.cpp b/utils/themeeditor/main.cpp index 87d38b861d..3f7379e0dd 100644 --- a/utils/themeeditor/main.cpp +++ b/utils/themeeditor/main.cpp | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include "skin_parser.h" | 22 | #include "skin_parser.h" |
23 | #include "skin_debug.h" | 23 | #include "skin_debug.h" |
24 | #include "editorwindow.h" | ||
24 | 25 | ||
25 | #include <cstdlib> | 26 | #include <cstdlib> |
26 | #include <cstdio> | 27 | #include <cstdio> |
@@ -35,17 +36,8 @@ int main(int argc, char* argv[]) | |||
35 | { | 36 | { |
36 | QApplication app(argc, argv); | 37 | QApplication app(argc, argv); |
37 | 38 | ||
38 | char doc[] = "#Comment\n" | 39 | EditorWindow mainWindow; |
39 | "%Vd(U);Hey\n" | 40 | mainWindow.show(); |
40 | "%?bl(test,3,5,2,1)<param2|param3>\n" | ||
41 | "%V(1,2,3,4,5)%pS(5)\n" | ||
42 | "Some more stuff here"; | ||
43 | |||
44 | ParseTreeModel tree(doc); | ||
45 | |||
46 | QTreeView view; | ||
47 | view.setModel(&tree); | ||
48 | view.show(); | ||
49 | 41 | ||
50 | return app.exec(); | 42 | return app.exec(); |
51 | 43 | ||
diff --git a/utils/themeeditor/parsetreemodel.cpp b/utils/themeeditor/parsetreemodel.cpp index 24eebac8d6..9faa9ea560 100644 --- a/utils/themeeditor/parsetreemodel.cpp +++ b/utils/themeeditor/parsetreemodel.cpp | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | #include <QObject> | 28 | #include <QObject> |
29 | 29 | ||
30 | ParseTreeModel::ParseTreeModel(char* document, QObject* parent): | 30 | ParseTreeModel::ParseTreeModel(const char* document, QObject* parent): |
31 | QAbstractItemModel(parent) | 31 | QAbstractItemModel(parent) |
32 | { | 32 | { |
33 | this->tree = skin_parse(document); | 33 | this->tree = skin_parse(document); |
diff --git a/utils/themeeditor/parsetreemodel.h b/utils/themeeditor/parsetreemodel.h index 6d1f153d25..4c448ce558 100644 --- a/utils/themeeditor/parsetreemodel.h +++ b/utils/themeeditor/parsetreemodel.h | |||
@@ -43,7 +43,7 @@ public: | |||
43 | static const int valueColumn = 2; | 43 | static const int valueColumn = 2; |
44 | 44 | ||
45 | /* Initializes a tree with a skin document in a string */ | 45 | /* Initializes a tree with a skin document in a string */ |
46 | ParseTreeModel(char* document, QObject* parent = 0); | 46 | ParseTreeModel(const char* document, QObject* parent = 0); |
47 | virtual ~ParseTreeModel(); | 47 | virtual ~ParseTreeModel(); |
48 | 48 | ||
49 | QString genCode(); | 49 | QString genCode(); |
diff --git a/utils/themeeditor/parsetreenode.cpp b/utils/themeeditor/parsetreenode.cpp index 22db94da89..41cdf3ca24 100644 --- a/utils/themeeditor/parsetreenode.cpp +++ b/utils/themeeditor/parsetreenode.cpp | |||
@@ -19,11 +19,8 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | extern "C" | ||
23 | { | ||
24 | #include "symbols.h" | 22 | #include "symbols.h" |
25 | #include "tag_table.h" | 23 | #include "tag_table.h" |
26 | } | ||
27 | 24 | ||
28 | #include "parsetreenode.h" | 25 | #include "parsetreenode.h" |
29 | #include "parsetreemodel.h" | 26 | #include "parsetreemodel.h" |
@@ -100,8 +97,6 @@ QString ParseTreeNode::genCode() const | |||
100 | { | 97 | { |
101 | 98 | ||
102 | case VIEWPORT: | 99 | case VIEWPORT: |
103 | buffer.append(children[0]->genCode()); | ||
104 | |||
105 | case LINE: | 100 | case LINE: |
106 | for(int i = 0; i < children.count(); i++) | 101 | for(int i = 0; i < children.count(); i++) |
107 | { | 102 | { |
diff --git a/utils/themeeditor/skin_parser.c b/utils/themeeditor/skin_parser.c index c0f1849523..8e4bc88e96 100644 --- a/utils/themeeditor/skin_parser.c +++ b/utils/themeeditor/skin_parser.c | |||
@@ -53,7 +53,7 @@ int skin_parse_newline(struct skin_element* element, char** document); | |||
53 | int skin_parse_comment(struct skin_element* element, char** document); | 53 | int skin_parse_comment(struct skin_element* element, char** document); |
54 | struct skin_element* skin_parse_code_as_arg(char** document); | 54 | struct skin_element* skin_parse_code_as_arg(char** document); |
55 | 55 | ||
56 | struct skin_element* skin_parse(char* document) | 56 | struct skin_element* skin_parse(const char* document) |
57 | { | 57 | { |
58 | 58 | ||
59 | struct skin_element* root = NULL; | 59 | struct skin_element* root = NULL; |
@@ -61,7 +61,7 @@ struct skin_element* skin_parse(char* document) | |||
61 | 61 | ||
62 | struct skin_element** to_write = 0; | 62 | struct skin_element** to_write = 0; |
63 | 63 | ||
64 | char* cursor = document; /* Keeps track of location in the document */ | 64 | char* cursor = (char*)document; /*Keeps track of location in the document*/ |
65 | 65 | ||
66 | skin_line = 1; | 66 | skin_line = 1; |
67 | 67 | ||
@@ -738,18 +738,20 @@ int skin_parse_comment(struct skin_element* element, char** document) | |||
738 | */ | 738 | */ |
739 | for(length = 0; cursor[length] != '\n' && cursor[length] != '\0'; length++); | 739 | for(length = 0; cursor[length] != '\n' && cursor[length] != '\0'; length++); |
740 | 740 | ||
741 | length--; | ||
742 | element->type = COMMENT; | 741 | element->type = COMMENT; |
743 | element->line = skin_line; | 742 | element->line = skin_line; |
744 | element->text = skin_alloc_string(length); | 743 | element->text = skin_alloc_string(length); |
745 | /* We copy from one char past cursor to leave out the # */ | 744 | /* We copy from one char past cursor to leave out the # */ |
746 | memcpy((void*)(element->text), (void*)(cursor + 1), sizeof(char) * length); | 745 | memcpy((void*)(element->text), (void*)(cursor + 1), |
747 | element->text[length] = '\0'; | 746 | sizeof(char) * (length-1)); |
747 | element->text[length - 1] = '\0'; | ||
748 | 748 | ||
749 | if(cursor[length + 1] == '\n') | 749 | if(cursor[length] == '\n') |
750 | skin_line++; | 750 | skin_line++; |
751 | 751 | ||
752 | *document += (length + 2); /* Move cursor up past # and all text */ | 752 | *document += (length); /* Move cursor up past # and all text */ |
753 | if(**document == '\n') | ||
754 | (*document)++; | ||
753 | 755 | ||
754 | return 1; | 756 | return 1; |
755 | } | 757 | } |
diff --git a/utils/themeeditor/skin_parser.h b/utils/themeeditor/skin_parser.h index cd50b996c0..ca2d7bc54b 100644 --- a/utils/themeeditor/skin_parser.h +++ b/utils/themeeditor/skin_parser.h | |||
@@ -123,7 +123,7 @@ struct skin_element | |||
123 | 123 | ||
124 | /* Parses a WPS document and returns a list of skin_element | 124 | /* Parses a WPS document and returns a list of skin_element |
125 | structures. */ | 125 | structures. */ |
126 | struct skin_element* skin_parse(char* document); | 126 | struct skin_element* skin_parse(const char* document); |
127 | 127 | ||
128 | /* Memory management functions */ | 128 | /* Memory management functions */ |
129 | struct skin_element* skin_alloc_element(); | 129 | struct skin_element* skin_alloc_element(); |
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro index b1c7688130..5b1ab34ca2 100644 --- a/utils/themeeditor/themeeditor.pro +++ b/utils/themeeditor/themeeditor.pro | |||
@@ -4,12 +4,15 @@ HEADERS += tag_table.h \ | |||
4 | skin_scan.h \ | 4 | skin_scan.h \ |
5 | skin_debug.h \ | 5 | skin_debug.h \ |
6 | parsetreemodel.h \ | 6 | parsetreemodel.h \ |
7 | parsetreenode.h | 7 | parsetreenode.h \ |
8 | editorwindow.h | ||
8 | SOURCES += tag_table.c \ | 9 | SOURCES += tag_table.c \ |
9 | skin_parser.c \ | 10 | skin_parser.c \ |
10 | skin_scan.c \ | 11 | skin_scan.c \ |
11 | skin_debug.c \ | 12 | skin_debug.c \ |
12 | main.cpp \ | 13 | main.cpp \ |
13 | parsetreemodel.cpp \ | 14 | parsetreemodel.cpp \ |
14 | parsetreenode.cpp | 15 | parsetreenode.cpp \ |
16 | editorwindow.cpp | ||
15 | OTHER_FILES += README | 17 | OTHER_FILES += README |
18 | FORMS += editorwindow.ui | ||