1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Robert Bieber 2010-07-23 21:15:15 +00:00
parent d15a4f617f
commit 5297db9904
7 changed files with 239 additions and 4 deletions

View file

@ -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);

View file

@ -72,6 +72,7 @@ private slots:
void closeProject();
void saveCurrent();
void saveCurrentAs();
void exportProject();
void openFile();
void openProject();
void tabTitleChanged(QString title);

View file

@ -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>

View file

@ -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();
}

View file

@ -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

View file

@ -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>

View file

@ -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 {