diff options
author | Frank Gevaerts <frank@gevaerts.be> | 2008-08-29 21:08:38 +0000 |
---|---|---|
committer | Frank Gevaerts <frank@gevaerts.be> | 2008-08-29 21:08:38 +0000 |
commit | 5d22e3cbdd251819a4d2d07b9a12994d5aef778d (patch) | |
tree | 4c6a81187ccf065a5f296a903b9f7da88503e403 /utils/wpseditor | |
parent | cc31b1fbdae455f975b69dd6bffc23d8bd021566 (diff) | |
download | rockbox-5d22e3cbdd251819a4d2d07b9a12994d5aef778d.tar.gz rockbox-5d22e3cbdd251819a4d2d07b9a12994d5aef778d.zip |
Add wpseditor, the Google Summer of Code 2008 project of Rostislav Chekan. Closes FS#9327
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18362 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/wpseditor')
48 files changed, 3641 insertions, 0 deletions
diff --git a/utils/wpseditor/README b/utils/wpseditor/README new file mode 100644 index 0000000000..3a8b87c511 --- /dev/null +++ b/utils/wpseditor/README | |||
@@ -0,0 +1,21 @@ | |||
1 | __________ __ ___. | ||
2 | Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
3 | Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
4 | Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
5 | Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
6 | \/ \/ \/ \/ \/ | ||
7 | |||
8 | Installation | ||
9 | |||
10 | Windows: | ||
11 | |||
12 | * be sure that you have properly installed mingw, QT > 4.3.* | ||
13 | * if you want to debug wpseditor, you'll have to build Qt debug libraries | ||
14 | * cd to rockbox/utils/wpseditor/ from Qt command promt and run qmake and then make | ||
15 | * >gui\bin\wpseditor.exe | ||
16 | |||
17 | Linux: | ||
18 | |||
19 | * Make sure you have libqt4-dev installed and you have a working Rockbox environment | ||
20 | * cd to utils/wpseditor/ and do 'qmake-qt4 && make' | ||
21 | * cd to gui/bin/ and start WPS editor with './wpseditord' | ||
diff --git a/utils/wpseditor/TODO b/utils/wpseditor/TODO new file mode 100644 index 0000000000..28f559111f --- /dev/null +++ b/utils/wpseditor/TODO | |||
@@ -0,0 +1,7 @@ | |||
1 | * Enable ability in gui to load different targets on the fly | ||
2 | * Enable animation(timers,sliding lines, etc) | ||
3 | * Test on Mac OS | ||
4 | * Redesign GUI for more usability | ||
5 | * Replace checkwps functionality | ||
6 | * Include 'screenshot utility' functionality | ||
7 | * Make editing via gui | ||
diff --git a/utils/wpseditor/gui/gui.pro b/utils/wpseditor/gui/gui.pro new file mode 100644 index 0000000000..db7cfa1343 --- /dev/null +++ b/utils/wpseditor/gui/gui.pro | |||
@@ -0,0 +1,40 @@ | |||
1 | TEMPLATE = app | ||
2 | TARGET = | ||
3 | DEPENDPATH += . build src ui | ||
4 | INCLUDEPATH += . src/QPropertyEditor ../libwps/src | ||
5 | DESTDIR = bin | ||
6 | OBJECTS_DIR = build | ||
7 | MOC_DIR = build | ||
8 | UI_DIR = build | ||
9 | QMAKE_LIBDIR += lib | ||
10 | QT = gui core | ||
11 | CONFIG += qt warn_on console debug_and_release | ||
12 | libwps.commands += $(MAKE) -C ../libwps shared | ||
13 | QMAKE_EXTRA_TARGETS += libwps | ||
14 | PRE_TARGETDEPS += libwps | ||
15 | HEADERS += ../libwps/src/api.h \ | ||
16 | ../libwps/src/defs.h \ | ||
17 | src/slider.h \ | ||
18 | src/qtrackstate.h \ | ||
19 | src/qwpsstate.h \ | ||
20 | src/qwpseditorwindow.h \ | ||
21 | src/utils.h \ | ||
22 | src/qwpsdrawer.h | ||
23 | FORMS += ui/mainwindow.ui ui/slider.ui | ||
24 | SOURCES += src/main.cpp \ | ||
25 | src/slider.cpp \ | ||
26 | src/qtrackstate.cpp \ | ||
27 | src/qwpsstate.cpp \ | ||
28 | src/qwpseditorwindow.cpp \ | ||
29 | src/utils.cpp \ | ||
30 | src/qwpsdrawer.cpp \ | ||
31 | src/qwpsdrawer_static.cpp | ||
32 | LIBS += -Lbin | ||
33 | CONFIG(debug, debug|release) { | ||
34 | LIBS += -lQPropertyEditord | ||
35 | TARGET = wpseditord | ||
36 | } | ||
37 | CONFIG(release, debug|release) { | ||
38 | LIBS += -lQPropertyEditor | ||
39 | TARGET = wpseditor | ||
40 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/ColorCombo.cpp b/utils/wpseditor/gui/src/QPropertyEditor/ColorCombo.cpp new file mode 100644 index 0000000000..f5eeb030dc --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/ColorCombo.cpp | |||
@@ -0,0 +1,73 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // | ||
24 | // This class is based on the Color Editor Factory Example by Trolltech | ||
25 | // | ||
26 | // ************************************************************************************************* | ||
27 | |||
28 | #include "ColorCombo.h" | ||
29 | |||
30 | #include <Qt/qcolordialog.h> | ||
31 | |||
32 | ColorCombo::ColorCombo(QWidget* parent /*= 0*/) : QComboBox(parent) { | ||
33 | QStringList colorNames = QColor::colorNames(); | ||
34 | for (int i = 0; i < colorNames.size(); ++i) { | ||
35 | QColor color(colorNames[i]); | ||
36 | insertItem(i, colorNames[i]); | ||
37 | setItemData(i, color, Qt::DecorationRole); | ||
38 | } | ||
39 | addItem(tr("Custom"), QVariant((int)QVariant::UserType)); | ||
40 | connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(currentChanged(int))); | ||
41 | } | ||
42 | |||
43 | |||
44 | ColorCombo::~ColorCombo() {} | ||
45 | |||
46 | |||
47 | QColor ColorCombo::color() const { | ||
48 | return qVariantValue<QColor>(itemData(currentIndex(), Qt::DecorationRole)); | ||
49 | } | ||
50 | |||
51 | void ColorCombo::setColor(QColor color) { | ||
52 | m_init = color; | ||
53 | setCurrentIndex(findData(color, int(Qt::DecorationRole))); | ||
54 | if (currentIndex() == -1) { | ||
55 | addItem(color.name()); | ||
56 | setItemData(count()-1, color, Qt::DecorationRole); | ||
57 | setCurrentIndex(count()-1); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | void ColorCombo::currentChanged(int index) { | ||
62 | if (itemData(index).isValid() && itemData(index) == QVariant((int)QVariant::UserType)) { | ||
63 | QColor color = QColorDialog::getColor(m_init, this); | ||
64 | if (color.isValid()) { | ||
65 | if (findData(color, int(Qt::DecorationRole)) == -1) { | ||
66 | addItem(color.name()); | ||
67 | setItemData(count()-1, color, Qt::DecorationRole); | ||
68 | } | ||
69 | setCurrentIndex(findData(color, int(Qt::DecorationRole))); | ||
70 | } else | ||
71 | setCurrentIndex(findData(m_init)); | ||
72 | } | ||
73 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/ColorCombo.h b/utils/wpseditor/gui/src/QPropertyEditor/ColorCombo.h new file mode 100644 index 0000000000..530b05bbc5 --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/ColorCombo.h | |||
@@ -0,0 +1,49 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // | ||
24 | // This class is based on the Color Editor Factory Example by Trolltech | ||
25 | // | ||
26 | // ************************************************************************************************* | ||
27 | |||
28 | #ifndef COLORCOMBO_H_ | ||
29 | #define COLORCOMBO_H_ | ||
30 | |||
31 | #include <Qt/qcombobox.h> | ||
32 | |||
33 | class ColorCombo : public QComboBox { | ||
34 | Q_OBJECT | ||
35 | public: | ||
36 | ColorCombo(QWidget* parent = 0); | ||
37 | virtual ~ColorCombo(); | ||
38 | |||
39 | QColor color() const; | ||
40 | void setColor(QColor c); | ||
41 | |||
42 | private slots: | ||
43 | void currentChanged(int index); | ||
44 | |||
45 | private: | ||
46 | QColor m_init; | ||
47 | |||
48 | }; | ||
49 | #endif | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/Property.cpp b/utils/wpseditor/gui/src/QPropertyEditor/Property.cpp new file mode 100644 index 0000000000..0746d15140 --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/Property.cpp | |||
@@ -0,0 +1,136 @@ | |||
1 | // **************************************************************************************** | ||
2 | // | ||
3 | // QPropertyEditor Library | ||
4 | // -------------------------------------- | ||
5 | // Copyright (C) 2007 Volker Wiendl | ||
6 | // | ||
7 | // This file is part of the Horde3D Scene Editor. | ||
8 | // | ||
9 | // The QPropertyEditor Library is free software; you can redistribute it and/or modify | ||
10 | // it under the terms of the GNU General Public License as published by | ||
11 | // the Free Software Foundation version 3 of the License | ||
12 | // | ||
13 | // The Horde3D Scene Editor is distributed in the hope that it will be useful, | ||
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | // GNU General Public License for more details. | ||
17 | // | ||
18 | // You should have received a copy of the GNU General Public License | ||
19 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | // | ||
21 | // **************************************************************************************** | ||
22 | |||
23 | #include "Property.h" | ||
24 | #include "ColorCombo.h" | ||
25 | |||
26 | #include <Qt/qmetaobject.h> | ||
27 | #include <Qt/qspinbox.h> | ||
28 | |||
29 | #include <limits.h> | ||
30 | |||
31 | Property::Property(const QString& name /*= QString()*/, QObject* propertyObject /*= 0*/, QObject* parent /*= 0*/) : QObject(parent), | ||
32 | m_propertyObject(propertyObject) { | ||
33 | setObjectName(name); | ||
34 | } | ||
35 | |||
36 | QVariant Property::value(int /*role = Qt::UserRole*/) const { | ||
37 | if (m_propertyObject) | ||
38 | return m_propertyObject->property(qPrintable(objectName())); | ||
39 | else | ||
40 | return QVariant(); | ||
41 | } | ||
42 | |||
43 | void Property::setValue(const QVariant &value) { | ||
44 | if (m_propertyObject) | ||
45 | m_propertyObject->setProperty(qPrintable(objectName()), value); | ||
46 | } | ||
47 | |||
48 | bool Property::isReadOnly() { | ||
49 | if (m_propertyObject && m_propertyObject->metaObject()->property(m_propertyObject->metaObject()->indexOfProperty(qPrintable(objectName()))).isWritable()) | ||
50 | return false; | ||
51 | else | ||
52 | return true; | ||
53 | } | ||
54 | |||
55 | QWidget* Property::createEditor(QWidget *parent, const QStyleOptionViewItem &option) { | ||
56 | (void)option; | ||
57 | QWidget* editor = 0; | ||
58 | switch (value().type()) { | ||
59 | case QVariant::Color: | ||
60 | editor = new ColorCombo(parent); | ||
61 | break; | ||
62 | case QVariant::Int: | ||
63 | editor = new QSpinBox(parent); | ||
64 | editor->setProperty("minimum", -INT_MAX); | ||
65 | editor->setProperty("maximum", INT_MAX); | ||
66 | connect(editor, SIGNAL(valueChanged(int)), this, SLOT(setValue(int))); | ||
67 | break; | ||
68 | case QMetaType::Float: | ||
69 | case QVariant::Double: | ||
70 | editor = new QDoubleSpinBox(parent); | ||
71 | editor->setProperty("minimum", -INT_MAX); | ||
72 | editor->setProperty("maximum", INT_MAX); | ||
73 | connect(editor, SIGNAL(valueChanged(double)), this, SLOT(setValue(double))); | ||
74 | break; | ||
75 | default: | ||
76 | return editor; | ||
77 | } | ||
78 | return editor; | ||
79 | } | ||
80 | |||
81 | bool Property::setEditorData(QWidget *editor, const QVariant &data) { | ||
82 | switch (value().type()) { | ||
83 | case QVariant::Color: | ||
84 | static_cast<ColorCombo*>(editor)->setColor(data.value<QColor>()); | ||
85 | return true; | ||
86 | ; | ||
87 | case QVariant::Int: | ||
88 | editor->blockSignals(true); | ||
89 | static_cast<QSpinBox*>(editor)->setValue(data.toInt()); | ||
90 | editor->blockSignals(false); | ||
91 | return true; | ||
92 | case QMetaType::Float: | ||
93 | case QVariant::Double: | ||
94 | editor->blockSignals(true); | ||
95 | static_cast<QDoubleSpinBox*>(editor)->setValue(data.toDouble()); | ||
96 | editor->blockSignals(false); | ||
97 | return true; | ||
98 | default: | ||
99 | return false; | ||
100 | } | ||
101 | return false; | ||
102 | } | ||
103 | |||
104 | QVariant Property::editorData(QWidget *editor) { | ||
105 | switch (value().type()) { | ||
106 | case QVariant::Color: | ||
107 | return QVariant::fromValue(static_cast<ColorCombo*>(editor)->color()); | ||
108 | case QVariant::Int: | ||
109 | return QVariant(static_cast<QSpinBox*>(editor)->value()); | ||
110 | case QMetaType::Float: | ||
111 | case QVariant::Double: | ||
112 | return QVariant(static_cast<QDoubleSpinBox*>(editor)->value()); | ||
113 | break; | ||
114 | default: | ||
115 | return QVariant(); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | Property* Property::findPropertyObject(QObject* propertyObject) { | ||
120 | if (m_propertyObject == propertyObject) | ||
121 | return this; | ||
122 | for (int i=0; i<children().size(); ++i) { | ||
123 | Property* child = static_cast<Property*>(children()[i])->findPropertyObject(propertyObject); | ||
124 | if (child) | ||
125 | return child; | ||
126 | } | ||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | void Property::setValue(double value) { | ||
131 | setValue(QVariant(value)); | ||
132 | } | ||
133 | |||
134 | void Property::setValue(int value) { | ||
135 | setValue(QVariant(value)); | ||
136 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/Property.h b/utils/wpseditor/gui/src/QPropertyEditor/Property.h new file mode 100644 index 0000000000..52d6842987 --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/Property.h | |||
@@ -0,0 +1,157 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #ifndef PROPERTY_H_ | ||
26 | #define PROPERTY_H_ | ||
27 | |||
28 | #include <Qt/qwidget.h> | ||
29 | #include <Qt/qstyleoption.h> | ||
30 | #include <Qt/qvariant.h> | ||
31 | |||
32 | /** | ||
33 | * The Property class is the base class for all properties in the QPropertyEditor | ||
34 | * You can implement custom properties inherited from this class to further enhence the | ||
35 | * functionality of the QPropertyEditor | ||
36 | */ | ||
37 | class Property : public QObject { | ||
38 | Q_OBJECT | ||
39 | |||
40 | public: | ||
41 | |||
42 | /** | ||
43 | * Constructor | ||
44 | * | ||
45 | * @param name the name of the property within the propertyObject (will be used in the QPropertyEditorWidget view too) | ||
46 | * @param propertyObject the object that contains the property | ||
47 | * @param parent optional parent object | ||
48 | */ | ||
49 | Property(const QString& name = QString(), QObject* propertyObject = 0, QObject* parent = 0); | ||
50 | |||
51 | /** | ||
52 | * The value stored by this property | ||
53 | * @return QVariant the data converted to a QVariant | ||
54 | */ | ||
55 | virtual QVariant value(int role = Qt::UserRole) const; | ||
56 | /** | ||
57 | * Sets the value stored by this property | ||
58 | * @param value the data converted to a QVariant | ||
59 | */ | ||
60 | virtual void setValue(const QVariant& value); | ||
61 | |||
62 | /** | ||
63 | * Returns the QObject which contains the property managed by this instance | ||
64 | * @return QObject* pointer to the QObject that contains user defined properties | ||
65 | */ | ||
66 | QObject* propertyObject() { | ||
67 | return m_propertyObject; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * Flag if property is used for indicating a group or really manages a property | ||
72 | * @return bool true if this property is only used to display a category in the QPropertyEditorWidget | ||
73 | */ | ||
74 | bool isRoot() { | ||
75 | return m_propertyObject == 0; | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | * Flag if the property can be set | ||
80 | * @return bool true if this property has no set method | ||
81 | */ | ||
82 | bool isReadOnly(); | ||
83 | |||
84 | /** | ||
85 | * Returns the row of this instance within the QPropertyModel | ||
86 | * @return int row within the QPropertyModel | ||
87 | */ | ||
88 | int row() { | ||
89 | return parent()->children().indexOf(this); | ||
90 | } | ||
91 | |||
92 | /** | ||
93 | * returns optional settings for the editor widget that is used to manipulate the properties value | ||
94 | * @return QString a string that contains property settings for the editor widget (e.g. "minimum=1.0;maximum=10.0;") | ||
95 | */ | ||
96 | QString editorHints() { | ||
97 | return m_hints; | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * Sets properties for the editor widget that is used to manipulate the data value managed by this instance | ||
102 | * @param hints a string containing property settings for the editor widget that manipulates this property | ||
103 | */ | ||
104 | virtual void setEditorHints(const QString& hints) { | ||
105 | m_hints = hints; | ||
106 | } | ||
107 | |||
108 | /** | ||
109 | * Creates an editor for the data managed by this instance | ||
110 | * @param parent widget the newly created editor widget will be child of | ||
111 | * @param option currently not used | ||
112 | * @return QWidget* pointer to the editor widget | ||
113 | */ | ||
114 | virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option); | ||
115 | |||
116 | /** | ||
117 | * Returns the data of the editor widget used to manipulate this instance | ||
118 | * @return QVariant the data converted to a QVariant | ||
119 | */ | ||
120 | virtual QVariant editorData(QWidget *editor); | ||
121 | |||
122 | /** | ||
123 | * Changes the editor widget's data to a specific value | ||
124 | * @param editor the editor widget | ||
125 | * @param data the data to set in the editor widget | ||
126 | * @return bool true if editor widget was set to the given data successfully, false if the data can not be set in the editor (e.g. wrong datatype) | ||
127 | */ | ||
128 | virtual bool setEditorData(QWidget *editor, const QVariant& data); | ||
129 | |||
130 | /** | ||
131 | * Tries to find the first property that manages the given propertyObject | ||
132 | * @param propertyObject | ||
133 | * @return Property | ||
134 | */ | ||
135 | Property* findPropertyObject(QObject* propertyObject); | ||
136 | |||
137 | private slots: | ||
138 | /** | ||
139 | * This slot is used to immediately set the properties when the editor widget's value of a double or float | ||
140 | * property has changed | ||
141 | * @param value the new value | ||
142 | */ | ||
143 | void setValue(double value); | ||
144 | /** | ||
145 | * This slot is used to immediately set the properties when the editor widget's value of an integer | ||
146 | * property has changed | ||
147 | * @param value the new value | ||
148 | */ | ||
149 | void setValue(int value); | ||
150 | |||
151 | private: | ||
152 | QObject* m_propertyObject; | ||
153 | QString m_hints; | ||
154 | |||
155 | }; | ||
156 | |||
157 | #endif | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditor.pro b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditor.pro new file mode 100644 index 0000000000..85fd29ee2c --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditor.pro | |||
@@ -0,0 +1,26 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += staticlib debug_and_release | ||
3 | SOURCES = ColorCombo.cpp \ | ||
4 | Property.cpp \ | ||
5 | QPropertyEditorWidget.cpp \ | ||
6 | QPropertyModel.cpp \ | ||
7 | QVariantDelegate.cpp | ||
8 | HEADERS = ColorCombo.h \ | ||
9 | Property.h \ | ||
10 | QPropertyEditorWidget.h \ | ||
11 | QPropertyModel.h \ | ||
12 | QVariantDelegate.h | ||
13 | INCLUDEPATH += . | ||
14 | DESTDIR = ../../lib | ||
15 | UI_DIR = . | ||
16 | CONFIG(debug, debug|release) { | ||
17 | TARGET = QPropertyEditord | ||
18 | OBJECTS_DIR = ../../build/QPropertyEditor/debug | ||
19 | MOC_DIR = ../../build/QPropertyEditor/debug | ||
20 | } | ||
21 | CONFIG(release, debug|release) { | ||
22 | TARGET = QPropertyEditor | ||
23 | OBJECTS_DIR = ../../build/QPropertyEditor/release | ||
24 | MOC_DIR = ../../build/QPropertyEditor/release | ||
25 | DEFINES += QT_NO_DEBUG | ||
26 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.cpp b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.cpp new file mode 100644 index 0000000000..fc4b90c227 --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.cpp | |||
@@ -0,0 +1,56 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #include "QPropertyEditorWidget.h" | ||
26 | #include "QPropertyModel.h" | ||
27 | #include "QVariantDelegate.h" | ||
28 | #include "Property.h" | ||
29 | |||
30 | QPropertyEditorWidget::QPropertyEditorWidget(QWidget* parent /*= 0*/) : QTreeView(parent) { | ||
31 | m_model = new QPropertyModel(this); | ||
32 | setModel(m_model); | ||
33 | setItemDelegate(new QVariantDelegate(this)); | ||
34 | } | ||
35 | |||
36 | |||
37 | QPropertyEditorWidget::~QPropertyEditorWidget() {} | ||
38 | |||
39 | void QPropertyEditorWidget::addObject(QObject* propertyObject) { | ||
40 | m_model->addItem(propertyObject); | ||
41 | expandToDepth(0); | ||
42 | } | ||
43 | |||
44 | void QPropertyEditorWidget::setObject(QObject* propertyObject) { | ||
45 | m_model->clear(); | ||
46 | if (propertyObject) | ||
47 | addObject(propertyObject); | ||
48 | } | ||
49 | |||
50 | void QPropertyEditorWidget::updateObject(QObject* propertyObject) { | ||
51 | m_model->updateItem(propertyObject); | ||
52 | } | ||
53 | |||
54 | void QPropertyEditorWidget::setCustomPropertyCB(UserTypeCB callback) { | ||
55 | m_model->setCustomPropertyCB(callback); | ||
56 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.h b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.h new file mode 100644 index 0000000000..2dab87722a --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.h | |||
@@ -0,0 +1,113 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #ifndef QPROPERTYEDITORWIDGET_H_ | ||
26 | #define QPROPERTYEDITORWIDGET_H_ | ||
27 | |||
28 | #include <Qt/qtreeview.h> | ||
29 | |||
30 | class QPropertyModel; | ||
31 | class Property; | ||
32 | |||
33 | /** | ||
34 | * \mainpage QPropertyEditor | ||
35 | * | ||
36 | * \section intro_sec Introduction | ||
37 | * | ||
38 | * The main purpose for the QPropertyEditor is the visualization and manipulation of properties defined via the Q_PROPERTY macro in | ||
39 | * QObject based classes. | ||
40 | */ | ||
41 | |||
42 | /** | ||
43 | * \brief The QPropertyEditorWidget offers an easy to use mechanism to visualize properties of a class inherited from QObject. | ||
44 | * | ||
45 | * Qt provides a nice way to define class properties by using the Q_PROPERTY macro. The purpose of the QPropertyEditor | ||
46 | * is to visualize these properties in an easy way. | ||
47 | * | ||
48 | * To use the property editor, all you have to do is to create a class that defines it's properties by using Q_PROPERTY | ||
49 | * and to add this class by using the addObject() method of this QPropertyEditorWidget class. | ||
50 | * The QPropertyEditorWidget is inherited from QTreeView and will display the properties in a tree with two columns: Name and Value | ||
51 | * | ||
52 | * For basic data types the build in editor widgets of Qt will be used. The QPropertyEditor itself only defines an additional | ||
53 | * editor for QColor (based on the Color Editor Factory Example from Trolltech). But it can easily be extended by yourself | ||
54 | * either within the library or for special datatypes also outside of the library in your application. | ||
55 | */ | ||
56 | class QPropertyEditorWidget : public QTreeView { | ||
57 | Q_OBJECT | ||
58 | public: | ||
59 | |||
60 | /** | ||
61 | * A typedef for a callback used to create user defined properties for custom datatypes | ||
62 | */ | ||
63 | typedef Property* (*UserTypeCB)(const QString& name, QObject* propertyObject, Property* parent); | ||
64 | |||
65 | /** | ||
66 | * \brief Constructor | ||
67 | * | ||
68 | * Creates a new editor widget based on QTreeView | ||
69 | * @param parent optional parent widget | ||
70 | */ | ||
71 | QPropertyEditorWidget(QWidget* parent = 0); | ||
72 | |||
73 | /// Destructor | ||
74 | virtual ~QPropertyEditorWidget(); | ||
75 | |||
76 | /** | ||
77 | * Adds the user properties of the given class to the QPropertyModel associated with this view | ||
78 | * | ||
79 | * @param propertyObject the class inherited from QObject that contains user properties that should be | ||
80 | * managed by the QPropertyModel associated with this view | ||
81 | */ | ||
82 | void addObject(QObject* propertyObject); | ||
83 | |||
84 | /** | ||
85 | * Similar to the addObject() method this method adds the properties of the given class to the QPropertyModel | ||
86 | * associated with this view. But in contrast to addObject() it will clear the model before, removing all | ||
87 | * previously added objects. | ||
88 | * | ||
89 | * @param propertyObject the class inherited from QObject that contains user properties that should be | ||
90 | * managed by the QPropertyModel associated with this view | ||
91 | */ | ||
92 | void setObject(QObject* propertyObject); | ||
93 | |||
94 | /** | ||
95 | * Updates the view for the given object. This can be usefull if a property was changed programmatically instead | ||
96 | * of using the view. In this case the view normally will display the new property values only after the user clicked | ||
97 | * on it. To overcome this problem you can call updateObject with the object whose property was changed. | ||
98 | */ | ||
99 | void updateObject(QObject* propertyObject); | ||
100 | |||
101 | /** | ||
102 | * If you define custom datatypes outside of this library the QPropertyModel will check if you | ||
103 | * also defined a callback that is responsible to create custom property classes inherited from Property to handle | ||
104 | * these datatypes. With this method you can set such a callback that will create custom properties for custom datatypes. | ||
105 | */ | ||
106 | void setCustomPropertyCB(UserTypeCB callback); | ||
107 | |||
108 | private: | ||
109 | /// The Model for this view | ||
110 | QPropertyModel* m_model; | ||
111 | |||
112 | }; | ||
113 | #endif | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.cpp b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.cpp new file mode 100644 index 0000000000..b147cd089d --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.cpp | |||
@@ -0,0 +1,236 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #include "QPropertyModel.h" | ||
26 | |||
27 | #include "Property.h" | ||
28 | |||
29 | #include <Qt/qapplication.h> | ||
30 | #include <Qt/qmetaobject.h> | ||
31 | #include <Qt/qitemeditorfactory.h> | ||
32 | |||
33 | struct PropertyPair { | ||
34 | PropertyPair(const QMetaObject* obj, QMetaProperty property) : Property(property), Object(obj) {} | ||
35 | |||
36 | QMetaProperty Property; | ||
37 | const QMetaObject* Object; | ||
38 | |||
39 | bool operator==(const PropertyPair& other) const { | ||
40 | return QString(other.Property.name()) == QString(Property.name()); | ||
41 | } | ||
42 | }; | ||
43 | |||
44 | |||
45 | QPropertyModel::QPropertyModel(QObject* parent /*= 0*/) : QAbstractItemModel(parent), m_userCallback(0) { | ||
46 | m_rootItem = new Property("Root",0, this); | ||
47 | } | ||
48 | |||
49 | |||
50 | QPropertyModel::~QPropertyModel() {} | ||
51 | |||
52 | QModelIndex QPropertyModel::index ( int row, int column, const QModelIndex & parent /*= QModelIndex()*/ ) const { | ||
53 | Property *parentItem = m_rootItem; | ||
54 | if (parent.isValid()) | ||
55 | parentItem = static_cast<Property*>(parent.internalPointer()); | ||
56 | if (row >= parentItem->children().size()) | ||
57 | return QModelIndex(); | ||
58 | return createIndex(row, column, parentItem->children().at(row)); | ||
59 | |||
60 | } | ||
61 | |||
62 | QModelIndex QPropertyModel::parent ( const QModelIndex & index ) const { | ||
63 | if (!index.isValid()) | ||
64 | return QModelIndex(); | ||
65 | |||
66 | Property *childItem = static_cast<Property*>(index.internalPointer()); | ||
67 | Property *parentItem = qobject_cast<Property*>(childItem->parent()); | ||
68 | |||
69 | if (!parentItem || parentItem == m_rootItem) | ||
70 | return QModelIndex(); | ||
71 | |||
72 | return createIndex(parentItem->row(), 0, parentItem); | ||
73 | } | ||
74 | |||
75 | int QPropertyModel::rowCount ( const QModelIndex & parent /*= QModelIndex()*/ ) const { | ||
76 | Property *parentItem = m_rootItem; | ||
77 | if (parent.isValid()) | ||
78 | parentItem = static_cast<Property*>(parent.internalPointer()); | ||
79 | return parentItem->children().size(); | ||
80 | } | ||
81 | |||
82 | int QPropertyModel::columnCount ( const QModelIndex & parent /*= QModelIndex()*/ ) const { | ||
83 | (void)parent; | ||
84 | return 2; | ||
85 | } | ||
86 | |||
87 | QVariant QPropertyModel::data ( const QModelIndex & index, int role /*= Qt::DisplayRole*/ ) const { | ||
88 | if (!index.isValid()) | ||
89 | return QVariant(); | ||
90 | |||
91 | Property *item = static_cast<Property*>(index.internalPointer()); | ||
92 | switch (role) { | ||
93 | case Qt::ToolTipRole: | ||
94 | case Qt::DecorationRole: | ||
95 | case Qt::DisplayRole: | ||
96 | case Qt::EditRole: | ||
97 | if (index.column() == 0) | ||
98 | return item->objectName(); | ||
99 | if (index.column() == 1) | ||
100 | return item->value(role); | ||
101 | case Qt::BackgroundRole: | ||
102 | if (item->isRoot()) return QApplication::palette("QTreeView").brush(QPalette::Normal, QPalette::Button).color(); | ||
103 | break; | ||
104 | }; | ||
105 | return QVariant(); | ||
106 | } | ||
107 | |||
108 | // edit methods | ||
109 | bool QPropertyModel::setData ( const QModelIndex & index, const QVariant & value, int role /*= Qt::EditRole*/ ) { | ||
110 | if (index.isValid() && role == Qt::EditRole) { | ||
111 | Property *item = static_cast<Property*>(index.internalPointer()); | ||
112 | item->setValue(value); | ||
113 | emit dataChanged(index, index); | ||
114 | return true; | ||
115 | } | ||
116 | return false; | ||
117 | } | ||
118 | |||
119 | Qt::ItemFlags QPropertyModel::flags ( const QModelIndex & index ) const { | ||
120 | if (!index.isValid()) | ||
121 | return Qt::ItemIsEnabled; | ||
122 | Property *item = static_cast<Property*>(index.internalPointer()); | ||
123 | // only allow change of value attribute | ||
124 | if (item->isRoot()) | ||
125 | return Qt::ItemIsEnabled; | ||
126 | else if (item->isReadOnly()) | ||
127 | return Qt::ItemIsDragEnabled | Qt::ItemIsSelectable; | ||
128 | else | ||
129 | return Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable; | ||
130 | } | ||
131 | |||
132 | |||
133 | QVariant QPropertyModel::headerData ( int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole*/ ) const { | ||
134 | if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { | ||
135 | switch (section) { | ||
136 | case 0: | ||
137 | return tr("Name"); | ||
138 | case 1: | ||
139 | return tr("Value"); | ||
140 | } | ||
141 | } | ||
142 | return QVariant(); | ||
143 | } | ||
144 | |||
145 | QModelIndex QPropertyModel::buddy ( const QModelIndex & index ) const { | ||
146 | if (index.isValid() && index.column() == 0) | ||
147 | return createIndex(index.row(), 1, index.internalPointer()); | ||
148 | return index; | ||
149 | } | ||
150 | |||
151 | void QPropertyModel::addItem(QObject *propertyObject) { | ||
152 | // first create property <-> class hierarchy | ||
153 | QList<PropertyPair> propertyMap; | ||
154 | QList<const QMetaObject*> classList; | ||
155 | const QMetaObject* metaObject = propertyObject->metaObject(); | ||
156 | do { | ||
157 | int count = metaObject->propertyCount(); | ||
158 | for (int i=0; i<count; ++i) { | ||
159 | QMetaProperty property = metaObject->property(i); | ||
160 | if (property.isUser()) // Hide Qt specific properties | ||
161 | { | ||
162 | PropertyPair pair(metaObject, property); | ||
163 | int index = propertyMap.indexOf(pair); | ||
164 | if (index != -1) | ||
165 | propertyMap[index] = pair; | ||
166 | else | ||
167 | propertyMap.push_back(pair); | ||
168 | } | ||
169 | } | ||
170 | classList.push_front(metaObject); | ||
171 | } while ((metaObject = metaObject->superClass())!=0); | ||
172 | |||
173 | QList<const QMetaObject*> finalClassList; | ||
174 | // remove empty classes from hierarchy list | ||
175 | foreach(const QMetaObject* obj, classList) { | ||
176 | bool keep = false; | ||
177 | foreach(PropertyPair pair, propertyMap) { | ||
178 | if (pair.Object == obj) { | ||
179 | keep = true; | ||
180 | break; | ||
181 | } | ||
182 | } | ||
183 | if (keep) | ||
184 | finalClassList.push_back(obj); | ||
185 | } | ||
186 | |||
187 | // finally insert properties for classes containing them | ||
188 | int i=rowCount(); | ||
189 | beginInsertRows(QModelIndex(), i, i + finalClassList.count()); | ||
190 | foreach(const QMetaObject* metaObject, finalClassList) { | ||
191 | // Set default name of the hierarchy property to the class name | ||
192 | QString name = metaObject->className(); | ||
193 | // Check if there is a special name for the class | ||
194 | int index = metaObject->indexOfClassInfo(qPrintable(name)); | ||
195 | if (index != -1) | ||
196 | name = metaObject->classInfo(index).value(); | ||
197 | // Create Property Item for class node | ||
198 | Property* propertyItem = new Property(name, 0, m_rootItem); | ||
199 | foreach(PropertyPair pair, propertyMap) { | ||
200 | // Check if the property is associated with the current class from the finalClassList | ||
201 | if (pair.Object == metaObject) { | ||
202 | QMetaProperty property(pair.Property); | ||
203 | Property* p = 0; | ||
204 | if (property.type() == QVariant::UserType && m_userCallback) | ||
205 | p = m_userCallback(property.name(), propertyObject, propertyItem); | ||
206 | else | ||
207 | p = new Property(property.name(), propertyObject, propertyItem); | ||
208 | int index = metaObject->indexOfClassInfo(property.name()); | ||
209 | if (index != -1) | ||
210 | p->setEditorHints(metaObject->classInfo(index).value()); | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | endInsertRows(); | ||
215 | } | ||
216 | |||
217 | void QPropertyModel::updateItem ( QObject* propertyObject, const QModelIndex& parent /*= QModelIndex() */ ) { | ||
218 | Property *parentItem = m_rootItem; | ||
219 | if (parent.isValid()) | ||
220 | parentItem = static_cast<Property*>(parent.internalPointer()); | ||
221 | if (parentItem->propertyObject() != propertyObject) | ||
222 | parentItem = parentItem->findPropertyObject(propertyObject); | ||
223 | if (parentItem) // Indicate view that the data for the indices have changed | ||
224 | dataChanged(createIndex(parentItem->row(), 0, static_cast<Property*>(parentItem)), createIndex(parentItem->row(), 1, static_cast<Property*>(parentItem))); | ||
225 | } | ||
226 | |||
227 | void QPropertyModel::clear() { | ||
228 | beginRemoveRows(QModelIndex(), 0, rowCount()); | ||
229 | delete m_rootItem; | ||
230 | m_rootItem = new Property("Root",0, this); | ||
231 | endRemoveRows(); | ||
232 | } | ||
233 | |||
234 | void QPropertyModel::setCustomPropertyCB(QPropertyEditorWidget::UserTypeCB callback) { | ||
235 | m_userCallback = callback; | ||
236 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.h b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.h new file mode 100644 index 0000000000..8a52bbe87c --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.h | |||
@@ -0,0 +1,105 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | #ifndef QPROPERTYMODEL_H_ | ||
25 | #define QPROPERTYMODEL_H_ | ||
26 | |||
27 | #include <Qt/qabstractitemmodel.h> | ||
28 | #include <Qt/qmap.h> | ||
29 | |||
30 | #include "QPropertyEditorWidget.h" | ||
31 | |||
32 | class Property; | ||
33 | |||
34 | /** | ||
35 | * The QPropertyModel handles the user defined properties of QObjects | ||
36 | */ | ||
37 | class QPropertyModel : public QAbstractItemModel { | ||
38 | Q_OBJECT | ||
39 | public: | ||
40 | /** | ||
41 | * Constructor | ||
42 | * @param parent optional parent object | ||
43 | */ | ||
44 | QPropertyModel(QObject* parent = 0); | ||
45 | /// Destructor | ||
46 | virtual ~QPropertyModel(); | ||
47 | |||
48 | /// QAbstractItemModel implementation | ||
49 | QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; | ||
50 | |||
51 | /// QAbstractItemModel implementation | ||
52 | QModelIndex parent ( const QModelIndex & index ) const; | ||
53 | /// QAbstractItemModel implementation | ||
54 | int rowCount ( const QModelIndex & parent = QModelIndex() ) const; | ||
55 | /// QAbstractItemModel implementation | ||
56 | int columnCount ( const QModelIndex & parent = QModelIndex() ) const; | ||
57 | /// QAbstractItemModel implementation | ||
58 | QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; | ||
59 | |||
60 | /// QAbstractItemModel implementation | ||
61 | bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); | ||
62 | /// QAbstractItemModel implementation | ||
63 | Qt::ItemFlags flags ( const QModelIndex & index ) const; | ||
64 | |||
65 | /// QAbstractItemModel implementation | ||
66 | QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; | ||
67 | |||
68 | /// QAbstractItemModel implementation | ||
69 | QModelIndex buddy ( const QModelIndex & index ) const; | ||
70 | |||
71 | /** | ||
72 | * Adds the user properties of the given class to the QPropertyModel instance | ||
73 | * | ||
74 | * @param propertyObject the class inherited from QObject that contains user properties that should be | ||
75 | * managed by this instance | ||
76 | */ | ||
77 | void addItem(QObject* propertyObject); | ||
78 | |||
79 | /** | ||
80 | * Creates a dataChanged signal for the given object | ||
81 | * @param propertyObject the instance of a QObject based class that should be updated | ||
82 | * @param parent optional model index the propertyObject is child of | ||
83 | */ | ||
84 | void updateItem ( QObject* propertyObject, const QModelIndex& parent = QModelIndex() ) ; | ||
85 | |||
86 | /** | ||
87 | * Removes all objects from the model | ||
88 | */ | ||
89 | void clear(); | ||
90 | |||
91 | /** | ||
92 | * Sets custom callback that will be used to create Property instances for custom datatypes | ||
93 | */ | ||
94 | void setCustomPropertyCB(QPropertyEditorWidget::UserTypeCB callback); | ||
95 | |||
96 | private: | ||
97 | |||
98 | /// The Root Property for all objects | ||
99 | Property* m_rootItem; | ||
100 | |||
101 | /// Custom callback | ||
102 | QPropertyEditorWidget::UserTypeCB m_userCallback; | ||
103 | |||
104 | }; | ||
105 | #endif | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.cpp b/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.cpp new file mode 100644 index 0000000000..ebda9b2c31 --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.cpp | |||
@@ -0,0 +1,105 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #include "QVariantDelegate.h" | ||
26 | |||
27 | #include "Property.h" | ||
28 | |||
29 | #include <Qt/qabstractitemview.h> | ||
30 | |||
31 | |||
32 | QVariantDelegate::QVariantDelegate(QObject* parent) : QItemDelegate(parent) {} | ||
33 | |||
34 | |||
35 | QVariantDelegate::~QVariantDelegate() {} | ||
36 | |||
37 | QWidget *QVariantDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem& option , const QModelIndex & index ) const { | ||
38 | QWidget* editor = 0; | ||
39 | Property* p = static_cast<Property*>(index.internalPointer()); | ||
40 | switch (p->value().type()) { | ||
41 | case QVariant::Color: | ||
42 | case QVariant::Int: | ||
43 | case QMetaType::Float: | ||
44 | case QVariant::Double: | ||
45 | case QVariant::UserType: | ||
46 | editor = p->createEditor(parent, option); | ||
47 | if (editor) break; // if no editor could be created take default case | ||
48 | default: | ||
49 | editor = QItemDelegate::createEditor(parent, option, index); | ||
50 | } | ||
51 | parseEditorHints(editor, p->editorHints()); | ||
52 | return editor; | ||
53 | } | ||
54 | |||
55 | void QVariantDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { | ||
56 | QVariant data = index.model()->data(index, Qt::EditRole); | ||
57 | switch (data.type()) { | ||
58 | case QVariant::Color: | ||
59 | case QMetaType::Double: | ||
60 | case QMetaType::Float: | ||
61 | case QVariant::UserType: | ||
62 | if (static_cast<Property*>(index.internalPointer())->setEditorData(editor, data)) // if editor couldn't be recognized use default | ||
63 | break; | ||
64 | default: | ||
65 | QItemDelegate::setEditorData(editor, index); | ||
66 | break; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | void QVariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { | ||
71 | QVariant data = index.model()->data(index, Qt::EditRole); | ||
72 | switch (data.type()) { | ||
73 | case QVariant::Color: | ||
74 | case QMetaType::Double: | ||
75 | case QMetaType::Float: | ||
76 | case QVariant::UserType: { | ||
77 | QVariant data = static_cast<Property*>(index.internalPointer())->editorData(editor); | ||
78 | if (data.isValid()) { | ||
79 | model->setData(index, data , Qt::EditRole); | ||
80 | break; | ||
81 | } | ||
82 | } | ||
83 | default: | ||
84 | QItemDelegate::setModelData(editor, model, index); | ||
85 | break; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | void QVariantDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index ) const { | ||
90 | return QItemDelegate::updateEditorGeometry(editor, option, index); | ||
91 | } | ||
92 | |||
93 | void QVariantDelegate::parseEditorHints(QWidget* editor, const QString& editorHints) const { | ||
94 | if (editor && !editorHints.isEmpty()) { | ||
95 | // Parse for property values | ||
96 | QRegExp rx("(.*)(=\\s*)(.*)(;{1})"); | ||
97 | rx.setMinimal(true); | ||
98 | int pos = 0; | ||
99 | while ((pos = rx.indexIn(editorHints, pos)) != -1) { | ||
100 | qDebug("Setting %s to %s", qPrintable(rx.cap(1)), qPrintable(rx.cap(3))); | ||
101 | editor->setProperty(qPrintable(rx.cap(1).trimmed()), rx.cap(3).trimmed()); | ||
102 | pos += rx.matchedLength(); | ||
103 | } | ||
104 | } | ||
105 | } | ||
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.h b/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.h new file mode 100644 index 0000000000..e06265af82 --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/QVariantDelegate.h | |||
@@ -0,0 +1,78 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library is distributed in the hope that it will be useful, | ||
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #ifndef COLORSELECTIONBUTTON_H_ | ||
26 | #define COLORSELECTIONBUTTON_H_ | ||
27 | |||
28 | #include <Qt/qitemdelegate.h> | ||
29 | |||
30 | |||
31 | /** | ||
32 | * This class is used to create the editor widgets for datatypes encapsulated in QVariant variables | ||
33 | */ | ||
34 | class QVariantDelegate : public QItemDelegate { | ||
35 | Q_OBJECT | ||
36 | |||
37 | public: | ||
38 | /** | ||
39 | * Constructor | ||
40 | * @param parent optional parent object | ||
41 | */ | ||
42 | QVariantDelegate(QObject* parent = 0); | ||
43 | /// Destructor | ||
44 | virtual ~QVariantDelegate(); | ||
45 | |||
46 | /** | ||
47 | * Creates an editor widget as child of a given widget for a specific QModelIndex | ||
48 | * | ||
49 | * @param parent the parent widget for the editor | ||
50 | * @param option some style options that the editor should use | ||
51 | * @param index the index of the item the editor will be created for | ||
52 | * @return QWidget the editor widget | ||
53 | */ | ||
54 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; | ||
55 | |||
56 | /** | ||
57 | * Tries to set the editor data based on the value stored at a specific QModelIndex | ||
58 | * @param editor the editor widget | ||
59 | * @param index the model index of the value that should be used in the editor | ||
60 | */ | ||
61 | virtual void setEditorData(QWidget *editor, const QModelIndex &index) const; | ||
62 | |||
63 | /** | ||
64 | * Sets the data of a specific QModelIndex to tha value of the editor widget | ||
65 | * @param editor the editor widget that contains the new value | ||
66 | * @param model the model that contains the index | ||
67 | * @param index the index within the model whose data value should be set to the data value of the editor | ||
68 | */ | ||
69 | virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; | ||
70 | |||
71 | /// QItemDelegate implementation | ||
72 | virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; | ||
73 | |||
74 | protected: | ||
75 | void parseEditorHints(QWidget* editor, const QString& editorHints) const; | ||
76 | |||
77 | }; | ||
78 | #endif | ||
diff --git a/utils/wpseditor/gui/src/main.cpp b/utils/wpseditor/gui/src/main.cpp new file mode 100644 index 0000000000..0ba22c9fce --- /dev/null +++ b/utils/wpseditor/gui/src/main.cpp | |||
@@ -0,0 +1,16 @@ | |||
1 | #include <QApplication> | ||
2 | #include "qwpseditorwindow.h" | ||
3 | #include "utils.h" | ||
4 | #include <QPointer> | ||
5 | |||
6 | QPointer<QWpsEditorWindow> win; | ||
7 | |||
8 | int main(int argc, char ** argv) { | ||
9 | QApplication app( argc, argv ); | ||
10 | |||
11 | win = new QWpsEditorWindow; | ||
12 | win->show(); | ||
13 | app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) ); | ||
14 | |||
15 | return app.exec(); | ||
16 | } | ||
diff --git a/utils/wpseditor/gui/src/qtrackstate.cpp b/utils/wpseditor/gui/src/qtrackstate.cpp new file mode 100644 index 0000000000..dad2f9a4aa --- /dev/null +++ b/utils/wpseditor/gui/src/qtrackstate.cpp | |||
@@ -0,0 +1,41 @@ | |||
1 | #include "qtrackstate.h" | ||
2 | #include <stdlib.h> | ||
3 | |||
4 | // | ||
5 | QTrackState::QTrackState( ) | ||
6 | : QObject() { | ||
7 | memset(&state,0,sizeof(state)); | ||
8 | state.title = (char*)"title"; | ||
9 | state.artist = (char*)"artist"; | ||
10 | state.album = (char*)"album"; | ||
11 | state.length = 100; | ||
12 | state.elapsed = 50; | ||
13 | } | ||
14 | |||
15 | void QTrackState::setTitle(const QString& name) { | ||
16 | state.title = new char[name.length()]; | ||
17 | strcpy(state.title,name.toAscii()); | ||
18 | emit stateChanged(state); | ||
19 | } | ||
20 | |||
21 | void QTrackState::setArtist(const QString& name) { | ||
22 | state.artist = new char[name.length()]; | ||
23 | strcpy(state.artist,name.toAscii()); | ||
24 | emit stateChanged(state); | ||
25 | } | ||
26 | |||
27 | void QTrackState::setAlbum(const QString& name) { | ||
28 | state.album = new char[name.length()]; | ||
29 | strcpy(state.album,name.toAscii()); | ||
30 | emit stateChanged(state); | ||
31 | } | ||
32 | |||
33 | void QTrackState::setLength(int le) { | ||
34 | state.length = le; | ||
35 | emit stateChanged(state); | ||
36 | } | ||
37 | |||
38 | void QTrackState::setElapsed(int le) { | ||
39 | state.elapsed = le; | ||
40 | emit stateChanged(state); | ||
41 | } | ||
diff --git a/utils/wpseditor/gui/src/qtrackstate.h b/utils/wpseditor/gui/src/qtrackstate.h new file mode 100644 index 0000000000..b57f7a8376 --- /dev/null +++ b/utils/wpseditor/gui/src/qtrackstate.h | |||
@@ -0,0 +1,57 @@ | |||
1 | #ifndef __QTRACKSTATE_H__ | ||
2 | #define __QTRACKSTATE_H__ | ||
3 | |||
4 | #include "wpsstate.h" | ||
5 | #include <QObject> | ||
6 | |||
7 | class QWpsState; | ||
8 | |||
9 | class QTrackState : public QObject { | ||
10 | Q_OBJECT | ||
11 | Q_CLASSINFO ( "QTrackState", "Mp3 State" ); | ||
12 | Q_PROPERTY ( QString Title READ title WRITE setTitle DESIGNABLE true USER true ) | ||
13 | Q_PROPERTY ( QString Artist READ artist WRITE setArtist DESIGNABLE true USER true ) | ||
14 | Q_PROPERTY ( QString Album READ album WRITE setAlbum DESIGNABLE true USER true ) | ||
15 | Q_PROPERTY ( int Length READ length WRITE setLength DESIGNABLE true USER true ) | ||
16 | Q_CLASSINFO("Length", "readOnly=true;value=100"); | ||
17 | Q_PROPERTY ( int Elapsed READ elapsed WRITE setElapsed DESIGNABLE true USER true ) | ||
18 | Q_CLASSINFO("Elapsed", "minimum=0;maximum=100;value=50"); | ||
19 | |||
20 | |||
21 | trackstate state; | ||
22 | |||
23 | public: | ||
24 | QTrackState(); | ||
25 | |||
26 | public slots: | ||
27 | QString title() const { | ||
28 | return state.title; | ||
29 | } | ||
30 | void setTitle ( const QString& name ); | ||
31 | |||
32 | QString artist() const { | ||
33 | return state.artist; | ||
34 | } | ||
35 | void setArtist ( const QString& name ); | ||
36 | |||
37 | QString album() const { | ||
38 | return state.album; | ||
39 | } | ||
40 | void setAlbum ( const QString& name ); | ||
41 | |||
42 | int length() const { | ||
43 | return state.length; | ||
44 | } | ||
45 | void setLength ( int l ); | ||
46 | |||
47 | int elapsed() const { | ||
48 | return state.elapsed; | ||
49 | } | ||
50 | void setElapsed ( int l ); | ||
51 | |||
52 | signals: | ||
53 | void stateChanged ( trackstate state ); | ||
54 | |||
55 | }; | ||
56 | |||
57 | #endif // __QTRACKSTATE_H__ | ||
diff --git a/utils/wpseditor/gui/src/qwpsdrawer.cpp b/utils/wpseditor/gui/src/qwpsdrawer.cpp new file mode 100644 index 0000000000..ab8a4b32d6 --- /dev/null +++ b/utils/wpseditor/gui/src/qwpsdrawer.cpp | |||
@@ -0,0 +1,200 @@ | |||
1 | #include "qwpsdrawer.h" | ||
2 | #include "slider.h" | ||
3 | #include "utils.h" | ||
4 | #include <QtGui> | ||
5 | #include <QLibrary> | ||
6 | #include <stdarg.h> | ||
7 | // | ||
8 | |||
9 | |||
10 | QPointer<QWpsDrawer> drawer; | ||
11 | QPixmap *QWpsDrawer::pix = NULL; | ||
12 | QString QWpsDrawer::mTmpWpsString; | ||
13 | QImage QWpsDrawer::backdrop; | ||
14 | proxy_api QWpsDrawer::api; | ||
15 | |||
16 | QWpsDrawer::QWpsDrawer( QWpsState *ws,QTrackState *ms, QWidget *parent ) | ||
17 | : QWidget(parent),wpsState(ws),trackState(ms),showGrid(false),mTargetLibName("libwps") { | ||
18 | |||
19 | tryResolve(); | ||
20 | memset(&api,0,sizeof(struct proxy_api)); | ||
21 | |||
22 | api.verbose = 2; | ||
23 | api.putsxy = &QWpsDrawer::putsxy; | ||
24 | api.transparent_bitmap_part = &QWpsDrawer::transparent_bitmap_part; | ||
25 | api.bitmap_part = &QWpsDrawer::bitmap_part; | ||
26 | api.drawpixel = &QWpsDrawer::drawpixel; | ||
27 | api.fillrect = &QWpsDrawer::fillrect; | ||
28 | api.hline = &QWpsDrawer::hline; | ||
29 | api.vline = &QWpsDrawer::vline; | ||
30 | api.clear_viewport = &QWpsDrawer::clear_viewport; | ||
31 | api.load_wps_backdrop = &QWpsDrawer::load_wps_backdrop; | ||
32 | api.read_bmp_file = &QWpsDrawer::read_bmp_file; | ||
33 | api.debugf = &qlogger; | ||
34 | newTempWps(); | ||
35 | } | ||
36 | |||
37 | bool QWpsDrawer::tryResolve() { | ||
38 | QLibrary lib(qApp->applicationDirPath()+"/"+mTargetLibName); | ||
39 | wps_init = (pfwps_init)lib.resolve("wps_init"); | ||
40 | wps_display = (pfwps_display)lib.resolve("wps_display"); | ||
41 | wps_refresh = (pfwps_refresh)lib.resolve("wps_refresh"); | ||
42 | mResolved = wps_init && wps_display && wps_refresh; | ||
43 | if (!mResolved) | ||
44 | DEBUGF1(tr("ERR: Failed to resolve funcs!")); | ||
45 | return mResolved; | ||
46 | } | ||
47 | QWpsDrawer::~QWpsDrawer() { | ||
48 | qDebug()<<"QWpsDrawer::~QWpsDrawer()"; | ||
49 | cleanTemp(); | ||
50 | } | ||
51 | |||
52 | void QWpsDrawer::mouseReleaseEvent ( QMouseEvent * event ) { | ||
53 | Q_UNUSED(event); | ||
54 | /*int x = event->x() - (this->width()-pix->width())/2, | ||
55 | y = event->y() - (this->height()-pix->height())/2; | ||
56 | DEBUGF1("x=%d,y=%d",x,y);*/ | ||
57 | } | ||
58 | void QWpsDrawer::newTempWps() { | ||
59 | QTemporaryFile tmpWps; | ||
60 | tmpWps.setAutoRemove(false); | ||
61 | tmpWps.setFileTemplate(QDir::tempPath()+"/XXXXXXXXXX.wps"); | ||
62 | if (tmpWps.open()) { | ||
63 | QString tmpDir = tmpWps.fileName().left(tmpWps.fileName().length()-4); | ||
64 | if (QDir::temp().mkpath(tmpDir)) { | ||
65 | mTmpWpsString = tmpDir; | ||
66 | DEBUGF1(mTmpWpsString); | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | |||
71 | void QWpsDrawer::WpsInit(QString buffer, bool isFile) { | ||
72 | |||
73 | if (!mResolved) | ||
74 | if (!tryResolve()) | ||
75 | return; | ||
76 | if (isFile) { | ||
77 | cleanTemp(); | ||
78 | DEBUGF1( tr("Loading %1").arg(buffer)); | ||
79 | QFile file(buffer); | ||
80 | if (file.open(QIODevice::ReadOnly | QIODevice::Text)) | ||
81 | mWpsString = file.readAll(); | ||
82 | newTempWps(); | ||
83 | } else | ||
84 | mWpsString = buffer; | ||
85 | { | ||
86 | QFile tfile(mTmpWpsString+".wps"); | ||
87 | if (tfile.open(QIODevice::WriteOnly | QIODevice::Text)) | ||
88 | tfile.write(mWpsString.toAscii(),mWpsString.length()); | ||
89 | } | ||
90 | |||
91 | if (isFile) | ||
92 | wps_init(buffer.toAscii(), &api, isFile); | ||
93 | else | ||
94 | wps_init(QString(mTmpWpsString+".wps").toAscii(), &api, true); | ||
95 | pix = new QPixmap(api.getwidth(),api.getheight()); | ||
96 | |||
97 | drawBackdrop(); | ||
98 | |||
99 | setMinimumWidth(api.getwidth()); | ||
100 | setMinimumHeight(api.getheight()); | ||
101 | |||
102 | update(); | ||
103 | } | ||
104 | |||
105 | void QWpsDrawer::paintEvent(QPaintEvent * event) { | ||
106 | if (!mResolved) | ||
107 | return; | ||
108 | if (pix==NULL) | ||
109 | return; | ||
110 | QPainter p(this); | ||
111 | QRect rect = event->rect(); | ||
112 | |||
113 | drawBackdrop(); | ||
114 | wps_refresh(); | ||
115 | |||
116 | if (showGrid) { | ||
117 | QPainter g(pix); | ||
118 | viewport_api avp; | ||
119 | api.get_current_vp(&avp); | ||
120 | |||
121 | g.setPen(Qt::green); | ||
122 | |||
123 | for (int i=0;i*avp.fontheight/1.5<avp.width ;i++) { | ||
124 | g.drawLine(int(i*avp.fontheight/1.5), 0, int(i*avp.fontheight/1.5), avp.height); | ||
125 | } | ||
126 | for (int j=0;j*avp.fontheight<avp.height; j++) { | ||
127 | g.drawLine(0,j*avp.fontheight,avp.width,j*avp.fontheight); | ||
128 | } | ||
129 | } | ||
130 | |||
131 | p.drawPixmap((rect.width()-pix->width())/2,(rect.height()-pix->height())/2,*pix); | ||
132 | |||
133 | } | ||
134 | |||
135 | void QWpsDrawer::clear_viewport(int x,int y,int w,int h, int color) { | ||
136 | DEBUGF2("clear_viewport(int x=%d,int y=%d,int w=%d,int h=%d, int color)",x,y,w,h); | ||
137 | QPainter p(pix); | ||
138 | //p.setOpacity(0.1); | ||
139 | //QImage img = backdrop.copy(x,y,w,h); | ||
140 | //p.drawImage(x,y,img); | ||
141 | } | ||
142 | |||
143 | void QWpsDrawer::slotSetVolume() { | ||
144 | Slider *slider = new Slider(this, tr("Volume"),-74,10); | ||
145 | slider->show(); | ||
146 | connect(slider, SIGNAL(valueChanged(int)), wpsState, SLOT(setVolume(int))); | ||
147 | connect(this, SIGNAL(destroyed()),slider, SLOT(close())); | ||
148 | } | ||
149 | |||
150 | void QWpsDrawer::slotSetProgress() { | ||
151 | Slider *slider = new Slider(this,tr("Progress"),0,100); | ||
152 | slider->show(); | ||
153 | connect(slider, SIGNAL(valueChanged(int)), trackState, SLOT(setElapsed(int))); | ||
154 | connect(this, SIGNAL(destroyed()),slider, SLOT(close())); | ||
155 | } | ||
156 | |||
157 | void QWpsDrawer::slotWpsStateChanged(wpsstate ws_) { | ||
158 | if (api.set_wpsstate) | ||
159 | api.set_wpsstate(ws_); | ||
160 | update(); | ||
161 | } | ||
162 | |||
163 | void QWpsDrawer::slotTrackStateChanged(trackstate ms_) { | ||
164 | if (api.set_wpsstate) | ||
165 | api.set_trackstate(ms_); | ||
166 | update(); | ||
167 | } | ||
168 | |||
169 | void QWpsDrawer::slotShowGrid(bool show) { | ||
170 | showGrid = show; | ||
171 | update(); | ||
172 | } | ||
173 | |||
174 | void QWpsDrawer::drawBackdrop() { | ||
175 | QPainter b(pix); | ||
176 | QImage pink = backdrop.createMaskFromColor(qRgb(255,0,255),Qt::MaskOutColor); | ||
177 | backdrop.setAlphaChannel(pink); | ||
178 | b.drawImage(0,0,backdrop); | ||
179 | } | ||
180 | |||
181 | void QWpsDrawer::slotSetAudioStatus(int status) { | ||
182 | api.set_audio_status(status); | ||
183 | update(); | ||
184 | } | ||
185 | |||
186 | void QWpsDrawer::cleanTemp(bool fileToo) { | ||
187 | if (fileToo) | ||
188 | QFile::remove(mTmpWpsString+".wps"); | ||
189 | QDirIterator it(mTmpWpsString, QDirIterator::Subdirectories); | ||
190 | while (it.hasNext()) { | ||
191 | QFile::remove(it.next()); | ||
192 | } | ||
193 | QDir(mTmpWpsString).rmdir(mTmpWpsString); | ||
194 | } | ||
195 | |||
196 | void QWpsDrawer::closeEvent(QCloseEvent *event) { | ||
197 | qDebug()<<"QWpsDrawer::closeEvent()"; | ||
198 | cleanTemp(); | ||
199 | event->accept(); | ||
200 | } | ||
diff --git a/utils/wpseditor/gui/src/qwpsdrawer.h b/utils/wpseditor/gui/src/qwpsdrawer.h new file mode 100644 index 0000000000..d4dfa6c7a2 --- /dev/null +++ b/utils/wpseditor/gui/src/qwpsdrawer.h | |||
@@ -0,0 +1,82 @@ | |||
1 | #ifndef WPSDRAWER_H | ||
2 | #define WPSDRAWER_H | ||
3 | // | ||
4 | #include <QWidget> | ||
5 | #include <QPixmap> | ||
6 | #include <QPointer> | ||
7 | #include <QTemporaryFile> | ||
8 | #include "api.h" | ||
9 | #include "qtrackstate.h" | ||
10 | #include "qwpsstate.h" | ||
11 | // | ||
12 | |||
13 | typedef int (*pfwps_init)(const char* buff,struct proxy_api *api, bool isfile); | ||
14 | typedef int (*pfwps_display)(); | ||
15 | typedef int (*pfwps_refresh)(); | ||
16 | |||
17 | class QWpsDrawer : public QWidget { | ||
18 | Q_OBJECT | ||
19 | |||
20 | pfwps_init wps_init; | ||
21 | pfwps_display wps_display; | ||
22 | pfwps_refresh wps_refresh; | ||
23 | |||
24 | static QPixmap *pix; | ||
25 | static QImage backdrop; | ||
26 | |||
27 | QWpsState *wpsState; | ||
28 | QTrackState *trackState; | ||
29 | |||
30 | bool showGrid; | ||
31 | bool mResolved; | ||
32 | QString mWpsString; | ||
33 | QString mTargetLibName; | ||
34 | static QString mTmpWpsString; | ||
35 | |||
36 | |||
37 | protected: | ||
38 | virtual void paintEvent(QPaintEvent * event); | ||
39 | virtual void closeEvent(QCloseEvent *event); | ||
40 | virtual void mouseReleaseEvent ( QMouseEvent * event ) ; | ||
41 | void drawBackdrop(); | ||
42 | void newTempWps(); | ||
43 | void cleanTemp(bool fileToo=true); | ||
44 | bool tryResolve(); | ||
45 | public: | ||
46 | QWpsDrawer(QWpsState *ws,QTrackState *ms, QWidget *parent=0); | ||
47 | ~QWpsDrawer(); | ||
48 | void WpsInit(QString buffer, bool isFile = true); | ||
49 | |||
50 | QString wpsString() const { | ||
51 | return mWpsString; | ||
52 | }; | ||
53 | QString tempWps() const { | ||
54 | return mTmpWpsString; | ||
55 | }; | ||
56 | |||
57 | |||
58 | static proxy_api api; | ||
59 | /***********Drawing api******************/ | ||
60 | static void putsxy(int x, int y, const unsigned char *str); | ||
61 | static void transparent_bitmap_part(const void *src, int src_x, int src_y, | ||
62 | int stride, int x, int y, int width, int height); | ||
63 | static void bitmap_part(const void *src, int src_x, int src_y, | ||
64 | int stride, int x, int y, int width, int height); | ||
65 | static void drawpixel(int x, int y); | ||
66 | static void fillrect(int x, int y, int width, int height); | ||
67 | static void hline(int x1, int x2, int y); | ||
68 | static void vline(int x, int y1, int y2); | ||
69 | static void clear_viewport(int x,int y,int w,int h, int color); | ||
70 | static bool load_wps_backdrop(char* filename); | ||
71 | static int read_bmp_file(const char* filename,int *width, int *height); | ||
72 | /****************************************/ | ||
73 | public slots: | ||
74 | void slotSetVolume(); | ||
75 | void slotSetProgress(); | ||
76 | |||
77 | void slotShowGrid(bool); | ||
78 | void slotWpsStateChanged(wpsstate); | ||
79 | void slotTrackStateChanged(trackstate); | ||
80 | void slotSetAudioStatus(int); | ||
81 | }; | ||
82 | #endif | ||
diff --git a/utils/wpseditor/gui/src/qwpsdrawer_static.cpp b/utils/wpseditor/gui/src/qwpsdrawer_static.cpp new file mode 100644 index 0000000000..bf94d28a5a --- /dev/null +++ b/utils/wpseditor/gui/src/qwpsdrawer_static.cpp | |||
@@ -0,0 +1,77 @@ | |||
1 | #include "qwpsdrawer.h" | ||
2 | #include <QPainter> | ||
3 | #include <QFile> | ||
4 | #include <QFileInfo> | ||
5 | #include "utils.h" | ||
6 | |||
7 | void QWpsDrawer::putsxy(int x, int y, const unsigned char *str) { | ||
8 | QPainter p(pix); | ||
9 | viewport_api avp; | ||
10 | api.get_current_vp(&avp); | ||
11 | p.setPen(Qt::gray); | ||
12 | |||
13 | |||
14 | QFont font("times",avp.fontheight,QFont::Bold); | ||
15 | p.setFont(font); | ||
16 | p.drawText(x+avp.x,y + avp.fontheight + avp.y,(char*)str); | ||
17 | } | ||
18 | void QWpsDrawer::transparent_bitmap_part(const void *src, int src_x, int src_y, | ||
19 | int stride, int x, int y, int width, int height) { | ||
20 | QImage img; | ||
21 | img.load((char*)src); | ||
22 | DEBUGF2("transparent_bitmap_part(const void *src=%s, int src_x=%d, int src_y=%d,int stride=%d, int x=%d, int y=%d, int width=%d, int height=%d",(char*)src,src_x, src_y,stride, x, y, width, height); | ||
23 | QPainter p(pix); | ||
24 | QPoint target(x,y); | ||
25 | QRectF source(src_x, src_y, width, height); | ||
26 | |||
27 | QImage pink = img.createMaskFromColor(qRgb(255,0,255),Qt::MaskOutColor); | ||
28 | img.setAlphaChannel(pink); | ||
29 | |||
30 | p.drawImage(target, img, source); | ||
31 | } | ||
32 | void QWpsDrawer::bitmap_part(const void *src, int src_x, int src_y, | ||
33 | int stride, int x, int y, int width, int height) { | ||
34 | transparent_bitmap_part(src,src_x,src_y,stride,x,y,width,height); | ||
35 | } | ||
36 | void QWpsDrawer::drawpixel(int x, int y) { | ||
37 | QPainter p(pix); | ||
38 | p.setPen(Qt::blue); | ||
39 | p.drawPoint(x,y); | ||
40 | } | ||
41 | void QWpsDrawer::fillrect(int x, int y, int width, int height) { | ||
42 | QPainter p(pix); | ||
43 | DEBUGF2("fillrect(int x=%d, int y=%d, int width=%d, int height=%d)\n",x, y, width, height); | ||
44 | p.setPen(Qt::green); | ||
45 | } | ||
46 | void QWpsDrawer::hline(int x1, int x2, int y) { | ||
47 | QPainter p(pix); | ||
48 | p.setPen(Qt::black); | ||
49 | p.drawLine(x1,y,x2,y); | ||
50 | } | ||
51 | void QWpsDrawer::vline(int x, int y1, int y2) { | ||
52 | QPainter p(pix); | ||
53 | p.setPen(Qt::black); | ||
54 | p.drawLine(x,y1,x,y2); | ||
55 | } | ||
56 | bool QWpsDrawer::load_wps_backdrop(char* filename) { | ||
57 | DEBUGF2("load backdrop: %s", filename); | ||
58 | QFile file(filename); | ||
59 | QFileInfo info(file); | ||
60 | file.copy(mTmpWpsString+"/"+info.fileName()); | ||
61 | backdrop.load(filename); | ||
62 | return true; | ||
63 | } | ||
64 | |||
65 | int QWpsDrawer::read_bmp_file(const char* filename,int *width, int *height) { | ||
66 | QImage img; | ||
67 | |||
68 | QFile file(filename); | ||
69 | QFileInfo info(file); | ||
70 | file.copy(mTmpWpsString+"/"+info.fileName()); | ||
71 | |||
72 | img.load(filename); | ||
73 | //qDebug()<<"QWpsDrawer::read_bmp_file"<<img.width()<<img.height(); | ||
74 | *width = img.width(); | ||
75 | *height = img.height(); | ||
76 | return 1; | ||
77 | } | ||
diff --git a/utils/wpseditor/gui/src/qwpseditorwindow.cpp b/utils/wpseditor/gui/src/qwpseditorwindow.cpp new file mode 100644 index 0000000000..c3090bd027 --- /dev/null +++ b/utils/wpseditor/gui/src/qwpseditorwindow.cpp | |||
@@ -0,0 +1,120 @@ | |||
1 | #include "qwpseditorwindow.h" | ||
2 | #include "qwpsdrawer.h" | ||
3 | #include "utils.h" | ||
4 | #include <QFileDialog> | ||
5 | #include <QDebug> | ||
6 | #include <QInputDialog> | ||
7 | |||
8 | enum api_playmode playmodes[PLAYMODES_NUM] = { | ||
9 | API_STATUS_PLAY, | ||
10 | API_STATUS_STOP, | ||
11 | API_STATUS_PAUSE, | ||
12 | API_STATUS_FASTFORWARD, | ||
13 | API_STATUS_FASTBACKWARD | ||
14 | }; | ||
15 | |||
16 | const char *playmodeNames[] = { | ||
17 | "Play", | ||
18 | "Stop", | ||
19 | "Pause", | ||
20 | "FastForward", | ||
21 | "FastBackward" | ||
22 | }; | ||
23 | |||
24 | QWpsEditorWindow::QWpsEditorWindow( QWidget * parent, Qt::WFlags f) | ||
25 | : QMainWindow(parent, f) { | ||
26 | logEdit = 0; | ||
27 | setupUi(this); | ||
28 | drawer = new QWpsDrawer(&wpsState,&trackState, this); | ||
29 | QWpsDrawer::api.verbose = 1; | ||
30 | //drawer->WpsInit("iCatcher.wps"); | ||
31 | setCentralWidget(drawer); | ||
32 | connectActions(); | ||
33 | m_propertyEditor->addObject(&trackState); | ||
34 | m_propertyEditor->addObject(&wpsState); | ||
35 | } | ||
36 | |||
37 | void QWpsEditorWindow::connectActions() { | ||
38 | qDebug()<<"connect actions"; | ||
39 | connect(actOpenWps, SIGNAL(triggered()), this, SLOT(slotOpenWps())); | ||
40 | connect(actSetVolume, SIGNAL(triggered()), drawer, SLOT(slotSetVolume())); | ||
41 | connect(actSetProgress, SIGNAL(triggered()), drawer, SLOT(slotSetProgress())); | ||
42 | connect(actShowGrid, SIGNAL(triggered(bool)), drawer, SLOT(slotShowGrid(bool))); | ||
43 | |||
44 | connect(actUpdatePlainWps, SIGNAL(triggered()), SLOT(slotUpdatePlainWps())); | ||
45 | connect(plainWpsEdit->document(), SIGNAL(modificationChanged(bool)), SLOT(slotPlainDocModChanged(bool))); | ||
46 | |||
47 | connect(&wpsState, SIGNAL(stateChanged(wpsstate)), drawer, SLOT(slotWpsStateChanged(wpsstate))); | ||
48 | connect(&trackState, SIGNAL(stateChanged(trackstate)), drawer, SLOT(slotTrackStateChanged(trackstate))); | ||
49 | connect(&wpsState, SIGNAL(stateChanged(wpsstate)), this, SLOT(slotWpsStateChanged(wpsstate))); | ||
50 | connect(&trackState, SIGNAL(stateChanged(trackstate)), this, SLOT(slotTrackStateChanged(trackstate))); | ||
51 | |||
52 | connect(actClearLog, SIGNAL(triggered()), logEdit, SLOT(clear())); | ||
53 | connect(actVerboseLevel, SIGNAL(triggered()), SLOT(slotVerboseLevel())); | ||
54 | |||
55 | actGroupAudios = new QActionGroup(this); | ||
56 | signalMapper = new QSignalMapper(this); | ||
57 | for (int i=0;i<PLAYMODES_NUM;i++) { | ||
58 | QAction *act = new QAction(playmodeNames[i],this); | ||
59 | act->setCheckable(true); | ||
60 | actGroupAudios->addAction(act); | ||
61 | connect(act,SIGNAL(triggered()),signalMapper,SLOT(map())); | ||
62 | signalMapper->setMapping(act, i); | ||
63 | menuPlay->addAction(act); | ||
64 | actAudios[playmodes[i]] = act; | ||
65 | } | ||
66 | connect(signalMapper, SIGNAL(mapped(int)), SIGNAL(signalAudioStatusChanged(int))); | ||
67 | connect(this, SIGNAL(signalAudioStatusChanged(int)), drawer, SLOT(slotSetAudioStatus(int))); | ||
68 | actGroupAudios->setEnabled(false); | ||
69 | } | ||
70 | |||
71 | void QWpsEditorWindow::slotWpsStateChanged(wpsstate) { | ||
72 | m_propertyEditor->updateObject(&wpsState); | ||
73 | m_propertyEditor->update(); | ||
74 | } | ||
75 | |||
76 | void QWpsEditorWindow::slotTrackStateChanged(trackstate) { | ||
77 | m_propertyEditor->updateObject(&trackState); | ||
78 | m_propertyEditor->update(); | ||
79 | } | ||
80 | |||
81 | void QWpsEditorWindow::slotOpenWps() { | ||
82 | QString wpsfile = QFileDialog::getOpenFileName(this, | ||
83 | tr("Open WPS"), "", tr("WPS Files (*.wps);; All Files (*.*)")); | ||
84 | if (wpsfile == "") { | ||
85 | DEBUGF1(tr("File wasn't chosen")); | ||
86 | return; | ||
87 | } | ||
88 | m_propertyEditor->setEnabled(true); | ||
89 | drawer->WpsInit(wpsfile); | ||
90 | plainWpsEdit->clear(); | ||
91 | plainWpsEdit->append(drawer->wpsString()); | ||
92 | trackState.setAlbum(trackState.album()); | ||
93 | actGroupAudios->setEnabled(true); | ||
94 | } | ||
95 | |||
96 | void QWpsEditorWindow::logMsg(QString s) { | ||
97 | logEdit->append(s); | ||
98 | } | ||
99 | |||
100 | void QWpsEditorWindow::slotVerboseLevel() { | ||
101 | bool ok; | ||
102 | int i = QInputDialog::getInteger(this, tr("Set Verbose Level"),tr("Level:"), QWpsDrawer::api.verbose, 0, 3, 1, &ok); | ||
103 | if (ok) | ||
104 | QWpsDrawer::api.verbose = i; | ||
105 | } | ||
106 | |||
107 | void QWpsEditorWindow::slotUpdatePlainWps() { | ||
108 | DEBUGF1(tr("Updating WPS")); | ||
109 | plainWpsEdit->document()->setModified(false); | ||
110 | drawer->WpsInit(plainWpsEdit->toPlainText(),false); | ||
111 | |||
112 | } | ||
113 | |||
114 | void QWpsEditorWindow::slotPlainDocModChanged(bool changed) { | ||
115 | if (changed) | ||
116 | dockPlainWps->setWindowTitle(tr("PlainWps*")); | ||
117 | else | ||
118 | dockPlainWps->setWindowTitle(tr("PlainWps")); | ||
119 | } | ||
120 | |||
diff --git a/utils/wpseditor/gui/src/qwpseditorwindow.h b/utils/wpseditor/gui/src/qwpseditorwindow.h new file mode 100644 index 0000000000..019eb63808 --- /dev/null +++ b/utils/wpseditor/gui/src/qwpseditorwindow.h | |||
@@ -0,0 +1,45 @@ | |||
1 | #ifndef MAINWINDOWIMPL_H | ||
2 | #define MAINWINDOWIMPL_H | ||
3 | // | ||
4 | #include <QMainWindow> | ||
5 | #include <QActionGroup> | ||
6 | #include <QSignalMapper> | ||
7 | #include "ui_mainwindow.h" | ||
8 | #include "wpsstate.h" | ||
9 | #include "qwpsdrawer.h" | ||
10 | #include "qwpsstate.h" | ||
11 | #include "qtrackstate.h" | ||
12 | // | ||
13 | class QWpsEditorWindow : public QMainWindow, public Ui::MainWindow { | ||
14 | Q_OBJECT | ||
15 | QWpsState wpsState; | ||
16 | QTrackState trackState; | ||
17 | QPointer<QWpsDrawer> drawer; | ||
18 | |||
19 | QHash<int, QAction*> actAudios; | ||
20 | QActionGroup *actGroupAudios; | ||
21 | QSignalMapper *signalMapper; | ||
22 | |||
23 | protected: | ||
24 | void connectActions(); | ||
25 | public: | ||
26 | QWpsEditorWindow( QWidget * parent = 0, Qt::WFlags f = 0 ); | ||
27 | void logMsg(QString s); | ||
28 | private slots: | ||
29 | void slotOpenWps(); | ||
30 | void slotVerboseLevel(); | ||
31 | void slotWpsStateChanged(wpsstate); | ||
32 | void slotTrackStateChanged(trackstate); | ||
33 | |||
34 | void slotUpdatePlainWps(); | ||
35 | void slotPlainDocModChanged(bool m); | ||
36 | |||
37 | signals: | ||
38 | void signalAudioStatusChanged(int); | ||
39 | |||
40 | }; | ||
41 | #endif | ||
42 | |||
43 | |||
44 | |||
45 | |||
diff --git a/utils/wpseditor/gui/src/qwpsstate.cpp b/utils/wpseditor/gui/src/qwpsstate.cpp new file mode 100644 index 0000000000..4244bf6293 --- /dev/null +++ b/utils/wpseditor/gui/src/qwpsstate.cpp | |||
@@ -0,0 +1,29 @@ | |||
1 | #include "qwpsstate.h" | ||
2 | |||
3 | QWpsState::QWpsState(): QObject() { | ||
4 | state.fontheight = 8; | ||
5 | state.fontwidth = 5; | ||
6 | state.volume = -30; | ||
7 | state.battery_level = 50; | ||
8 | |||
9 | } | ||
10 | |||
11 | void QWpsState::setFontHeight(int val) { | ||
12 | state.fontheight = val; | ||
13 | emit stateChanged(state); | ||
14 | } | ||
15 | |||
16 | void QWpsState::setFontWidth(int val) { | ||
17 | state.fontwidth = val; | ||
18 | emit stateChanged(state); | ||
19 | } | ||
20 | |||
21 | void QWpsState::setVolume(int val) { | ||
22 | state.volume = val; | ||
23 | emit stateChanged(state); | ||
24 | } | ||
25 | |||
26 | void QWpsState::setBattery(int val) { | ||
27 | state.battery_level = val; | ||
28 | emit stateChanged(state); | ||
29 | } | ||
diff --git a/utils/wpseditor/gui/src/qwpsstate.h b/utils/wpseditor/gui/src/qwpsstate.h new file mode 100644 index 0000000000..eb43531de6 --- /dev/null +++ b/utils/wpseditor/gui/src/qwpsstate.h | |||
@@ -0,0 +1,54 @@ | |||
1 | #ifndef __WPSSTATE_H__ | ||
2 | #define __WPSSTATE_H__ | ||
3 | |||
4 | #include <QObject> | ||
5 | #include "wpsstate.h" | ||
6 | |||
7 | class QWpsState : public QObject { | ||
8 | Q_OBJECT | ||
9 | |||
10 | |||
11 | Q_CLASSINFO("QWpsState", "WPS State"); | ||
12 | Q_PROPERTY(int FontHeight READ fontHeight WRITE setFontHeight DESIGNABLE true USER true) | ||
13 | Q_CLASSINFO("FontHeight", "minimum=6;maximum=20;value=10"); | ||
14 | Q_PROPERTY(int FontWidth READ fontWidth WRITE setFontWidth DESIGNABLE true USER true) | ||
15 | Q_CLASSINFO("FontWidth", "minimum=4;maximum=20;value=8"); | ||
16 | Q_PROPERTY(int Volume READ volume WRITE setVolume DESIGNABLE true USER true) | ||
17 | Q_CLASSINFO("Volume", "minimum=-74;maximum=24;value=-15"); | ||
18 | Q_PROPERTY(int Battery READ battery WRITE setBattery DESIGNABLE true USER true) | ||
19 | Q_CLASSINFO("Battery", "minimum=0;maximum=100;value=50"); | ||
20 | |||
21 | wpsstate state; | ||
22 | |||
23 | public: | ||
24 | QWpsState(); | ||
25 | |||
26 | int fontHeight() const { | ||
27 | return state.fontheight; | ||
28 | } | ||
29 | void setFontHeight(int val); | ||
30 | |||
31 | int fontWidth() const { | ||
32 | return state.fontwidth; | ||
33 | } | ||
34 | void setFontWidth(int val); | ||
35 | |||
36 | int battery() const { | ||
37 | return state.battery_level; | ||
38 | } | ||
39 | void setBattery(int val); | ||
40 | |||
41 | int volume() const { | ||
42 | return state.volume; | ||
43 | } | ||
44 | public slots: | ||
45 | void setVolume(int val); | ||
46 | |||
47 | |||
48 | |||
49 | |||
50 | |||
51 | signals: | ||
52 | void stateChanged ( wpsstate state ); | ||
53 | }; | ||
54 | #endif // __WPSSTATE_H__ | ||
diff --git a/utils/wpseditor/gui/src/slider.cpp b/utils/wpseditor/gui/src/slider.cpp new file mode 100644 index 0000000000..7e3c9a942c --- /dev/null +++ b/utils/wpseditor/gui/src/slider.cpp | |||
@@ -0,0 +1,20 @@ | |||
1 | #include "slider.h" | ||
2 | #include <QDebug> | ||
3 | // | ||
4 | Slider::Slider(QWidget *parent, QString caption, int min, int max ):QDialog(parent) { | ||
5 | setupUi ( this ); | ||
6 | connect(horslider, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int))); | ||
7 | connect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged(int))); | ||
8 | setWindowTitle(caption); | ||
9 | horslider->setMinimum(min); | ||
10 | horslider->setMaximum(max); | ||
11 | } | ||
12 | // | ||
13 | int Slider::value() { | ||
14 | return horslider->value(); | ||
15 | } | ||
16 | void Slider::slotValueChanged(int step) { | ||
17 | setWindowTitle(tr("Value =%1 ").arg(step)); | ||
18 | } | ||
19 | |||
20 | |||
diff --git a/utils/wpseditor/gui/src/slider.h b/utils/wpseditor/gui/src/slider.h new file mode 100644 index 0000000000..2620731644 --- /dev/null +++ b/utils/wpseditor/gui/src/slider.h | |||
@@ -0,0 +1,21 @@ | |||
1 | #ifndef SLIDERIMPL_H | ||
2 | #define SLIDERIMPL_H | ||
3 | // | ||
4 | #include <QWidget> | ||
5 | #include <QDialog> | ||
6 | #include "ui_slider.h" | ||
7 | // | ||
8 | class Slider : public QDialog , Ui::slider { | ||
9 | Q_OBJECT | ||
10 | public slots: | ||
11 | void slotValueChanged(int step); | ||
12 | signals: | ||
13 | void valueChanged(int); | ||
14 | public: | ||
15 | Slider(QWidget *parent, QString caption, int min, int max ); | ||
16 | int value(); | ||
17 | |||
18 | |||
19 | |||
20 | }; | ||
21 | #endif | ||
diff --git a/utils/wpseditor/gui/src/utils.cpp b/utils/wpseditor/gui/src/utils.cpp new file mode 100644 index 0000000000..f18442555b --- /dev/null +++ b/utils/wpseditor/gui/src/utils.cpp | |||
@@ -0,0 +1,28 @@ | |||
1 | #include "utils.h" | ||
2 | #include <QPointer> | ||
3 | #include <QtGlobal> | ||
4 | #include "qwpseditorwindow.h" | ||
5 | |||
6 | extern QPointer<QWpsEditorWindow> win; | ||
7 | |||
8 | int qlogger(const char* fmt,...) { | ||
9 | va_list ap; | ||
10 | va_start(ap, fmt); | ||
11 | QString s; | ||
12 | s.vsprintf(fmt,ap); | ||
13 | va_end(ap); | ||
14 | s.replace("\n",""); | ||
15 | //qDebug()<<s; | ||
16 | if (win==0) | ||
17 | qDebug()<<s; | ||
18 | if (s.indexOf("ERR")>=0) | ||
19 | s = "<font color=red>"+s+"</font>"; | ||
20 | if (win!=0) | ||
21 | win->logMsg(s); | ||
22 | va_end(ap); | ||
23 | return s.length(); | ||
24 | } | ||
25 | |||
26 | int qlogger(const QString& s) { | ||
27 | return qlogger(s.toAscii().data()); | ||
28 | } | ||
diff --git a/utils/wpseditor/gui/src/utils.h b/utils/wpseditor/gui/src/utils.h new file mode 100644 index 0000000000..ae88d78249 --- /dev/null +++ b/utils/wpseditor/gui/src/utils.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef __UTILS_H__ | ||
2 | #define __UTILS_H__ | ||
3 | |||
4 | #include <QDebug> | ||
5 | |||
6 | #define DEBUGF1 qlogger | ||
7 | #define DEBUGF2(...) | ||
8 | |||
9 | extern int qlogger(const char* fmt,...); | ||
10 | extern int qlogger(const QString& s); | ||
11 | |||
12 | #endif // __UTILS_H__ | ||
diff --git a/utils/wpseditor/gui/ui/mainwindow.ui b/utils/wpseditor/gui/ui/mainwindow.ui new file mode 100644 index 0000000000..cd3f52bd66 --- /dev/null +++ b/utils/wpseditor/gui/ui/mainwindow.ui | |||
@@ -0,0 +1,290 @@ | |||
1 | <ui version="4.0" > | ||
2 | <class>MainWindow</class> | ||
3 | <widget class="QMainWindow" name="MainWindow" > | ||
4 | <property name="geometry" > | ||
5 | <rect> | ||
6 | <x>0</x> | ||
7 | <y>0</y> | ||
8 | <width>882</width> | ||
9 | <height>669</height> | ||
10 | </rect> | ||
11 | </property> | ||
12 | <property name="windowTitle" > | ||
13 | <string>WPS Editor</string> | ||
14 | </property> | ||
15 | <widget class="QWidget" name="centralwidget" > | ||
16 | <property name="geometry" > | ||
17 | <rect> | ||
18 | <x>260</x> | ||
19 | <y>21</y> | ||
20 | <width>344</width> | ||
21 | <height>345</height> | ||
22 | </rect> | ||
23 | </property> | ||
24 | </widget> | ||
25 | <widget class="QMenuBar" name="menubar" > | ||
26 | <property name="geometry" > | ||
27 | <rect> | ||
28 | <x>0</x> | ||
29 | <y>0</y> | ||
30 | <width>882</width> | ||
31 | <height>21</height> | ||
32 | </rect> | ||
33 | </property> | ||
34 | <widget class="QMenu" name="menuFile" > | ||
35 | <property name="title" > | ||
36 | <string>File</string> | ||
37 | </property> | ||
38 | <addaction name="actOpenWps" /> | ||
39 | <addaction name="actSetVolume" /> | ||
40 | <addaction name="actSetProgress" /> | ||
41 | <addaction name="actShowGrid" /> | ||
42 | <addaction name="actClearLog" /> | ||
43 | <addaction name="actVerboseLevel" /> | ||
44 | <addaction name="actQuit" /> | ||
45 | </widget> | ||
46 | <widget class="QMenu" name="menuPlay" > | ||
47 | <property name="title" > | ||
48 | <string>Play</string> | ||
49 | </property> | ||
50 | </widget> | ||
51 | <addaction name="menuFile" /> | ||
52 | <addaction name="menuPlay" /> | ||
53 | </widget> | ||
54 | <widget class="QStatusBar" name="statusbar" > | ||
55 | <property name="geometry" > | ||
56 | <rect> | ||
57 | <x>0</x> | ||
58 | <y>650</y> | ||
59 | <width>882</width> | ||
60 | <height>19</height> | ||
61 | </rect> | ||
62 | </property> | ||
63 | </widget> | ||
64 | <widget class="QDockWidget" name="dockPlainWps" > | ||
65 | <property name="geometry" > | ||
66 | <rect> | ||
67 | <x>0</x> | ||
68 | <y>370</y> | ||
69 | <width>882</width> | ||
70 | <height>280</height> | ||
71 | </rect> | ||
72 | </property> | ||
73 | <property name="minimumSize" > | ||
74 | <size> | ||
75 | <width>0</width> | ||
76 | <height>30</height> | ||
77 | </size> | ||
78 | </property> | ||
79 | <property name="windowTitle" > | ||
80 | <string>PlainWps</string> | ||
81 | </property> | ||
82 | <attribute name="dockWidgetArea" > | ||
83 | <number>8</number> | ||
84 | </attribute> | ||
85 | <widget class="QWidget" name="dockWidgetContents_3" > | ||
86 | <property name="geometry" > | ||
87 | <rect> | ||
88 | <x>0</x> | ||
89 | <y>22</y> | ||
90 | <width>882</width> | ||
91 | <height>258</height> | ||
92 | </rect> | ||
93 | </property> | ||
94 | <layout class="QGridLayout" name="gridLayout_2" > | ||
95 | <item rowspan="2" row="0" column="0" > | ||
96 | <widget class="QTextEdit" name="plainWpsEdit" > | ||
97 | <property name="autoFillBackground" > | ||
98 | <bool>false</bool> | ||
99 | </property> | ||
100 | <property name="readOnly" > | ||
101 | <bool>false</bool> | ||
102 | </property> | ||
103 | </widget> | ||
104 | </item> | ||
105 | <item row="0" column="1" > | ||
106 | <widget class="QPushButton" name="btnUpdatePlainWps" > | ||
107 | <property name="text" > | ||
108 | <string>Update WPS</string> | ||
109 | </property> | ||
110 | </widget> | ||
111 | </item> | ||
112 | <item row="1" column="1" > | ||
113 | <spacer name="verticalSpacer" > | ||
114 | <property name="orientation" > | ||
115 | <enum>Qt::Vertical</enum> | ||
116 | </property> | ||
117 | <property name="sizeHint" stdset="0" > | ||
118 | <size> | ||
119 | <width>20</width> | ||
120 | <height>211</height> | ||
121 | </size> | ||
122 | </property> | ||
123 | </spacer> | ||
124 | </item> | ||
125 | </layout> | ||
126 | </widget> | ||
127 | </widget> | ||
128 | <widget class="QDockWidget" name="m_dockWidget" > | ||
129 | <property name="geometry" > | ||
130 | <rect> | ||
131 | <x>0</x> | ||
132 | <y>21</y> | ||
133 | <width>256</width> | ||
134 | <height>345</height> | ||
135 | </rect> | ||
136 | </property> | ||
137 | <property name="windowTitle" > | ||
138 | <string>Property Editor</string> | ||
139 | </property> | ||
140 | <attribute name="dockWidgetArea" > | ||
141 | <number>1</number> | ||
142 | </attribute> | ||
143 | <widget class="QPropertyEditorWidget" name="m_propertyEditor" > | ||
144 | <property name="enabled" > | ||
145 | <bool>false</bool> | ||
146 | </property> | ||
147 | <property name="geometry" > | ||
148 | <rect> | ||
149 | <x>0</x> | ||
150 | <y>22</y> | ||
151 | <width>256</width> | ||
152 | <height>323</height> | ||
153 | </rect> | ||
154 | </property> | ||
155 | </widget> | ||
156 | </widget> | ||
157 | <widget class="QDockWidget" name="dockWidget" > | ||
158 | <property name="geometry" > | ||
159 | <rect> | ||
160 | <x>608</x> | ||
161 | <y>21</y> | ||
162 | <width>274</width> | ||
163 | <height>345</height> | ||
164 | </rect> | ||
165 | </property> | ||
166 | <property name="minimumSize" > | ||
167 | <size> | ||
168 | <width>0</width> | ||
169 | <height>30</height> | ||
170 | </size> | ||
171 | </property> | ||
172 | <property name="windowTitle" > | ||
173 | <string>Log</string> | ||
174 | </property> | ||
175 | <attribute name="dockWidgetArea" > | ||
176 | <number>2</number> | ||
177 | </attribute> | ||
178 | <widget class="QWidget" name="dockWidgetContents" > | ||
179 | <property name="geometry" > | ||
180 | <rect> | ||
181 | <x>0</x> | ||
182 | <y>22</y> | ||
183 | <width>274</width> | ||
184 | <height>323</height> | ||
185 | </rect> | ||
186 | </property> | ||
187 | <layout class="QGridLayout" name="gridLayout" > | ||
188 | <item row="0" column="0" > | ||
189 | <widget class="QTextEdit" name="logEdit" > | ||
190 | <property name="autoFillBackground" > | ||
191 | <bool>false</bool> | ||
192 | </property> | ||
193 | <property name="readOnly" > | ||
194 | <bool>true</bool> | ||
195 | </property> | ||
196 | </widget> | ||
197 | </item> | ||
198 | </layout> | ||
199 | </widget> | ||
200 | </widget> | ||
201 | <action name="actQuit" > | ||
202 | <property name="text" > | ||
203 | <string>Quit</string> | ||
204 | </property> | ||
205 | </action> | ||
206 | <action name="actOpenWps" > | ||
207 | <property name="text" > | ||
208 | <string>Open WPS</string> | ||
209 | </property> | ||
210 | </action> | ||
211 | <action name="actSetVolume" > | ||
212 | <property name="text" > | ||
213 | <string>Set Volume</string> | ||
214 | </property> | ||
215 | </action> | ||
216 | <action name="actSetProgress" > | ||
217 | <property name="text" > | ||
218 | <string>Set Progress</string> | ||
219 | </property> | ||
220 | </action> | ||
221 | <action name="actShowGrid" > | ||
222 | <property name="checkable" > | ||
223 | <bool>true</bool> | ||
224 | </property> | ||
225 | <property name="checked" > | ||
226 | <bool>false</bool> | ||
227 | </property> | ||
228 | <property name="text" > | ||
229 | <string>Show Grid</string> | ||
230 | </property> | ||
231 | </action> | ||
232 | <action name="actClearLog" > | ||
233 | <property name="text" > | ||
234 | <string>Clear Log</string> | ||
235 | </property> | ||
236 | </action> | ||
237 | <action name="actVerboseLevel" > | ||
238 | <property name="text" > | ||
239 | <string>Verbose Level</string> | ||
240 | </property> | ||
241 | </action> | ||
242 | <action name="actUpdatePlainWps" > | ||
243 | <property name="text" > | ||
244 | <string>Update WPS</string> | ||
245 | </property> | ||
246 | </action> | ||
247 | </widget> | ||
248 | <customwidgets> | ||
249 | <customwidget> | ||
250 | <class>QPropertyEditorWidget</class> | ||
251 | <extends>QTreeView</extends> | ||
252 | <header>QPropertyEditorWidget.h</header> | ||
253 | </customwidget> | ||
254 | </customwidgets> | ||
255 | <resources/> | ||
256 | <connections> | ||
257 | <connection> | ||
258 | <sender>btnUpdatePlainWps</sender> | ||
259 | <signal>clicked()</signal> | ||
260 | <receiver>actUpdatePlainWps</receiver> | ||
261 | <slot>trigger()</slot> | ||
262 | <hints> | ||
263 | <hint type="sourcelabel" > | ||
264 | <x>835</x> | ||
265 | <y>411</y> | ||
266 | </hint> | ||
267 | <hint type="destinationlabel" > | ||
268 | <x>-1</x> | ||
269 | <y>-1</y> | ||
270 | </hint> | ||
271 | </hints> | ||
272 | </connection> | ||
273 | <connection> | ||
274 | <sender>actQuit</sender> | ||
275 | <signal>triggered()</signal> | ||
276 | <receiver>MainWindow</receiver> | ||
277 | <slot>close()</slot> | ||
278 | <hints> | ||
279 | <hint type="sourcelabel" > | ||
280 | <x>-1</x> | ||
281 | <y>-1</y> | ||
282 | </hint> | ||
283 | <hint type="destinationlabel" > | ||
284 | <x>440</x> | ||
285 | <y>334</y> | ||
286 | </hint> | ||
287 | </hints> | ||
288 | </connection> | ||
289 | </connections> | ||
290 | </ui> | ||
diff --git a/utils/wpseditor/gui/ui/slider.ui b/utils/wpseditor/gui/ui/slider.ui new file mode 100644 index 0000000000..24fff0bf23 --- /dev/null +++ b/utils/wpseditor/gui/ui/slider.ui | |||
@@ -0,0 +1,43 @@ | |||
1 | <ui version="4.0" > | ||
2 | <class>slider</class> | ||
3 | <widget class="QWidget" name="slider" > | ||
4 | <property name="geometry" > | ||
5 | <rect> | ||
6 | <x>0</x> | ||
7 | <y>0</y> | ||
8 | <width>295</width> | ||
9 | <height>37</height> | ||
10 | </rect> | ||
11 | </property> | ||
12 | <property name="windowTitle" > | ||
13 | <string>Value</string> | ||
14 | </property> | ||
15 | <widget class="QSlider" name="horslider" > | ||
16 | <property name="geometry" > | ||
17 | <rect> | ||
18 | <x>0</x> | ||
19 | <y>10</y> | ||
20 | <width>291</width> | ||
21 | <height>21</height> | ||
22 | </rect> | ||
23 | </property> | ||
24 | <property name="minimum" > | ||
25 | <number>-78</number> | ||
26 | </property> | ||
27 | <property name="maximum" > | ||
28 | <number>24</number> | ||
29 | </property> | ||
30 | <property name="singleStep" > | ||
31 | <number>1</number> | ||
32 | </property> | ||
33 | <property name="value" > | ||
34 | <number>-78</number> | ||
35 | </property> | ||
36 | <property name="orientation" > | ||
37 | <enum>Qt::Horizontal</enum> | ||
38 | </property> | ||
39 | </widget> | ||
40 | </widget> | ||
41 | <resources/> | ||
42 | <connections/> | ||
43 | </ui> | ||
diff --git a/utils/wpseditor/libwps/Makefile b/utils/wpseditor/libwps/Makefile new file mode 100644 index 0000000000..3779a9ed30 --- /dev/null +++ b/utils/wpseditor/libwps/Makefile | |||
@@ -0,0 +1,100 @@ | |||
1 | # __________ __ ___. | ||
2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
6 | # \/ \/ \/ \/ \/ | ||
7 | # $Id$ | ||
8 | # | ||
9 | ROOT=../../.. | ||
10 | |||
11 | OS = w32 | ||
12 | CC = gcc | ||
13 | MKDIR = mkdir -p | ||
14 | |||
15 | ifeq ($(findstring MINGW,$(shell uname)),MINGW) | ||
16 | OS = w32 | ||
17 | CC = mingw32-gcc | ||
18 | COPY = copy | ||
19 | RM = rm | ||
20 | endif | ||
21 | |||
22 | ifeq ($(findstring Linux,$(shell uname)),Linux) | ||
23 | OS = linux | ||
24 | CC = gcc | ||
25 | COPY = cp | ||
26 | RM = rm -f | ||
27 | endif | ||
28 | |||
29 | |||
30 | |||
31 | COMMON= \ | ||
32 | src/dummies.c \ | ||
33 | src/api.c \ | ||
34 | src/lcd.c \ | ||
35 | $(ROOT)/apps/gui/wps_parser.c \ | ||
36 | $(ROOT)/apps/gui/wps_debug.c \ | ||
37 | $(ROOT)/firmware/font.c \ | ||
38 | $(ROOT)/apps/misc.c \ | ||
39 | $(ROOT)/apps/gui/gwps-common.c \ | ||
40 | $(ROOT)/apps/status.c \ | ||
41 | $(ROOT)/apps/recorder/peakmeter.c \ | ||
42 | $(ROOT)/apps/recorder/icons.c \ | ||
43 | $(ROOT)/apps/gui/scrollbar.c \ | ||
44 | $(ROOT)/firmware/common/timefuncs.c \ | ||
45 | $(ROOT)/firmware/common/unicode.c \ | ||
46 | $(ROOT)/firmware/common/ctype.c \ | ||
47 | $(ROOT)/firmware/id3.c \ | ||
48 | $(ROOT)/firmware/font_cache.c \ | ||
49 | $(ROOT)/firmware/lru.c \ | ||
50 | $(ROOT)/firmware/mp3data.c \ | ||
51 | $(ROOT)/firmware/replaygain.c | ||
52 | |||
53 | # $(ROOT)/apps/recorder/bmp.c | ||
54 | # $(ROOT)/apps/abrepeat.c \ | ||
55 | # $(ROOT)/apps/action.c \ | ||
56 | # $(ROOT)/apps/cuesheet.c \ | ||
57 | # $(ROOT)/apps/gui/statusbar.c \ | ||
58 | # $(ROOT)/apps/gui/gwps.c \ | ||
59 | |||
60 | INCLUDE=-I src/include \ | ||
61 | -I $(ROOT)/apps/gui \ | ||
62 | -I $(ROOT)/firmware/export \ | ||
63 | -I $(ROOT)/firmware/include \ | ||
64 | -I $(ROOT)/apps/recorder \ | ||
65 | -I $(ROOT)/apps \ | ||
66 | -I src | ||
67 | |||
68 | CFLAGS = -g -Wall -D__PCTOOL__ -DWPSEDITOR -DDEBUG -DROCKBOX_DIR_LEN=1 -DBUTTON_REMOTE | ||
69 | |||
70 | all: | ||
71 | @echo To build, run the buildall.sh script | ||
72 | |||
73 | build: build-$(OS) | ||
74 | |||
75 | build-w32: src/proxy.c $(COMMON) | ||
76 | @echo CC [$(TARGET)] | ||
77 | @$(CC) $(INCLUDE) $(CFLAGS) -D$(TARGET) -DTARGET_MODEL=\"$(MODEL)\" -DBUILD_DLL $(COMMON) -shared src/proxy.c -o libwps_$(MODEL).dll | ||
78 | |||
79 | build-linux: src/proxy.c $(COMMON) | ||
80 | @echo CC [$(TARGET)] | ||
81 | @$(CC) $(INCLUDE) $(CFLAGS) -D$(TARGET) -DTARGET_MODEL=\"$(MODEL)\" -shared -Wl,-soname,libwps_$(MODEL).so,-olibwps_$(MODEL).so -fPIC $(COMMON) src/proxy.c | ||
82 | |||
83 | clean: clean-$(OS) | ||
84 | |||
85 | clean-w32: | ||
86 | $(RM) "libwps_$(MODEL).dll" | ||
87 | |||
88 | clean-linux: | ||
89 | $(RM) "libwps_$(MODEL).so.1" | ||
90 | |||
91 | shared: shared-$(OS) | ||
92 | |||
93 | shared-w32: src/proxy.c $(COMMON) | ||
94 | @echo CC [IRIVER_H10_5GB] | ||
95 | @$(CC) $(INCLUDE) $(CFLAGS) -DIRIVER_H10_5GB -DTARGET_MODEL=\"h10_5gb\" -DBUILD_DLL $(COMMON) -shared src/proxy.c -o ../gui/bin/libwps.dll | ||
96 | |||
97 | shared-linux: src/proxy.c $(COMMON) | ||
98 | @echo CC [IRIVER_H10_5GB] | ||
99 | @$(CC) $(INCLUDE) $(CFLAGS) -DIRIVER_H10_5GB -DTARGET_MODEL=\"h10_5gb\" -shared -Wl,-soname,libwps.so,-olibwps.so -fPIC $(COMMON) src/proxy.c | ||
100 | @$(COPY) libwps.so ../gui/bin/libwps.so | ||
diff --git a/utils/wpseditor/libwps/buildall.sh b/utils/wpseditor/libwps/buildall.sh new file mode 100644 index 0000000000..60677d22b6 --- /dev/null +++ b/utils/wpseditor/libwps/buildall.sh | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/sh | ||
2 | cat targets.txt | ( | ||
3 | while read target model | ||
4 | do | ||
5 | make MODEL=$model TARGET=$target build | ||
6 | done | ||
7 | ) | ||
diff --git a/utils/wpseditor/libwps/cleanall.sh b/utils/wpseditor/libwps/cleanall.sh new file mode 100644 index 0000000000..15b733a6a7 --- /dev/null +++ b/utils/wpseditor/libwps/cleanall.sh | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/sh | ||
2 | cat targets.txt | ( | ||
3 | while read target model | ||
4 | do | ||
5 | make MODEL=$model TARGET=$target clean | ||
6 | done | ||
7 | ) | ||
diff --git a/utils/wpseditor/libwps/src/api.c b/utils/wpseditor/libwps/src/api.c new file mode 100644 index 0000000000..485efa8e00 --- /dev/null +++ b/utils/wpseditor/libwps/src/api.c | |||
@@ -0,0 +1,268 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include "sound.h" | ||
4 | #include "api.h" | ||
5 | #include "proxy.h" | ||
6 | #include "dummies.h" | ||
7 | #include "scroll_engine.h" | ||
8 | #include "wpsstate.h" | ||
9 | #include <string.h> | ||
10 | |||
11 | struct proxy_api *xapi; | ||
12 | |||
13 | void get_current_vp(struct viewport_api *avp); | ||
14 | /************************************************************* | ||
15 | |||
16 | *************************************************************/ | ||
17 | #ifdef HAVE_LCD_BITMAP | ||
18 | void screen_clear_area(struct screen * display, int xstart, int ystart, | ||
19 | int width, int height) { | ||
20 | display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
21 | display->fillrect(xstart, ystart, width, height); | ||
22 | display->set_drawmode(DRMODE_SOLID); | ||
23 | } | ||
24 | #endif | ||
25 | |||
26 | bool load_wps_backdrop(char* filename) { | ||
27 | return xapi->load_wps_backdrop(filename); | ||
28 | } | ||
29 | |||
30 | bool load_remote_wps_backdrop(char* filename) { | ||
31 | return xapi->load_remote_wps_backdrop(filename); | ||
32 | } | ||
33 | |||
34 | int read_bmp_file(const char* filename,struct bitmap *bm, int maxsize,int format) { | ||
35 | if (!xapi->read_bmp_file) | ||
36 | { | ||
37 | DEBUGF1("can't read bmp file! NULL api!\n"); | ||
38 | return -1; | ||
39 | } | ||
40 | bm->format = 3;//FORMAT_ANY? | ||
41 | bm->data = (unsigned char*)malloc(255); | ||
42 | memset(bm->data,0,255); | ||
43 | strcpy((char*)bm->data,filename); | ||
44 | //bm->data[strlen(filename)] = '\0'; | ||
45 | xapi->read_bmp_file(filename,&bm->width, &bm->height); | ||
46 | return 1; | ||
47 | } | ||
48 | |||
49 | bool load_wps_backdrop2(char* filename) { | ||
50 | DEBUGF1("load_wps_backdrop(char* filename='%s')",filename); | ||
51 | return true; | ||
52 | } | ||
53 | |||
54 | bool load_remote_wps_backdrop2(char* filename) { | ||
55 | DEBUGF1("load_remote_wps_backdrop2(char* filename='%s')",filename); | ||
56 | return true; | ||
57 | } | ||
58 | |||
59 | void stop_scroll() { | ||
60 | DEBUGF3("stop_scroll\n"); | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | void puts_scroll(int x, int y, const unsigned char *string) { | ||
65 | DEBUGF2("puts_scroll(int x=%d, int y=%d, const unsigned char *string='%s'\n",x,y,string); | ||
66 | } | ||
67 | |||
68 | void putsxy(int x, int y, const unsigned char *str) { | ||
69 | DEBUGF2("putsxy(int =%d, int y=%d, const unsigned char *str='%s')\n",x,y,str); | ||
70 | } | ||
71 | |||
72 | void lcd_update() { | ||
73 | DEBUGF3("update\n"); | ||
74 | } | ||
75 | |||
76 | void clear_viewport(int x, int y, int w, int h, int color) { | ||
77 | DEBUGF3("clear_viewport(int x=%d, int y=%d, int w=%d, int h=%d, int color=%d)\n", x, y, w, h, color); | ||
78 | }; | ||
79 | |||
80 | int getstringsize(const unsigned char *str, int *w, int *h) { | ||
81 | //DEBUGF1("getstringsize(const unsigned char *str=\"%s\", int *w=%d, int *h=%d \n",str,*w,*h); | ||
82 | *w=strlen((char*)str)*sysfont.maxwidth; | ||
83 | *h=sysfont.height; | ||
84 | return 1; | ||
85 | } | ||
86 | |||
87 | void set_wpsstate(struct wpsstate state){ | ||
88 | sysfont.height = state.fontheight; | ||
89 | sysfont.maxwidth = state.fontwidth; | ||
90 | global_settings.volume = state.volume; | ||
91 | battery_percent = state.battery_level; | ||
92 | _audio_status = state.audio_status; | ||
93 | } | ||
94 | |||
95 | void set_trackstate(struct trackstate state){ | ||
96 | gui_wps[0].state->id3->title = state.title; | ||
97 | gui_wps[0].state->id3->artist = state.artist; | ||
98 | gui_wps[0].state->id3->album = state.album; | ||
99 | gui_wps[0].state->id3->elapsed = state.elapsed; | ||
100 | gui_wps[0].state->id3->length = state.length; | ||
101 | } | ||
102 | |||
103 | void set_next_trackstate(struct trackstate state) | ||
104 | { | ||
105 | gui_wps[0].state->nid3->title = state.title; | ||
106 | gui_wps[0].state->nid3->artist = state.artist; | ||
107 | gui_wps[0].state->nid3->album = state.album; | ||
108 | gui_wps[0].state->nid3->elapsed = state.elapsed; | ||
109 | gui_wps[0].state->nid3->length = state.length; | ||
110 | } | ||
111 | |||
112 | enum api_playmode playmodes[PLAYMODES_NUM] = { | ||
113 | API_STATUS_PLAY, | ||
114 | API_STATUS_STOP, | ||
115 | API_STATUS_PAUSE, | ||
116 | API_STATUS_FASTFORWARD, | ||
117 | API_STATUS_FASTBACKWARD | ||
118 | }; | ||
119 | |||
120 | const char *playmodeNames[] = { | ||
121 | "Play", "Stop", "Pause", "FastForward", "FastBackward" | ||
122 | }; | ||
123 | |||
124 | |||
125 | void set_audio_status(int status){ | ||
126 | DEBUGF1("%s",playmodeNames[status]); | ||
127 | switch(status){ | ||
128 | case API_STATUS_PLAY: | ||
129 | _audio_status = AUDIO_STATUS_PLAY; | ||
130 | status_set_ffmode(STATUS_PLAY); | ||
131 | break; | ||
132 | case API_STATUS_STOP: | ||
133 | _audio_status = 0; | ||
134 | status_set_ffmode(STATUS_STOP); | ||
135 | break; | ||
136 | case API_STATUS_PAUSE: | ||
137 | _audio_status = AUDIO_STATUS_PAUSE; | ||
138 | status_set_ffmode(STATUS_PLAY); | ||
139 | break; | ||
140 | case API_STATUS_FASTFORWARD: | ||
141 | status_set_ffmode(STATUS_FASTFORWARD); | ||
142 | break; | ||
143 | case API_STATUS_FASTBACKWARD: | ||
144 | status_set_ffmode(STATUS_FASTBACKWARD); | ||
145 | break; | ||
146 | default: | ||
147 | DEBUGF1("ERR: Unknown status"); | ||
148 | } | ||
149 | } | ||
150 | |||
151 | void test_api(struct proxy_api *api) { | ||
152 | if (!api->stop_scroll) | ||
153 | api->stop_scroll=stop_scroll; | ||
154 | if (!api->set_viewport) | ||
155 | api->set_viewport=lcd_set_viewport; | ||
156 | if (!api->clear_viewport) | ||
157 | api->clear_viewport=clear_viewport; | ||
158 | if (!api->getstringsize) | ||
159 | api->getstringsize=getstringsize; | ||
160 | if (!api->getwidth) | ||
161 | api->getwidth=lcd_getwidth; | ||
162 | if (!api->getheight) | ||
163 | api->getheight=lcd_getheight; | ||
164 | if (!api->set_drawmode) | ||
165 | api->set_drawmode=lcd_set_drawmode; | ||
166 | if (!api->puts_scroll) | ||
167 | api->puts_scroll=puts_scroll; | ||
168 | if (!api->update) | ||
169 | api->update=lcd_update; | ||
170 | if (!api->clear_display) | ||
171 | api->clear_display=lcd_clear_display; | ||
172 | if (!api->getfont) | ||
173 | api->getfont=lcd_getfont; | ||
174 | if (!api->putsxy) | ||
175 | api->putsxy=putsxy; | ||
176 | |||
177 | #if LCD_DEPTH > 1 | ||
178 | if (!api->get_foreground) | ||
179 | api->get_foreground=lcd_get_foreground; | ||
180 | if (!api->get_background) | ||
181 | api->get_background=lcd_get_background; | ||
182 | #endif | ||
183 | if (!api->load_remote_wps_backdrop) | ||
184 | api->load_remote_wps_backdrop = load_remote_wps_backdrop2; | ||
185 | if (!api->load_wps_backdrop) | ||
186 | api->load_wps_backdrop = load_wps_backdrop2; | ||
187 | //dbgf = printf; | ||
188 | } | ||
189 | |||
190 | /************************************************************** | ||
191 | |||
192 | **************************************************************/ | ||
193 | |||
194 | int set_api(struct proxy_api* api) { | ||
195 | if (api->debugf) | ||
196 | dbgf = api->debugf; | ||
197 | screens[0].screen_type=SCREEN_MAIN; | ||
198 | screens[0].lcdwidth=LCD_WIDTH; | ||
199 | screens[0].lcdheight=LCD_HEIGHT; | ||
200 | screens[0].depth=LCD_DEPTH; | ||
201 | #ifdef HAVE_LCD_COLOR | ||
202 | screens[0].is_color=true; | ||
203 | #else | ||
204 | screens[0].is_color=false; | ||
205 | #endif | ||
206 | if (api->getwidth) | ||
207 | screens[0].getwidth = api->getwidth; | ||
208 | if (api->stop_scroll) | ||
209 | screens[0].stop_scroll=api->stop_scroll; | ||
210 | screens[0].scroll_stop = lcd_scroll_stop; | ||
211 | if (api->set_viewport) | ||
212 | screens[0].set_viewport=api->set_viewport; | ||
213 | if (api->clear_viewport) | ||
214 | screens[0].clear_viewport=lcd_clear_viewport; | ||
215 | if (api->getstringsize) | ||
216 | screens[0].getstringsize=api->getstringsize; | ||
217 | if (api->getwidth) | ||
218 | screens[0].getwidth=api->getwidth; | ||
219 | if (api->getheight) | ||
220 | screens[0].getheight=api->getheight; | ||
221 | if (api->set_drawmode) | ||
222 | screens[0].set_drawmode=api->set_drawmode; | ||
223 | if (api->fillrect) | ||
224 | screens[0].fillrect=api->fillrect; | ||
225 | if (api->puts_scroll) | ||
226 | screens[0].puts_scroll=api->puts_scroll; | ||
227 | if (api->transparent_bitmap_part) | ||
228 | screens[0].transparent_bitmap_part=api->transparent_bitmap_part; | ||
229 | if (api->update) | ||
230 | screens[0].update=api->update; | ||
231 | if (api->clear_display) | ||
232 | screens[0].clear_display=api->clear_display; | ||
233 | if (api->getfont) | ||
234 | screens[0].getfont=api->getfont; | ||
235 | if (api->hline) | ||
236 | screens[0].hline=api->hline; | ||
237 | if (api->vline) | ||
238 | screens[0].vline=api->vline; | ||
239 | if (api->drawpixel) | ||
240 | screens[0].drawpixel=api->drawpixel; | ||
241 | if (api->putsxy) | ||
242 | screens[0].putsxy=api->putsxy; | ||
243 | #if LCD_DEPTH > 1 | ||
244 | if (api->get_foreground) | ||
245 | screens[0].get_foreground=api->get_foreground; | ||
246 | if (api->get_background) | ||
247 | screens[0].get_background=api->get_background; | ||
248 | #endif | ||
249 | |||
250 | screens[0].bitmap_part = api->bitmap_part; | ||
251 | /************************** | ||
252 | * OUT * | ||
253 | **************************/ | ||
254 | api->get_model_name = get_model_name; | ||
255 | api->get_current_vp = get_current_vp; | ||
256 | api->set_wpsstate = set_wpsstate; | ||
257 | api->set_trackstate = set_trackstate; | ||
258 | api->set_next_trackstate= set_next_trackstate; | ||
259 | api->set_audio_status= set_audio_status; | ||
260 | xapi = api; | ||
261 | return 0; | ||
262 | } | ||
263 | |||
264 | |||
265 | |||
266 | |||
267 | |||
268 | |||
diff --git a/utils/wpseditor/libwps/src/api.h b/utils/wpseditor/libwps/src/api.h new file mode 100644 index 0000000000..86bb1a6597 --- /dev/null +++ b/utils/wpseditor/libwps/src/api.h | |||
@@ -0,0 +1,85 @@ | |||
1 | #ifndef API_H_INCLUDED | ||
2 | #define API_H_INCLUDED | ||
3 | #include <stdbool.h> | ||
4 | #include <stddef.h> | ||
5 | #include "defs.h" | ||
6 | #include "wpsstate.h" | ||
7 | #ifdef __PCTOOL__ | ||
8 | #include "dummies.h" | ||
9 | #endif | ||
10 | |||
11 | struct viewport_api { | ||
12 | int x; | ||
13 | int y; | ||
14 | int width; | ||
15 | int height; | ||
16 | int font; | ||
17 | int drawmode; | ||
18 | unsigned fg_pattern; | ||
19 | unsigned bg_pattern; | ||
20 | unsigned lss_pattern; | ||
21 | unsigned lse_pattern; | ||
22 | unsigned lst_pattern; | ||
23 | |||
24 | //TODO: ?? | ||
25 | int fontheight; | ||
26 | int fontwidth; | ||
27 | }; | ||
28 | |||
29 | struct proxy_api | ||
30 | { | ||
31 | bool (*load_remote_wps_backdrop)(char* file_name); | ||
32 | bool (*load_wps_backdrop)(char* file_name); | ||
33 | |||
34 | unsigned (*get_foreground)(void); | ||
35 | unsigned (*get_background)(void); | ||
36 | int (*getwidth)(void); | ||
37 | int (*getheight)(void); | ||
38 | |||
39 | void (*puts_scroll)(int x, int y, const unsigned char *string); | ||
40 | void (*putsxy)(int x, int y, const unsigned char *str); | ||
41 | int (*getfont)(); | ||
42 | int (*getstringsize)(const unsigned char *str, int *w, int *h); | ||
43 | void (*stop_scroll)(); | ||
44 | |||
45 | void (*transparent_bitmap_part)(const void *src, int src_x, int src_y, | ||
46 | int stride, int x, int y, int width, int height); | ||
47 | void (*bitmap_part)(const void *src, int src_x, int src_y, | ||
48 | int stride, int x, int y, int width, int height); | ||
49 | void (*hline)(int x1, int x2, int y); | ||
50 | void (*vline)(int x, int y1, int y2); | ||
51 | void (*drawpixel)(int x, int y); | ||
52 | void (*set_drawmode)(int mode); | ||
53 | void (*fillrect)(int x, int y, int width, int height); | ||
54 | |||
55 | |||
56 | void (*update)(); | ||
57 | void (*set_viewport)(struct viewport* vp); | ||
58 | void (*clear_display)(void); | ||
59 | void (*clear_viewport)(int x,int y,int w,int h, int color); | ||
60 | |||
61 | void* (*plugin_get_buffer)(size_t *buffer_size); | ||
62 | int (*read_bmp_file)(const char* filename,int *width, int *height); | ||
63 | void (*set_wpsstate)(struct wpsstate state); | ||
64 | void (*set_trackstate)(struct trackstate state); | ||
65 | void (*set_next_trackstate)(struct trackstate state); | ||
66 | void (*set_audio_status)(int status); | ||
67 | |||
68 | pfdebugf debugf; | ||
69 | int verbose; | ||
70 | |||
71 | |||
72 | /************************** | ||
73 | * OUT * | ||
74 | **************************/ | ||
75 | const char* (*get_model_name)(); | ||
76 | void (*get_current_vp)(struct viewport_api *avp); | ||
77 | |||
78 | |||
79 | }; | ||
80 | |||
81 | extern struct proxy_api *xapi; | ||
82 | |||
83 | EXPORT int set_api(struct proxy_api* api); | ||
84 | |||
85 | #endif // API_H_INCLUDED | ||
diff --git a/utils/wpseditor/libwps/src/defs.h b/utils/wpseditor/libwps/src/defs.h new file mode 100644 index 0000000000..810c8da238 --- /dev/null +++ b/utils/wpseditor/libwps/src/defs.h | |||
@@ -0,0 +1,41 @@ | |||
1 | #ifndef DEFS_H_INCLUDED | ||
2 | #define DEFS_H_INCLUDED | ||
3 | |||
4 | typedef int (*pfdebugf)(const char* fmt,...); | ||
5 | extern pfdebugf dbgf; | ||
6 | |||
7 | #ifdef BUILD_DLL | ||
8 | # define EXPORT __declspec(dllexport) | ||
9 | #else | ||
10 | # define EXPORT | ||
11 | #endif | ||
12 | |||
13 | #ifndef MIN | ||
14 | # define MIN(a, b) (((a)<(b))?(a):(b)) | ||
15 | #endif | ||
16 | |||
17 | #ifndef MAX | ||
18 | # define MAX(a, b) (((a)>(b))?(a):(b)) | ||
19 | #endif | ||
20 | |||
21 | #define SWAP_16(x) ((typeof(x))(unsigned short)(((unsigned short)(x) >> 8) | \ | ||
22 | ((unsigned short)(x) << 8))) | ||
23 | |||
24 | #define SWAP_32(x) ((typeof(x))(unsigned long)( ((unsigned long)(x) >> 24) | \ | ||
25 | (((unsigned long)(x) & 0xff0000ul) >> 8) | \ | ||
26 | (((unsigned long)(x) & 0xff00ul) << 8) | \ | ||
27 | ((unsigned long)(x) << 24))) | ||
28 | |||
29 | #define PLAYMODES_NUM 5 | ||
30 | enum api_playmode { | ||
31 | API_STATUS_PLAY, | ||
32 | API_STATUS_STOP, | ||
33 | API_STATUS_PAUSE, | ||
34 | API_STATUS_FASTFORWARD, | ||
35 | API_STATUS_FASTBACKWARD | ||
36 | }; | ||
37 | |||
38 | extern enum api_playmode playmodes[PLAYMODES_NUM]; | ||
39 | extern const char *playmodeNames[]; | ||
40 | |||
41 | #endif // DEFS_H_INCLUDED | ||
diff --git a/utils/wpseditor/libwps/src/dummies.c b/utils/wpseditor/libwps/src/dummies.c new file mode 100644 index 0000000000..8592610701 --- /dev/null +++ b/utils/wpseditor/libwps/src/dummies.c | |||
@@ -0,0 +1,363 @@ | |||
1 | #include <string.h> | ||
2 | #include <stdio.h> | ||
3 | #include "dummies.h" | ||
4 | #include "proxy.h" | ||
5 | |||
6 | struct user_settings global_settings; | ||
7 | |||
8 | struct wps_state wps_state; | ||
9 | struct gui_wps gui_wps[NB_SCREENS]; | ||
10 | struct wps_data wps_datas[NB_SCREENS]; | ||
11 | struct cuesheet *curr_cue; | ||
12 | struct cuesheet *temp_cue; | ||
13 | struct system_status global_status; | ||
14 | struct gui_syncstatusbar statusbars; | ||
15 | struct playlist_info current_playlist; | ||
16 | struct font sysfont; | ||
17 | int battery_percent = 100; | ||
18 | struct mp3entry current_song, next_song; | ||
19 | int _audio_status; | ||
20 | |||
21 | charger_input_state_type charger_input_state; | ||
22 | #if CONFIG_CHARGING >= CHARGING_MONITOR | ||
23 | charge_state_type charge_state; | ||
24 | #endif | ||
25 | |||
26 | #if defined(CPU_PP) && defined(BOOTLOADER) | ||
27 | /* We don't enable interrupts in the iPod bootloader, so we need to fake | ||
28 | the current_tick variable */ | ||
29 | #define current_tick (signed)(USEC_TIMER/10000) | ||
30 | #else | ||
31 | volatile long current_tick; | ||
32 | #endif | ||
33 | |||
34 | |||
35 | void dummies_init(){ | ||
36 | sysfont.height = 9; | ||
37 | sysfont.maxwidth = 6; | ||
38 | global_settings.statusbar=true; | ||
39 | } | ||
40 | |||
41 | int playlist_amount_ex(const struct playlist_info* playlist); | ||
42 | void sound_set_volume(int value) | ||
43 | { | ||
44 | DEBUGF3("sound_set_volume(int value=%d)",value); | ||
45 | global_settings.volume = value; | ||
46 | } | ||
47 | int sound_get_pitch(void) | ||
48 | { | ||
49 | return 0; | ||
50 | } | ||
51 | int sound_min(int setting) | ||
52 | { | ||
53 | DEBUGF3("sound_min(int setting=%d)",setting); | ||
54 | return -78; //audiohw_settings[setting].minval; | ||
55 | } | ||
56 | |||
57 | void sleep(int hz) | ||
58 | { | ||
59 | } | ||
60 | |||
61 | void audio_init(void){} | ||
62 | void audio_wait_for_init(void){} | ||
63 | void audio_play(long offset){} | ||
64 | void audio_stop(void){} | ||
65 | void audio_pause(void){} | ||
66 | void audio_resume(void){} | ||
67 | void audio_next(void){} | ||
68 | void audio_prev(void){} | ||
69 | int audio_status(void) | ||
70 | { | ||
71 | return _audio_status; | ||
72 | } | ||
73 | |||
74 | #if CONFIG_CODEC == SWCODEC | ||
75 | int audio_track_count(void){return 0;} /* SWCODEC only */ | ||
76 | long audio_filebufused(void){return 0;} /* SWCODEC only */ | ||
77 | void audio_pre_ff_rewind(void){} /* SWCODEC only */ | ||
78 | #endif /* CONFIG_CODEC == SWCODEC */ | ||
79 | void audio_ff_rewind(long newtime){} | ||
80 | void audio_flush_and_reload_tracks(void){} | ||
81 | #ifdef HAVE_ALBUMART | ||
82 | int audio_current_aa_hid(void){return -1;} | ||
83 | #endif | ||
84 | struct mp3entry* audio_current_track(void){return 0;} | ||
85 | struct mp3entry* audio_next_track(void){return 0;} | ||
86 | bool audio_has_changed_track(void) | ||
87 | { | ||
88 | return false; | ||
89 | } | ||
90 | |||
91 | int get_sleep_timer(void){return 0;} | ||
92 | |||
93 | |||
94 | int battery_level(void){return battery_percent;} /* percent */ | ||
95 | int battery_time(void){return 0;} /* minutes */ | ||
96 | unsigned int battery_adc_voltage(void){return 0;} /* voltage from ADC in millivolts */ | ||
97 | unsigned int battery_voltage(void){return 0;} /* filtered batt. voltage in millivolts */ | ||
98 | int get_radio_status(void){return 0;} | ||
99 | |||
100 | |||
101 | /* returns full path of playlist (minus extension) */ | ||
102 | char *playlist_name(const struct playlist_info* playlist, char *buf, | ||
103 | int buf_size) | ||
104 | { | ||
105 | char *sep; | ||
106 | |||
107 | if (!playlist) | ||
108 | return "no"; | ||
109 | |||
110 | snprintf(buf, buf_size, "%s", playlist->filename+playlist->dirlen); | ||
111 | |||
112 | if (!buf[0]) | ||
113 | return NULL; | ||
114 | |||
115 | /* Remove extension */ | ||
116 | sep = strrchr(buf, '.'); | ||
117 | if(sep) | ||
118 | *sep = 0; | ||
119 | |||
120 | return buf; | ||
121 | } | ||
122 | int playlist_get_display_index(void) | ||
123 | { | ||
124 | return 1; | ||
125 | } | ||
126 | |||
127 | void gui_syncsplash(int ticks, const unsigned char *fmt, ...) | ||
128 | { | ||
129 | |||
130 | } | ||
131 | |||
132 | void splash(int ticks, const unsigned char *fmt, ...) | ||
133 | { | ||
134 | |||
135 | } | ||
136 | |||
137 | void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw){ | ||
138 | DEBUGF3("gui_statusbar_draw"); | ||
139 | } | ||
140 | |||
141 | void yield(void){} | ||
142 | |||
143 | |||
144 | /* returns true if cuesheet support is initialised */ | ||
145 | bool cuesheet_is_enabled(void){return false;} | ||
146 | |||
147 | /* allocates the cuesheet buffer */ | ||
148 | void cuesheet_init(void){} | ||
149 | |||
150 | /* looks if there is a cuesheet file that has a name matching "trackpath" */ | ||
151 | bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path){return false;} | ||
152 | |||
153 | /* parse cuesheet "file" and store the information in "cue" */ | ||
154 | bool parse_cuesheet(char *file, struct cuesheet *cue){return false;} | ||
155 | |||
156 | /* reads a cuesheet to find the audio track associated to it */ | ||
157 | bool get_trackname_from_cuesheet(char *filename, char *buf){return false;} | ||
158 | |||
159 | /* display a cuesheet struct */ | ||
160 | void browse_cuesheet(struct cuesheet *cue){} | ||
161 | |||
162 | /* display a cuesheet file after parsing and loading it to the plugin buffer */ | ||
163 | bool display_cuesheet_content(char* filename){return false;} | ||
164 | |||
165 | /* finds the index of the current track played within a cuesheet */ | ||
166 | int cue_find_current_track(struct cuesheet *cue, unsigned long curpos){return 0;} | ||
167 | |||
168 | /* update the id3 info to that of the currently playing track in the cuesheet */ | ||
169 | void cue_spoof_id3(struct cuesheet *cue, struct mp3entry *id3){} | ||
170 | |||
171 | /* skip to next track in the cuesheet towards "direction" (which is 1 or -1) */ | ||
172 | bool curr_cuesheet_skip(int direction, unsigned long curr_pos){return false;} | ||
173 | |||
174 | #ifdef HAVE_LCD_BITMAP | ||
175 | /* draw track markers on the progressbar */ | ||
176 | void cue_draw_markers(struct screen *screen, unsigned long tracklen, | ||
177 | int x1, int x2, int y, int h){} | ||
178 | #endif | ||
179 | |||
180 | |||
181 | void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear) | ||
182 | { | ||
183 | if (!gwps || !gwps->data || !gwps->display || handle_id < 0) | ||
184 | return; | ||
185 | |||
186 | struct wps_data *data = gwps->data; | ||
187 | |||
188 | #ifdef HAVE_REMOTE_LCD | ||
189 | /* No album art on RWPS */ | ||
190 | if (data->remote_wps) | ||
191 | return; | ||
192 | #endif | ||
193 | |||
194 | struct bitmap *bmp; | ||
195 | /* if (bufgetdata(handle_id, 0, (void *)&bmp) <= 0) | ||
196 | return;*/ | ||
197 | |||
198 | short x = data->albumart_x; | ||
199 | short y = data->albumart_y; | ||
200 | short width = bmp->width; | ||
201 | short height = bmp->height; | ||
202 | |||
203 | if (data->albumart_max_width > 0) | ||
204 | { | ||
205 | /* Crop if the bitmap is too wide */ | ||
206 | width = MIN(bmp->width, data->albumart_max_width); | ||
207 | |||
208 | /* Align */ | ||
209 | if (data->albumart_xalign & WPS_ALBUMART_ALIGN_RIGHT) | ||
210 | x += data->albumart_max_width - width; | ||
211 | else if (data->albumart_xalign & WPS_ALBUMART_ALIGN_CENTER) | ||
212 | x += (data->albumart_max_width - width) / 2; | ||
213 | } | ||
214 | |||
215 | if (data->albumart_max_height > 0) | ||
216 | { | ||
217 | /* Crop if the bitmap is too high */ | ||
218 | height = MIN(bmp->height, data->albumart_max_height); | ||
219 | |||
220 | /* Align */ | ||
221 | if (data->albumart_yalign & WPS_ALBUMART_ALIGN_BOTTOM) | ||
222 | y += data->albumart_max_height - height; | ||
223 | else if (data->albumart_yalign & WPS_ALBUMART_ALIGN_CENTER) | ||
224 | y += (data->albumart_max_height - height) / 2; | ||
225 | } | ||
226 | |||
227 | if (!clear) | ||
228 | { | ||
229 | /* Draw the bitmap */ | ||
230 | gwps->display->set_drawmode(DRMODE_FG); | ||
231 | gwps->display->bitmap_part((fb_data*)bmp->data, 0, 0, bmp->width, | ||
232 | x, y, width, height); | ||
233 | gwps->display->set_drawmode(DRMODE_SOLID); | ||
234 | } | ||
235 | else | ||
236 | { | ||
237 | /* Clear the bitmap */ | ||
238 | gwps->display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
239 | gwps->display->fillrect(x, y, width, height); | ||
240 | gwps->display->set_drawmode(DRMODE_SOLID); | ||
241 | } | ||
242 | } | ||
243 | |||
244 | /* Update the "data" pointer to make the handle's data available to the caller. | ||
245 | Return the length of the available linear data or < 0 for failure (handle | ||
246 | not found). | ||
247 | The caller is blocked until the requested amount of data is available. | ||
248 | size is the amount of linear data requested. it can be 0 to get as | ||
249 | much as possible. | ||
250 | The guard buffer may be used to provide the requested size. This means it's | ||
251 | unsafe to request more than the size of the guard buffer. | ||
252 | */ | ||
253 | size_t bufgetdata(int handle_id, size_t size, void **data) | ||
254 | { | ||
255 | |||
256 | |||
257 | return size; | ||
258 | } | ||
259 | |||
260 | |||
261 | void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars, | ||
262 | bool force_redraw) | ||
263 | { | ||
264 | #ifdef HAVE_LCD_BITMAP | ||
265 | if(!global_settings.statusbar) | ||
266 | return; | ||
267 | #endif /* HAVE_LCD_BITMAP */ | ||
268 | int i; | ||
269 | FOR_NB_SCREENS(i) { | ||
270 | gui_statusbar_draw( &(bars->statusbars[i]), force_redraw ); | ||
271 | } | ||
272 | } | ||
273 | void unload_wps_backdrop(void) | ||
274 | { | ||
275 | |||
276 | } | ||
277 | |||
278 | #if CONFIG_CODEC == SWCODEC | ||
279 | int get_replaygain_mode(bool have_track_gain, bool have_album_gain) | ||
280 | { | ||
281 | int type; | ||
282 | |||
283 | bool track = ((global_settings.replaygain_type == REPLAYGAIN_TRACK) | ||
284 | || ((global_settings.replaygain_type == REPLAYGAIN_SHUFFLE) | ||
285 | && global_settings.playlist_shuffle)); | ||
286 | |||
287 | type = (!track && have_album_gain) ? REPLAYGAIN_ALBUM | ||
288 | : have_track_gain ? REPLAYGAIN_TRACK : -1; | ||
289 | |||
290 | return type; | ||
291 | } | ||
292 | #endif | ||
293 | |||
294 | /* Common functions for all targets */ | ||
295 | void rtc_init(void){} | ||
296 | int rtc_read_datetime(unsigned char* buf){return 0;} | ||
297 | int rtc_write_datetime(unsigned char* buf){return 0;} | ||
298 | |||
299 | void backlight_on(void){} | ||
300 | void backlight_off(void){} | ||
301 | |||
302 | |||
303 | void debugf(const char *fmt, ...) | ||
304 | {} | ||
305 | void panicf( const char *fmt, ...) | ||
306 | { | ||
307 | } | ||
308 | |||
309 | off_t filesize(int fd){return 0;} | ||
310 | |||
311 | int playlist_amount(void) | ||
312 | { | ||
313 | return playlist_amount_ex(NULL); | ||
314 | } | ||
315 | int playlist_amount_ex(const struct playlist_info* playlist) | ||
316 | { | ||
317 | if (!playlist) | ||
318 | playlist = ¤t_playlist; | ||
319 | |||
320 | return playlist->amount; | ||
321 | } | ||
322 | |||
323 | int get_action(int context, int timeout) | ||
324 | { | ||
325 | return 0; | ||
326 | } | ||
327 | |||
328 | void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, | ||
329 | int height){} | ||
330 | |||
331 | void pcm_calculate_rec_peaks(int *left, int *right) | ||
332 | { | ||
333 | } | ||
334 | void pcm_calculate_peaks(int *left, int *right) | ||
335 | { | ||
336 | } | ||
337 | bool led_read(int delayticks) /* read by status bar update */ | ||
338 | { | ||
339 | return false; | ||
340 | } | ||
341 | |||
342 | #ifndef HAS_BUTTON_HOLD | ||
343 | bool is_keys_locked(void) | ||
344 | { | ||
345 | return false; | ||
346 | } | ||
347 | #endif | ||
348 | |||
349 | long default_event_handler_ex(long event, void (*callback)(void *), void *parameter) | ||
350 | { | ||
351 | return 0; | ||
352 | } | ||
353 | |||
354 | long default_event_handler(long event) | ||
355 | { | ||
356 | return default_event_handler_ex(event, NULL, NULL); | ||
357 | } | ||
358 | |||
359 | void ab_draw_markers(struct screen * screen, int capacity, | ||
360 | int x0, int x1, int y, int h) | ||
361 | { | ||
362 | } | ||
363 | void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude){} | ||
diff --git a/utils/wpseditor/libwps/src/dummies.h b/utils/wpseditor/libwps/src/dummies.h new file mode 100644 index 0000000000..2bfce1d53b --- /dev/null +++ b/utils/wpseditor/libwps/src/dummies.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef DUMMIES_H_INCLUDED | ||
2 | #define DUMMIES_H_INCLUDED | ||
3 | |||
4 | #include <stdio.h> | ||
5 | |||
6 | #include "settings.h" | ||
7 | #include "gwps.h" | ||
8 | #include "lang.h" | ||
9 | #include "powermgmt.h" | ||
10 | #include "font.h" | ||
11 | #include "playlist.h" | ||
12 | |||
13 | #include "defs.h" | ||
14 | |||
15 | extern struct font sysfont; | ||
16 | extern struct user_settings global_settings; | ||
17 | extern struct wps_state wps_state; | ||
18 | extern struct gui_wps gui_wps[NB_SCREENS]; | ||
19 | extern struct wps_data wps_datas[NB_SCREENS]; | ||
20 | extern struct cuesheet *curr_cue; | ||
21 | extern struct cuesheet *temp_cue; | ||
22 | extern struct system_status global_status; | ||
23 | extern struct gui_syncstatusbar statusbars; | ||
24 | extern struct playlist_info current_playlist; | ||
25 | extern int battery_percent; | ||
26 | extern struct mp3entry current_song, next_song; | ||
27 | extern int _audio_status; | ||
28 | |||
29 | charger_input_state_type charger_input_state; | ||
30 | #if CONFIG_CHARGING >= CHARGING_MONITOR | ||
31 | extern charge_state_type charge_state; | ||
32 | #endif | ||
33 | |||
34 | #if defined(CPU_PP) && defined(BOOTLOADER) | ||
35 | /* We don't enable interrupts in the iPod bootloader, so we need to fake | ||
36 | the current_tick variable */ | ||
37 | #define current_tick (signed)(USEC_TIMER/10000) | ||
38 | #else | ||
39 | extern volatile long current_tick; | ||
40 | #endif | ||
41 | |||
42 | void dummies_init(); | ||
43 | |||
44 | #endif /*DUMMIES_H_INCLUDED*/ | ||
diff --git a/utils/wpseditor/libwps/src/include/lang.h b/utils/wpseditor/libwps/src/include/lang.h new file mode 100644 index 0000000000..3274bdec6c --- /dev/null +++ b/utils/wpseditor/libwps/src/include/lang.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #define LANG_END_PLAYLIST (signed char)1 | ||
2 | #define LANG_KEYLOCK_ON (signed char)2 | ||
3 | #define LANG_KEYLOCK_OFF (signed char)3 | ||
4 | #define LANG_WEEKDAY_SUNDAY (signed char)4 | ||
5 | #define LANG_MONTH_JANUARY (signed char)5 | ||
6 | #define VOICE_PAUSE (signed char)6 | ||
7 | #define LANG_BATTERY_TIME (signed char)7 | ||
8 | #define UNIT_PERCENT (signed char)8 | ||
9 | |||
10 | #define str(...) "empty" | ||
diff --git a/utils/wpseditor/libwps/src/include/rockboxlogo.h b/utils/wpseditor/libwps/src/include/rockboxlogo.h new file mode 100644 index 0000000000..8d1c8b69c3 --- /dev/null +++ b/utils/wpseditor/libwps/src/include/rockboxlogo.h | |||
@@ -0,0 +1 @@ | |||
diff --git a/utils/wpseditor/libwps/src/include/sysfont.h b/utils/wpseditor/libwps/src/include/sysfont.h new file mode 100644 index 0000000000..4ba770347c --- /dev/null +++ b/utils/wpseditor/libwps/src/include/sysfont.h | |||
@@ -0,0 +1 @@ | |||
#define SYSFONT_HEIGHT 9 | |||
diff --git a/utils/wpseditor/libwps/src/include/system-target.h b/utils/wpseditor/libwps/src/include/system-target.h new file mode 100644 index 0000000000..8d1c8b69c3 --- /dev/null +++ b/utils/wpseditor/libwps/src/include/system-target.h | |||
@@ -0,0 +1 @@ | |||
diff --git a/utils/wpseditor/libwps/src/lcd.c b/utils/wpseditor/libwps/src/lcd.c new file mode 100644 index 0000000000..1f12332750 --- /dev/null +++ b/utils/wpseditor/libwps/src/lcd.c | |||
@@ -0,0 +1,150 @@ | |||
1 | #include "font.h" | ||
2 | #include "screen_access.h" | ||
3 | //#include <windef.h> | ||
4 | #include "api.h" | ||
5 | #include "defs.h" | ||
6 | #include "proxy.h" | ||
7 | #include "dummies.h" | ||
8 | |||
9 | static struct viewport default_vp = | ||
10 | { | ||
11 | .x = 0, | ||
12 | .y = 0, | ||
13 | .width = LCD_WIDTH, | ||
14 | .height = LCD_HEIGHT, | ||
15 | .font = FONT_SYSFIXED, | ||
16 | .drawmode = DRMODE_SOLID, | ||
17 | .fg_pattern = LCD_DEFAULT_FG, | ||
18 | .bg_pattern = LCD_DEFAULT_BG, | ||
19 | .lss_pattern = LCD_DEFAULT_BG, | ||
20 | .lse_pattern = LCD_DEFAULT_BG, | ||
21 | .lst_pattern = LCD_DEFAULT_BG, | ||
22 | }; | ||
23 | |||
24 | struct viewport* current_vp = &default_vp; | ||
25 | |||
26 | void get_current_vp(struct viewport_api *avp){ | ||
27 | avp->x = current_vp->x; | ||
28 | avp->y = current_vp->y; | ||
29 | avp->width = current_vp->width; | ||
30 | avp->height = current_vp->height; | ||
31 | |||
32 | //TODO: font_get(current_vp->font)->height; | ||
33 | avp->fontheight = sysfont.height; | ||
34 | } | ||
35 | |||
36 | void lcd_set_viewport(struct viewport* vp) | ||
37 | { | ||
38 | if (vp == NULL){ | ||
39 | current_vp = &default_vp; | ||
40 | DEBUGF3("lcd_set_viewport(struct viewport* vp= DEFAULT)\n"); | ||
41 | } | ||
42 | else{ | ||
43 | current_vp = vp; | ||
44 | DEBUGF3("lcd_set_viewport(struct viewport* vp=%x,vpx=%d,vpy=%d,vpw=%d,vph=%d)\n",vp,vp->x,vp->y,vp->width,vp->height); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | void lcd_update_viewport(void) | ||
49 | { | ||
50 | //lcd_update_rect(current_vp->x, current_vp->y,current_vp->width, current_vp->height); | ||
51 | } | ||
52 | |||
53 | void lcd_update_viewport_rect(int x, int y, int width, int height) | ||
54 | { | ||
55 | //lcd_update_rect(current_vp->x + x, current_vp->y + y, width, height); | ||
56 | } | ||
57 | /*** parameter handling ***/ | ||
58 | |||
59 | void lcd_set_drawmode(int mode) | ||
60 | { | ||
61 | current_vp->drawmode = mode & (DRMODE_SOLID|DRMODE_INVERSEVID); | ||
62 | } | ||
63 | |||
64 | int lcd_get_drawmode(void) | ||
65 | { | ||
66 | return current_vp->drawmode; | ||
67 | } | ||
68 | |||
69 | void lcd_set_foreground(unsigned color) | ||
70 | { | ||
71 | current_vp->fg_pattern = color; | ||
72 | } | ||
73 | |||
74 | unsigned lcd_get_foreground(void) | ||
75 | { | ||
76 | return current_vp->fg_pattern; | ||
77 | } | ||
78 | |||
79 | void lcd_set_background(unsigned color) | ||
80 | { | ||
81 | current_vp->bg_pattern = color; | ||
82 | } | ||
83 | |||
84 | unsigned lcd_get_background(void) | ||
85 | { | ||
86 | return current_vp->bg_pattern; | ||
87 | } | ||
88 | |||
89 | void lcd_set_selector_start(unsigned color) | ||
90 | { | ||
91 | current_vp->lss_pattern = color; | ||
92 | } | ||
93 | |||
94 | void lcd_set_selector_end(unsigned color) | ||
95 | { | ||
96 | current_vp->lse_pattern = color; | ||
97 | } | ||
98 | |||
99 | void lcd_set_selector_text(unsigned color) | ||
100 | { | ||
101 | current_vp->lst_pattern = color; | ||
102 | } | ||
103 | |||
104 | void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color) | ||
105 | { | ||
106 | //lcd_set_drawmode(mode); | ||
107 | current_vp->fg_pattern = fg_color; | ||
108 | current_vp->bg_pattern = bg_color; | ||
109 | } | ||
110 | |||
111 | int lcd_getwidth(void) | ||
112 | { | ||
113 | return current_vp->width; | ||
114 | } | ||
115 | |||
116 | int lcd_getheight(void) | ||
117 | { | ||
118 | return current_vp->height; | ||
119 | } | ||
120 | |||
121 | void lcd_setfont(int newfont) | ||
122 | { | ||
123 | current_vp->font = newfont; | ||
124 | } | ||
125 | |||
126 | int lcd_getfont(void) | ||
127 | { | ||
128 | return current_vp->font; | ||
129 | } | ||
130 | |||
131 | /* Clear the whole display */ | ||
132 | void lcd_clear_display(void) | ||
133 | { | ||
134 | struct viewport* old_vp = current_vp; | ||
135 | |||
136 | current_vp = &default_vp; | ||
137 | |||
138 | lcd_clear_viewport(); | ||
139 | |||
140 | current_vp = old_vp; | ||
141 | } | ||
142 | |||
143 | void lcd_clear_viewport(){ | ||
144 | DEBUGF2("lcd_clear_viewport()\n"); | ||
145 | xapi->clear_viewport(current_vp->x,current_vp->y,current_vp->width,current_vp->height,current_vp->bg_pattern); | ||
146 | |||
147 | } | ||
148 | void lcd_scroll_stop(struct viewport* vp){ | ||
149 | DEBUGF3("lcd_scroll_stop(struct viewport* vp=%x)\n",vp); | ||
150 | } | ||
diff --git a/utils/wpseditor/libwps/src/proxy.c b/utils/wpseditor/libwps/src/proxy.c new file mode 100644 index 0000000000..3a3b8ce4d9 --- /dev/null +++ b/utils/wpseditor/libwps/src/proxy.c | |||
@@ -0,0 +1,132 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <stdlib.h> | ||
3 | #include "dummies.h" | ||
4 | #include "proxy.h" | ||
5 | #include "api.h" | ||
6 | #include "gwps.h" | ||
7 | #include "gwps-common.h" | ||
8 | #include <string.h> | ||
9 | |||
10 | struct screen screens[NB_SCREENS]; | ||
11 | struct wps_data wpsdata; | ||
12 | struct gui_wps gwps; | ||
13 | struct mp3entry id3; | ||
14 | struct mp3entry nid3; | ||
15 | |||
16 | extern void test_api(struct proxy_api *api); | ||
17 | |||
18 | bool debug_wps = true; | ||
19 | int wps_verbose_level = 0; | ||
20 | int errno_; | ||
21 | pfdebugf dbgf = 0; | ||
22 | |||
23 | static char pluginbuf[PLUGIN_BUFFER_SIZE]; | ||
24 | |||
25 | const char* get_model_name(){ | ||
26 | #ifdef TARGET_MODEL | ||
27 | return TARGET_MODEL; | ||
28 | #else | ||
29 | return "unknown"; | ||
30 | #endif | ||
31 | } | ||
32 | |||
33 | int read_line(int fd, char* buffer, int buffer_size) | ||
34 | { | ||
35 | int count = 0; | ||
36 | int num_read = 0; | ||
37 | |||
38 | errno_ = 0; | ||
39 | |||
40 | while (count < buffer_size) | ||
41 | { | ||
42 | unsigned char c; | ||
43 | |||
44 | if (1 != read(fd, &c, 1)) | ||
45 | break; | ||
46 | |||
47 | num_read++; | ||
48 | |||
49 | if ( c == '\n' ) | ||
50 | break; | ||
51 | |||
52 | if ( c == '\r' ) | ||
53 | continue; | ||
54 | |||
55 | buffer[count++] = c; | ||
56 | } | ||
57 | |||
58 | buffer[MIN(count, buffer_size - 1)] = 0; | ||
59 | |||
60 | return errno_ ? -1 : num_read; | ||
61 | } | ||
62 | |||
63 | void* plugin_get_buffer(size_t *buffer_size) | ||
64 | { | ||
65 | *buffer_size = PLUGIN_BUFFER_SIZE; | ||
66 | return pluginbuf; | ||
67 | } | ||
68 | |||
69 | int checkwps(const char *filename, int verbose){ | ||
70 | int res; | ||
71 | int fd; | ||
72 | |||
73 | struct wps_data wps; | ||
74 | wps_verbose_level = verbose; | ||
75 | |||
76 | fd = open(filename, O_RDONLY); | ||
77 | if (fd < 0) { | ||
78 | DEBUGF1("Failed to open %s\n",filename); | ||
79 | return 2; | ||
80 | } | ||
81 | close(fd); | ||
82 | |||
83 | res = wps_data_load(&wps, &screens[0], filename, true); | ||
84 | |||
85 | if (!res) { | ||
86 | DEBUGF1("WPS parsing failure\n"); | ||
87 | return 3; | ||
88 | } | ||
89 | |||
90 | DEBUGF1("WPS parsed OK\n"); | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | int wps_init(const char* filename,struct proxy_api *api, bool isfile){ | ||
95 | int res; | ||
96 | if (!api) | ||
97 | return 4; | ||
98 | dummies_init(); | ||
99 | test_api(api); | ||
100 | set_api(api); | ||
101 | wps_data_init(&wpsdata); | ||
102 | wps_verbose_level = api->verbose; | ||
103 | res = wps_data_load(&wpsdata, &screens[0], filename, isfile); | ||
104 | if (!res) | ||
105 | { | ||
106 | DEBUGF1("ERR: WPS parsing failure\n"); | ||
107 | return 3; | ||
108 | } | ||
109 | DEBUGF1("WPS parsed OK\n"); | ||
110 | DEBUGF1("\n-------------------------------------------------\n"); | ||
111 | wps_state.paused = true; | ||
112 | gwps.data = &wpsdata; | ||
113 | gwps.display = &screens[0]; | ||
114 | gwps.state = &wps_state; | ||
115 | gwps.state->id3 = &id3; | ||
116 | gwps.state->nid3 = &nid3; | ||
117 | gui_wps[0] = gwps; | ||
118 | return res; | ||
119 | } | ||
120 | |||
121 | int wps_display(){ | ||
122 | DEBUGF3("wps_display(): begin\n"); | ||
123 | int res = gui_wps_display(); | ||
124 | DEBUGF3("\nWPS %sdisplayed\n", (res ? "" : "not ")); | ||
125 | return res; | ||
126 | } | ||
127 | int wps_refresh(){ | ||
128 | DEBUGF3("-----------------<wps_refresh(): begin>-----------------\n"); | ||
129 | int res = gui_wps_refresh(&gwps, 0, WPS_REFRESH_ALL); | ||
130 | DEBUGF3("\nWPS %srefreshed\n", (res ? "" : "not ")); | ||
131 | return res; | ||
132 | } | ||
diff --git a/utils/wpseditor/libwps/src/proxy.h b/utils/wpseditor/libwps/src/proxy.h new file mode 100644 index 0000000000..3836ecc6d0 --- /dev/null +++ b/utils/wpseditor/libwps/src/proxy.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef PROXY_H | ||
2 | #define PROXY_h | ||
3 | |||
4 | #include "screen_access.h" | ||
5 | #include "api.h" | ||
6 | #include "defs.h" | ||
7 | |||
8 | #define DEBUGF dbgf | ||
9 | #define DEBUGF1 dbgf | ||
10 | #define DEBUGF2(...) | ||
11 | #define DEBUGF3(...) | ||
12 | |||
13 | EXPORT int checkwps(const char *filename, int verbose); | ||
14 | EXPORT int wps_init(const char* filename,struct proxy_api *api,bool isfile); | ||
15 | EXPORT int wps_display(); | ||
16 | EXPORT int wps_refresh(); | ||
17 | |||
18 | const char* get_model_name(); | ||
19 | |||
20 | extern struct screen screens[NB_SCREENS]; | ||
21 | extern bool debug_wps; | ||
22 | extern int wps_verbose_level; | ||
23 | |||
24 | |||
25 | #endif | ||
diff --git a/utils/wpseditor/libwps/src/wpsstate.h b/utils/wpseditor/libwps/src/wpsstate.h new file mode 100644 index 0000000000..148936a481 --- /dev/null +++ b/utils/wpseditor/libwps/src/wpsstate.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef STATES_H | ||
2 | #define STATES_H | ||
3 | // | ||
4 | struct trackstate | ||
5 | { | ||
6 | char* title; | ||
7 | char* artist; | ||
8 | char* album; | ||
9 | char* genre_string; | ||
10 | char* disc_string; | ||
11 | char* track_string; | ||
12 | char* year_string; | ||
13 | char* composer; | ||
14 | char* comment; | ||
15 | char* albumartist; | ||
16 | char* grouping; | ||
17 | int discnum; | ||
18 | int tracknum; | ||
19 | int version; | ||
20 | int layer; | ||
21 | int year; | ||
22 | |||
23 | int length; | ||
24 | int elapsed; | ||
25 | }; | ||
26 | |||
27 | struct wpsstate{ | ||
28 | int volume; | ||
29 | int fontheight; | ||
30 | int fontwidth; | ||
31 | int battery_level; | ||
32 | int audio_status; | ||
33 | }; | ||
34 | #endif | ||
diff --git a/utils/wpseditor/libwps/targets.txt b/utils/wpseditor/libwps/targets.txt new file mode 100644 index 0000000000..d2c54378d9 --- /dev/null +++ b/utils/wpseditor/libwps/targets.txt | |||
@@ -0,0 +1,33 @@ | |||
1 | ARCHOS_RECORDER recorder | ||
2 | ARCHOS_FMRECORDER fmrecorder | ||
3 | ARCHOS_RECORDERV2 recorderv2 | ||
4 | ARCHOS_ONDIOSP ondiosp | ||
5 | ARCHOS_ONDIOFM ondiofm | ||
6 | IRIVER_H120 h120 | ||
7 | IRIVER_H300 h300 | ||
8 | IRIVER_H100 h100 | ||
9 | IRIVER_IFP7XX ifp7xx | ||
10 | IRIVER_H10 h10 | ||
11 | IRIVER_H10_5GB h10_5gb | ||
12 | IPOD_COLOR ipodcolor | ||
13 | IPOD_NANO ipodnano | ||
14 | IPOD_VIDEO ipodvideo | ||
15 | IPOD_3G ipod3g | ||
16 | IPOD_4G ipod4g | ||
17 | IPOD_MINI ipodmini | ||
18 | IPOD_MINI2G ipodmini2g | ||
19 | IPOD_1G2G ipod1g2g | ||
20 | IAUDIO_X5 x5 | ||
21 | IAUDIO_M5 m5 | ||
22 | COWON_D2 cowond2 | ||
23 | IAUDIO_M3 m3 | ||
24 | GIGABEAT_F gigabeatf | ||
25 | GIGABEAT_S gigabeats | ||
26 | MROBE_500 mrobe500 | ||
27 | MROBE_100 mrobe100 | ||
28 | LOGIK_DAX logikdax | ||
29 | CREATIVE_ZVM creativezvm | ||
30 | SANSA_E200 e200 | ||
31 | SANSA_E200 e200r | ||
32 | SANSA_C200 c200 | ||
33 | ELIO_TPJ1022 tpj1022 | ||
diff --git a/utils/wpseditor/wpseditor.pro b/utils/wpseditor/wpseditor.pro new file mode 100644 index 0000000000..0e9ecbbf51 --- /dev/null +++ b/utils/wpseditor/wpseditor.pro | |||
@@ -0,0 +1,2 @@ | |||
1 | SUBDIRS =gui/src/QPropertyEditor gui | ||
2 | TEMPLATE = subdirs | ||