f6ceb73e92b6d599b9059eea33cba4b700ef4f4d
[kugel-rb.git] / utils / themeeditor / gui / skindocument.h
blobf6ceb73e92b6d599b9059eea33cba4b700ef4f4d
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2010 Robert Bieber
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef SKINDOCUMENT_H
23 #define SKINDOCUMENT_H
25 #include <QWidget>
26 #include <QLabel>
27 #include <QHBoxLayout>
28 #include <QGraphicsScene>
30 #include "skinhighlighter.h"
31 #include "parsetreemodel.h"
32 #include "preferencesdialog.h"
33 #include "codeeditor.h"
34 #include "tabcontent.h"
35 #include "projectmodel.h"
37 class SkinDocument : public TabContent
39 Q_OBJECT
40 public:
41 static QString fileFilter()
43 return tr("WPS Files (*.wps *.rwps);;"
44 "SBS Files (*.sbs *.rsbs);;"
45 "FMS Files (*.fms *.rfms);;"
46 "All Skin Files (*.wps *.rwps *.sbs "
47 "*.rsbs *.fms *.rfms);;"
48 "All Files (*.*)");
51 SkinDocument(QLabel* statusLabel, ProjectModel* project = 0,
52 QWidget *parent = 0);
53 SkinDocument(QLabel* statusLabel, QString file, ProjectModel* project = 0,
54 QWidget* parent = 0);
55 virtual ~SkinDocument();
57 void connectPrefs(PreferencesDialog* prefs);
59 ParseTreeModel* getModel(){ return model; }
60 QString file() const{ return fileName; }
61 QString title() const{ return titleText; }
62 QString getStatus(){ return parseStatus; }
63 void genCode(){ editor->document()->setPlainText(model->genCode()); }
64 void setProject(ProjectModel* project){ this->project = project; }
66 void save();
67 void saveAs();
69 bool requestClose();
71 TabType type() const{ return Skin; }
73 QGraphicsScene* scene(){ return model->render(project, &fileName); }
75 signals:
77 public slots:
78 void settingsChanged();
79 void cursorChanged();
81 private slots:
82 void codeChanged();
84 private:
85 void setupUI();
86 QString findSetting(QString key, QString fallback);
88 QString titleText;
89 QString fileName;
90 QString saved;
91 QString parseStatus;
93 QLayout* layout;
94 CodeEditor* editor;
96 SkinHighlighter* highlighter;
97 ParseTreeModel* model;
99 QLabel* statusLabel;
101 bool blockUpdate;
103 ProjectModel* project;
106 #endif // SKINDOCUMENT_H