summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp103
1 files changed, 100 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 2e00a07..895fa9e 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,256 +1,353 @@
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#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
14#include <qpe/filemanager.h> 14#include <qpe/filemanager.h>
15#include <qpe/mimetype.h> 15#include <qpe/mimetype.h>
16 16
17#include <opie/ofiledialog.h> 17#include <opie/ofiledialog.h>
18 18
19#include "keytrans.h" 19#include "keytrans.h"
20#include "profileeditordialog.h" 20#include "profileeditordialog.h"
21#include "configdialog.h" 21#include "configdialog.h"
22#include "default.h" 22#include "default.h"
23#include "metafactory.h" 23#include "metafactory.h"
24#include "profile.h" 24#include "profile.h"
25#include "profilemanager.h" 25#include "profilemanager.h"
26#include "mainwindow.h" 26#include "mainwindow.h"
27#include "tabwidget.h" 27#include "tabwidget.h"
28#include "transferdialog.h" 28#include "transferdialog.h"
29#include "function_keyboard.h" 29#include "function_keyboard.h"
30#include "emulation_handler.h" 30#include "emulation_handler.h"
31#include "script.h" 31#include "script.h"
32 32
33static char * filesave_xpm[] = {
34"16 16 78 1",
35" c None",
36". c #343434",
37"+ c #A0A0A0",
38"@ c #565656",
39"# c #9E9E9E",
40"$ c #525252",
41"% c #929292",
42"& c #676767",
43"* c #848484",
44"= c #666666",
45"- c #D8D8D8",
46"; c #FFFFFF",
47"> c #DBDBDB",
48", c #636363",
49"' c #989898",
50") c #2D2D2D",
51"! c #909090",
52"~ c #AEAEAE",
53"{ c #EAEAEA",
54"] c #575757",
55"^ c #585858",
56"/ c #8A8A8A",
57"( c #828282",
58"_ c #6F6F6F",
59": c #C9C9C9",
60"< c #050505",
61"[ c #292929",
62"} c #777777",
63"| c #616161",
64"1 c #3A3A3A",
65"2 c #BEBEBE",
66"3 c #2C2C2C",
67"4 c #7C7C7C",
68"5 c #F6F6F6",
69"6 c #FCFCFC",
70"7 c #6B6B6B",
71"8 c #959595",
72"9 c #4F4F4F",
73"0 c #808080",
74"a c #767676",
75"b c #818181",
76"c c #B8B8B8",
77"d c #FBFBFB",
78"e c #F9F9F9",
79"f c #CCCCCC",
80"g c #030303",
81"h c #737373",
82"i c #7A7A7A",
83"j c #7E7E7E",
84"k c #6A6A6A",
85"l c #FAFAFA",
86"m c #505050",
87"n c #9D9D9D",
88"o c #333333",
89"p c #7B7B7B",
90"q c #787878",
91"r c #696969",
92"s c #494949",
93"t c #555555",
94"u c #949494",
95"v c #E6E6E6",
96"w c #424242",
97"x c #515151",
98"y c #535353",
99"z c #3E3E3E",
100"A c #D4D4D4",
101"B c #0C0C0C",
102"C c #353535",
103"D c #474747",
104"E c #ECECEC",
105"F c #919191",
106"G c #7D7D7D",
107"H c #000000",
108"I c #404040",
109"J c #858585",
110"K c #323232",
111"L c #D0D0D0",
112"M c #1C1C1C",
113" ...+ ",
114" @#$%&..+ ",
115" .*=-;;>,..+ ",
116" ')!~;;;;;;{]..",
117" ^/(-;;;;;;;_:<",
118" [}|;;;;;;;{12$",
119" #34-55;;;;678$+",
120" 90ab=c;dd;e1fg ",
121" [ahij((kbl0mn$ ",
122" op^q^^7r&]s/$+ ",
123"@btu;vbwxy]zAB ",
124"CzDEvEv;;DssF$ ",
125"G.H{E{E{IxsJ$+ ",
126" +...vEKxzLM ",
127" +...z]n$ ",
128" +... "};
129
33 130
34 131
35MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 132MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
36 KeyTrans::loadAll(); 133 KeyTrans::loadAll();
37 for (int i = 0; i < KeyTrans::count(); i++ ) { 134 for (int i = 0; i < KeyTrans::count(); i++ ) {
38 KeyTrans* s = KeyTrans::find(i ); 135 KeyTrans* s = KeyTrans::find(i );
39 assert( s ); 136 assert( s );
40 } 137 }
41 m_factory = new MetaFactory(); 138 m_factory = new MetaFactory();
42 Default def(m_factory); 139 Default def(m_factory);
43 m_sessions.setAutoDelete( TRUE ); 140 m_sessions.setAutoDelete( TRUE );
44 m_curSession = 0; 141 m_curSession = 0;
45 m_manager = new ProfileManager( m_factory ); 142 m_manager = new ProfileManager( m_factory );
46 m_manager->load(); 143 m_manager->load();
47 144
48 initUI(); 145 initUI();
49 populateProfiles(); 146 populateProfiles();
50 populateScripts(); 147 populateScripts();
51} 148}
52void MainWindow::initUI() { 149void MainWindow::initUI() {
53 setToolBarsMovable( FALSE ); 150 setToolBarsMovable( FALSE );
54 151
55 /* tool bar for the menu */ 152 /* tool bar for the menu */
56 m_tool = new QToolBar( this ); 153 m_tool = new QToolBar( this );
57 m_tool->setHorizontalStretchable( TRUE ); 154 m_tool->setHorizontalStretchable( TRUE );
58 155
59 m_bar = new QMenuBar( m_tool ); 156 m_bar = new QMenuBar( m_tool );
60 m_console = new QPopupMenu( this ); 157 m_console = new QPopupMenu( this );
61 m_scripts = new QPopupMenu( this ); 158 m_scripts = new QPopupMenu( this );
62 m_sessionsPop= new QPopupMenu( this ); 159 m_sessionsPop= new QPopupMenu( this );
63 m_scriptsPop = new QPopupMenu( this ); 160 m_scriptsPop = new QPopupMenu( this );
64 161
65 /* add a toolbar for icons */ 162 /* add a toolbar for icons */
66 m_icons = new QToolBar(this); 163 m_icons = new QToolBar(this);
67 164
68 /* 165 /*
69 * the settings action 166 * the settings action
70 */ 167 */
71 m_setProfiles = new QAction(tr("Configure Profiles"), 168 m_setProfiles = new QAction(tr("Configure Profiles"),
72 Resource::loadPixmap( "SettingsIcon" ), 169 Resource::loadPixmap( "SettingsIcon" ),
73 QString::null, 0, this, 0); 170 QString::null, 0, this, 0);
74 m_setProfiles->addTo( m_console ); 171 m_setProfiles->addTo( m_console );
75 connect( m_setProfiles, SIGNAL(activated() ), 172 connect( m_setProfiles, SIGNAL(activated() ),
76 this, SLOT(slotConfigure() ) ); 173 this, SLOT(slotConfigure() ) );
77 174
78 m_console->insertSeparator(); 175 m_console->insertSeparator();
79 /* 176 /*
80 * new Action for new sessions 177 * new Action for new sessions
81 */ 178 */
82 QAction* newCon = new QAction(tr("New Connection"), 179 QAction* newCon = new QAction(tr("New Connection"),
83 Resource::loadPixmap( "new" ), 180 Resource::loadPixmap( "new" ),
84 QString::null, 0, this, 0); 181 QString::null, 0, this, 0);
85 newCon->addTo( m_console ); 182 newCon->addTo( m_console );
86 connect( newCon, SIGNAL(activated() ), 183 connect( newCon, SIGNAL(activated() ),
87 this, SLOT(slotNew() ) ); 184 this, SLOT(slotNew() ) );
88 185
89 m_console->insertSeparator(); 186 m_console->insertSeparator();
90 /* save icon is not available */ 187 /* save icon is not available */
91 188
92 QAction *saveCon = new QAction(tr("Save Connection"), 189 QAction *saveCon = new QAction(tr("Save Connection"),
93 Resource::loadPixmap("save"), QString::null, 190 QPixmap( ( const char** ) filesave_xpm ) , QString::null,
94 0, this, 0 ); 191 0, this, 0 );
95 saveCon->addTo( m_console ); 192 saveCon->addTo( m_console );
96 connect( saveCon, SIGNAL(activated() ), 193 connect( saveCon, SIGNAL(activated() ),
97 this, SLOT(slotSaveSession() ) ); 194 this, SLOT(slotSaveSession() ) );
98 m_console->insertSeparator(); 195 m_console->insertSeparator();
99 196
100 /* 197 /*
101 * connect action 198 * connect action
102 */ 199 */
103 m_connect = new QAction(); 200 m_connect = new QAction();
104 m_connect->setText( tr("Connect") ); 201 m_connect->setText( tr("Connect") );
105 m_connect->addTo( m_console ); 202 m_connect->addTo( m_console );
106 connect(m_connect, SIGNAL(activated() ), 203 connect(m_connect, SIGNAL(activated() ),
107 this, SLOT(slotConnect() ) ); 204 this, SLOT(slotConnect() ) );
108 205
109 /* 206 /*
110 * disconnect action 207 * disconnect action
111 */ 208 */
112 m_disconnect = new QAction(); 209 m_disconnect = new QAction();
113 m_disconnect->setText( tr("Disconnect") ); 210 m_disconnect->setText( tr("Disconnect") );
114 m_disconnect->addTo( m_console ); 211 m_disconnect->addTo( m_console );
115 connect(m_disconnect, SIGNAL(activated() ), 212 connect(m_disconnect, SIGNAL(activated() ),
116 this, SLOT(slotDisconnect() ) ); 213 this, SLOT(slotDisconnect() ) );
117 214
118 m_console->insertSeparator(); 215 m_console->insertSeparator();
119 216
120 m_transfer = new QAction(); 217 m_transfer = new QAction();
121 m_transfer->setText( tr("Transfer file...") ); 218 m_transfer->setText( tr("Transfer file...") );
122 m_transfer->addTo( m_console ); 219 m_transfer->addTo( m_console );
123 connect(m_transfer, SIGNAL(activated() ), 220 connect(m_transfer, SIGNAL(activated() ),
124 this, SLOT(slotTransfer() ) ); 221 this, SLOT(slotTransfer() ) );
125 222
126 223
127 /* 224 /*
128 * fullscreen 225 * fullscreen
129 */ 226 */
130 m_isFullscreen = false; 227 m_isFullscreen = false;
131 228
132 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 229 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
133 , QString::null, 0, this, 0); 230 , QString::null, 0, this, 0);
134 m_fullscreen->addTo( m_console ); 231 m_fullscreen->addTo( m_console );
135 connect( m_fullscreen, SIGNAL( activated() ), 232 connect( m_fullscreen, SIGNAL( activated() ),
136 this, SLOT( slotFullscreen() ) ); 233 this, SLOT( slotFullscreen() ) );
137 234
138 m_console->insertSeparator(); 235 m_console->insertSeparator();
139 /* 236 /*
140 * terminate action 237 * terminate action
141 */ 238 */
142 m_terminate = new QAction(); 239 m_terminate = new QAction();
143 m_terminate->setText( tr("Terminate") ); 240 m_terminate->setText( tr("Terminate") );
144 m_terminate->addTo( m_console ); 241 m_terminate->addTo( m_console );
145 connect(m_terminate, SIGNAL(activated() ), 242 connect(m_terminate, SIGNAL(activated() ),
146 this, SLOT(slotTerminate() ) ); 243 this, SLOT(slotTerminate() ) );
147 244
148 m_closewindow = new QAction(); 245 m_closewindow = new QAction();
149 m_closewindow->setText( tr("Close Window") ); 246 m_closewindow->setText( tr("Close Window") );
150 m_closewindow->addTo( m_console ); 247 m_closewindow->addTo( m_console );
151 connect( m_closewindow, SIGNAL(activated() ), 248 connect( m_closewindow, SIGNAL(activated() ),
152 this, SLOT(slotClose() ) ); 249 this, SLOT(slotClose() ) );
153 250
154 251
155 /* 252 /*
156 * script actions 253 * script actions
157 */ 254 */
158 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); 255 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
159 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); 256 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
160 257
161 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 258 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
162 m_recordScript->addTo(m_scripts); 259 m_recordScript->addTo(m_scripts);
163 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 260 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
164 261
165 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 262 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
166 m_saveScript->addTo(m_scripts); 263 m_saveScript->addTo(m_scripts);
167 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 264 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
168 265
169 266
170 /* 267 /*
171 * action that open/closes the keyboard 268 * action that open/closes the keyboard
172 */ 269 */
173 m_openKeys = new QAction (tr("Open Keyboard..."), 270 m_openKeys = new QAction (tr("Open Keyboard..."),
174 Resource::loadPixmap( "console/keys/keyboard_icon" ), 271 Resource::loadPixmap( "console/keys/keyboard_icon" ),
175 QString::null, 0, this, 0); 272 QString::null, 0, this, 0);
176 m_openKeys->setToggleAction(true); 273 m_openKeys->setToggleAction(true);
177 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); 274 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
178 275
179 /* insert the submenu */ 276 /* insert the submenu */
180 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 277 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
181 -1, 0); 278 -1, 0);
182 279
183 /* insert the connection menu */ 280 /* insert the connection menu */
184 m_bar->insertItem( tr("Connection"), m_console ); 281 m_bar->insertItem( tr("Connection"), m_console );
185 282
186 /* the scripts menu */ 283 /* the scripts menu */
187 m_bar->insertItem( tr("Scripts"), m_scripts ); 284 m_bar->insertItem( tr("Scripts"), m_scripts );
188 285
189 /* and the keyboard */ 286 /* and the keyboard */
190 m_keyBar = new QToolBar(this); 287 m_keyBar = new QToolBar(this);
191 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 288 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
192 m_keyBar->setHorizontalStretchable( TRUE ); 289 m_keyBar->setHorizontalStretchable( TRUE );
193 m_keyBar->hide(); 290 m_keyBar->hide();
194 291
195 m_kb = new FunctionKeyboard(m_keyBar); 292 m_kb = new FunctionKeyboard(m_keyBar);
196 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 293 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
197 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); 294 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool)));
198 295
199 296
200 QAction *a = new QAction(tr("Copy"), 297 QAction *a = new QAction(tr("Copy"),
201 Resource::loadPixmap("copy"), QString::null, 298 Resource::loadPixmap("copy"), QString::null,
202 0, this, 0 ); 299 0, this, 0 );
203 //a->addTo( m_icons ); 300 //a->addTo( m_icons );
204 connect( a, SIGNAL(activated() ), 301 connect( a, SIGNAL(activated() ),
205 this, SLOT(slotCopy() ) ); 302 this, SLOT(slotCopy() ) );
206 303
207 QAction *paste = new QAction(tr("Paste"), 304 QAction *paste = new QAction(tr("Paste"),
208 Resource::loadPixmap("paste"), QString::null, 305 Resource::loadPixmap("paste"), QString::null,
209 0, this, 0 ); 306 0, this, 0 );
210 connect( paste, SIGNAL(activated() ), 307 connect( paste, SIGNAL(activated() ),
211 this, SLOT(slotPaste() ) ); 308 this, SLOT(slotPaste() ) );
212 309
213 310
214 newCon->addTo( m_icons ); 311 newCon->addTo( m_icons );
215 m_setProfiles->addTo( m_icons ); 312 m_setProfiles->addTo( m_icons );
216 paste->addTo( m_icons ); 313 paste->addTo( m_icons );
217 m_openKeys->addTo(m_icons); 314 m_openKeys->addTo(m_icons);
218 m_fullscreen->addTo( m_icons ); 315 m_fullscreen->addTo( m_icons );
219 316
220 m_connect->setEnabled( false ); 317 m_connect->setEnabled( false );
221 m_disconnect->setEnabled( false ); 318 m_disconnect->setEnabled( false );
222 m_terminate->setEnabled( false ); 319 m_terminate->setEnabled( false );
223 m_transfer->setEnabled( false ); 320 m_transfer->setEnabled( false );
224 m_scripts->setItemEnabled(m_runScript_id, false); 321 m_scripts->setItemEnabled(m_runScript_id, false);
225 m_recordScript->setEnabled( false ); 322 m_recordScript->setEnabled( false );
226 m_saveScript->setEnabled( false ); 323 m_saveScript->setEnabled( false );
227 m_fullscreen->setEnabled( false ); 324 m_fullscreen->setEnabled( false );
228 m_closewindow->setEnabled( false ); 325 m_closewindow->setEnabled( false );
229 326
230 /* 327 /*
231 * connect to the menu activation 328 * connect to the menu activation
232 */ 329 */
233 connect( m_sessionsPop, SIGNAL(activated( int ) ), 330 connect( m_sessionsPop, SIGNAL(activated( int ) ),
234 this, SLOT(slotProfile( int ) ) ); 331 this, SLOT(slotProfile( int ) ) );
235 332
236 m_consoleWindow = new TabWidget( this, "blah"); 333 m_consoleWindow = new TabWidget( this, "blah");
237 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 334 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
238 this, SLOT(slotSessionChanged(Session*) ) ); 335 this, SLOT(slotSessionChanged(Session*) ) );
239 setCentralWidget( m_consoleWindow ); 336 setCentralWidget( m_consoleWindow );
240 337
241} 338}
242 339
243ProfileManager* MainWindow::manager() { 340ProfileManager* MainWindow::manager() {
244 return m_manager; 341 return m_manager;
245} 342}
246TabWidget* MainWindow::tabWidget() { 343TabWidget* MainWindow::tabWidget() {
247 return m_consoleWindow; 344 return m_consoleWindow;
248} 345}
249void MainWindow::populateProfiles() { 346void MainWindow::populateProfiles() {
250 m_sessionsPop->clear(); 347 m_sessionsPop->clear();
251 Profile::ValueList list = manager()->all(); 348 Profile::ValueList list = manager()->all();
252 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 349 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
253 m_sessionsPop->insertItem( (*it).name() ); 350 m_sessionsPop->insertItem( (*it).name() );
254 } 351 }
255 352
256} 353}