1
0
Fork 0
forked from len0rd/rockbox

Theme Editor: Got document title change signal working, beginning work on save function

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26567 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-05 08:22:30 +00:00
parent d41a681053
commit 4051b34039
4 changed files with 53 additions and 0 deletions

View file

@ -106,6 +106,10 @@ void EditorWindow::newTab()
{ {
SkinDocument* doc = new SkinDocument; SkinDocument* doc = new SkinDocument;
ui->editorTabs->addTab(doc, doc->getTitle()); ui->editorTabs->addTab(doc, doc->getTitle());
/* Connecting to title change events */
QObject::connect(doc, SIGNAL(titleChanged(QString)),
this, SLOT(tabTitleChanged(QString)));
} }
void EditorWindow::shiftTab(int index) void EditorWindow::shiftTab(int index)
@ -128,6 +132,12 @@ void EditorWindow::closeTab(int index)
} }
} }
void EditorWindow::tabTitleChanged(QString title)
{
SkinDocument* sender = dynamic_cast<SkinDocument*>(QObject::sender());
ui->editorTabs->setTabText(ui->editorTabs->indexOf(sender), title);
}
void EditorWindow::showPanel() void EditorWindow::showPanel()
{ {
if(sender() == ui->actionFile_Panel) if(sender() == ui->actionFile_Panel)

View file

@ -46,6 +46,7 @@ private slots:
void newTab(); void newTab();
void shiftTab(int index); void shiftTab(int index);
void closeTab(int index); void closeTab(int index);
void tabTitleChanged(QString title);
private: private:
/* Setup functions */ /* Setup functions */

View file

@ -21,12 +21,18 @@
#include "skindocument.h" #include "skindocument.h"
#include <QFile>
#include <QTimer>
#include <QSettings>
SkinDocument::SkinDocument(QWidget *parent) : SkinDocument::SkinDocument(QWidget *parent) :
QWidget(parent) QWidget(parent)
{ {
setupUI(); setupUI();
title = "Untitled"; title = "Untitled";
fileName = "";
saved = true;
} }
SkinDocument::~SkinDocument() SkinDocument::~SkinDocument()
@ -65,4 +71,33 @@ void SkinDocument::setupUI()
void SkinDocument::codeChanged() void SkinDocument::codeChanged()
{ {
model->changeTree(editor->document()->toPlainText().toAscii()); model->changeTree(editor->document()->toPlainText().toAscii());
if(saved == true)
{
saved = false;
title.append(tr("*"));
emit titleChanged(title);
}
}
void SkinDocument::save()
{
QFile fout(fileName);
if(!fout.exists())
{
QTimer::singleShot(0, this, SLOT(saveAs()));
return;
}
fout.open(QFile::WriteOnly);
fout.write(editor->document()->toPlainText().toAscii());
fout.close();
saved = true;
}
void SkinDocument::saveAs()
{
/* Determining the directory to open */
} }

View file

@ -42,6 +42,11 @@ public:
bool requestClose(); bool requestClose();
signals: signals:
void titleChanged(QString);
public slots:
void save();
void saveAs();
private slots: private slots:
void codeChanged(); void codeChanged();
@ -50,6 +55,8 @@ private:
void setupUI(); void setupUI();
QString title; QString title;
QString fileName;
bool saved;
QLayout* layout; QLayout* layout;
QPlainTextEdit* editor; QPlainTextEdit* editor;