From 219f5db1dcd779f0373d1b97d3878df5b3ab801f Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Sat, 5 Jun 2010 08:40:27 +0000 Subject: [PATCH] Theme Editor: Basic save-as functionality working, but only invoked when a tab is closed git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26568 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/skindocument.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp index 2e4f6f464b..8617030180 100644 --- a/utils/themeeditor/skindocument.cpp +++ b/utils/themeeditor/skindocument.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include SkinDocument::SkinDocument(QWidget *parent) : QWidget(parent) @@ -43,6 +45,7 @@ SkinDocument::~SkinDocument() bool SkinDocument::requestClose() { + saveAs(); return true; } @@ -99,5 +102,22 @@ void SkinDocument::save() void SkinDocument::saveAs() { /* Determining the directory to open */ + QSettings settings; + settings.beginGroup("SkinDocument"); + QString openDir = settings.value("defaultDirectory", "").toString(); + + fileName = QFileDialog::getSaveFileName(this, tr("Save File"), openDir,""); + QString directory = fileName; + directory.chop(fileName.length() - fileName.lastIndexOf('/') - 1); + settings.setValue("defaultDirectory", directory); + + settings.endGroup(); + + QFile fout(fileName); + fout.open(QFile::WriteOnly); + fout.write(editor->document()->toPlainText().toAscii()); + fout.close(); + + saved = true; }