Theme Editor: Added an edit menu with a find/replace function (copied from an LGPL...
[kugel-rb.git] / utils / themeeditor / gui / skindocument.h
blob17130237799f557234fff5e8809cd6841880ec52
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 "findreplacedialog.h"
32 #include "skinhighlighter.h"
33 #include "parsetreemodel.h"
34 #include "preferencesdialog.h"
35 #include "codeeditor.h"
36 #include "tabcontent.h"
37 #include "projectmodel.h"
38 #include "devicestate.h"
40 class SkinDocument : public TabContent
42 Q_OBJECT
43 public:
44 static QString fileFilter()
46 return tr("WPS Files (*.wps *.rwps);;"
47 "SBS Files (*.sbs *.rsbs);;"
48 "FMS Files (*.fms *.rfms);;"
49 "All Skin Files (*.wps *.rwps *.sbs "
50 "*.rsbs *.fms *.rfms);;"
51 "All Files (*.*)");
54 SkinDocument(QLabel* statusLabel, ProjectModel* project = 0,
55 DeviceState* device = 0, QWidget *parent = 0);
56 SkinDocument(QLabel* statusLabel, QString file, ProjectModel* project = 0,
57 DeviceState* device = 0, QWidget* parent = 0);
58 virtual ~SkinDocument();
60 void connectPrefs(PreferencesDialog* prefs);
62 ParseTreeModel* getModel(){ return model; }
63 QString file() const{ return fileName; }
64 QString title() const{ return titleText; }
65 QString getStatus(){ return parseStatus; }
66 CodeEditor* getEditor(){ return editor; }
67 void genCode(){ editor->document()->setPlainText(model->genCode()); }
68 void setProject(ProjectModel* project){ this->project = project; }
70 void save();
71 void saveAs();
73 bool requestClose();
75 TabType type() const{ return Skin; }
77 QGraphicsScene* scene(){ return model->render(project, device, &fileName); }
79 void showFind(){ findReplace->show(); }
80 void hideFind(){ findReplace->hide(); }
82 signals:
84 public slots:
85 void settingsChanged();
86 void cursorChanged();
88 private slots:
89 void codeChanged();
90 void deviceChanged(){ scene(); }
92 private:
93 void setupUI();
94 QString findSetting(QString key, QString fallback);
96 QString titleText;
97 QString fileName;
98 QString saved;
99 QString parseStatus;
101 QLayout* layout;
102 CodeEditor* editor;
104 SkinHighlighter* highlighter;
105 ParseTreeModel* model;
107 QLabel* statusLabel;
109 bool blockUpdate;
111 ProjectModel* project;
112 DeviceState* device;
114 FindReplaceDialog* findReplace;
117 #endif // SKINDOCUMENT_H