c6b36873f8ebb9e81d6eb620511a594cf8f95a7d
[kugel-rb.git] / utils / themeeditor / gui / skindocument.h
blobc6b36873f8ebb9e81d6eb620511a594cf8f95a7d
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"
36 #include "devicestate.h"
38 class SkinDocument : public TabContent
40 Q_OBJECT
41 public:
42 static QString fileFilter()
44 return tr("WPS Files (*.wps *.rwps);;"
45 "SBS Files (*.sbs *.rsbs);;"
46 "FMS Files (*.fms *.rfms);;"
47 "All Skin Files (*.wps *.rwps *.sbs "
48 "*.rsbs *.fms *.rfms);;"
49 "All Files (*.*)");
52 SkinDocument(QLabel* statusLabel, ProjectModel* project = 0,
53 DeviceState* device = 0, QWidget *parent = 0);
54 SkinDocument(QLabel* statusLabel, QString file, ProjectModel* project = 0,
55 DeviceState* device = 0, QWidget* parent = 0);
56 virtual ~SkinDocument();
58 void connectPrefs(PreferencesDialog* prefs);
60 ParseTreeModel* getModel(){ return model; }
61 QString file() const{ return fileName; }
62 QString title() const{ return titleText; }
63 QString getStatus(){ return parseStatus; }
64 void genCode(){ editor->document()->setPlainText(model->genCode()); }
65 void setProject(ProjectModel* project){ this->project = project; }
67 void save();
68 void saveAs();
70 bool requestClose();
72 TabType type() const{ return Skin; }
74 QGraphicsScene* scene(){ return model->render(project, device, &fileName); }
76 signals:
78 public slots:
79 void settingsChanged();
80 void cursorChanged();
82 private slots:
83 void codeChanged();
84 void deviceChanged(){ scene(); }
86 private:
87 void setupUI();
88 QString findSetting(QString key, QString fallback);
90 QString titleText;
91 QString fileName;
92 QString saved;
93 QString parseStatus;
95 QLayout* layout;
96 CodeEditor* editor;
98 SkinHighlighter* highlighter;
99 ParseTreeModel* model;
101 QLabel* statusLabel;
103 bool blockUpdate;
105 ProjectModel* project;
106 DeviceState* device;
109 #endif // SKINDOCUMENT_H