From 5297db990412a34dee96de5bf61258ae31f3b4f9 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Fri, 23 Jul 2010 21:15:15 +0000 Subject: 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 --- utils/themeeditor/gui/editorwindow.cpp | 24 ++++++++++ utils/themeeditor/gui/editorwindow.h | 1 + utils/themeeditor/gui/editorwindow.ui | 14 +++++- utils/themeeditor/gui/projectexporter.cpp | 79 +++++++++++++++++++++++++++++++ utils/themeeditor/gui/projectexporter.h | 58 +++++++++++++++++++++++ utils/themeeditor/gui/projectexporter.ui | 58 +++++++++++++++++++++++ utils/themeeditor/themeeditor.pro | 9 ++-- 7 files changed, 239 insertions(+), 4 deletions(-) create mode 100644 utils/themeeditor/gui/projectexporter.cpp create mode 100644 utils/themeeditor/gui/projectexporter.h create mode 100644 utils/themeeditor/gui/projectexporter.ui (limited to 'utils') 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 #include @@ -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(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 @@ 0 0 628 - 27 + 25 @@ -57,6 +57,7 @@ + @@ -395,6 +396,17 @@ Ctrl+Shift+N + + + false + + + E&xport Project + + + Ctrl+Shift+X + + projectTree 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("Error opening zip file
"); + 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 +#include +#include + +#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 @@ + + + ProjectExporter + + + + 0 + 0 + 400 + 300 + + + + Exporting Project + + + + :/resources/windowicon.png:/resources/windowicon.png + + + + + + true + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + + + + + + + + + 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 { -- cgit