Theme Editor: Began working on open document functionality (still incomplete), fixed a nested conditional parsing bug in the parser, and fixed segfault-on-codegen-from-empty-tree bug
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26609 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
5619b4f6cf
commit
f3491e97d0
6 changed files with 35 additions and 11 deletions
|
@ -25,6 +25,7 @@
|
|||
#include <QDesktopWidget>
|
||||
#include <QFileSystemModel>
|
||||
#include <QSettings>
|
||||
#include <QFileDialog>
|
||||
|
||||
EditorWindow::EditorWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
|
@ -183,6 +184,17 @@ void EditorWindow::saveCurrentAs()
|
|||
dynamic_cast<SkinDocument*>(ui->editorTabs->currentWidget())->saveAs();
|
||||
}
|
||||
|
||||
void EditorWindow::openFile()
|
||||
{
|
||||
QStringList fileNames;
|
||||
QSettings settings;
|
||||
|
||||
settings.beginGroup("SkinDocument");
|
||||
QString directory = settings.value("defaultDirectory", "").toString();
|
||||
fileNames = QFileDialog::getOpenFileNames(this, tr("Open Files"), directory,
|
||||
SkinDocument::fileFilter());
|
||||
}
|
||||
|
||||
|
||||
void EditorWindow::tabTitleChanged(QString title)
|
||||
{
|
||||
|
|
|
@ -49,6 +49,7 @@ private slots:
|
|||
void closeCurrent();
|
||||
void saveCurrent();
|
||||
void saveCurrentAs();
|
||||
void openFile();
|
||||
void tabTitleChanged(QString title);
|
||||
void updateCurrent(); /* Generates code in the current tab */
|
||||
|
||||
|
|
|
@ -49,7 +49,10 @@ ParseTreeModel::~ParseTreeModel()
|
|||
|
||||
QString ParseTreeModel::genCode()
|
||||
{
|
||||
return root->genCode();
|
||||
if(root)
|
||||
return root->genCode();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
bool ParseTreeModel::changeTree(const char *document)
|
||||
|
|
|
@ -685,9 +685,15 @@ int skin_parse_conditional(struct skin_element* element, char** document)
|
|||
while(nested)
|
||||
{
|
||||
if(*cursor == ENUMLISTOPENSYM)
|
||||
{
|
||||
nested++;
|
||||
if(*cursor == ENUMLISTCLOSESYM)
|
||||
break;
|
||||
}
|
||||
else if(*cursor == ENUMLISTCLOSESYM)
|
||||
{
|
||||
nested--;
|
||||
break;
|
||||
}
|
||||
cursor++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,12 +28,7 @@
|
|||
#include <QFileDialog>
|
||||
|
||||
SkinDocument::SkinDocument(QWidget *parent) :
|
||||
QWidget(parent), fileFilter(tr("WPS Files (*.wps *.rwps);;"
|
||||
"SBS Files (*.sbs *.rsbs);;"
|
||||
"FMS Files (*.fms *.rfms);;"
|
||||
"All Skin Files (*.wps *.rwps *.sbs "
|
||||
"*.rsbs *.fms *.rfms);;"
|
||||
"All Files (*.*)"))
|
||||
QWidget(parent)
|
||||
{
|
||||
setupUI();
|
||||
|
||||
|
@ -147,7 +142,7 @@ void SkinDocument::saveAs()
|
|||
directory = settings.value("defaultDirectory", "").toString();
|
||||
|
||||
fileName = QFileDialog::getSaveFileName(this, tr("Save Document"),
|
||||
directory, fileFilter);
|
||||
directory, fileFilter());
|
||||
directory = fileName;
|
||||
if(fileName == "")
|
||||
return;
|
||||
|
|
|
@ -33,8 +33,15 @@ class SkinDocument : public QWidget
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
const QString fileFilter;
|
||||
|
||||
static QString fileFilter()
|
||||
{
|
||||
return tr("WPS Files (*.wps *.rwps);;"
|
||||
"SBS Files (*.sbs *.rsbs);;"
|
||||
"FMS Files (*.fms *.rfms);;"
|
||||
"All Skin Files (*.wps *.rwps *.sbs "
|
||||
"*.rsbs *.fms *.rfms);;"
|
||||
"All Files (*.*)");
|
||||
}
|
||||
|
||||
SkinDocument(QWidget *parent = 0);
|
||||
virtual ~SkinDocument();
|
||||
|
|
Loading…
Reference in a new issue