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
This commit is contained in:
Robert Bieber 2010-06-05 08:40:27 +00:00
parent 4051b34039
commit 219f5db1dc

View file

@ -24,6 +24,8 @@
#include <QFile> #include <QFile>
#include <QTimer> #include <QTimer>
#include <QSettings> #include <QSettings>
#include <QMessageBox>
#include <QFileDialog>
SkinDocument::SkinDocument(QWidget *parent) : SkinDocument::SkinDocument(QWidget *parent) :
QWidget(parent) QWidget(parent)
@ -43,6 +45,7 @@ SkinDocument::~SkinDocument()
bool SkinDocument::requestClose() bool SkinDocument::requestClose()
{ {
saveAs();
return true; return true;
} }
@ -99,5 +102,22 @@ void SkinDocument::save()
void SkinDocument::saveAs() void SkinDocument::saveAs()
{ {
/* Determining the directory to open */ /* 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;
} }