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:
parent
d41a681053
commit
4051b34039
4 changed files with 53 additions and 0 deletions
|
|
@ -106,6 +106,10 @@ void EditorWindow::newTab()
|
|||
{
|
||||
SkinDocument* doc = new SkinDocument;
|
||||
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)
|
||||
|
|
@ -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()
|
||||
{
|
||||
if(sender() == ui->actionFile_Panel)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ private slots:
|
|||
void newTab();
|
||||
void shiftTab(int index);
|
||||
void closeTab(int index);
|
||||
void tabTitleChanged(QString title);
|
||||
|
||||
private:
|
||||
/* Setup functions */
|
||||
|
|
|
|||
|
|
@ -21,12 +21,18 @@
|
|||
|
||||
#include "skindocument.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QTimer>
|
||||
#include <QSettings>
|
||||
|
||||
SkinDocument::SkinDocument(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
setupUI();
|
||||
|
||||
title = "Untitled";
|
||||
fileName = "";
|
||||
saved = true;
|
||||
}
|
||||
|
||||
SkinDocument::~SkinDocument()
|
||||
|
|
@ -65,4 +71,33 @@ void SkinDocument::setupUI()
|
|||
void SkinDocument::codeChanged()
|
||||
{
|
||||
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 */
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ public:
|
|||
bool requestClose();
|
||||
|
||||
signals:
|
||||
void titleChanged(QString);
|
||||
|
||||
public slots:
|
||||
void save();
|
||||
void saveAs();
|
||||
|
||||
private slots:
|
||||
void codeChanged();
|
||||
|
|
@ -50,6 +55,8 @@ private:
|
|||
void setupUI();
|
||||
|
||||
QString title;
|
||||
QString fileName;
|
||||
bool saved;
|
||||
|
||||
QLayout* layout;
|
||||
QPlainTextEdit* editor;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue