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 /utils/wpseditor/gui/src | |
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
Diffstat (limited to 'utils/wpseditor/gui/src')
-rw-r--r-- | utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditor.pro | 2 | ||||
-rw-r--r-- | utils/wpseditor/gui/src/qsyntaxer.cpp | 44 | ||||
-rw-r--r-- | utils/wpseditor/gui/src/qsyntaxer.h | 21 | ||||
-rw-r--r-- | utils/wpseditor/gui/src/qtrackstate.h | 5 | ||||
-rw-r--r-- | utils/wpseditor/gui/src/qwpsdrawer.cpp | 112 | ||||
-rw-r--r-- | utils/wpseditor/gui/src/qwpsdrawer.h | 27 | ||||
-rw-r--r-- | utils/wpseditor/gui/src/qwpsdrawer_static.cpp | 7 | ||||
-rw-r--r-- | utils/wpseditor/gui/src/qwpseditorwindow.cpp | 70 | ||||
-rw-r--r-- | utils/wpseditor/gui/src/qwpseditorwindow.h | 18 | ||||
-rw-r--r-- | utils/wpseditor/gui/src/slider.cpp | 7 | ||||
-rw-r--r-- | utils/wpseditor/gui/src/slider.h | 1 | ||||
-rw-r--r-- | utils/wpseditor/gui/src/utils.cpp | 1 | ||||
-rw-r--r-- | utils/wpseditor/gui/src/utils.h | 1 |
13 files changed, 236 insertions, 80 deletions
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); |