A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef SKINDOCUMENT_H
23#define SKINDOCUMENT_H
24
25#include <QWidget>
26#include <QLabel>
27#include <QHBoxLayout>
28#include <QGraphicsScene>
29#include <QTime>
30#include <QTimer>
31
32#include "findreplacedialog.h"
33
34#include "skinhighlighter.h"
35#include "parsetreemodel.h"
36#include "preferencesdialog.h"
37#include "codeeditor.h"
38#include "tabcontent.h"
39#include "projectmodel.h"
40#include "devicestate.h"
41
42class SkinDocument : public TabContent
43{
44Q_OBJECT
45public:
46 static QString fileFilter()
47 {
48 return tr("WPS Files (*.wps *.WPS *.rwps *.RWPS);;"
49 "SBS Files (*.sbs *.SBS *.rsbs *.RSBS);;"
50 "FMS Files (*.fms *.FMS *.rfms *.RFMS);;"
51 "All Skin Files (*.wps *.WPS *.rwps *.RWPS *.sbs *.SBS "
52 "*.rsbs *.RSBS *.fms *.FMS *.rfms *.RFMS);;"
53 "All Files (*)");
54 }
55
56 SkinDocument(QLabel* statusLabel, ProjectModel* project = 0,
57 DeviceState* device = 0, QWidget *parent = 0);
58 SkinDocument(QLabel* statusLabel, QString file, ProjectModel* project = 0,
59 DeviceState* device = 0, QWidget* parent = 0);
60 virtual ~SkinDocument();
61
62 void connectPrefs(PreferencesDialog* prefs);
63
64 ParseTreeModel* getModel(){ return model; }
65 QString file() const{ return fileName; }
66 QString title() const{ return titleText; }
67 QString getStatus(){ return parseStatus; }
68 CodeEditor* getEditor(){ return editor; }
69 void setProject(ProjectModel* project){ this->project = project; }
70
71 void save();
72 void saveAs();
73
74 bool requestClose();
75
76 TabType type() const{ return Skin; }
77
78 RBScene* scene()
79 {
80 return model->render(project, device, this, &fileName);
81 }
82
83 void showFind(){ findReplace->show(); }
84 void hideFind(){ findReplace->hide(); }
85
86 bool isSynced(){ return treeInSync; }
87
88
89signals:
90 void antiSync(bool outOfSync);
91
92public slots:
93 void settingsChanged();
94 void cursorChanged();
95 void parseCode(){ codeChanged(); }
96 void genCode(){ editor->document()->setPlainText(model->genCode()); }
97
98private slots:
99 void codeChanged();
100 void modelChanged();
101 void deviceChanged(){ scene(); }
102
103private:
104 void setupUI();
105 QString findSetting(QString key, QString fallback);
106
107 QString titleText;
108 QString fileName;
109 QString saved;
110 QString parseStatus;
111 int currentLine;
112
113 QLayout* layout;
114 CodeEditor* editor;
115
116 SkinHighlighter* highlighter;
117 ParseTreeModel* model;
118
119 QLabel* statusLabel;
120
121 bool blockUpdate;
122
123 ProjectModel* project;
124 DeviceState* device;
125
126 FindReplaceDialog* findReplace;
127
128 QTime lastUpdate;
129 static const int updateInterval;
130 QTimer checkUpdate;
131
132 bool treeInSync;
133};
134
135#endif // SKINDOCUMENT_H