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
This commit is contained in:
Dominik Wenger 2008-09-03 19:24:50 +00:00
parent ca0de82cec
commit 254fa65c7b
26 changed files with 360 additions and 186 deletions

View file

@ -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();
}