diff options
Diffstat (limited to 'utils/wpseditor/gui/src/qwpseditorwindow.cpp')
-rw-r--r-- | utils/wpseditor/gui/src/qwpseditorwindow.cpp | 120 |
1 files changed, 120 insertions, 0 deletions
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 | |||