author | wazlaf <wazlaf> | 2002-10-13 13:49:11 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-10-13 13:49:11 (UTC) |
commit | 68c37a3412ef4609ba0209318ef2b06f7dd1aaf1 (patch) (unidiff) | |
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 | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qtoolbar.h> | 6 | #include <qtoolbar.h> |
7 | #include <qpe/resource.h> | 7 | #include <qpe/resource.h> |
8 | 8 | #include <opie/ofiledialog.h> | |
9 | 9 | ||
10 | #include "profileeditordialog.h" | 10 | #include "profileeditordialog.h" |
11 | #include "configdialog.h" | 11 | #include "configdialog.h" |
@@ -17,6 +17,7 @@ | |||
17 | #include "tabwidget.h" | 17 | #include "tabwidget.h" |
18 | #include "transferdialog.h" | 18 | #include "transferdialog.h" |
19 | #include "function_keyboard.h" | 19 | #include "function_keyboard.h" |
20 | #include "script.h" | ||
20 | 21 | ||
21 | MainWindow::MainWindow() { | 22 | MainWindow::MainWindow() { |
22 | m_factory = new MetaFactory(); | 23 | m_factory = new MetaFactory(); |
@@ -38,6 +39,7 @@ void MainWindow::initUI() { | |||
38 | 39 | ||
39 | m_bar = new QMenuBar( m_tool ); | 40 | m_bar = new QMenuBar( m_tool ); |
40 | m_console = new QPopupMenu( this ); | 41 | m_console = new QPopupMenu( this ); |
42 | m_scripts = new QPopupMenu( this ); | ||
41 | m_sessionsPop= new QPopupMenu( this ); | 43 | m_sessionsPop= new QPopupMenu( this ); |
42 | m_settings = new QPopupMenu( this ); | 44 | m_settings = new QPopupMenu( this ); |
43 | 45 | ||
@@ -106,6 +108,21 @@ void MainWindow::initUI() { | |||
106 | this, SLOT(slotConfigure() ) ); | 108 | this, SLOT(slotConfigure() ) ); |
107 | 109 | ||
108 | /* | 110 | /* |
111 | * script actions | ||
112 | */ | ||
113 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | ||
114 | m_recordScript->addTo(m_scripts); | ||
115 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | ||
116 | |||
117 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | ||
118 | m_saveScript->addTo(m_scripts); | ||
119 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | ||
120 | |||
121 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); | ||
122 | m_runScript->addTo(m_scripts); | ||
123 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); | ||
124 | |||
125 | /* | ||
109 | * action that open/closes the keyboard | 126 | * action that open/closes the keyboard |
110 | */ | 127 | */ |
111 | m_openKeys = new QAction (tr("Open Keyboard..."), | 128 | m_openKeys = new QAction (tr("Open Keyboard..."), |
@@ -126,6 +143,9 @@ void MainWindow::initUI() { | |||
126 | /* insert the connection menu */ | 143 | /* insert the connection menu */ |
127 | m_bar->insertItem( tr("Connection"), m_console ); | 144 | m_bar->insertItem( tr("Connection"), m_console ); |
128 | 145 | ||
146 | /* the scripts menu */ | ||
147 | m_bar->insertItem( tr("Scripts"), m_scripts ); | ||
148 | |||
129 | /* the settings menu */ | 149 | /* the settings menu */ |
130 | m_bar->insertItem( tr("Settings"), m_settings ); | 150 | m_bar->insertItem( tr("Settings"), m_settings ); |
131 | 151 | ||
@@ -189,6 +209,40 @@ void MainWindow::slotNew() { | |||
189 | } | 209 | } |
190 | } | 210 | } |
191 | 211 | ||
212 | void MainWindow::slotRecordScript() { | ||
213 | if (currentSession()) { | ||
214 | currentSession()->emulationLayer()->startRecording(); | ||
215 | } | ||
216 | } | ||
217 | |||
218 | void MainWindow::slotSaveScript() { | ||
219 | if (currentSession() && currentSession()->emulationLayer()->isRecording()) { | ||
220 | MimeTypes types; | ||
221 | QStringList script; | ||
222 | script << "text/plain"; | ||
223 | types.insert("Script", script); | ||
224 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); | ||
225 | if (!filename.isEmpty()) { | ||
226 | currentSession()->emulationLayer()->script()->saveTo(filename); | ||
227 | currentSession()->emulationLayer()->clearScript(); | ||
228 | } | ||
229 | } | ||
230 | } | ||
231 | |||
232 | void MainWindow::slotRunScript() { | ||
233 | if (currentSession()) { | ||
234 | MimeTypes types; | ||
235 | QStringList script; | ||
236 | script << "text/plain"; | ||
237 | types.insert("Script", script); | ||
238 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); | ||
239 | if (!filename.isEmpty()) { | ||
240 | Script script(DocLnk(filename).file()); | ||
241 | currentSession()->emulationLayer()->runScript(&script); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | |||
192 | void MainWindow::slotConnect() { | 246 | void MainWindow::slotConnect() { |
193 | if ( currentSession() ) | 247 | if ( currentSession() ) |
194 | currentSession()->layer()->open(); | 248 | currentSession()->layer()->open(); |