summaryrefslogtreecommitdiff
authorwazlaf <wazlaf>2002-10-24 19:23:56 (UTC)
committer wazlaf <wazlaf>2002-10-24 19:23:56 (UTC)
commit1fb831ed1804a22455b5e4c9c8d9411e098c17e8 (patch) (unidiff)
tree6c3eac70c91c5a82b2f010f41c5d1dee09638c7a
parent2f2f9dc5f45fe7cf194a057e104c2d54394e4cef (diff)
downloadopie-1fb831ed1804a22455b5e4c9c8d9411e098c17e8.zip
opie-1fb831ed1804a22455b5e4c9c8d9411e098c17e8.tar.gz
opie-1fb831ed1804a22455b5e4c9c8d9411e098c17e8.tar.bz2
scripting changes: scripts are now available in a pop-down menu and are managed using DocLnks
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp1
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp87
-rw-r--r--noncore/apps/opie-console/mainwindow.h9
3 files changed, 60 insertions, 37 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index b2b107e..e80168d 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -65,3 +65,2 @@ void EmulationHandler::recvEmulation(const char* src, int len ) {
65 memcpy(ar.data(), src, sizeof(char) * len ); 65 memcpy(ar.data(), src, sizeof(char) * len );
66
67 if (isRecording()) 66 if (isRecording())
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 44ef458..2e00a07 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -12,2 +12,5 @@
12#include <qpe/resource.h> 12#include <qpe/resource.h>
13#include <qpe/qpeapplication.h>
14#include <qpe/filemanager.h>
15#include <qpe/mimetype.h>
13 16
@@ -46,2 +49,3 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(
46 populateProfiles(); 49 populateProfiles();
50 populateScripts();
47} 51}
@@ -58,2 +62,3 @@ void MainWindow::initUI() {
58 m_sessionsPop= new QPopupMenu( this ); 62 m_sessionsPop= new QPopupMenu( this );
63 m_scriptsPop = new QPopupMenu( this );
59 64
@@ -152,2 +157,5 @@ void MainWindow::initUI() {
152 */ 157 */
158 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
159 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
160
153 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 161 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
@@ -160,5 +168,2 @@ void MainWindow::initUI() {
160 168
161 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0);
162 m_runScript->addTo(m_scripts);
163 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript()));
164 169
@@ -218,5 +223,5 @@ void MainWindow::initUI() {
218 m_transfer->setEnabled( false ); 223 m_transfer->setEnabled( false );
224 m_scripts->setItemEnabled(m_runScript_id, false);
219 m_recordScript->setEnabled( false ); 225 m_recordScript->setEnabled( false );
220 m_saveScript->setEnabled( false ); 226 m_saveScript->setEnabled( false );
221 m_runScript->setEnabled( false );
222 m_fullscreen->setEnabled( false ); 227 m_fullscreen->setEnabled( false );
@@ -251,2 +256,17 @@ void MainWindow::populateProfiles() {
251} 256}
257
258void MainWindow::populateScripts() {
259 m_scriptsPop->clear();
260 m_scriptsData.clear();
261 DocLnkSet files(QPEApplication::documentDir(), "text/plain");
262 QListIterator<DocLnk> dit(files.children());
263 for (; dit.current(); ++dit) {
264 if (*dit && (*dit)->name().length()>0) {
265 m_scriptsData.append((*dit));
266 m_scriptsPop->insertItem((*dit)->name());
267 }
268 }
269
270}
271
252MainWindow::~MainWindow() { 272MainWindow::~MainWindow() {
@@ -281,2 +301,4 @@ void MainWindow::slotRecordScript() {
281 currentSession()->emulationHandler()->startRecording(); 301 currentSession()->emulationHandler()->startRecording();
302 m_saveScript->setEnabled(true);
303 m_recordScript->setEnabled(false);
282 } 304 }
@@ -286,12 +308,18 @@ void MainWindow::slotSaveScript() {
286 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 308 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
287 MimeTypes types; 309 QMap<QString, QStringList> map;
288 QStringList script; 310 QStringList text;
289 script << "text/plain"; 311 text << "text/plain";
290 script << "text/all"; 312 map.insert(tr("Script"), text );
291 script << "application/octet-stream"; 313 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
292 types.insert("Script", script);
293 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
294 if (!filename.isEmpty()) { 314 if (!filename.isEmpty()) {
295 currentSession()->emulationHandler()->script()->saveTo(filename); 315 DocLnk nf;
316 nf.setType("text/plain");
317 nf.setFile(filename);
318 nf.setName(filename);
319 FileManager fm;
320 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
296 currentSession()->emulationHandler()->clearScript(); 321 currentSession()->emulationHandler()->clearScript();
322 m_saveScript->setEnabled(false);
323 m_recordScript->setEnabled(true);
324 populateScripts();
297 } 325 }
@@ -300,15 +328,9 @@ void MainWindow::slotSaveScript() {
300 328
301void MainWindow::slotRunScript() { 329void MainWindow::slotRunScript(int id) {
302 if (currentSession()) { 330 if (currentSession()) {
303 MimeTypes types; 331 DocLnk *lnk = m_scriptsData.at(m_scriptsPop->indexOf(id));
304 QStringList script; 332 QString filePath = lnk->file();
305 script << "text/plain"; 333 printf("path is : %s\n", filePath.latin1());
306 script << "text/all"; 334 Script script(filePath);
307 script << "application/octet-stream"; 335 currentSession()->emulationHandler()->runScript(&script);
308 types.insert("Script", script);
309 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
310 if (!filename.isEmpty()) {
311 Script script(DocLnk(filename).file());
312 currentSession()->emulationHandler()->runScript(&script);
313 }
314 } 336 }
@@ -327,4 +349,3 @@ void MainWindow::slotConnect() {
327 m_recordScript->setEnabled( true ); 349 m_recordScript->setEnabled( true );
328 m_saveScript->setEnabled( true ); 350 m_scripts->setItemEnabled(m_runScript_id, true);
329 m_runScript->setEnabled( true );
330 } 351 }
@@ -341,3 +362,3 @@ void MainWindow::slotDisconnect() {
341 m_saveScript->setEnabled( false ); 362 m_saveScript->setEnabled( false );
342 m_runScript->setEnabled( false ); 363 m_scripts->setItemEnabled(m_runScript_id, false);
343 } 364 }
@@ -392,3 +413,3 @@ void MainWindow::slotClose() {
392 m_saveScript->setEnabled( false ); 413 m_saveScript->setEnabled( false );
393 m_runScript->setEnabled( false ); 414 m_scripts->setItemEnabled(m_runScript_id, false);
394 m_fullscreen->setEnabled( false ); 415 m_fullscreen->setEnabled( false );
@@ -435,3 +456,3 @@ void MainWindow::create( const Profile& prof ) {
435 m_saveScript->setEnabled( false ); 456 m_saveScript->setEnabled( false );
436 m_runScript->setEnabled( false ); 457 m_scripts->setItemEnabled(m_runScript_id, false);
437 458
@@ -489,5 +510,5 @@ void MainWindow::slotSessionChanged( Session* ses ) {
489 m_disconnect->setEnabled( true ); 510 m_disconnect->setEnabled( true );
490 m_recordScript->setEnabled( true ); 511 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
491 m_saveScript->setEnabled( true ); 512 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
492 m_runScript->setEnabled( true ); 513 m_scripts->setItemEnabled(m_runScript_id, true);
493 } else { 514 } else {
@@ -497,3 +518,3 @@ void MainWindow::slotSessionChanged( Session* ses ) {
497 m_saveScript->setEnabled( false ); 518 m_saveScript->setEnabled( false );
498 m_runScript->setEnabled( false ); 519 m_scripts->setItemEnabled(m_runScript_id, false);
499 } 520 }
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h
index 19d3a3d..3b16f0a 100644
--- a/noncore/apps/opie-console/mainwindow.h
+++ b/noncore/apps/opie-console/mainwindow.h
@@ -23,3 +23,3 @@ class FunctionKeyboard;
23class FKey; 23class FKey;
24 24class DocLnk;
25 25
@@ -67,3 +67,3 @@ private slots:
67 void slotSaveScript(); 67 void slotSaveScript();
68 void slotRunScript(); 68 void slotRunScript(int);
69 void slotFullscreen(); 69 void slotFullscreen();
@@ -82,2 +82,3 @@ private:
82 void populateProfiles(); 82 void populateProfiles();
83 void populateScripts();
83 void create( const Profile& ); 84 void create( const Profile& );
@@ -92,2 +93,3 @@ private:
92 QList<Session> m_sessions; 93 QList<Session> m_sessions;
94 QList<DocLnk> m_scriptsData;
93 95
@@ -107,2 +109,3 @@ private:
107 QPopupMenu* m_sessionsPop; 109 QPopupMenu* m_sessionsPop;
110 QPopupMenu* m_scriptsPop;
108 QPopupMenu* m_scripts; 111 QPopupMenu* m_scripts;
@@ -117,3 +120,2 @@ private:
117 QAction* m_saveScript; 120 QAction* m_saveScript;
118 QAction* m_runScript;
119 QAction* m_fullscreen; 121 QAction* m_fullscreen;
@@ -122,2 +124,3 @@ private:
122 FunctionKeyboard *m_kb; 124 FunctionKeyboard *m_kb;
125 int m_runScript_id;
123 bool m_isFullscreen; 126 bool m_isFullscreen;