diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-07-23 21:15:15 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-07-23 21:15:15 +0000 |
commit | 5297db990412a34dee96de5bf61258ae31f3b4f9 (patch) | |
tree | 8b7d850cf3051549e04492a260049328b55641f5 | |
parent | d15a4f617f7d6e524ef811efef5707958031dc8f (diff) | |
download | rockbox-5297db990412a34dee96de5bf61258ae31f3b4f9.tar.gz rockbox-5297db990412a34dee96de5bf61258ae31f3b4f9.zip |
Theme Editor: Added interface for project export, exporting files to zip is still todo
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27534 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | utils/themeeditor/gui/editorwindow.cpp | 24 | ||||
-rw-r--r-- | utils/themeeditor/gui/editorwindow.h | 1 | ||||
-rw-r--r-- | utils/themeeditor/gui/editorwindow.ui | 14 | ||||
-rw-r--r-- | utils/themeeditor/gui/projectexporter.cpp | 79 | ||||
-rw-r--r-- | utils/themeeditor/gui/projectexporter.h | 58 | ||||
-rw-r--r-- | utils/themeeditor/gui/projectexporter.ui | 58 | ||||
-rw-r--r-- | utils/themeeditor/themeeditor.pro | 9 |
7 files changed, 239 insertions, 4 deletions
diff --git a/utils/themeeditor/gui/editorwindow.cpp b/utils/themeeditor/gui/editorwindow.cpp index 57de72358a..f919224a2f 100644 --- a/utils/themeeditor/gui/editorwindow.cpp +++ b/utils/themeeditor/gui/editorwindow.cpp | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "rbfontcache.h" | 25 | #include "rbfontcache.h" |
26 | #include "rbtextcache.h" | 26 | #include "rbtextcache.h" |
27 | #include "newprojectdialog.h" | 27 | #include "newprojectdialog.h" |
28 | #include "projectexporter.h" | ||
28 | 29 | ||
29 | #include <QDesktopWidget> | 30 | #include <QDesktopWidget> |
30 | #include <QFileSystemModel> | 31 | #include <QFileSystemModel> |
@@ -220,6 +221,8 @@ void EditorWindow::setupMenus() | |||
220 | this, SLOT(saveCurrentAs())); | 221 | this, SLOT(saveCurrentAs())); |
221 | QObject::connect(ui->actionToolbarSave, SIGNAL(triggered()), | 222 | QObject::connect(ui->actionToolbarSave, SIGNAL(triggered()), |
222 | this, SLOT(saveCurrent())); | 223 | this, SLOT(saveCurrent())); |
224 | QObject::connect(ui->actionExport_Project, SIGNAL(triggered()), | ||
225 | this, SLOT(exportProject())); | ||
223 | 226 | ||
224 | QObject::connect(ui->actionOpen_Document, SIGNAL(triggered()), | 227 | QObject::connect(ui->actionOpen_Document, SIGNAL(triggered()), |
225 | this, SLOT(openFile())); | 228 | this, SLOT(openFile())); |
@@ -466,6 +469,7 @@ void EditorWindow::closeProject() | |||
466 | } | 469 | } |
467 | 470 | ||
468 | ui->actionClose_Project->setEnabled(false); | 471 | ui->actionClose_Project->setEnabled(false); |
472 | ui->actionExport_Project->setEnabled(false); | ||
469 | } | 473 | } |
470 | 474 | ||
471 | void EditorWindow::saveCurrent() | 475 | void EditorWindow::saveCurrent() |
@@ -480,6 +484,25 @@ void EditorWindow::saveCurrentAs() | |||
480 | dynamic_cast<TabContent*>(ui->editorTabs->currentWidget())->saveAs(); | 484 | dynamic_cast<TabContent*>(ui->editorTabs->currentWidget())->saveAs(); |
481 | } | 485 | } |
482 | 486 | ||
487 | void EditorWindow::exportProject() | ||
488 | { | ||
489 | QDir dir = project->getSetting("themebase", ""); | ||
490 | dir.cdUp(); | ||
491 | QString file = project->getSetting("configfile", "").split("/"). | ||
492 | last().split(".").first() + ".zip"; | ||
493 | file = dir.filePath(file); | ||
494 | |||
495 | file = QFileDialog::getSaveFileName(this, tr("Export Project"), | ||
496 | file, "Zip Files (*.zip *.ZIP);;" | ||
497 | "All Files (*)"); | ||
498 | |||
499 | if(file != "") | ||
500 | { | ||
501 | ProjectExporter* exporter = new ProjectExporter(file, project, this); | ||
502 | exporter->show(); | ||
503 | } | ||
504 | } | ||
505 | |||
483 | void EditorWindow::openFile() | 506 | void EditorWindow::openFile() |
484 | { | 507 | { |
485 | QStringList fileNames; | 508 | QStringList fileNames; |
@@ -724,6 +747,7 @@ void EditorWindow::loadProjectFile(QString fileName) | |||
724 | project->deleteLater(); | 747 | project->deleteLater(); |
725 | 748 | ||
726 | ui->actionClose_Project->setEnabled(true); | 749 | ui->actionClose_Project->setEnabled(true); |
750 | ui->actionExport_Project->setEnabled(true); | ||
727 | 751 | ||
728 | project = new ProjectModel(fileName, this); | 752 | project = new ProjectModel(fileName, this); |
729 | ui->projectTree->setModel(project); | 753 | ui->projectTree->setModel(project); |
diff --git a/utils/themeeditor/gui/editorwindow.h b/utils/themeeditor/gui/editorwindow.h index 55e18732d0..996ddcd40e 100644 --- a/utils/themeeditor/gui/editorwindow.h +++ b/utils/themeeditor/gui/editorwindow.h | |||
@@ -72,6 +72,7 @@ private slots: | |||
72 | void closeProject(); | 72 | void closeProject(); |
73 | void saveCurrent(); | 73 | void saveCurrent(); |
74 | void saveCurrentAs(); | 74 | void saveCurrentAs(); |
75 | void exportProject(); | ||
75 | void openFile(); | 76 | void openFile(); |
76 | void openProject(); | 77 | void openProject(); |
77 | void tabTitleChanged(QString title); | 78 | void tabTitleChanged(QString title); |
diff --git a/utils/themeeditor/gui/editorwindow.ui b/utils/themeeditor/gui/editorwindow.ui index a7246b9def..edfdfe3d84 100644 --- a/utils/themeeditor/gui/editorwindow.ui +++ b/utils/themeeditor/gui/editorwindow.ui | |||
@@ -40,7 +40,7 @@ | |||
40 | <x>0</x> | 40 | <x>0</x> |
41 | <y>0</y> | 41 | <y>0</y> |
42 | <width>628</width> | 42 | <width>628</width> |
43 | <height>27</height> | 43 | <height>25</height> |
44 | </rect> | 44 | </rect> |
45 | </property> | 45 | </property> |
46 | <widget class="QMenu" name="menuFile"> | 46 | <widget class="QMenu" name="menuFile"> |
@@ -57,6 +57,7 @@ | |||
57 | <addaction name="separator"/> | 57 | <addaction name="separator"/> |
58 | <addaction name="actionSave_Document"/> | 58 | <addaction name="actionSave_Document"/> |
59 | <addaction name="actionSave_Document_As"/> | 59 | <addaction name="actionSave_Document_As"/> |
60 | <addaction name="actionExport_Project"/> | ||
60 | <addaction name="separator"/> | 61 | <addaction name="separator"/> |
61 | <addaction name="actionPreferences"/> | 62 | <addaction name="actionPreferences"/> |
62 | <addaction name="separator"/> | 63 | <addaction name="separator"/> |
@@ -395,6 +396,17 @@ | |||
395 | <string>Ctrl+Shift+N</string> | 396 | <string>Ctrl+Shift+N</string> |
396 | </property> | 397 | </property> |
397 | </action> | 398 | </action> |
399 | <action name="actionExport_Project"> | ||
400 | <property name="enabled"> | ||
401 | <bool>false</bool> | ||
402 | </property> | ||
403 | <property name="text"> | ||
404 | <string>E&xport Project</string> | ||
405 | </property> | ||
406 | <property name="shortcut"> | ||
407 | <string>Ctrl+Shift+X</string> | ||
408 | </property> | ||
409 | </action> | ||
398 | </widget> | 410 | </widget> |
399 | <tabstops> | 411 | <tabstops> |
400 | <tabstop>projectTree</tabstop> | 412 | <tabstop>projectTree</tabstop> |
diff --git a/utils/themeeditor/gui/projectexporter.cpp b/utils/themeeditor/gui/projectexporter.cpp new file mode 100644 index 0000000000..b9718d11c5 --- /dev/null +++ b/utils/themeeditor/gui/projectexporter.cpp | |||
@@ -0,0 +1,79 @@ | |||
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 "projectexporter.h" | ||
23 | #include "ui_projectexporter.h" | ||
24 | |||
25 | ProjectExporter::ProjectExporter(QString path, ProjectModel* project, | ||
26 | QWidget *parent) | ||
27 | :QDialog(parent), | ||
28 | ui(new Ui::ProjectExporter), zipFile(path) | ||
29 | { | ||
30 | ui->setupUi(this); | ||
31 | |||
32 | QObject::connect(ui->closeButton, SIGNAL(clicked()), | ||
33 | this, SLOT(close())); | ||
34 | |||
35 | if(zipFile.open(QuaZip::mdCreate)) | ||
36 | { | ||
37 | writeZip(project); | ||
38 | } | ||
39 | else | ||
40 | { | ||
41 | html += tr("<span style = \"color:red\">Error opening zip file</span><br>"); | ||
42 | ui->statusBox->document()->setHtml(html); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | ProjectExporter::~ProjectExporter() | ||
47 | { | ||
48 | delete ui; | ||
49 | } | ||
50 | |||
51 | void ProjectExporter::changeEvent(QEvent *e) | ||
52 | { | ||
53 | QDialog::changeEvent(e); | ||
54 | switch (e->type()) { | ||
55 | case QEvent::LanguageChange: | ||
56 | ui->retranslateUi(this); | ||
57 | break; | ||
58 | default: | ||
59 | break; | ||
60 | } | ||
61 | } | ||
62 | |||
63 | void ProjectExporter::closeEvent(QCloseEvent *event) | ||
64 | { | ||
65 | close(); | ||
66 | event->accept(); | ||
67 | } | ||
68 | |||
69 | void ProjectExporter::close() | ||
70 | { | ||
71 | deleteLater(); | ||
72 | hide(); | ||
73 | } | ||
74 | |||
75 | void ProjectExporter::writeZip(ProjectModel *project) | ||
76 | { | ||
77 | (void)project; | ||
78 | zipFile.close(); | ||
79 | } | ||
diff --git a/utils/themeeditor/gui/projectexporter.h b/utils/themeeditor/gui/projectexporter.h new file mode 100644 index 0000000000..4012d384ac --- /dev/null +++ b/utils/themeeditor/gui/projectexporter.h | |||
@@ -0,0 +1,58 @@ | |||
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 PROJECTEXPORTER_H | ||
23 | #define PROJECTEXPORTER_H | ||
24 | |||
25 | #include <QDialog> | ||
26 | #include <QCloseEvent> | ||
27 | #include <QFile> | ||
28 | |||
29 | #include "quazip.h" | ||
30 | |||
31 | #include "projectmodel.h" | ||
32 | |||
33 | namespace Ui { | ||
34 | class ProjectExporter; | ||
35 | } | ||
36 | |||
37 | class ProjectExporter : public QDialog { | ||
38 | Q_OBJECT | ||
39 | public: | ||
40 | ProjectExporter(QString path, ProjectModel* project, QWidget *parent = 0); | ||
41 | ~ProjectExporter(); | ||
42 | |||
43 | protected: | ||
44 | void changeEvent(QEvent *e); | ||
45 | void closeEvent(QCloseEvent *event); | ||
46 | |||
47 | private slots: | ||
48 | void close(); | ||
49 | |||
50 | private: | ||
51 | void writeZip(ProjectModel* project); | ||
52 | |||
53 | Ui::ProjectExporter *ui; | ||
54 | QuaZip zipFile; | ||
55 | QString html; | ||
56 | }; | ||
57 | |||
58 | #endif // PROJECTEXPORTER_H | ||
diff --git a/utils/themeeditor/gui/projectexporter.ui b/utils/themeeditor/gui/projectexporter.ui new file mode 100644 index 0000000000..cb47ce91f4 --- /dev/null +++ b/utils/themeeditor/gui/projectexporter.ui | |||
@@ -0,0 +1,58 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ui version="4.0"> | ||
3 | <class>ProjectExporter</class> | ||
4 | <widget class="QDialog" name="ProjectExporter"> | ||
5 | <property name="geometry"> | ||
6 | <rect> | ||
7 | <x>0</x> | ||
8 | <y>0</y> | ||
9 | <width>400</width> | ||
10 | <height>300</height> | ||
11 | </rect> | ||
12 | </property> | ||
13 | <property name="windowTitle"> | ||
14 | <string>Exporting Project</string> | ||
15 | </property> | ||
16 | <property name="windowIcon"> | ||
17 | <iconset resource="../resources.qrc"> | ||
18 | <normaloff>:/resources/windowicon.png</normaloff>:/resources/windowicon.png</iconset> | ||
19 | </property> | ||
20 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
21 | <item> | ||
22 | <widget class="QPlainTextEdit" name="statusBox"> | ||
23 | <property name="readOnly"> | ||
24 | <bool>true</bool> | ||
25 | </property> | ||
26 | </widget> | ||
27 | </item> | ||
28 | <item> | ||
29 | <layout class="QHBoxLayout" name="horizontalLayout"> | ||
30 | <item> | ||
31 | <spacer name="horizontalSpacer"> | ||
32 | <property name="orientation"> | ||
33 | <enum>Qt::Horizontal</enum> | ||
34 | </property> | ||
35 | <property name="sizeHint" stdset="0"> | ||
36 | <size> | ||
37 | <width>40</width> | ||
38 | <height>20</height> | ||
39 | </size> | ||
40 | </property> | ||
41 | </spacer> | ||
42 | </item> | ||
43 | <item> | ||
44 | <widget class="QPushButton" name="closeButton"> | ||
45 | <property name="text"> | ||
46 | <string>Close</string> | ||
47 | </property> | ||
48 | </widget> | ||
49 | </item> | ||
50 | </layout> | ||
51 | </item> | ||
52 | </layout> | ||
53 | </widget> | ||
54 | <resources> | ||
55 | <include location="../resources.qrc"/> | ||
56 | </resources> | ||
57 | <connections/> | ||
58 | </ui> | ||
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro index a8df4fcff6..3d9ddca694 100644 --- a/utils/themeeditor/themeeditor.pro +++ b/utils/themeeditor/themeeditor.pro | |||
@@ -92,7 +92,8 @@ HEADERS += models/parsetreemodel.h \ | |||
92 | qtfindreplacedialog/findreplaceform.h \ | 92 | qtfindreplacedialog/findreplaceform.h \ |
93 | qtfindreplacedialog/findreplacedialog.h \ | 93 | qtfindreplacedialog/findreplacedialog.h \ |
94 | qtfindreplacedialog/findform.h \ | 94 | qtfindreplacedialog/findform.h \ |
95 | qtfindreplacedialog/finddialog.h | 95 | qtfindreplacedialog/finddialog.h \ |
96 | gui/projectexporter.h | ||
96 | SOURCES += main.cpp \ | 97 | SOURCES += main.cpp \ |
97 | models/parsetreemodel.cpp \ | 98 | models/parsetreemodel.cpp \ |
98 | models/parsetreenode.cpp \ | 99 | models/parsetreenode.cpp \ |
@@ -130,7 +131,8 @@ SOURCES += main.cpp \ | |||
130 | qtfindreplacedialog/findreplaceform.cpp \ | 131 | qtfindreplacedialog/findreplaceform.cpp \ |
131 | qtfindreplacedialog/findreplacedialog.cpp \ | 132 | qtfindreplacedialog/findreplacedialog.cpp \ |
132 | qtfindreplacedialog/findform.cpp \ | 133 | qtfindreplacedialog/findform.cpp \ |
133 | qtfindreplacedialog/finddialog.cpp | 134 | qtfindreplacedialog/finddialog.cpp \ |
135 | gui/projectexporter.cpp | ||
134 | OTHER_FILES += README \ | 136 | OTHER_FILES += README \ |
135 | resources/windowicon.png \ | 137 | resources/windowicon.png \ |
136 | resources/appicon.xcf \ | 138 | resources/appicon.xcf \ |
@@ -164,7 +166,8 @@ FORMS += gui/editorwindow.ui \ | |||
164 | gui/newprojectdialog.ui \ | 166 | gui/newprojectdialog.ui \ |
165 | gui/fontdownloader.ui \ | 167 | gui/fontdownloader.ui \ |
166 | qtfindreplacedialog/findreplaceform.ui \ | 168 | qtfindreplacedialog/findreplaceform.ui \ |
167 | qtfindreplacedialog/findreplacedialog.ui | 169 | qtfindreplacedialog/findreplacedialog.ui \ |
170 | gui/projectexporter.ui | ||
168 | RESOURCES += resources.qrc | 171 | RESOURCES += resources.qrc |
169 | win32:RC_FILE = themeeditor.rc | 172 | win32:RC_FILE = themeeditor.rc |
170 | macx { | 173 | macx { |