author | hash <hash> | 2002-10-24 08:17:22 (UTC) |
---|---|---|
committer | hash <hash> | 2002-10-24 08:17:22 (UTC) |
commit | 4e8f0ba4a0c43d3dc4f3c4f89f2d796c3f8e5990 (patch) (unidiff) | |
tree | f7c83378e657bcbae6ae505d25214bdac405641a | |
parent | 541035d4308ca1931d5068ced83b0cb5350b0766 (diff) | |
download | opie-4e8f0ba4a0c43d3dc4f3c4f89f2d796c3f8e5990.zip opie-4e8f0ba4a0c43d3dc4f3c4f89f2d796c3f8e5990.tar.gz opie-4e8f0ba4a0c43d3dc4f3c4f89f2d796c3f8e5990.tar.bz2 |
commented out the other button bar.
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 8e529a3..e2f4d12 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,540 +1,541 @@ | |||
1 | #include <assert.h> | 1 | #include <assert.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qmenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qtoolbar.h> | 7 | #include <qtoolbar.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
11 | 11 | ||
12 | #include <qpe/resource.h> | 12 | #include <qpe/resource.h> |
13 | 13 | ||
14 | #include <opie/ofiledialog.h> | 14 | #include <opie/ofiledialog.h> |
15 | 15 | ||
16 | #include "keytrans.h" | 16 | #include "keytrans.h" |
17 | #include "profileeditordialog.h" | 17 | #include "profileeditordialog.h" |
18 | #include "configdialog.h" | 18 | #include "configdialog.h" |
19 | #include "default.h" | 19 | #include "default.h" |
20 | #include "metafactory.h" | 20 | #include "metafactory.h" |
21 | #include "profile.h" | 21 | #include "profile.h" |
22 | #include "profilemanager.h" | 22 | #include "profilemanager.h" |
23 | #include "mainwindow.h" | 23 | #include "mainwindow.h" |
24 | #include "tabwidget.h" | 24 | #include "tabwidget.h" |
25 | #include "transferdialog.h" | 25 | #include "transferdialog.h" |
26 | #include "function_keyboard.h" | 26 | #include "function_keyboard.h" |
27 | #include "emulation_handler.h" | 27 | #include "emulation_handler.h" |
28 | #include "script.h" | 28 | #include "script.h" |
29 | #include "quick_button.h" | 29 | #include "quick_button.h" |
30 | 30 | ||
31 | 31 | ||
32 | 32 | ||
33 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 33 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
34 | KeyTrans::loadAll(); | 34 | KeyTrans::loadAll(); |
35 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 35 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
36 | KeyTrans* s = KeyTrans::find(i ); | 36 | KeyTrans* s = KeyTrans::find(i ); |
37 | assert( s ); | 37 | assert( s ); |
38 | } | 38 | } |
39 | m_factory = new MetaFactory(); | 39 | m_factory = new MetaFactory(); |
40 | Default def(m_factory); | 40 | Default def(m_factory); |
41 | m_sessions.setAutoDelete( TRUE ); | 41 | m_sessions.setAutoDelete( TRUE ); |
42 | m_curSession = 0; | 42 | m_curSession = 0; |
43 | m_manager = new ProfileManager( m_factory ); | 43 | m_manager = new ProfileManager( m_factory ); |
44 | m_manager->load(); | 44 | m_manager->load(); |
45 | 45 | ||
46 | initUI(); | 46 | initUI(); |
47 | populateProfiles(); | 47 | populateProfiles(); |
48 | } | 48 | } |
49 | void MainWindow::initUI() { | 49 | void MainWindow::initUI() { |
50 | setToolBarsMovable( FALSE ); | 50 | setToolBarsMovable( FALSE ); |
51 | 51 | ||
52 | /* tool bar for the menu */ | 52 | /* tool bar for the menu */ |
53 | m_tool = new QToolBar( this ); | 53 | m_tool = new QToolBar( this ); |
54 | m_tool->setHorizontalStretchable( TRUE ); | 54 | m_tool->setHorizontalStretchable( TRUE ); |
55 | 55 | ||
56 | m_bar = new QMenuBar( m_tool ); | 56 | m_bar = new QMenuBar( m_tool ); |
57 | m_console = new QPopupMenu( this ); | 57 | m_console = new QPopupMenu( this ); |
58 | m_scripts = new QPopupMenu( this ); | 58 | m_scripts = new QPopupMenu( this ); |
59 | m_sessionsPop= new QPopupMenu( this ); | 59 | m_sessionsPop= new QPopupMenu( this ); |
60 | //m_settings = new QPopupMenu( this ); | 60 | //m_settings = new QPopupMenu( this ); |
61 | 61 | ||
62 | /* add a toolbar for icons */ | 62 | /* add a toolbar for icons */ |
63 | m_icons = new QToolBar(this); | 63 | m_icons = new QToolBar(this); |
64 | 64 | ||
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | /* | 68 | /* |
69 | * the settings action | 69 | * the settings action |
70 | */ | 70 | */ |
71 | m_setProfiles = new QAction(tr("Configure Profiles"), | 71 | m_setProfiles = new QAction(tr("Configure Profiles"), |
72 | Resource::loadPixmap( "SettingsIcon" ), | 72 | Resource::loadPixmap( "SettingsIcon" ), |
73 | QString::null, 0, this, 0); | 73 | QString::null, 0, this, 0); |
74 | // m_setProfiles->addTo( m_settings ); | 74 | // m_setProfiles->addTo( m_settings ); |
75 | m_setProfiles->addTo( m_icons ); | 75 | m_setProfiles->addTo( m_icons ); |
76 | m_setProfiles->addTo( m_console ); | 76 | m_setProfiles->addTo( m_console ); |
77 | connect( m_setProfiles, SIGNAL(activated() ), | 77 | connect( m_setProfiles, SIGNAL(activated() ), |
78 | this, SLOT(slotConfigure() ) ); | 78 | this, SLOT(slotConfigure() ) ); |
79 | 79 | ||
80 | m_console->insertSeparator(); | 80 | m_console->insertSeparator(); |
81 | /* | 81 | /* |
82 | * new Action for new sessions | 82 | * new Action for new sessions |
83 | */ | 83 | */ |
84 | QAction* a = new QAction(tr("New Connection"), | 84 | QAction* a = new QAction(tr("New Connection"), |
85 | Resource::loadPixmap( "new" ), | 85 | Resource::loadPixmap( "new" ), |
86 | QString::null, 0, this, 0); | 86 | QString::null, 0, this, 0); |
87 | a->addTo( m_console ); | 87 | a->addTo( m_console ); |
88 | a->addTo( m_icons ); | 88 | a->addTo( m_icons ); |
89 | connect(a, SIGNAL(activated() ), | 89 | connect(a, SIGNAL(activated() ), |
90 | this, SLOT(slotNew() ) ); | 90 | this, SLOT(slotNew() ) ); |
91 | 91 | ||
92 | /* | 92 | /* |
93 | * connect action | 93 | * connect action |
94 | */ | 94 | */ |
95 | m_connect = new QAction(); | 95 | m_connect = new QAction(); |
96 | m_connect->setText( tr("Connect") ); | 96 | m_connect->setText( tr("Connect") ); |
97 | m_connect->addTo( m_console ); | 97 | m_connect->addTo( m_console ); |
98 | connect(m_connect, SIGNAL(activated() ), | 98 | connect(m_connect, SIGNAL(activated() ), |
99 | this, SLOT(slotConnect() ) ); | 99 | this, SLOT(slotConnect() ) ); |
100 | 100 | ||
101 | /* | 101 | /* |
102 | * disconnect action | 102 | * disconnect action |
103 | */ | 103 | */ |
104 | m_disconnect = new QAction(); | 104 | m_disconnect = new QAction(); |
105 | m_disconnect->setText( tr("Disconnect") ); | 105 | m_disconnect->setText( tr("Disconnect") ); |
106 | m_disconnect->addTo( m_console ); | 106 | m_disconnect->addTo( m_console ); |
107 | connect(m_disconnect, SIGNAL(activated() ), | 107 | connect(m_disconnect, SIGNAL(activated() ), |
108 | this, SLOT(slotDisconnect() ) ); | 108 | this, SLOT(slotDisconnect() ) ); |
109 | 109 | ||
110 | m_console->insertSeparator(); | 110 | m_console->insertSeparator(); |
111 | 111 | ||
112 | m_transfer = new QAction(); | 112 | m_transfer = new QAction(); |
113 | m_transfer->setText( tr("Transfer file...") ); | 113 | m_transfer->setText( tr("Transfer file...") ); |
114 | m_transfer->addTo( m_console ); | 114 | m_transfer->addTo( m_console ); |
115 | connect(m_transfer, SIGNAL(activated() ), | 115 | connect(m_transfer, SIGNAL(activated() ), |
116 | this, SLOT(slotTransfer() ) ); | 116 | this, SLOT(slotTransfer() ) ); |
117 | 117 | ||
118 | 118 | ||
119 | /* | 119 | /* |
120 | * fullscreen | 120 | * fullscreen |
121 | */ | 121 | */ |
122 | m_isFullscreen = false; | 122 | m_isFullscreen = false; |
123 | 123 | ||
124 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 124 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
125 | , QString::null, 0, this, 0); | 125 | , QString::null, 0, this, 0); |
126 | m_fullscreen->addTo( m_console ); | 126 | m_fullscreen->addTo( m_console ); |
127 | m_fullscreen->addTo( m_icons ); | 127 | m_fullscreen->addTo( m_icons ); |
128 | connect( m_fullscreen, SIGNAL( activated() ), | 128 | connect( m_fullscreen, SIGNAL( activated() ), |
129 | this, SLOT( slotFullscreen() ) ); | 129 | this, SLOT( slotFullscreen() ) ); |
130 | 130 | ||
131 | m_console->insertSeparator(); | 131 | m_console->insertSeparator(); |
132 | /* | 132 | /* |
133 | * terminate action | 133 | * terminate action |
134 | */ | 134 | */ |
135 | m_terminate = new QAction(); | 135 | m_terminate = new QAction(); |
136 | m_terminate->setText( tr("Terminate") ); | 136 | m_terminate->setText( tr("Terminate") ); |
137 | m_terminate->addTo( m_console ); | 137 | m_terminate->addTo( m_console ); |
138 | connect(m_terminate, SIGNAL(activated() ), | 138 | connect(m_terminate, SIGNAL(activated() ), |
139 | this, SLOT(slotTerminate() ) ); | 139 | this, SLOT(slotTerminate() ) ); |
140 | 140 | ||
141 | m_closewindow = new QAction(); | 141 | m_closewindow = new QAction(); |
142 | m_closewindow->setText( tr("Close Window") ); | 142 | m_closewindow->setText( tr("Close Window") ); |
143 | m_closewindow->addTo( m_console ); | 143 | m_closewindow->addTo( m_console ); |
144 | connect( m_closewindow, SIGNAL(activated() ), | 144 | connect( m_closewindow, SIGNAL(activated() ), |
145 | this, SLOT(slotClose() ) ); | 145 | this, SLOT(slotClose() ) ); |
146 | 146 | ||
147 | 147 | ||
148 | /* | 148 | /* |
149 | * script actions | 149 | * script actions |
150 | */ | 150 | */ |
151 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 151 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
152 | m_recordScript->addTo(m_scripts); | 152 | m_recordScript->addTo(m_scripts); |
153 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 153 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
154 | 154 | ||
155 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 155 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
156 | m_saveScript->addTo(m_scripts); | 156 | m_saveScript->addTo(m_scripts); |
157 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 157 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
158 | 158 | ||
159 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); | 159 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); |
160 | m_runScript->addTo(m_scripts); | 160 | m_runScript->addTo(m_scripts); |
161 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); | 161 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); |
162 | 162 | ||
163 | /* | 163 | /* |
164 | * action that open/closes the keyboard | 164 | * action that open/closes the keyboard |
165 | */ | 165 | */ |
166 | m_openKeys = new QAction (tr("Open Keyboard..."), | 166 | m_openKeys = new QAction (tr("Open Keyboard..."), |
167 | Resource::loadPixmap( "console/keyboard_icon.png" ), | 167 | Resource::loadPixmap( "down" ), |
168 | QString::null, 0, this, 0); | 168 | QString::null, 0, this, 0); |
169 | 169 | ||
170 | m_openKeys->setToggleAction(true); | 170 | m_openKeys->setToggleAction(true); |
171 | 171 | ||
172 | connect (m_openKeys, SIGNAL(toggled(bool)), | 172 | connect (m_openKeys, SIGNAL(toggled(bool)), |
173 | this, SLOT(slotOpenKeb(bool))); | 173 | this, SLOT(slotOpenKeb(bool))); |
174 | m_openKeys->addTo(m_icons); | 174 | m_openKeys->addTo(m_icons); |
175 | 175 | ||
176 | 176 | ||
177 | /* | 177 | /* |
178 | * action that open/closes the keyboard | 178 | * action that open/closes the keyboard |
179 | */ | 179 | |
180 | m_openButtons = new QAction ( tr( "Open Buttons..." ), | 180 | m_openButtons = new QAction ( tr( "Open Buttons..." ), |
181 | Resource::loadPixmap( "down" ), | 181 | Resource::loadPixmap( "" ), |
182 | QString::null, 0, this, 0 ); | 182 | QString::null, 0, this, 0 ); |
183 | 183 | ||
184 | m_openButtons->setToggleAction( true ); | 184 | m_openButtons->setToggleAction( true ); |
185 | 185 | ||
186 | connect ( m_openButtons, SIGNAL( toggled( bool ) ), | 186 | connect ( m_openButtons, SIGNAL( toggled( bool ) ), |
187 | this, SLOT( slotOpenButtons( bool ) ) ); | 187 | this, SLOT( slotOpenButtons( bool ) ) ); |
188 | m_openButtons->addTo( m_icons ); | 188 | m_openButtons->addTo( m_icons ); |
189 | 189 | ||
190 | */ | ||
190 | 191 | ||
191 | /* insert the submenu */ | 192 | /* insert the submenu */ |
192 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 193 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
193 | -1, 0); | 194 | -1, 0); |
194 | 195 | ||
195 | /* insert the connection menu */ | 196 | /* insert the connection menu */ |
196 | m_bar->insertItem( tr("Connection"), m_console ); | 197 | m_bar->insertItem( tr("Connection"), m_console ); |
197 | 198 | ||
198 | /* the scripts menu */ | 199 | /* the scripts menu */ |
199 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 200 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
200 | 201 | ||
201 | /* the settings menu */ | 202 | /* the settings menu */ |
202 | // m_bar->insertItem( tr("Settings"), m_settings ); | 203 | // m_bar->insertItem( tr("Settings"), m_settings ); |
203 | 204 | ||
204 | /* and the keyboard */ | 205 | /* and the keyboard */ |
205 | m_keyBar = new QToolBar(this); | 206 | m_keyBar = new QToolBar(this); |
206 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 207 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
207 | m_keyBar->setHorizontalStretchable( TRUE ); | 208 | m_keyBar->setHorizontalStretchable( TRUE ); |
208 | m_keyBar->hide(); | 209 | m_keyBar->hide(); |
209 | 210 | ||
210 | m_kb = new FunctionKeyboard(m_keyBar); | 211 | m_kb = new FunctionKeyboard(m_keyBar); |
211 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 212 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
212 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); | 213 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
213 | 214 | ||
214 | m_buttonBar = new QToolBar( this ); | 215 | m_buttonBar = new QToolBar( this ); |
215 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); | 216 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); |
216 | m_buttonBar->setHorizontalStretchable( TRUE ); | 217 | m_buttonBar->setHorizontalStretchable( TRUE ); |
217 | m_buttonBar->hide(); | 218 | m_buttonBar->hide(); |
218 | 219 | ||
219 | /* | 220 | /* |
220 | m_qb = new QuickButton( m_buttonBar ); | 221 | m_qb = new QuickButton( m_buttonBar ); |
221 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), | 222 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), |
222 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); | 223 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); |
223 | */ | 224 | */ |
224 | 225 | ||
225 | 226 | ||
226 | m_connect->setEnabled( false ); | 227 | m_connect->setEnabled( false ); |
227 | m_disconnect->setEnabled( false ); | 228 | m_disconnect->setEnabled( false ); |
228 | m_terminate->setEnabled( false ); | 229 | m_terminate->setEnabled( false ); |
229 | m_transfer->setEnabled( false ); | 230 | m_transfer->setEnabled( false ); |
230 | m_recordScript->setEnabled( false ); | 231 | m_recordScript->setEnabled( false ); |
231 | m_saveScript->setEnabled( false ); | 232 | m_saveScript->setEnabled( false ); |
232 | m_runScript->setEnabled( false ); | 233 | m_runScript->setEnabled( false ); |
233 | m_fullscreen->setEnabled( false ); | 234 | m_fullscreen->setEnabled( false ); |
234 | m_closewindow->setEnabled( false ); | 235 | m_closewindow->setEnabled( false ); |
235 | 236 | ||
236 | /* | 237 | /* |
237 | * connect to the menu activation | 238 | * connect to the menu activation |
238 | */ | 239 | */ |
239 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 240 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
240 | this, SLOT(slotProfile( int ) ) ); | 241 | this, SLOT(slotProfile( int ) ) ); |
241 | 242 | ||
242 | m_consoleWindow = new TabWidget( this, "blah"); | 243 | m_consoleWindow = new TabWidget( this, "blah"); |
243 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 244 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
244 | this, SLOT(slotSessionChanged(Session*) ) ); | 245 | this, SLOT(slotSessionChanged(Session*) ) ); |
245 | setCentralWidget( m_consoleWindow ); | 246 | setCentralWidget( m_consoleWindow ); |
246 | 247 | ||
247 | } | 248 | } |
248 | 249 | ||
249 | ProfileManager* MainWindow::manager() { | 250 | ProfileManager* MainWindow::manager() { |
250 | return m_manager; | 251 | return m_manager; |
251 | } | 252 | } |
252 | TabWidget* MainWindow::tabWidget() { | 253 | TabWidget* MainWindow::tabWidget() { |
253 | return m_consoleWindow; | 254 | return m_consoleWindow; |
254 | } | 255 | } |
255 | void MainWindow::populateProfiles() { | 256 | void MainWindow::populateProfiles() { |
256 | m_sessionsPop->clear(); | 257 | m_sessionsPop->clear(); |
257 | Profile::ValueList list = manager()->all(); | 258 | Profile::ValueList list = manager()->all(); |
258 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 259 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
259 | m_sessionsPop->insertItem( (*it).name() ); | 260 | m_sessionsPop->insertItem( (*it).name() ); |
260 | } | 261 | } |
261 | 262 | ||
262 | } | 263 | } |
263 | MainWindow::~MainWindow() { | 264 | MainWindow::~MainWindow() { |
264 | delete m_factory; | 265 | delete m_factory; |
265 | manager()->save(); | 266 | manager()->save(); |
266 | } | 267 | } |
267 | 268 | ||
268 | MetaFactory* MainWindow::factory() { | 269 | MetaFactory* MainWindow::factory() { |
269 | return m_factory; | 270 | return m_factory; |
270 | } | 271 | } |
271 | 272 | ||
272 | Session* MainWindow::currentSession() { | 273 | Session* MainWindow::currentSession() { |
273 | return m_curSession; | 274 | return m_curSession; |
274 | } | 275 | } |
275 | 276 | ||
276 | QList<Session> MainWindow::sessions() { | 277 | QList<Session> MainWindow::sessions() { |
277 | return m_sessions; | 278 | return m_sessions; |
278 | } | 279 | } |
279 | 280 | ||
280 | void MainWindow::slotNew() { | 281 | void MainWindow::slotNew() { |
281 | ProfileEditorDialog dlg(factory() ); | 282 | ProfileEditorDialog dlg(factory() ); |
282 | dlg.showMaximized(); | 283 | dlg.showMaximized(); |
283 | int ret = dlg.exec(); | 284 | int ret = dlg.exec(); |
284 | 285 | ||
285 | if ( ret == QDialog::Accepted ) { | 286 | if ( ret == QDialog::Accepted ) { |
286 | create( dlg.profile() ); | 287 | create( dlg.profile() ); |
287 | } | 288 | } |
288 | } | 289 | } |
289 | 290 | ||
290 | void MainWindow::slotRecordScript() { | 291 | void MainWindow::slotRecordScript() { |
291 | if (currentSession()) { | 292 | if (currentSession()) { |
292 | currentSession()->emulationHandler()->startRecording(); | 293 | currentSession()->emulationHandler()->startRecording(); |
293 | } | 294 | } |
294 | } | 295 | } |
295 | 296 | ||
296 | void MainWindow::slotSaveScript() { | 297 | void MainWindow::slotSaveScript() { |
297 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 298 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
298 | MimeTypes types; | 299 | MimeTypes types; |
299 | QStringList script; | 300 | QStringList script; |
300 | script << "text/plain"; | 301 | script << "text/plain"; |
301 | script << "text/all"; | 302 | script << "text/all"; |
302 | script << "application/octet-stream"; | 303 | script << "application/octet-stream"; |
303 | types.insert("Script", script); | 304 | types.insert("Script", script); |
304 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); | 305 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); |
305 | if (!filename.isEmpty()) { | 306 | if (!filename.isEmpty()) { |
306 | currentSession()->emulationHandler()->script()->saveTo(filename); | 307 | currentSession()->emulationHandler()->script()->saveTo(filename); |
307 | currentSession()->emulationHandler()->clearScript(); | 308 | currentSession()->emulationHandler()->clearScript(); |
308 | } | 309 | } |
309 | } | 310 | } |
310 | } | 311 | } |
311 | 312 | ||
312 | void MainWindow::slotRunScript() { | 313 | void MainWindow::slotRunScript() { |
313 | if (currentSession()) { | 314 | if (currentSession()) { |
314 | MimeTypes types; | 315 | MimeTypes types; |
315 | QStringList script; | 316 | QStringList script; |
316 | script << "text/plain"; | 317 | script << "text/plain"; |
317 | script << "text/all"; | 318 | script << "text/all"; |
318 | script << "application/octet-stream"; | 319 | script << "application/octet-stream"; |
319 | types.insert("Script", script); | 320 | types.insert("Script", script); |
320 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); | 321 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); |
321 | if (!filename.isEmpty()) { | 322 | if (!filename.isEmpty()) { |
322 | Script script(DocLnk(filename).file()); | 323 | Script script(DocLnk(filename).file()); |
323 | currentSession()->emulationHandler()->runScript(&script); | 324 | currentSession()->emulationHandler()->runScript(&script); |
324 | } | 325 | } |
325 | } | 326 | } |
326 | } | 327 | } |
327 | 328 | ||
328 | void MainWindow::slotConnect() { | 329 | void MainWindow::slotConnect() { |
329 | if ( currentSession() ) { | 330 | if ( currentSession() ) { |
330 | bool ret = currentSession()->layer()->open(); | 331 | bool ret = currentSession()->layer()->open(); |
331 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 332 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
332 | QObject::tr("Failed"), | 333 | QObject::tr("Failed"), |
333 | QObject::tr("Connecting failed for this session.")); | 334 | QObject::tr("Connecting failed for this session.")); |
334 | else { | 335 | else { |
335 | m_connect->setEnabled( false ); | 336 | m_connect->setEnabled( false ); |
336 | m_disconnect->setEnabled( true ); | 337 | m_disconnect->setEnabled( true ); |
337 | } | 338 | } |
338 | } | 339 | } |
339 | } | 340 | } |
340 | 341 | ||
341 | void MainWindow::slotDisconnect() { | 342 | void MainWindow::slotDisconnect() { |
342 | if ( currentSession() ) { | 343 | if ( currentSession() ) { |
343 | currentSession()->layer()->close(); | 344 | currentSession()->layer()->close(); |
344 | m_connect->setEnabled( true ); | 345 | m_connect->setEnabled( true ); |
345 | m_disconnect->setEnabled( false ); | 346 | m_disconnect->setEnabled( false ); |
346 | } | 347 | } |
347 | } | 348 | } |
348 | 349 | ||
349 | void MainWindow::slotTerminate() { | 350 | void MainWindow::slotTerminate() { |
350 | if ( currentSession() ) | 351 | if ( currentSession() ) |
351 | currentSession()->layer()->close(); | 352 | currentSession()->layer()->close(); |
352 | 353 | ||
353 | slotClose(); | 354 | slotClose(); |
354 | /* FIXME move to the next session */ | 355 | /* FIXME move to the next session */ |
355 | } | 356 | } |
356 | 357 | ||
357 | void MainWindow::slotConfigure() { | 358 | void MainWindow::slotConfigure() { |
358 | ConfigDialog conf( manager()->all(), factory() ); | 359 | ConfigDialog conf( manager()->all(), factory() ); |
359 | conf.showMaximized(); | 360 | conf.showMaximized(); |
360 | 361 | ||
361 | int ret = conf.exec(); | 362 | int ret = conf.exec(); |
362 | 363 | ||
363 | if ( QDialog::Accepted == ret ) { | 364 | if ( QDialog::Accepted == ret ) { |
364 | manager()->setProfiles( conf.list() ); | 365 | manager()->setProfiles( conf.list() ); |
365 | manager()->save(); | 366 | manager()->save(); |
366 | populateProfiles(); | 367 | populateProfiles(); |
367 | } | 368 | } |
368 | } | 369 | } |
369 | /* | 370 | /* |
370 | * we will remove | 371 | * we will remove |
371 | * this window from the tabwidget | 372 | * this window from the tabwidget |
372 | * remove it from the list | 373 | * remove it from the list |
373 | * delete it | 374 | * delete it |
374 | * and set the currentSession() | 375 | * and set the currentSession() |
375 | */ | 376 | */ |
376 | void MainWindow::slotClose() { | 377 | void MainWindow::slotClose() { |
377 | if (!currentSession() ) | 378 | if (!currentSession() ) |
378 | return; | 379 | return; |
379 | 380 | ||
380 | Session* ses = currentSession(); | 381 | Session* ses = currentSession(); |
381 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 382 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
382 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 383 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
383 | m_curSession = NULL; | 384 | m_curSession = NULL; |
384 | tabWidget()->remove( /*currentSession()*/ses ); | 385 | tabWidget()->remove( /*currentSession()*/ses ); |
385 | /*it's autodelete */ | 386 | /*it's autodelete */ |
386 | m_sessions.remove( ses ); | 387 | m_sessions.remove( ses ); |
387 | qWarning("after remove!!"); | 388 | qWarning("after remove!!"); |
388 | 389 | ||
389 | if (!currentSession() ) { | 390 | if (!currentSession() ) { |
390 | m_connect->setEnabled( false ); | 391 | m_connect->setEnabled( false ); |
391 | m_disconnect->setEnabled( false ); | 392 | m_disconnect->setEnabled( false ); |
392 | m_terminate->setEnabled( false ); | 393 | m_terminate->setEnabled( false ); |
393 | m_transfer->setEnabled( false ); | 394 | m_transfer->setEnabled( false ); |
394 | m_recordScript->setEnabled( false ); | 395 | m_recordScript->setEnabled( false ); |
395 | m_saveScript->setEnabled( false ); | 396 | m_saveScript->setEnabled( false ); |
396 | m_runScript->setEnabled( false ); | 397 | m_runScript->setEnabled( false ); |
397 | m_fullscreen->setEnabled( false ); | 398 | m_fullscreen->setEnabled( false ); |
398 | m_closewindow->setEnabled( false ); | 399 | m_closewindow->setEnabled( false ); |
399 | } | 400 | } |
400 | } | 401 | } |
401 | 402 | ||
402 | /* | 403 | /* |
403 | * We will get the name | 404 | * We will get the name |
404 | * Then the profile | 405 | * Then the profile |
405 | * and then we will make a profile | 406 | * and then we will make a profile |
406 | */ | 407 | */ |
407 | void MainWindow::slotProfile( int id) { | 408 | void MainWindow::slotProfile( int id) { |
408 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 409 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
409 | create( prof ); | 410 | create( prof ); |
410 | } | 411 | } |
411 | void MainWindow::create( const Profile& prof ) { | 412 | void MainWindow::create( const Profile& prof ) { |
412 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 413 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
413 | 414 | ||
414 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 415 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
415 | { | 416 | { |
416 | QMessageBox::warning(this, | 417 | QMessageBox::warning(this, |
417 | QObject::tr("Session failed"), | 418 | QObject::tr("Session failed"), |
418 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 419 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
419 | //if(ses) delete ses; | 420 | //if(ses) delete ses; |
420 | return; | 421 | return; |
421 | } | 422 | } |
422 | 423 | ||
423 | m_sessions.append( ses ); | 424 | m_sessions.append( ses ); |
424 | tabWidget()->add( ses ); | 425 | tabWidget()->add( ses ); |
425 | m_curSession = ses; | 426 | m_curSession = ses; |
426 | 427 | ||
427 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 428 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
428 | m_connect->setEnabled( true ); | 429 | m_connect->setEnabled( true ); |
429 | m_disconnect->setEnabled( false ); | 430 | m_disconnect->setEnabled( false ); |
430 | m_terminate->setEnabled( true ); | 431 | m_terminate->setEnabled( true ); |
431 | m_transfer->setEnabled( true ); | 432 | m_transfer->setEnabled( true ); |
432 | m_recordScript->setEnabled( true ); | 433 | m_recordScript->setEnabled( true ); |
433 | m_saveScript->setEnabled( true ); | 434 | m_saveScript->setEnabled( true ); |
434 | m_runScript->setEnabled( true ); | 435 | m_runScript->setEnabled( true ); |
435 | m_fullscreen->setEnabled( true ); | 436 | m_fullscreen->setEnabled( true ); |
436 | m_closewindow->setEnabled( true ); | 437 | m_closewindow->setEnabled( true ); |
437 | 438 | ||
438 | 439 | ||
439 | // is io_layer wants direct connection, then autoconnect | 440 | // is io_layer wants direct connection, then autoconnect |
440 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 441 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
441 | if (prof.autoConnect()) { | 442 | if (prof.autoConnect()) { |
442 | slotConnect(); | 443 | slotConnect(); |
443 | } | 444 | } |
444 | 445 | ||
445 | QWidget *w = currentSession()->widget(); | 446 | QWidget *w = currentSession()->widget(); |
446 | if(w) w->setFocus(); | 447 | if(w) w->setFocus(); |
447 | } | 448 | } |
448 | 449 | ||
449 | void MainWindow::slotTransfer() | 450 | void MainWindow::slotTransfer() |
450 | { | 451 | { |
451 | if ( currentSession() ) { | 452 | if ( currentSession() ) { |
452 | TransferDialog dlg(currentSession()->widgetStack(), this); | 453 | TransferDialog dlg(currentSession()->widgetStack(), this); |
453 | dlg.showMaximized(); | 454 | dlg.showMaximized(); |
454 | //currentSession()->widgetStack()->add(dlg); | 455 | //currentSession()->widgetStack()->add(dlg); |
455 | dlg.exec(); | 456 | dlg.exec(); |
456 | } | 457 | } |
457 | } | 458 | } |
458 | 459 | ||
459 | 460 | ||
460 | void MainWindow::slotOpenKeb(bool state) { | 461 | void MainWindow::slotOpenKeb(bool state) { |
461 | 462 | ||
462 | if (state) m_keyBar->show(); | 463 | if (state) m_keyBar->show(); |
463 | else m_keyBar->hide(); | 464 | else m_keyBar->hide(); |
464 | 465 | ||
465 | } | 466 | } |
466 | 467 | ||
467 | 468 | ||
468 | void MainWindow::slotOpenButtons( bool state ) { | 469 | void MainWindow::slotOpenButtons( bool state ) { |
469 | 470 | ||
470 | if ( state ) { | 471 | if ( state ) { |
471 | m_buttonBar->show(); | 472 | m_buttonBar->show(); |
472 | } else { | 473 | } else { |
473 | m_buttonBar->hide(); | 474 | m_buttonBar->hide(); |
474 | } | 475 | } |
475 | } | 476 | } |
476 | 477 | ||
477 | 478 | ||
478 | 479 | ||
479 | void MainWindow::slotSessionChanged( Session* ses ) { | 480 | void MainWindow::slotSessionChanged( Session* ses ) { |
480 | qWarning("changed!"); | 481 | qWarning("changed!"); |
481 | if ( ses ) { | 482 | if ( ses ) { |
482 | m_curSession = ses; | 483 | m_curSession = ses; |
483 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 484 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
484 | if ( m_curSession->layer()->isConnected() ) { | 485 | if ( m_curSession->layer()->isConnected() ) { |
485 | m_connect->setEnabled( false ); | 486 | m_connect->setEnabled( false ); |
486 | m_disconnect->setEnabled( true ); | 487 | m_disconnect->setEnabled( true ); |
487 | } else { | 488 | } else { |
488 | m_connect->setEnabled( true ); | 489 | m_connect->setEnabled( true ); |
489 | m_disconnect->setEnabled( false ); | 490 | m_disconnect->setEnabled( false ); |
490 | } | 491 | } |
491 | 492 | ||
492 | QWidget *w = m_curSession->widget(); | 493 | QWidget *w = m_curSession->widget(); |
493 | if(w) w->setFocus(); | 494 | if(w) w->setFocus(); |
494 | } | 495 | } |
495 | } | 496 | } |
496 | 497 | ||
497 | void MainWindow::slotFullscreen() { | 498 | void MainWindow::slotFullscreen() { |
498 | 499 | ||
499 | 500 | ||
500 | 501 | ||
501 | if ( m_isFullscreen ) { | 502 | if ( m_isFullscreen ) { |
502 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 503 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
503 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 504 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
504 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 505 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
505 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 506 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
506 | 507 | ||
507 | } else { | 508 | } else { |
508 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 509 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
509 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 510 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
510 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 511 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
511 | , QPoint(0,0), false ); | 512 | , QPoint(0,0), false ); |
512 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 513 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
513 | ( m_curSession->widgetStack() )->setFocus(); | 514 | ( m_curSession->widgetStack() )->setFocus(); |
514 | ( m_curSession->widgetStack() )->show(); | 515 | ( m_curSession->widgetStack() )->show(); |
515 | 516 | ||
516 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 517 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
517 | 518 | ||
518 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 519 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
519 | } | 520 | } |
520 | 521 | ||
521 | m_isFullscreen = !m_isFullscreen; | 522 | m_isFullscreen = !m_isFullscreen; |
522 | } | 523 | } |
523 | 524 | ||
524 | 525 | ||
525 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 526 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
526 | 527 | ||
527 | if ( m_curSession ) { | 528 | if ( m_curSession ) { |
528 | 529 | ||
529 | QEvent::Type state; | 530 | QEvent::Type state; |
530 | 531 | ||
531 | if (pressed) state = QEvent::KeyPress; | 532 | if (pressed) state = QEvent::KeyPress; |
532 | else state = QEvent::KeyRelease; | 533 | else state = QEvent::KeyRelease; |
533 | 534 | ||
534 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 535 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
535 | 536 | ||
536 | // where should i send this event? doesnt work sending it here | 537 | // where should i send this event? doesnt work sending it here |
537 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 538 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
538 | ke.ignore(); | 539 | ke.ignore(); |
539 | } | 540 | } |
540 | } | 541 | } |