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 | |||
@@ -2,24 +2,25 @@ | |||
2 | #include <qaction.h> | 2 | #include <qaction.h> |
3 | #include <qmenubar.h> | 3 | #include <qmenubar.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
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" |
12 | #include "default.h" | 12 | #include "default.h" |
13 | #include "metafactory.h" | 13 | #include "metafactory.h" |
14 | #include "profile.h" | 14 | #include "profile.h" |
15 | #include "profilemanager.h" | 15 | #include "profilemanager.h" |
16 | #include "mainwindow.h" | 16 | #include "mainwindow.h" |
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(); |
23 | Default def(m_factory); | 24 | Default def(m_factory); |
24 | m_sessions.setAutoDelete( TRUE ); | 25 | m_sessions.setAutoDelete( TRUE ); |
25 | m_curSession = 0; | 26 | m_curSession = 0; |
@@ -35,12 +36,13 @@ void MainWindow::initUI() { | |||
35 | /* tool bar for the menu */ | 36 | /* tool bar for the menu */ |
36 | m_tool = new QToolBar( this ); | 37 | m_tool = new QToolBar( this ); |
37 | m_tool->setHorizontalStretchable( TRUE ); | 38 | m_tool->setHorizontalStretchable( TRUE ); |
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 | ||
44 | /* add a toolbar for icons */ | 46 | /* add a toolbar for icons */ |
45 | m_icons = new QToolBar(this); | 47 | m_icons = new QToolBar(this); |
46 | 48 | ||
@@ -103,12 +105,27 @@ void MainWindow::initUI() { | |||
103 | m_setProfiles->addTo( m_settings ); | 105 | m_setProfiles->addTo( m_settings ); |
104 | m_setProfiles->addTo( m_icons ); | 106 | m_setProfiles->addTo( m_icons ); |
105 | connect( m_setProfiles, SIGNAL(activated() ), | 107 | connect( m_setProfiles, SIGNAL(activated() ), |
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..."), |
112 | Resource::loadPixmap( "down" ), | 129 | Resource::loadPixmap( "down" ), |
113 | QString::null, 0, this, 0); | 130 | QString::null, 0, this, 0); |
114 | 131 | ||
@@ -123,12 +140,15 @@ void MainWindow::initUI() { | |||
123 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 140 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
124 | -1, 0); | 141 | -1, 0); |
125 | 142 | ||
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 | ||
132 | /* and the keyboard */ | 152 | /* and the keyboard */ |
133 | m_keyBar = new QToolBar(this); | 153 | m_keyBar = new QToolBar(this); |
134 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 154 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
@@ -186,12 +206,46 @@ void MainWindow::slotNew() { | |||
186 | 206 | ||
187 | if ( ret == QDialog::Accepted ) { | 207 | if ( ret == QDialog::Accepted ) { |
188 | create( dlg.profile() ); | 208 | create( dlg.profile() ); |
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(); |
195 | } | 249 | } |
196 | 250 | ||
197 | void MainWindow::slotDisconnect() { | 251 | void MainWindow::slotDisconnect() { |