diff options
author | Dominik Wenger <domonoky@googlemail.com> | 2008-09-03 19:24:50 +0000 |
---|---|---|
committer | Dominik Wenger <domonoky@googlemail.com> | 2008-09-03 19:24:50 +0000 |
commit | 254fa65c7b75f61147186d9f9146b89ee11b2b26 (patch) | |
tree | bb5355f04275394ebfd2aa200abc44b188c08df9 | |
parent | ca0de82cec434fcd4af827ff1a1d473667249338 (diff) |
WpsEditor: commit FS#9344 by Rostislav Chekan - multitarget support (only colour targets for now)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18399 a1c6a512-1295-4272-9138-f99709370657
26 files changed, 360 insertions, 186 deletions
diff --git a/utils/wpseditor/README b/utils/wpseditor/README index 3a8b87c511..c2b6a62866 100644 --- a/utils/wpseditor/README +++ b/utils/wpseditor/README @@ -7,15 +7,18 @@ Installation +To make a release version, change value in CONFIG from "debug" to "release" in gui.pro and QPropertyEditor.pro. + Windows: - * be sure that you have properly installed mingw, QT > 4.3.* + * be sure that you have properly installed mingw, QT > 4.3.* and bin directories are set properly * if you want to debug wpseditor, you'll have to build Qt debug libraries - * cd to rockbox/utils/wpseditor/ from Qt command promt and run qmake and then make - * >gui\bin\wpseditor.exe + * if you haven't qmake from PATH enviromet use Qts command line. + * run 'buildall.bat' in utils\wpseditor\ + * the binary is then in utils\wpseditor\gui\bin\wpseditord.exe Linux: * Make sure you have libqt4-dev installed and you have a working Rockbox environment - * cd to utils/wpseditor/ and do 'qmake-qt4 && make' + * cd to utils/wpseditor/ and run 'buildall.sh' * cd to gui/bin/ and start WPS editor with './wpseditord' diff --git a/utils/wpseditor/TODO b/utils/wpseditor/TODO index 28f559111f..0fb4afca86 100644 --- a/utils/wpseditor/TODO +++ b/utils/wpseditor/TODO @@ -1,7 +1,19 @@ -* Enable ability in gui to load different targets on the fly +* Make better logging system +* Replace checkwps functionality +* Include 'screenshot utility' functionality +* Options * Enable animation(timers,sliding lines, etc) * Test on Mac OS * Redesign GUI for more usability -* Replace checkwps functionality -* Include 'screenshot utility' functionality * Make editing via gui +* Use native rockbox fonts +* Replace shared libs as Qt Plugins +* Edit wiki :-) + +Partially solved +* Enable ability in gui to load different targets on the fly [Not all targets are built yet] +* Syntax highlight [Comments are done; enable for logEdit; tag highlight] + +THE BUGZ ARE COMING! +* While loading wps for the first time, gui doesn't show properties from editor properly +* Strange text horisontal position in cabbie(probably other themes) diff --git a/utils/wpseditor/buildall.bat b/utils/wpseditor/buildall.bat new file mode 100644 index 0000000000..c550a30850 --- /dev/null +++ b/utils/wpseditor/buildall.bat @@ -0,0 +1,9 @@ +@echo off
+echo qmake...
+qmake
+echo Building gui...
+mingw32-make 1>nul
+echo Building libs...
+cd libwps
+call buildall.bat 2>nul
+cd ..
diff --git a/utils/wpseditor/buildall.sh b/utils/wpseditor/buildall.sh new file mode 100755 index 0000000000..2539ba2161 --- /dev/null +++ b/utils/wpseditor/buildall.sh @@ -0,0 +1,4 @@ +#!/bin/sh
+qmake && make
+cd libwps
+./buildall.sh 2> /dev/null
diff --git a/utils/wpseditor/gui/gui.pro b/utils/wpseditor/gui/gui.pro index db7cfa1343..ada7ea3c98 100644 --- a/utils/wpseditor/gui/gui.pro +++ b/utils/wpseditor/gui/gui.pro @@ -8,10 +8,7 @@ MOC_DIR = build UI_DIR = build QMAKE_LIBDIR += lib QT = gui core -CONFIG += qt warn_on console debug_and_release -libwps.commands += $(MAKE) -C ../libwps shared -QMAKE_EXTRA_TARGETS += libwps -PRE_TARGETDEPS += libwps +CONFIG += qt warn_on debug HEADERS += ../libwps/src/api.h \ ../libwps/src/defs.h \ src/slider.h \ @@ -19,7 +16,8 @@ HEADERS += ../libwps/src/api.h \ src/qwpsstate.h \ src/qwpseditorwindow.h \ src/utils.h \ - src/qwpsdrawer.h + src/qwpsdrawer.h \ + src/qsyntaxer.h FORMS += ui/mainwindow.ui ui/slider.ui SOURCES += src/main.cpp \ src/slider.cpp \ @@ -28,11 +26,13 @@ SOURCES += src/main.cpp \ src/qwpseditorwindow.cpp \ src/utils.cpp \ src/qwpsdrawer.cpp \ - src/qwpsdrawer_static.cpp + src/qwpsdrawer_static.cpp \ + src/qsyntaxer.cpp LIBS += -Lbin CONFIG(debug, debug|release) { LIBS += -lQPropertyEditord TARGET = wpseditord + CONFIG += console } CONFIG(release, debug|release) { LIBS += -lQPropertyEditor diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditor.pro b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditor.pro index 85fd29ee2c..ad1e31ce9a 100644 --- a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditor.pro +++ b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditor.pro @@ -1,5 +1,5 @@ TEMPLATE = lib -CONFIG += staticlib debug_and_release +CONFIG += staticlib debug SOURCES = ColorCombo.cpp \ Property.cpp \ QPropertyEditorWidget.cpp \ diff --git a/utils/wpseditor/gui/src/qsyntaxer.cpp b/utils/wpseditor/gui/src/qsyntaxer.cpp new file mode 100644 index 0000000000..412ca38148 --- /dev/null +++ b/utils/wpseditor/gui/src/qsyntaxer.cpp @@ -0,0 +1,44 @@ +#include <QTextCharFormat>
+
+#include "qsyntaxer.h"
+
+QSyntaxer::QSyntaxer(QTextDocument *parent)
+ : QSyntaxHighlighter(parent) {
+ HighlightingRule rule;
+
+ hrules["operator"].pattern = QRegExp("%[^\\| \n<\\?%]{1,2}");
+ hrules["operator"].format.setFontWeight(QFont::Bold);
+ hrules["operator"].format.setForeground(Qt::darkBlue);
+
+
+ hrules["question"].pattern = QRegExp("%[\\?]{1}[^<]{1,2}");
+ hrules["question"].format.setForeground(Qt::darkMagenta);
+
+ hrules["question2"].pattern = QRegExp("(<|>)");
+ hrules["question2"].format.setForeground(Qt::red);
+
+
+ hrules["limiter"].pattern = QRegExp("\\|");
+ hrules["limiter"].format.setForeground(Qt::darkRed);
+
+ hrules["comment"].pattern = QRegExp("#[^\n]*");
+ hrules["comment"].format.setForeground(Qt::darkGreen);
+ hrules["comment"].format.setFontItalic(true);
+}
+//
+void QSyntaxer::highlightBlock(const QString &text) {
+ QTextCharFormat wholeText;
+ wholeText.setFont(QFont("arial",11,QFont::Normal));
+ setFormat(0,text.length(),wholeText);
+
+ foreach (HighlightingRule rule, hrules) {
+ QRegExp expression(rule.pattern);
+ int index = text.indexOf(expression);
+ while (index >= 0) {
+ int length = expression.matchedLength();
+ setFormat(index, length, rule.format);
+ index = text.indexOf(expression, index + length);
+ }
+ }
+
+}
diff --git a/utils/wpseditor/gui/src/qsyntaxer.h b/utils/wpseditor/gui/src/qsyntaxer.h new file mode 100644 index 0000000000..9cecd3e5ed --- /dev/null +++ b/utils/wpseditor/gui/src/qsyntaxer.h @@ -0,0 +1,21 @@ +#ifndef QSYNTAXER_H
+#define QSYNTAXER_H
+//
+#include <QSyntaxHighlighter>
+
+class QTextCharFormat;
+
+class QSyntaxer : public QSyntaxHighlighter {
+ Q_OBJECT
+ struct HighlightingRule {
+ QRegExp pattern;
+ QTextCharFormat format;
+ };
+ QMap<QString,HighlightingRule> hrules;
+public:
+ QSyntaxer(QTextDocument *parent = 0);
+
+protected:
+ void highlightBlock(const QString &text);
+};
+#endif
diff --git a/utils/wpseditor/gui/src/qtrackstate.h b/utils/wpseditor/gui/src/qtrackstate.h index b57f7a8376..9c3f324be6 100644 --- a/utils/wpseditor/gui/src/qtrackstate.h +++ b/utils/wpseditor/gui/src/qtrackstate.h @@ -4,11 +4,9 @@ #include "wpsstate.h" #include <QObject> -class QWpsState; - class QTrackState : public QObject { Q_OBJECT - Q_CLASSINFO ( "QTrackState", "Mp3 State" ); + Q_CLASSINFO ( "QTrackState", "Track State" ); Q_PROPERTY ( QString Title READ title WRITE setTitle DESIGNABLE true USER true ) Q_PROPERTY ( QString Artist READ artist WRITE setArtist DESIGNABLE true USER true ) Q_PROPERTY ( QString Album READ album WRITE setAlbum DESIGNABLE true USER true ) @@ -17,7 +15,6 @@ class QTrackState : public QObject { Q_PROPERTY ( int Elapsed READ elapsed WRITE setElapsed DESIGNABLE true USER true ) Q_CLASSINFO("Elapsed", "minimum=0;maximum=100;value=50"); - trackstate state; public: diff --git a/utils/wpseditor/gui/src/qwpsdrawer.cpp b/utils/wpseditor/gui/src/qwpsdrawer.cpp index ab8a4b32d6..a506d5c03b 100644 --- a/utils/wpseditor/gui/src/qwpsdrawer.cpp +++ b/utils/wpseditor/gui/src/qwpsdrawer.cpp @@ -1,11 +1,14 @@ -#include "qwpsdrawer.h" -#include "slider.h" -#include "utils.h" +#include <stdarg.h> + #include <QtGui> #include <QLibrary> -#include <stdarg.h> -// +#include "qwpsdrawer.h" +#include "slider.h" +#include "utils.h" +#include "qtrackstate.h" +#include "qwpsstate.h" +#include "api.h" QPointer<QWpsDrawer> drawer; QPixmap *QWpsDrawer::pix = NULL; @@ -14,34 +17,38 @@ QImage QWpsDrawer::backdrop; proxy_api QWpsDrawer::api; QWpsDrawer::QWpsDrawer( QWpsState *ws,QTrackState *ms, QWidget *parent ) - : QWidget(parent),wpsState(ws),trackState(ms),showGrid(false),mTargetLibName("libwps") { + : QWidget(parent),wpsState(ws),trackState(ms),showGrid(false),mCurTarget("h10_5gb") { tryResolve(); - memset(&api,0,sizeof(struct proxy_api)); - - api.verbose = 2; - api.putsxy = &QWpsDrawer::putsxy; - api.transparent_bitmap_part = &QWpsDrawer::transparent_bitmap_part; - api.bitmap_part = &QWpsDrawer::bitmap_part; - api.drawpixel = &QWpsDrawer::drawpixel; - api.fillrect = &QWpsDrawer::fillrect; - api.hline = &QWpsDrawer::hline; - api.vline = &QWpsDrawer::vline; - api.clear_viewport = &QWpsDrawer::clear_viewport; - api.load_wps_backdrop = &QWpsDrawer::load_wps_backdrop; - api.read_bmp_file = &QWpsDrawer::read_bmp_file; - api.debugf = &qlogger; newTempWps(); } bool QWpsDrawer::tryResolve() { - QLibrary lib(qApp->applicationDirPath()+"/"+mTargetLibName); - wps_init = (pfwps_init)lib.resolve("wps_init"); - wps_display = (pfwps_display)lib.resolve("wps_display"); - wps_refresh = (pfwps_refresh)lib.resolve("wps_refresh"); - mResolved = wps_init && wps_display && wps_refresh; + QLibrary lib(qApp->applicationDirPath()+"/libwps_"+mCurTarget); + lib_wps_init = (pfwps_init)lib.resolve("wps_init"); + lib_wps_display = (pfwps_display)lib.resolve("wps_display"); + lib_wps_refresh = (pfwps_refresh)lib.resolve("wps_refresh"); + lib_get_model_name = (pfget_model_name)lib.resolve("get_model_name"); + mResolved = lib_wps_init && lib_wps_display && lib_wps_refresh && lib_get_model_name; if (!mResolved) DEBUGF1(tr("ERR: Failed to resolve funcs!")); + else { + int v = api.verbose; + memset(&api,0,sizeof(struct proxy_api)); + api.verbose = v; + api.putsxy = &QWpsDrawer::putsxy; + api.transparent_bitmap_part = &QWpsDrawer::transparent_bitmap_part; + api.bitmap_part = &QWpsDrawer::bitmap_part; + api.drawpixel = &QWpsDrawer::drawpixel; + api.fillrect = &QWpsDrawer::fillrect; + api.hline = &QWpsDrawer::hline; + api.vline = &QWpsDrawer::vline; + api.clear_viewport = &QWpsDrawer::clear_viewport; + api.load_wps_backdrop = &QWpsDrawer::load_wps_backdrop; + api.read_bmp_file = &QWpsDrawer::read_bmp_file; + api.debugf = &qlogger; + qDebug()<<(qApp->applicationDirPath()+"/libwps_"+mCurTarget+" resolved"); + } return mResolved; } QWpsDrawer::~QWpsDrawer() { @@ -56,20 +63,20 @@ void QWpsDrawer::mouseReleaseEvent ( QMouseEvent * event ) { DEBUGF1("x=%d,y=%d",x,y);*/ } void QWpsDrawer::newTempWps() { - QTemporaryFile tmpWps; + QTemporaryFile tmpWps; tmpWps.setAutoRemove(false); tmpWps.setFileTemplate(QDir::tempPath()+"/XXXXXXXXXX.wps"); if (tmpWps.open()) { QString tmpDir = tmpWps.fileName().left(tmpWps.fileName().length()-4); if (QDir::temp().mkpath(tmpDir)) { mTmpWpsString = tmpDir; - DEBUGF1(mTmpWpsString); + DEBUGF3(QString("Created :"+mTmpWpsString).toAscii()); } } } void QWpsDrawer::WpsInit(QString buffer, bool isFile) { - + DEBUGF3("QWpsDrawer::WpsInit"); if (!mResolved) if (!tryResolve()) return; @@ -87,22 +94,24 @@ void QWpsDrawer::WpsInit(QString buffer, bool isFile) { if (tfile.open(QIODevice::WriteOnly | QIODevice::Text)) tfile.write(mWpsString.toAscii(),mWpsString.length()); } - + backdrop.fill(Qt::black); + DEBUGF3("clear backdrop"); if (isFile) - wps_init(buffer.toAscii(), &api, isFile); + lib_wps_init(buffer.toAscii(), &api, isFile); else - wps_init(QString(mTmpWpsString+".wps").toAscii(), &api, true); + lib_wps_init(QString(mTmpWpsString+".wps").toAscii(), &api, true); pix = new QPixmap(api.getwidth(),api.getheight()); + pix->fill(Qt::black); drawBackdrop(); setMinimumWidth(api.getwidth()); setMinimumHeight(api.getheight()); - update(); } void QWpsDrawer::paintEvent(QPaintEvent * event) { + DEBUGF3("QWpsDrawer::paintEvent()"); if (!mResolved) return; if (pix==NULL) @@ -111,7 +120,7 @@ void QWpsDrawer::paintEvent(QPaintEvent * event) { QRect rect = event->rect(); drawBackdrop(); - wps_refresh(); + lib_wps_refresh(); if (showGrid) { QPainter g(pix); @@ -172,10 +181,13 @@ void QWpsDrawer::slotShowGrid(bool show) { } void QWpsDrawer::drawBackdrop() { + DEBUGF3("QWpsDrawer::drawBackdrop()"); + if (backdrop.isNull()) + return; QPainter b(pix); QImage pink = backdrop.createMaskFromColor(qRgb(255,0,255),Qt::MaskOutColor); backdrop.setAlphaChannel(pink); - b.drawImage(0,0,backdrop); + b.drawImage(0,0,backdrop,0,0,pix->width(),pix->height()); } void QWpsDrawer::slotSetAudioStatus(int status) { @@ -198,3 +210,35 @@ void QWpsDrawer::closeEvent(QCloseEvent *event) { cleanTemp(); event->accept(); } + +QString QWpsDrawer::getModelName(QString libraryName) { + QLibrary lib(libraryName); + if ((pfget_model_name)lib.resolve("get_model_name")) + return ((pfget_model_name)lib.resolve("get_model_name"))(); + DEBUGF1("ERR: failed to resolve <get_model_name>"); + return "unknown"; +} + +QList<QString> QWpsDrawer::getTargets() { + QList<QString> list ; + QDir d = QDir(qApp->applicationDirPath()); + QFileInfoList libs = d.entryInfoList(QStringList("libwps*")); + qDebug() << libs.size()<<"libs found"; + for (int i = 0; i < libs.size(); i++) { + QString modelName = getModelName(libs[i].absoluteFilePath()); + qDebug() << libs[i].fileName()<<modelName; + if (modelName == "unknown") + continue; + list.append(modelName); + } + return list; +} +bool QWpsDrawer::setTarget(QString target) { + QLibrary lib(qApp->applicationDirPath()+"/libwps_"+mCurTarget); + //lib.unload(); + if (getModelName("libwps_"+target)!="unknown") { + mCurTarget = target; + return tryResolve(); + } + return false; +} diff --git a/utils/wpseditor/gui/src/qwpsdrawer.h b/utils/wpseditor/gui/src/qwpsdrawer.h index d4dfa6c7a2..65e98723f5 100644 --- a/utils/wpseditor/gui/src/qwpsdrawer.h +++ b/utils/wpseditor/gui/src/qwpsdrawer.h @@ -1,25 +1,30 @@ #ifndef WPSDRAWER_H #define WPSDRAWER_H -// + #include <QWidget> #include <QPixmap> #include <QPointer> #include <QTemporaryFile> -#include "api.h" -#include "qtrackstate.h" -#include "qwpsstate.h" -// + +#include "wpsstate.h" + +struct proxy_api; + +class QWpsState; +class QTrackState; typedef int (*pfwps_init)(const char* buff,struct proxy_api *api, bool isfile); typedef int (*pfwps_display)(); typedef int (*pfwps_refresh)(); +typedef const char* (*pfget_model_name)(); class QWpsDrawer : public QWidget { Q_OBJECT - pfwps_init wps_init; - pfwps_display wps_display; - pfwps_refresh wps_refresh; + pfwps_init lib_wps_init; + pfwps_display lib_wps_display; + pfwps_refresh lib_wps_refresh; + pfget_model_name lib_get_model_name; static QPixmap *pix; static QImage backdrop; @@ -30,7 +35,7 @@ class QWpsDrawer : public QWidget { bool showGrid; bool mResolved; QString mWpsString; - QString mTargetLibName; + QString mCurTarget; static QString mTmpWpsString; @@ -42,6 +47,7 @@ protected: void newTempWps(); void cleanTemp(bool fileToo=true); bool tryResolve(); + QString getModelName(QString libraryName); public: QWpsDrawer(QWpsState *ws,QTrackState *ms, QWidget *parent=0); ~QWpsDrawer(); @@ -53,6 +59,8 @@ public: QString tempWps() const { return mTmpWpsString; }; + QList<QString> getTargets(); + bool setTarget(QString target); static proxy_api api; @@ -73,7 +81,6 @@ public: public slots: void slotSetVolume(); void slotSetProgress(); - void slotShowGrid(bool); void slotWpsStateChanged(wpsstate); void slotTrackStateChanged(trackstate); diff --git a/utils/wpseditor/gui/src/qwpsdrawer_static.cpp b/utils/wpseditor/gui/src/qwpsdrawer_static.cpp index bf94d28a5a..a9346ae430 100644 --- a/utils/wpseditor/gui/src/qwpsdrawer_static.cpp +++ b/utils/wpseditor/gui/src/qwpsdrawer_static.cpp @@ -3,14 +3,14 @@ #include <QFile> #include <QFileInfo> #include "utils.h" +#include "api.h" void QWpsDrawer::putsxy(int x, int y, const unsigned char *str) { + DEBUGF3("putsxy(int x=%d, int y=%d, *str=%s)",x,y,str); QPainter p(pix); viewport_api avp; api.get_current_vp(&avp); p.setPen(Qt::gray); - - QFont font("times",avp.fontheight,QFont::Bold); p.setFont(font); p.drawText(x+avp.x,y + avp.fontheight + avp.y,(char*)str); @@ -54,7 +54,7 @@ void QWpsDrawer::vline(int x, int y1, int y2) { p.drawLine(x,y1,x,y2); } bool QWpsDrawer::load_wps_backdrop(char* filename) { - DEBUGF2("load backdrop: %s", filename); + DEBUGF3("load backdrop: %s", filename); QFile file(filename); QFileInfo info(file); file.copy(mTmpWpsString+"/"+info.fileName()); @@ -70,7 +70,6 @@ int QWpsDrawer::read_bmp_file(const char* filename,int *width, int *height) { file.copy(mTmpWpsString+"/"+info.fileName()); img.load(filename); - //qDebug()<<"QWpsDrawer::read_bmp_file"<<img.width()<<img.height(); *width = img.width(); *height = img.height(); return 1; diff --git a/utils/wpseditor/gui/src/qwpseditorwindow.cpp b/utils/wpseditor/gui/src/qwpseditorwindow.cpp index c3090bd027..74d18ffe23 100644 --- a/utils/wpseditor/gui/src/qwpseditorwindow.cpp +++ b/utils/wpseditor/gui/src/qwpseditorwindow.cpp @@ -1,9 +1,11 @@ -#include "qwpseditorwindow.h" -#include "qwpsdrawer.h" -#include "utils.h" #include <QFileDialog> #include <QDebug> #include <QInputDialog> +#include "api.h" +#include "qwpseditorwindow.h" +#include "utils.h" +#include "qsyntaxer.h" + enum api_playmode playmodes[PLAYMODES_NUM] = { API_STATUS_PLAY, @@ -27,45 +29,61 @@ QWpsEditorWindow::QWpsEditorWindow( QWidget * parent, Qt::WFlags f) setupUi(this); drawer = new QWpsDrawer(&wpsState,&trackState, this); QWpsDrawer::api.verbose = 1; - //drawer->WpsInit("iCatcher.wps"); setCentralWidget(drawer); connectActions(); m_propertyEditor->addObject(&trackState); m_propertyEditor->addObject(&wpsState); + new QSyntaxer(plainWpsEdit->document()); } void QWpsEditorWindow::connectActions() { - qDebug()<<"connect actions"; + DEBUGF3("connect actions"); connect(actOpenWps, SIGNAL(triggered()), this, SLOT(slotOpenWps())); connect(actSetVolume, SIGNAL(triggered()), drawer, SLOT(slotSetVolume())); connect(actSetProgress, SIGNAL(triggered()), drawer, SLOT(slotSetProgress())); connect(actShowGrid, SIGNAL(triggered(bool)), drawer, SLOT(slotShowGrid(bool))); - connect(actUpdatePlainWps, SIGNAL(triggered()), SLOT(slotUpdatePlainWps())); - connect(plainWpsEdit->document(), SIGNAL(modificationChanged(bool)), SLOT(slotPlainDocModChanged(bool))); + connect(actUpdatePlainWps, SIGNAL(triggered()), SLOT(slotUpdatePlainWps())); + connect(plainWpsEdit->document(),SIGNAL(modificationChanged(bool)),SLOT(slotPlainDocModChanged(bool))); - connect(&wpsState, SIGNAL(stateChanged(wpsstate)), drawer, SLOT(slotWpsStateChanged(wpsstate))); - connect(&trackState, SIGNAL(stateChanged(trackstate)), drawer, SLOT(slotTrackStateChanged(trackstate))); - connect(&wpsState, SIGNAL(stateChanged(wpsstate)), this, SLOT(slotWpsStateChanged(wpsstate))); - connect(&trackState, SIGNAL(stateChanged(trackstate)), this, SLOT(slotTrackStateChanged(trackstate))); + connect(&wpsState, SIGNAL(stateChanged(wpsstate)), drawer, SLOT(slotWpsStateChanged(wpsstate))); + connect(&trackState, SIGNAL(stateChanged(trackstate)), drawer, SLOT(slotTrackStateChanged(trackstate))); + connect(&wpsState, SIGNAL(stateChanged(wpsstate)), this, SLOT(slotWpsStateChanged(wpsstate))); + connect(&trackState, SIGNAL(stateChanged(trackstate)), this, SLOT(slotTrackStateChanged(trackstate))); - connect(actClearLog, SIGNAL(triggered()), logEdit, SLOT(clear())); + connect(actClearLog, SIGNAL(triggered()), logEdit, SLOT(clear())); connect(actVerboseLevel, SIGNAL(triggered()), SLOT(slotVerboseLevel())); actGroupAudios = new QActionGroup(this); - signalMapper = new QSignalMapper(this); + audiosSignalMapper = new QSignalMapper(this); for (int i=0;i<PLAYMODES_NUM;i++) { QAction *act = new QAction(playmodeNames[i],this); act->setCheckable(true); actGroupAudios->addAction(act); - connect(act,SIGNAL(triggered()),signalMapper,SLOT(map())); - signalMapper->setMapping(act, i); + connect(act,SIGNAL(triggered()),audiosSignalMapper,SLOT(map())); + audiosSignalMapper->setMapping(act, i); menuPlay->addAction(act); actAudios[playmodes[i]] = act; } - connect(signalMapper, SIGNAL(mapped(int)), SIGNAL(signalAudioStatusChanged(int))); - connect(this, SIGNAL(signalAudioStatusChanged(int)), drawer, SLOT(slotSetAudioStatus(int))); + connect(audiosSignalMapper, SIGNAL(mapped(int)), SIGNAL(signalAudioStatusChanged(int))); + connect(this, SIGNAL(signalAudioStatusChanged(int)), drawer, SLOT(slotSetAudioStatus(int))); actGroupAudios->setEnabled(false); + + QList<QString> targets = drawer->getTargets(); + actGroupTargets = new QActionGroup(this); + targetsSignalMapper = new QSignalMapper(this); + + for (int i=0;i<targets.size();i++) { + QAction *act = new QAction(targets[i],this); + act->setCheckable(true); + actGroupTargets->addAction(act); + connect(act,SIGNAL(triggered()),targetsSignalMapper,SLOT(map())); + targetsSignalMapper->setMapping(act, targets[i]); + menuTarget->addAction(act); + actTargets[targets[i]] = act; + } + connect(targetsSignalMapper, SIGNAL(mapped(const QString &)),this, SIGNAL(signalSetTarget(const QString &))); + connect(this, SIGNAL(signalSetTarget(const QString &)),this, SLOT(slotSetTarget(const QString &))); } void QWpsEditorWindow::slotWpsStateChanged(wpsstate) { @@ -89,8 +107,9 @@ void QWpsEditorWindow::slotOpenWps() { drawer->WpsInit(wpsfile); plainWpsEdit->clear(); plainWpsEdit->append(drawer->wpsString()); - trackState.setAlbum(trackState.album()); + trackState.setAlbum(trackState.album()); ////updating property editor actGroupAudios->setEnabled(true); + } void QWpsEditorWindow::logMsg(QString s) { @@ -108,7 +127,9 @@ void QWpsEditorWindow::slotUpdatePlainWps() { DEBUGF1(tr("Updating WPS")); plainWpsEdit->document()->setModified(false); drawer->WpsInit(plainWpsEdit->toPlainText(),false); - + m_propertyEditor->setEnabled(true); + actGroupAudios->setEnabled(true); + trackState.setAlbum(trackState.album()); //updating property editor } void QWpsEditorWindow::slotPlainDocModChanged(bool changed) { @@ -117,4 +138,15 @@ void QWpsEditorWindow::slotPlainDocModChanged(bool changed) { else dockPlainWps->setWindowTitle(tr("PlainWps")); } +void QWpsEditorWindow::slotSetTarget(const QString & target) { + if (drawer->setTarget(target)) { + DEBUGF1(tr("New target <%1> switched").arg(target)); + actTargets[target]->setChecked(true); + } else + DEBUGF1(tr("ERR: Target <%1> failed!").arg(target)); + update(); + slotUpdatePlainWps(); +} + + diff --git a/utils/wpseditor/gui/src/qwpseditorwindow.h b/utils/wpseditor/gui/src/qwpseditorwindow.h index 019eb63808..1becd74885 100644 --- a/utils/wpseditor/gui/src/qwpseditorwindow.h +++ b/utils/wpseditor/gui/src/qwpseditorwindow.h @@ -4,22 +4,29 @@ #include <QMainWindow> #include <QActionGroup> #include <QSignalMapper> + +#include "wpsstate.h" #include "ui_mainwindow.h" #include "wpsstate.h" -#include "qwpsdrawer.h" #include "qwpsstate.h" #include "qtrackstate.h" -// +#include "qwpsdrawer.h" + class QWpsEditorWindow : public QMainWindow, public Ui::MainWindow { Q_OBJECT + QWpsState wpsState; QTrackState trackState; QPointer<QWpsDrawer> drawer; QHash<int, QAction*> actAudios; - QActionGroup *actGroupAudios; - QSignalMapper *signalMapper; + QActionGroup *actGroupAudios; + QSignalMapper *audiosSignalMapper; + QHash<QString,QAction *> actTargets; + QActionGroup *actGroupTargets; + QSignalMapper *targetsSignalMapper; + protected: void connectActions(); public: @@ -33,9 +40,11 @@ private slots: void slotUpdatePlainWps(); void slotPlainDocModChanged(bool m); + void slotSetTarget(const QString &); signals: void signalAudioStatusChanged(int); + void signalSetTarget(const QString &); }; #endif @@ -43,3 +52,4 @@ signals: + diff --git a/utils/wpseditor/gui/src/slider.cpp b/utils/wpseditor/gui/src/slider.cpp index 7e3c9a942c..4cbc714507 100644 --- a/utils/wpseditor/gui/src/slider.cpp +++ b/utils/wpseditor/gui/src/slider.cpp @@ -1,11 +1,11 @@ #include "slider.h" #include <QDebug> // -Slider::Slider(QWidget *parent, QString caption, int min, int max ):QDialog(parent) { +Slider::Slider(QWidget *parent, QString caption, int min, int max ):QDialog(parent),mCaption(caption) { setupUi ( this ); connect(horslider, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int))); connect(this, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged(int))); - setWindowTitle(caption); + setWindowTitle(mCaption); horslider->setMinimum(min); horslider->setMaximum(max); } @@ -14,7 +14,8 @@ int Slider::value() { return horslider->value(); } void Slider::slotValueChanged(int step) { - setWindowTitle(tr("Value =%1 ").arg(step)); + setWindowTitle(tr("%1 = %2 ").arg(mCaption).arg(step)); } + diff --git a/utils/wpseditor/gui/src/slider.h b/utils/wpseditor/gui/src/slider.h index 2620731644..8b8c1990d8 100644 --- a/utils/wpseditor/gui/src/slider.h +++ b/utils/wpseditor/gui/src/slider.h @@ -7,6 +7,7 @@ // class Slider : public QDialog , Ui::slider { Q_OBJECT + QString mCaption; public slots: void slotValueChanged(int step); signals: diff --git a/utils/wpseditor/gui/src/utils.cpp b/utils/wpseditor/gui/src/utils.cpp index f18442555b..5b35f752a3 100644 --- a/utils/wpseditor/gui/src/utils.cpp +++ b/utils/wpseditor/gui/src/utils.cpp @@ -19,7 +19,6 @@ int qlogger(const char* fmt,...) { s = "<font color=red>"+s+"</font>"; if (win!=0) win->logMsg(s); - va_end(ap); return s.length(); } diff --git a/utils/wpseditor/gui/src/utils.h b/utils/wpseditor/gui/src/utils.h index ae88d78249..f1a05d3397 100644 --- a/utils/wpseditor/gui/src/utils.h +++ b/utils/wpseditor/gui/src/utils.h @@ -5,6 +5,7 @@ #define DEBUGF1 qlogger #define DEBUGF2(...) +#define DEBUGF3 qDebug extern int qlogger(const char* fmt,...); extern int qlogger(const QString& s); diff --git a/utils/wpseditor/gui/ui/mainwindow.ui b/utils/wpseditor/gui/ui/mainwindow.ui index cd3f52bd66..f1186e4e7a 100644 --- a/utils/wpseditor/gui/ui/mainwindow.ui +++ b/utils/wpseditor/gui/ui/mainwindow.ui @@ -15,10 +15,10 @@ <widget class="QWidget" name="centralwidget" > <property name="geometry" > <rect> - <x>260</x> - <y>21</y> - <width>344</width> - <height>345</height> + <x>262</x> + <y>19</y> + <width>340</width> + <height>346</height> </rect> </property> </widget> @@ -28,7 +28,7 @@ <x>0</x> <y>0</y> <width>882</width> - <height>21</height> + <height>19</height> </rect> </property> <widget class="QMenu" name="menuFile" > @@ -48,8 +48,14 @@ <string>Play</string> </property> </widget> + <widget class="QMenu" name="menuTarget" > + <property name="title" > + <string>Target</string> + </property> + </widget> <addaction name="menuFile" /> <addaction name="menuPlay" /> + <addaction name="menuTarget" /> </widget> <widget class="QStatusBar" name="statusbar" > <property name="geometry" > @@ -65,9 +71,9 @@ <property name="geometry" > <rect> <x>0</x> - <y>370</y> + <y>371</y> <width>882</width> - <height>280</height> + <height>279</height> </rect> </property> <property name="minimumSize" > @@ -86,9 +92,9 @@ <property name="geometry" > <rect> <x>0</x> - <y>22</y> + <y>20</y> <width>882</width> - <height>258</height> + <height>259</height> </rect> </property> <layout class="QGridLayout" name="gridLayout_2" > @@ -129,9 +135,9 @@ <property name="geometry" > <rect> <x>0</x> - <y>21</y> + <y>19</y> <width>256</width> - <height>345</height> + <height>346</height> </rect> </property> <property name="windowTitle" > @@ -147,9 +153,9 @@ <property name="geometry" > <rect> <x>0</x> - <y>22</y> + <y>20</y> <width>256</width> - <height>323</height> + <height>326</height> </rect> </property> </widget> @@ -158,9 +164,9 @@ <property name="geometry" > <rect> <x>608</x> - <y>21</y> + <y>19</y> <width>274</width> - <height>345</height> + <height>346</height> </rect> </property> <property name="minimumSize" > @@ -179,9 +185,9 @@ <property name="geometry" > <rect> <x>0</x> - <y>22</y> + <y>20</y> <width>274</width> - <height>323</height> + <height>326</height> </rect> </property> <layout class="QGridLayout" name="gridLayout" > diff --git a/utils/wpseditor/libwps/Makefile b/utils/wpseditor/libwps/Makefile index 3779a9ed30..c5d0a39de1 100644 --- a/utils/wpseditor/libwps/Makefile +++ b/utils/wpseditor/libwps/Makefile @@ -13,39 +13,40 @@ CC = gcc MKDIR = mkdir -p ifeq ($(findstring MINGW,$(shell uname)),MINGW) -OS = w32 -CC = mingw32-gcc -COPY = copy -RM = rm + OS = w32 + CC = mingw32-gcc + COPY = copy + RM = rm endif ifeq ($(findstring Linux,$(shell uname)),Linux) -OS = linux -CC = gcc -COPY = cp -RM = rm -f + OS = linux + CC = gcc + COPY = cp + RM = rm -f endif -COMMON= \ - src/dummies.c \ +SOURCES= \ src/api.c \ + src/dummies.c \ src/lcd.c \ + src/proxy.c \ + $(ROOT)/apps/gui/scrollbar.c \ + $(ROOT)/apps/gui/gwps-common.c \ $(ROOT)/apps/gui/wps_parser.c \ $(ROOT)/apps/gui/wps_debug.c \ - $(ROOT)/firmware/font.c \ - $(ROOT)/apps/misc.c \ - $(ROOT)/apps/gui/gwps-common.c \ - $(ROOT)/apps/status.c \ $(ROOT)/apps/recorder/peakmeter.c \ $(ROOT)/apps/recorder/icons.c \ - $(ROOT)/apps/gui/scrollbar.c \ + $(ROOT)/apps/misc.c \ + $(ROOT)/apps/status.c \ + $(ROOT)/firmware/common/ctype.c \ $(ROOT)/firmware/common/timefuncs.c \ $(ROOT)/firmware/common/unicode.c \ - $(ROOT)/firmware/common/ctype.c \ - $(ROOT)/firmware/id3.c \ + $(ROOT)/firmware/font.c \ $(ROOT)/firmware/font_cache.c \ + $(ROOT)/firmware/id3.c \ $(ROOT)/firmware/lru.c \ $(ROOT)/firmware/mp3data.c \ $(ROOT)/firmware/replaygain.c @@ -72,13 +73,13 @@ all: build: build-$(OS) -build-w32: src/proxy.c $(COMMON) +build-w32: $(SOURCES) @echo CC [$(TARGET)] - @$(CC) $(INCLUDE) $(CFLAGS) -D$(TARGET) -DTARGET_MODEL=\"$(MODEL)\" -DBUILD_DLL $(COMMON) -shared src/proxy.c -o libwps_$(MODEL).dll + @$(CC) $(INCLUDE) $(CFLAGS) -D$(TARGET) -DTARGET_MODEL=\"$(MODEL)\" -DBUILD_DLL $(SOURCES) -shared -o libwps_$(MODEL).dll -build-linux: src/proxy.c $(COMMON) +build-linux: $(SOURCES) @echo CC [$(TARGET)] - @$(CC) $(INCLUDE) $(CFLAGS) -D$(TARGET) -DTARGET_MODEL=\"$(MODEL)\" -shared -Wl,-soname,libwps_$(MODEL).so,-olibwps_$(MODEL).so -fPIC $(COMMON) src/proxy.c + @$(CC) $(INCLUDE) $(CFLAGS) -D$(TARGET) -DTARGET_MODEL=\"$(MODEL)\" -shared -Wl,-soname,libwps_$(MODEL).so,-olibwps_$(MODEL).so -fPIC $(SOURCES) clean: clean-$(OS) @@ -86,15 +87,15 @@ clean-w32: $(RM) "libwps_$(MODEL).dll" clean-linux: - $(RM) "libwps_$(MODEL).so.1" + $(RM) "libwps_$(MODEL).so" shared: shared-$(OS) -shared-w32: src/proxy.c $(COMMON) +shared-w32: $(SOURCES) @echo CC [IRIVER_H10_5GB] - @$(CC) $(INCLUDE) $(CFLAGS) -DIRIVER_H10_5GB -DTARGET_MODEL=\"h10_5gb\" -DBUILD_DLL $(COMMON) -shared src/proxy.c -o ../gui/bin/libwps.dll + @$(CC) $(INCLUDE) $(CFLAGS) -DIRIVER_H10_5GB -DTARGET_MODEL=\"h10_5gb\" -DBUILD_DLL -shared $(SOURCES) -o ../gui/bin/libwps_h10_5gb.dll -shared-linux: src/proxy.c $(COMMON) +shared-linux: $(SOURCES) @echo CC [IRIVER_H10_5GB] - @$(CC) $(INCLUDE) $(CFLAGS) -DIRIVER_H10_5GB -DTARGET_MODEL=\"h10_5gb\" -shared -Wl,-soname,libwps.so,-olibwps.so -fPIC $(COMMON) src/proxy.c - @$(COPY) libwps.so ../gui/bin/libwps.so + @$(CC) $(INCLUDE) $(CFLAGS) -DIRIVER_H10_5GB -DTARGET_MODEL=\"h10_5gb\" -shared -Wl,-soname,libwps_h10_5gb.so,-olibwps_h10_5gb.so -fPIC $(SOURCES) + @$(COPY) libwps_h10_5gb.so ../gui/bin/libwps_h10_5gb.so diff --git a/utils/wpseditor/libwps/buildall.bat b/utils/wpseditor/libwps/buildall.bat new file mode 100644 index 0000000000..c545453934 --- /dev/null +++ b/utils/wpseditor/libwps/buildall.bat @@ -0,0 +1,4 @@ +@echo off
+FOR /F "tokens=1,2* delims=, " %%i in (targets.txt) do @mingw32-make MODEL=%%j TARGET=%%i build 2>nul
+echo Copying files...
+xcopy /I /Y *.dll ..\gui\bin
diff --git a/utils/wpseditor/libwps/buildall.sh b/utils/wpseditor/libwps/buildall.sh index 60677d22b6..0f32bb9b9a 100644..100755 --- a/utils/wpseditor/libwps/buildall.sh +++ b/utils/wpseditor/libwps/buildall.sh @@ -4,4 +4,6 @@ cat targets.txt | ( do make MODEL=$model TARGET=$target build done + cp *.dll ../gui/bin + cp *.so ../gui/bin ) diff --git a/utils/wpseditor/libwps/src/api.c b/utils/wpseditor/libwps/src/api.c index 485efa8e00..89538423b4 100644 --- a/utils/wpseditor/libwps/src/api.c +++ b/utils/wpseditor/libwps/src/api.c @@ -32,8 +32,7 @@ bool load_remote_wps_backdrop(char* filename) { } int read_bmp_file(const char* filename,struct bitmap *bm, int maxsize,int format) { - if (!xapi->read_bmp_file) - { + if (!xapi->read_bmp_file) { DEBUGF1("can't read bmp file! NULL api!\n"); return -1; } @@ -84,7 +83,7 @@ int getstringsize(const unsigned char *str, int *w, int *h) { return 1; } -void set_wpsstate(struct wpsstate state){ +void set_wpsstate(struct wpsstate state) { sysfont.height = state.fontheight; sysfont.maxwidth = state.fontwidth; global_settings.volume = state.volume; @@ -92,7 +91,10 @@ void set_wpsstate(struct wpsstate state){ _audio_status = state.audio_status; } -void set_trackstate(struct trackstate state){ +void set_trackstate(struct trackstate state) { + if (!(gui_wps[0].state) || + !(gui_wps[0].state->id3)) + return; gui_wps[0].state->id3->title = state.title; gui_wps[0].state->id3->artist = state.artist; gui_wps[0].state->id3->album = state.album; @@ -100,8 +102,7 @@ void set_trackstate(struct trackstate state){ gui_wps[0].state->id3->length = state.length; } -void set_next_trackstate(struct trackstate state) -{ +void set_next_trackstate(struct trackstate state) { gui_wps[0].state->nid3->title = state.title; gui_wps[0].state->nid3->artist = state.artist; gui_wps[0].state->nid3->album = state.album; @@ -110,21 +111,21 @@ void set_next_trackstate(struct trackstate state) } enum api_playmode playmodes[PLAYMODES_NUM] = { - API_STATUS_PLAY, - API_STATUS_STOP, - API_STATUS_PAUSE, - API_STATUS_FASTFORWARD, - API_STATUS_FASTBACKWARD -}; + API_STATUS_PLAY, + API_STATUS_STOP, + API_STATUS_PAUSE, + API_STATUS_FASTFORWARD, + API_STATUS_FASTBACKWARD + }; const char *playmodeNames[] = { - "Play", "Stop", "Pause", "FastForward", "FastBackward" -}; + "Play", "Stop", "Pause", "FastForward", "FastBackward" + }; -void set_audio_status(int status){ +void set_audio_status(int status) { DEBUGF1("%s",playmodeNames[status]); - switch(status){ + switch (status) { case API_STATUS_PLAY: _audio_status = AUDIO_STATUS_PLAY; status_set_ffmode(STATUS_PLAY); @@ -203,8 +204,6 @@ int set_api(struct proxy_api* api) { #else screens[0].is_color=false; #endif - if (api->getwidth) - screens[0].getwidth = api->getwidth; if (api->stop_scroll) screens[0].stop_scroll=api->stop_scroll; screens[0].scroll_stop = lcd_scroll_stop; @@ -266,3 +265,4 @@ int set_api(struct proxy_api* api) { + diff --git a/utils/wpseditor/libwps/src/proxy.c b/utils/wpseditor/libwps/src/proxy.c index 3a3b8ce4d9..8f9218e3ff 100644 --- a/utils/wpseditor/libwps/src/proxy.c +++ b/utils/wpseditor/libwps/src/proxy.c @@ -69,7 +69,7 @@ void* plugin_get_buffer(size_t *buffer_size) int checkwps(const char *filename, int verbose){ int res; int fd; - + struct wps_data wps; wps_verbose_level = verbose; @@ -104,9 +104,8 @@ int wps_init(const char* filename,struct proxy_api *api, bool isfile){ if (!res) { DEBUGF1("ERR: WPS parsing failure\n"); - return 3; - } - DEBUGF1("WPS parsed OK\n"); + } else + DEBUGF1("WPS parsed OK\n"); DEBUGF1("\n-------------------------------------------------\n"); wps_state.paused = true; gwps.data = &wpsdata; @@ -115,7 +114,7 @@ int wps_init(const char* filename,struct proxy_api *api, bool isfile){ gwps.state->id3 = &id3; gwps.state->nid3 = &nid3; gui_wps[0] = gwps; - return res; + return (res?res:3); } int wps_display(){ diff --git a/utils/wpseditor/libwps/src/proxy.h b/utils/wpseditor/libwps/src/proxy.h index 3836ecc6d0..df0abd3c3e 100644 --- a/utils/wpseditor/libwps/src/proxy.h +++ b/utils/wpseditor/libwps/src/proxy.h @@ -1,6 +1,8 @@ #ifndef PROXY_H #define PROXY_h +#include <stdio.h> + #include "screen_access.h" #include "api.h" #include "defs.h" @@ -9,13 +11,13 @@ #define DEBUGF1 dbgf #define DEBUGF2(...) #define DEBUGF3(...) +#define DEBUGF4(...) EXPORT int checkwps(const char *filename, int verbose); EXPORT int wps_init(const char* filename,struct proxy_api *api,bool isfile); EXPORT int wps_display(); EXPORT int wps_refresh(); - -const char* get_model_name(); +EXPORT const char* get_model_name(); extern struct screen screens[NB_SCREENS]; extern bool debug_wps; diff --git a/utils/wpseditor/libwps/targets.txt b/utils/wpseditor/libwps/targets.txt index d2c54378d9..547a2ba42c 100644 --- a/utils/wpseditor/libwps/targets.txt +++ b/utils/wpseditor/libwps/targets.txt @@ -1,33 +1,9 @@ -ARCHOS_RECORDER recorder -ARCHOS_FMRECORDER fmrecorder -ARCHOS_RECORDERV2 recorderv2 -ARCHOS_ONDIOSP ondiosp -ARCHOS_ONDIOFM ondiofm -IRIVER_H120 h120 -IRIVER_H300 h300 -IRIVER_H100 h100 -IRIVER_IFP7XX ifp7xx IRIVER_H10 h10 IRIVER_H10_5GB h10_5gb IPOD_COLOR ipodcolor IPOD_NANO ipodnano IPOD_VIDEO ipodvideo -IPOD_3G ipod3g -IPOD_4G ipod4g -IPOD_MINI ipodmini -IPOD_MINI2G ipodmini2g -IPOD_1G2G ipod1g2g -IAUDIO_X5 x5 -IAUDIO_M5 m5 -COWON_D2 cowond2 -IAUDIO_M3 m3 GIGABEAT_F gigabeatf GIGABEAT_S gigabeats -MROBE_500 mrobe500 -MROBE_100 mrobe100 -LOGIK_DAX logikdax -CREATIVE_ZVM creativezvm SANSA_E200 e200 -SANSA_E200 e200r SANSA_C200 c200 -ELIO_TPJ1022 tpj1022 |