2010-06-04 07:57:19 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Robert Bieber
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef SKINDOCUMENT_H
|
|
|
|
#define SKINDOCUMENT_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
2010-06-07 20:29:46 +00:00
|
|
|
#include <QLabel>
|
2010-06-04 07:57:19 +00:00
|
|
|
#include <QHBoxLayout>
|
2010-06-17 06:59:46 +00:00
|
|
|
#include <QGraphicsScene>
|
2010-07-07 09:33:47 +00:00
|
|
|
#include <QTime>
|
|
|
|
#include <QTimer>
|
2010-06-04 07:57:19 +00:00
|
|
|
|
2010-06-26 07:59:23 +00:00
|
|
|
#include "findreplacedialog.h"
|
|
|
|
|
2010-06-04 07:57:19 +00:00
|
|
|
#include "skinhighlighter.h"
|
|
|
|
#include "parsetreemodel.h"
|
2010-06-07 03:25:40 +00:00
|
|
|
#include "preferencesdialog.h"
|
2010-06-08 07:57:43 +00:00
|
|
|
#include "codeeditor.h"
|
2010-06-15 06:54:58 +00:00
|
|
|
#include "tabcontent.h"
|
2010-06-17 06:59:46 +00:00
|
|
|
#include "projectmodel.h"
|
2010-06-26 05:18:21 +00:00
|
|
|
#include "devicestate.h"
|
2010-06-04 07:57:19 +00:00
|
|
|
|
2010-06-15 06:54:58 +00:00
|
|
|
class SkinDocument : public TabContent
|
2010-06-04 07:57:19 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2010-06-06 03:35:40 +00:00
|
|
|
static QString fileFilter()
|
|
|
|
{
|
2010-07-21 20:08:51 +00:00
|
|
|
return tr("WPS Files (*.wps *.WPS *.rwps *.RWPS);;"
|
|
|
|
"SBS Files (*.sbs *.SBS *.rsbs *.RSBS);;"
|
|
|
|
"FMS Files (*.fms *.FMS *.rfms *.RFMS);;"
|
|
|
|
"All Skin Files (*.wps *.WPS *.rwps *.RWPS *.sbs *.SBS "
|
|
|
|
"*.rsbs *.RSBS *.fms *.FMS *.rfms *.RFMS);;"
|
2010-07-21 07:45:29 +00:00
|
|
|
"All Files (*)");
|
2010-06-06 03:35:40 +00:00
|
|
|
}
|
2010-06-05 19:47:49 +00:00
|
|
|
|
2010-06-17 06:59:46 +00:00
|
|
|
SkinDocument(QLabel* statusLabel, ProjectModel* project = 0,
|
2010-06-26 05:18:21 +00:00
|
|
|
DeviceState* device = 0, QWidget *parent = 0);
|
2010-06-17 06:59:46 +00:00
|
|
|
SkinDocument(QLabel* statusLabel, QString file, ProjectModel* project = 0,
|
2010-06-26 05:18:21 +00:00
|
|
|
DeviceState* device = 0, QWidget* parent = 0);
|
2010-06-04 07:57:19 +00:00
|
|
|
virtual ~SkinDocument();
|
|
|
|
|
2010-06-07 03:25:40 +00:00
|
|
|
void connectPrefs(PreferencesDialog* prefs);
|
|
|
|
|
2010-06-04 07:57:19 +00:00
|
|
|
ParseTreeModel* getModel(){ return model; }
|
2010-06-15 06:54:58 +00:00
|
|
|
QString file() const{ return fileName; }
|
|
|
|
QString title() const{ return titleText; }
|
2010-06-07 20:29:46 +00:00
|
|
|
QString getStatus(){ return parseStatus; }
|
2010-06-26 07:59:23 +00:00
|
|
|
CodeEditor* getEditor(){ return editor; }
|
2010-06-17 06:59:46 +00:00
|
|
|
void setProject(ProjectModel* project){ this->project = project; }
|
2010-06-04 07:57:19 +00:00
|
|
|
|
2010-06-05 19:47:49 +00:00
|
|
|
void save();
|
|
|
|
void saveAs();
|
|
|
|
|
2010-06-05 07:38:29 +00:00
|
|
|
bool requestClose();
|
|
|
|
|
2010-06-15 06:54:58 +00:00
|
|
|
TabType type() const{ return Skin; }
|
|
|
|
|
2010-08-06 20:53:50 +00:00
|
|
|
RBScene* scene()
|
2010-08-04 09:16:52 +00:00
|
|
|
{
|
|
|
|
return model->render(project, device, this, &fileName);
|
|
|
|
}
|
2010-06-17 06:59:46 +00:00
|
|
|
|
2010-06-26 07:59:23 +00:00
|
|
|
void showFind(){ findReplace->show(); }
|
|
|
|
void hideFind(){ findReplace->hide(); }
|
|
|
|
|
2010-08-05 00:43:33 +00:00
|
|
|
bool isSynced(){ return treeInSync; }
|
|
|
|
|
|
|
|
|
2010-06-04 07:57:19 +00:00
|
|
|
signals:
|
2010-08-05 00:43:33 +00:00
|
|
|
void antiSync(bool outOfSync);
|
2010-06-05 08:22:30 +00:00
|
|
|
|
2010-06-07 03:25:40 +00:00
|
|
|
public slots:
|
2010-06-07 07:57:56 +00:00
|
|
|
void settingsChanged();
|
2010-06-11 21:24:38 +00:00
|
|
|
void cursorChanged();
|
2010-08-05 00:43:33 +00:00
|
|
|
void parseCode(){ codeChanged(); }
|
|
|
|
void genCode(){ editor->document()->setPlainText(model->genCode()); }
|
2010-06-07 03:25:40 +00:00
|
|
|
|
2010-06-04 07:57:19 +00:00
|
|
|
private slots:
|
|
|
|
void codeChanged();
|
2010-08-05 00:43:33 +00:00
|
|
|
void modelChanged();
|
2010-06-26 05:18:21 +00:00
|
|
|
void deviceChanged(){ scene(); }
|
2010-06-04 07:57:19 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void setupUI();
|
2010-06-17 06:59:46 +00:00
|
|
|
QString findSetting(QString key, QString fallback);
|
2010-06-04 07:57:19 +00:00
|
|
|
|
2010-06-15 06:54:58 +00:00
|
|
|
QString titleText;
|
2010-06-05 08:22:30 +00:00
|
|
|
QString fileName;
|
2010-06-05 19:47:49 +00:00
|
|
|
QString saved;
|
2010-06-07 20:29:46 +00:00
|
|
|
QString parseStatus;
|
2010-06-29 06:14:36 +00:00
|
|
|
int currentLine;
|
2010-06-04 07:57:19 +00:00
|
|
|
|
|
|
|
QLayout* layout;
|
2010-06-08 07:57:43 +00:00
|
|
|
CodeEditor* editor;
|
2010-06-04 07:57:19 +00:00
|
|
|
|
|
|
|
SkinHighlighter* highlighter;
|
|
|
|
ParseTreeModel* model;
|
2010-06-07 20:29:46 +00:00
|
|
|
|
|
|
|
QLabel* statusLabel;
|
2010-06-11 20:51:49 +00:00
|
|
|
|
|
|
|
bool blockUpdate;
|
2010-06-17 06:59:46 +00:00
|
|
|
|
|
|
|
ProjectModel* project;
|
2010-06-26 05:18:21 +00:00
|
|
|
DeviceState* device;
|
2010-06-26 07:59:23 +00:00
|
|
|
|
|
|
|
FindReplaceDialog* findReplace;
|
2010-07-07 09:33:47 +00:00
|
|
|
|
|
|
|
QTime lastUpdate;
|
|
|
|
static const int updateInterval;
|
|
|
|
QTimer checkUpdate;
|
2010-08-05 00:43:33 +00:00
|
|
|
|
|
|
|
bool treeInSync;
|
2010-06-04 07:57:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SKINDOCUMENT_H
|