summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-07-23 21:15:15 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-07-23 21:15:15 +0000
commit5297db990412a34dee96de5bf61258ae31f3b4f9 (patch)
tree8b7d850cf3051549e04492a260049328b55641f5 /utils
parentd15a4f617f7d6e524ef811efef5707958031dc8f (diff)
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
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/gui/editorwindow.cpp24
-rw-r--r--utils/themeeditor/gui/editorwindow.h1
-rw-r--r--utils/themeeditor/gui/editorwindow.ui14
-rw-r--r--utils/themeeditor/gui/projectexporter.cpp79
-rw-r--r--utils/themeeditor/gui/projectexporter.h58
-rw-r--r--utils/themeeditor/gui/projectexporter.ui58
-rw-r--r--utils/themeeditor/themeeditor.pro9
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 @@
#include "rbfontcache.h"
#include "rbtextcache.h"
#include "newprojectdialog.h"
+#include "projectexporter.h"
#include <QDesktopWidget>
#include <QFileSystemModel>
@@ -220,6 +221,8 @@ void EditorWindow::setupMenus()
this, SLOT(saveCurrentAs()));
QObject::connect(ui->actionToolbarSave, SIGNAL(triggered()),
this, SLOT(saveCurrent()));
+ QObject::connect(ui->actionExport_Project, SIGNAL(triggered()),
+ this, SLOT(exportProject()));
QObject::connect(ui->actionOpen_Document, SIGNAL(triggered()),
this, SLOT(openFile()));
@@ -466,6 +469,7 @@ void EditorWindow::closeProject()
}
ui->actionClose_Project->setEnabled(false);
+ ui->actionExport_Project->setEnabled(false);
}
void EditorWindow::saveCurrent()
@@ -480,6 +484,25 @@ void EditorWindow::saveCurrentAs()
dynamic_cast<TabContent*>(ui->editorTabs->currentWidget())->saveAs();
}
+void EditorWindow::exportProject()
+{
+ QDir dir = project->getSetting("themebase", "");
+ dir.cdUp();
+ QString file = project->getSetting("configfile", "").split("/").
+ last().split(".").first() + ".zip";
+ file = dir.filePath(file);
+
+ file = QFileDialog::getSaveFileName(this, tr("Export Project"),
+ file, "Zip Files (*.zip *.ZIP);;"
+ "All Files (*)");
+
+ if(file != "")
+ {
+ ProjectExporter* exporter = new ProjectExporter(file, project, this);
+ exporter->show();
+ }
+}
+
void EditorWindow::openFile()
{
QStringList fileNames;
@@ -724,6 +747,7 @@ void EditorWindow::loadProjectFile(QString fileName)
project->deleteLater();
ui->actionClose_Project->setEnabled(true);
+ ui->actionExport_Project->setEnabled(true);
project = new ProjectModel(fileName, this);
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:
void closeProject();
void saveCurrent();
void saveCurrentAs();
+ void exportProject();
void openFile();
void openProject();
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 @@
<x>0</x>
<y>0</y>
<width>628</width>
- <height>27</height>
+ <height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@@ -57,6 +57,7 @@
<addaction name="separator"/>
<addaction name="actionSave_Document"/>
<addaction name="actionSave_Document_As"/>
+ <addaction name="actionExport_Project"/>
<addaction name="separator"/>
<addaction name="actionPreferences"/>
<addaction name="separator"/>
@@ -395,6 +396,17 @@
<string>Ctrl+Shift+N</string>
</property>
</action>
+ <action name="actionExport_Project">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>E&amp;xport Project</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Shift+X</string>
+ </property>
+ </action>
</widget>
<tabstops>
<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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Robert Bieber
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "projectexporter.h"
+#include "ui_projectexporter.h"
+
+ProjectExporter::ProjectExporter(QString path, ProjectModel* project,
+ QWidget *parent)
+ :QDialog(parent),
+ ui(new Ui::ProjectExporter), zipFile(path)
+{
+ ui->setupUi(this);
+
+ QObject::connect(ui->closeButton, SIGNAL(clicked()),
+ this, SLOT(close()));
+
+ if(zipFile.open(QuaZip::mdCreate))
+ {
+ writeZip(project);
+ }
+ else
+ {
+ html += tr("<span style = \"color:red\">Error opening zip file</span><br>");
+ ui->statusBox->document()->setHtml(html);
+ }
+}
+
+ProjectExporter::~ProjectExporter()
+{
+ delete ui;
+}
+
+void ProjectExporter::changeEvent(QEvent *e)
+{
+ QDialog::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+
+void ProjectExporter::closeEvent(QCloseEvent *event)
+{
+ close();
+ event->accept();
+}
+
+void ProjectExporter::close()
+{
+ deleteLater();
+ hide();
+}
+
+void ProjectExporter::writeZip(ProjectModel *project)
+{
+ (void)project;
+ zipFile.close();
+}
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Robert Bieber
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef PROJECTEXPORTER_H
+#define PROJECTEXPORTER_H
+
+#include <QDialog>
+#include <QCloseEvent>
+#include <QFile>
+
+#include "quazip.h"
+
+#include "projectmodel.h"
+
+namespace Ui {
+ class ProjectExporter;
+}
+
+class ProjectExporter : public QDialog {
+ Q_OBJECT
+public:
+ ProjectExporter(QString path, ProjectModel* project, QWidget *parent = 0);
+ ~ProjectExporter();
+
+protected:
+ void changeEvent(QEvent *e);
+ void closeEvent(QCloseEvent *event);
+
+private slots:
+ void close();
+
+private:
+ void writeZip(ProjectModel* project);
+
+ Ui::ProjectExporter *ui;
+ QuaZip zipFile;
+ QString html;
+};
+
+#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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ProjectExporter</class>
+ <widget class="QDialog" name="ProjectExporter">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Exporting Project</string>
+ </property>
+ <property name="windowIcon">
+ <iconset resource="../resources.qrc">
+ <normaloff>:/resources/windowicon.png</normaloff>:/resources/windowicon.png</iconset>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPlainTextEdit" name="statusBox">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="closeButton">
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources>
+ <include location="../resources.qrc"/>
+ </resources>
+ <connections/>
+</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 \
qtfindreplacedialog/findreplaceform.h \
qtfindreplacedialog/findreplacedialog.h \
qtfindreplacedialog/findform.h \
- qtfindreplacedialog/finddialog.h
+ qtfindreplacedialog/finddialog.h \
+ gui/projectexporter.h
SOURCES += main.cpp \
models/parsetreemodel.cpp \
models/parsetreenode.cpp \
@@ -130,7 +131,8 @@ SOURCES += main.cpp \
qtfindreplacedialog/findreplaceform.cpp \
qtfindreplacedialog/findreplacedialog.cpp \
qtfindreplacedialog/findform.cpp \
- qtfindreplacedialog/finddialog.cpp
+ qtfindreplacedialog/finddialog.cpp \
+ gui/projectexporter.cpp
OTHER_FILES += README \
resources/windowicon.png \
resources/appicon.xcf \
@@ -164,7 +166,8 @@ FORMS += gui/editorwindow.ui \
gui/newprojectdialog.ui \
gui/fontdownloader.ui \
qtfindreplacedialog/findreplaceform.ui \
- qtfindreplacedialog/findreplacedialog.ui
+ qtfindreplacedialog/findreplacedialog.ui \
+ gui/projectexporter.ui
RESOURCES += resources.qrc
win32:RC_FILE = themeeditor.rc
macx {