author | wazlaf <wazlaf> | 2002-10-13 13:49:11 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-10-13 13:49:11 (UTC) |
commit | 68c37a3412ef4609ba0209318ef2b06f7dd1aaf1 (patch) (side-by-side diff) | |
tree | f81ee5460dd49c4fcb8a61bf50911c5036742bed /noncore/apps/opie-console/mainwindow.cpp | |
parent | 0e6d241e26211a8ffff07ba8e23f4a3cec9065be (diff) | |
download | opie-68c37a3412ef4609ba0209318ef2b06f7dd1aaf1.zip opie-68c37a3412ef4609ba0209318ef2b06f7dd1aaf1.tar.gz opie-68c37a3412ef4609ba0209318ef2b06f7dd1aaf1.tar.bz2 |
Scripting functionality added. What this currently does is catch keys in the emulation_layer
and store them in a "Script" instance. This can later be saved to a file and on request
"replayed" by sending the typed keys to the associated IOLayer
Diffstat (limited to 'noncore/apps/opie-console/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 8f5d56b..46c5bed 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -7,3 +7,3 @@ #include <qpe/resource.h> - +#include <opie/ofiledialog.h> @@ -19,2 +19,3 @@ #include "function_keyboard.h" +#include "script.h" @@ -40,2 +41,3 @@ void MainWindow::initUI() { m_console = new QPopupMenu( this ); + m_scripts = new QPopupMenu( this ); m_sessionsPop= new QPopupMenu( this ); @@ -108,2 +110,17 @@ void MainWindow::initUI() { /* + * script actions + */ + m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); + m_recordScript->addTo(m_scripts); + connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); + + m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); + m_saveScript->addTo(m_scripts); + connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); + + m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); + m_runScript->addTo(m_scripts); + connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); + + /* * action that open/closes the keyboard @@ -128,2 +145,5 @@ void MainWindow::initUI() { + /* the scripts menu */ + m_bar->insertItem( tr("Scripts"), m_scripts ); + /* the settings menu */ @@ -191,2 +211,36 @@ void MainWindow::slotNew() { +void MainWindow::slotRecordScript() { + if (currentSession()) { + currentSession()->emulationLayer()->startRecording(); + } +} + +void MainWindow::slotSaveScript() { + if (currentSession() && currentSession()->emulationLayer()->isRecording()) { + MimeTypes types; + QStringList script; + script << "text/plain"; + types.insert("Script", script); + QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); + if (!filename.isEmpty()) { + currentSession()->emulationLayer()->script()->saveTo(filename); + currentSession()->emulationLayer()->clearScript(); + } + } +} + +void MainWindow::slotRunScript() { + if (currentSession()) { + MimeTypes types; + QStringList script; + script << "text/plain"; + types.insert("Script", script); + QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); + if (!filename.isEmpty()) { + Script script(DocLnk(filename).file()); + currentSession()->emulationLayer()->runScript(&script); + } + } +} + void MainWindow::slotConnect() { |