author | harlekin <harlekin> | 2003-03-21 23:38:17 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-03-21 23:38:17 (UTC) |
commit | ab8cb739c666f5f22049258a4bcbb06d1e1ad0c4 (patch) (unidiff) | |
tree | 82690d415f22ffe554d4fcfe359ee8121b90d888 | |
parent | 43b0fded770624c907aae043e88449f80040d7df (diff) | |
download | opie-ab8cb739c666f5f22049258a4bcbb06d1e1ad0c4.zip opie-ab8cb739c666f5f22049258a4bcbb06d1e1ad0c4.tar.gz opie-ab8cb739c666f5f22049258a4bcbb06d1e1ad0c4.tar.bz2 |
even better then poping up an error dialog: make a new profile
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index a6fc30b..3acbfad 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -29,698 +29,705 @@ | |||
29 | #include "mainwindow.h" | 29 | #include "mainwindow.h" |
30 | #include "tabwidget.h" | 30 | #include "tabwidget.h" |
31 | #include "transferdialog.h" | 31 | #include "transferdialog.h" |
32 | #include "function_keyboard.h" | 32 | #include "function_keyboard.h" |
33 | #include "emulation_handler.h" | 33 | #include "emulation_handler.h" |
34 | #include "script.h" | 34 | #include "script.h" |
35 | 35 | ||
36 | 36 | ||
37 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 37 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
38 | KeyTrans::loadAll(); | 38 | KeyTrans::loadAll(); |
39 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 39 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
40 | KeyTrans* s = KeyTrans::find(i ); | 40 | KeyTrans* s = KeyTrans::find(i ); |
41 | assert( s ); | 41 | assert( s ); |
42 | } | 42 | } |
43 | m_factory = new MetaFactory(); | 43 | m_factory = new MetaFactory(); |
44 | Default def(m_factory); | 44 | Default def(m_factory); |
45 | m_sessions.setAutoDelete( TRUE ); | 45 | m_sessions.setAutoDelete( TRUE ); |
46 | m_curSession = 0; | 46 | m_curSession = 0; |
47 | m_manager = new ProfileManager( m_factory ); | 47 | m_manager = new ProfileManager( m_factory ); |
48 | m_manager->load(); | 48 | m_manager->load(); |
49 | m_scriptsData.setAutoDelete(TRUE); | 49 | m_scriptsData.setAutoDelete(TRUE); |
50 | 50 | ||
51 | initUI(); | 51 | initUI(); |
52 | populateProfiles(); | 52 | populateProfiles(); |
53 | populateScripts(); | 53 | populateScripts(); |
54 | } | 54 | } |
55 | 55 | ||
56 | void MainWindow::initUI() { | 56 | void MainWindow::initUI() { |
57 | setToolBarsMovable( FALSE ); | 57 | setToolBarsMovable( FALSE ); |
58 | 58 | ||
59 | /* tool bar for the menu */ | 59 | /* tool bar for the menu */ |
60 | m_tool = new QToolBar( this ); | 60 | m_tool = new QToolBar( this ); |
61 | m_tool->setHorizontalStretchable( TRUE ); | 61 | m_tool->setHorizontalStretchable( TRUE ); |
62 | 62 | ||
63 | m_bar = new QMenuBar( m_tool ); | 63 | m_bar = new QMenuBar( m_tool ); |
64 | m_console = new QPopupMenu( this ); | 64 | m_console = new QPopupMenu( this ); |
65 | m_scripts = new QPopupMenu( this ); | 65 | m_scripts = new QPopupMenu( this ); |
66 | m_sessionsPop= new QPopupMenu( this ); | 66 | m_sessionsPop= new QPopupMenu( this ); |
67 | m_scriptsPop = new QPopupMenu( this ); | 67 | m_scriptsPop = new QPopupMenu( this ); |
68 | 68 | ||
69 | /* add a toolbar for icons */ | 69 | /* add a toolbar for icons */ |
70 | m_icons = new QToolBar(this); | 70 | m_icons = new QToolBar(this); |
71 | 71 | ||
72 | /* | 72 | /* |
73 | * the settings action | 73 | * the settings action |
74 | */ | 74 | */ |
75 | m_setProfiles = new QAction(tr("Configure Profiles"), | 75 | m_setProfiles = new QAction(tr("Configure Profiles"), |
76 | Resource::loadPixmap( "SettingsIcon" ), | 76 | Resource::loadPixmap( "SettingsIcon" ), |
77 | QString::null, 0, this, 0); | 77 | QString::null, 0, this, 0); |
78 | m_setProfiles->addTo( m_console ); | 78 | m_setProfiles->addTo( m_console ); |
79 | connect( m_setProfiles, SIGNAL(activated() ), | 79 | connect( m_setProfiles, SIGNAL(activated() ), |
80 | this, SLOT(slotConfigure() ) ); | 80 | this, SLOT(slotConfigure() ) ); |
81 | 81 | ||
82 | m_console->insertSeparator(); | 82 | m_console->insertSeparator(); |
83 | /* | 83 | /* |
84 | * new Action for new sessions | 84 | * new Action for new sessions |
85 | */ | 85 | */ |
86 | QAction* newCon = new QAction(tr("New Connection"), | 86 | QAction* newCon = new QAction(tr("New Connection"), |
87 | Resource::loadPixmap( "new" ), | 87 | Resource::loadPixmap( "new" ), |
88 | QString::null, 0, this, 0); | 88 | QString::null, 0, this, 0); |
89 | newCon->addTo( m_console ); | 89 | newCon->addTo( m_console ); |
90 | connect( newCon, SIGNAL(activated() ), | 90 | connect( newCon, SIGNAL(activated() ), |
91 | this, SLOT(slotNew() ) ); | 91 | this, SLOT(slotNew() ) ); |
92 | 92 | ||
93 | m_console->insertSeparator(); | 93 | m_console->insertSeparator(); |
94 | 94 | ||
95 | QAction *saveCon = new QAction(tr("Save Connection"), | 95 | QAction *saveCon = new QAction(tr("Save Connection"), |
96 | Resource::loadPixmap( "save" ), QString::null, | 96 | Resource::loadPixmap( "save" ), QString::null, |
97 | 0, this, 0 ); | 97 | 0, this, 0 ); |
98 | saveCon->addTo( m_console ); | 98 | saveCon->addTo( m_console ); |
99 | connect( saveCon, SIGNAL(activated() ), | 99 | connect( saveCon, SIGNAL(activated() ), |
100 | this, SLOT(slotSaveSession() ) ); | 100 | this, SLOT(slotSaveSession() ) ); |
101 | m_console->insertSeparator(); | 101 | m_console->insertSeparator(); |
102 | 102 | ||
103 | /* | 103 | /* |
104 | * connect action | 104 | * connect action |
105 | */ | 105 | */ |
106 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), | 106 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), |
107 | QString::null, 0, this, 0 ); | 107 | QString::null, 0, this, 0 ); |
108 | m_connect->addTo( m_console ); | 108 | m_connect->addTo( m_console ); |
109 | connect(m_connect, SIGNAL(activated() ), | 109 | connect(m_connect, SIGNAL(activated() ), |
110 | this, SLOT(slotConnect() ) ); | 110 | this, SLOT(slotConnect() ) ); |
111 | 111 | ||
112 | /* | 112 | /* |
113 | * disconnect action | 113 | * disconnect action |
114 | */ | 114 | */ |
115 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), | 115 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), |
116 | QString::null, 0, this, 0 ); | 116 | QString::null, 0, this, 0 ); |
117 | m_disconnect->addTo( m_console ); | 117 | m_disconnect->addTo( m_console ); |
118 | connect(m_disconnect, SIGNAL(activated() ), | 118 | connect(m_disconnect, SIGNAL(activated() ), |
119 | this, SLOT(slotDisconnect() ) ); | 119 | this, SLOT(slotDisconnect() ) ); |
120 | 120 | ||
121 | m_console->insertSeparator(); | 121 | m_console->insertSeparator(); |
122 | 122 | ||
123 | m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); | 123 | m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); |
124 | m_quickLaunch->addTo( m_icons ); | 124 | m_quickLaunch->addTo( m_icons ); |
125 | connect( m_quickLaunch, SIGNAL( activated() ), | 125 | connect( m_quickLaunch, SIGNAL( activated() ), |
126 | this, SLOT( slotQuickLaunch() ) ); | 126 | this, SLOT( slotQuickLaunch() ) ); |
127 | 127 | ||
128 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, | 128 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, |
129 | 0, this, 0 ); | 129 | 0, this, 0 ); |
130 | m_transfer->addTo( m_console ); | 130 | m_transfer->addTo( m_console ); |
131 | connect(m_transfer, SIGNAL(activated() ), | 131 | connect(m_transfer, SIGNAL(activated() ), |
132 | this, SLOT(slotTransfer() ) ); | 132 | this, SLOT(slotTransfer() ) ); |
133 | 133 | ||
134 | 134 | ||
135 | 135 | ||
136 | /* | 136 | /* |
137 | * immediate change of line wrap policy | 137 | * immediate change of line wrap policy |
138 | */ | 138 | */ |
139 | m_isWrapped = false; | 139 | m_isWrapped = false; |
140 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); | 140 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); |
141 | m_wrap->addTo( m_console ); | 141 | m_wrap->addTo( m_console ); |
142 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); | 142 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); |
143 | 143 | ||
144 | /* | 144 | /* |
145 | * fullscreen | 145 | * fullscreen |
146 | */ | 146 | */ |
147 | m_isFullscreen = false; | 147 | m_isFullscreen = false; |
148 | 148 | ||
149 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 149 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
150 | , QString::null, 0, this, 0); | 150 | , QString::null, 0, this, 0); |
151 | m_fullscreen->addTo( m_console ); | 151 | m_fullscreen->addTo( m_console ); |
152 | connect( m_fullscreen, SIGNAL( activated() ), | 152 | connect( m_fullscreen, SIGNAL( activated() ), |
153 | this, SLOT( slotFullscreen() ) ); | 153 | this, SLOT( slotFullscreen() ) ); |
154 | 154 | ||
155 | m_console->insertSeparator(); | 155 | m_console->insertSeparator(); |
156 | 156 | ||
157 | QAction *a = new QAction(); | 157 | QAction *a = new QAction(); |
158 | a->setText( tr("Save history") ); | 158 | a->setText( tr("Save history") ); |
159 | a->addTo( m_console ); | 159 | a->addTo( m_console ); |
160 | connect(a, SIGNAL(activated() ), | 160 | connect(a, SIGNAL(activated() ), |
161 | this, SLOT(slotSaveHistory() ) ); | 161 | this, SLOT(slotSaveHistory() ) ); |
162 | /* | 162 | /* |
163 | * terminate action | 163 | * terminate action |
164 | */ | 164 | */ |
165 | m_terminate = new QAction(); | 165 | m_terminate = new QAction(); |
166 | m_terminate->setText( tr("Terminate") ); | 166 | m_terminate->setText( tr("Terminate") ); |
167 | m_terminate->addTo( m_console ); | 167 | m_terminate->addTo( m_console ); |
168 | connect(m_terminate, SIGNAL(activated() ), | 168 | connect(m_terminate, SIGNAL(activated() ), |
169 | this, SLOT(slotTerminate() ) ); | 169 | this, SLOT(slotTerminate() ) ); |
170 | 170 | ||
171 | m_closewindow = new QAction(); | 171 | m_closewindow = new QAction(); |
172 | m_closewindow->setText( tr("Close Window") ); | 172 | m_closewindow->setText( tr("Close Window") ); |
173 | m_closewindow->addTo( m_console ); | 173 | m_closewindow->addTo( m_console ); |
174 | connect( m_closewindow, SIGNAL(activated() ), | 174 | connect( m_closewindow, SIGNAL(activated() ), |
175 | this, SLOT(slotClose() ) ); | 175 | this, SLOT(slotClose() ) ); |
176 | 176 | ||
177 | 177 | ||
178 | /* | 178 | /* |
179 | * script actions | 179 | * script actions |
180 | */ | 180 | */ |
181 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | 181 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); |
182 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | 182 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); |
183 | 183 | ||
184 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 184 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
185 | m_recordScript->addTo(m_scripts); | 185 | m_recordScript->addTo(m_scripts); |
186 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 186 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
187 | 187 | ||
188 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 188 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
189 | m_saveScript->addTo(m_scripts); | 189 | m_saveScript->addTo(m_scripts); |
190 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 190 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
191 | 191 | ||
192 | 192 | ||
193 | /* | 193 | /* |
194 | * action that open/closes the keyboard | 194 | * action that open/closes the keyboard |
195 | */ | 195 | */ |
196 | m_openKeys = new QAction (tr("Open Keyboard..."), | 196 | m_openKeys = new QAction (tr("Open Keyboard..."), |
197 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 197 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
198 | QString::null, 0, this, 0); | 198 | QString::null, 0, this, 0); |
199 | m_openKeys->setToggleAction(true); | 199 | m_openKeys->setToggleAction(true); |
200 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 200 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
201 | 201 | ||
202 | /* insert the submenu */ | 202 | /* insert the submenu */ |
203 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 203 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
204 | -1, 0); | 204 | -1, 0); |
205 | 205 | ||
206 | /* insert the connection menu */ | 206 | /* insert the connection menu */ |
207 | m_bar->insertItem( tr("Connection"), m_console ); | 207 | m_bar->insertItem( tr("Connection"), m_console ); |
208 | 208 | ||
209 | /* the scripts menu */ | 209 | /* the scripts menu */ |
210 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 210 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
211 | 211 | ||
212 | /* and the keyboard */ | 212 | /* and the keyboard */ |
213 | m_keyBar = new QToolBar(this); | 213 | m_keyBar = new QToolBar(this); |
214 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 214 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
215 | m_keyBar->setHorizontalStretchable( TRUE ); | 215 | m_keyBar->setHorizontalStretchable( TRUE ); |
216 | m_keyBar->hide(); | 216 | m_keyBar->hide(); |
217 | 217 | ||
218 | m_kb = new FunctionKeyboard(m_keyBar); | 218 | m_kb = new FunctionKeyboard(m_keyBar); |
219 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 219 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
220 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); | 220 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
221 | 221 | ||
222 | 222 | ||
223 | a = new QAction(tr("Copy"), | 223 | a = new QAction(tr("Copy"), |
224 | Resource::loadPixmap("copy"), QString::null, | 224 | Resource::loadPixmap("copy"), QString::null, |
225 | 0, this, 0 ); | 225 | 0, this, 0 ); |
226 | //a->addTo( m_icons ); | 226 | //a->addTo( m_icons ); |
227 | connect( a, SIGNAL(activated() ), | 227 | connect( a, SIGNAL(activated() ), |
228 | this, SLOT(slotCopy() ) ); | 228 | this, SLOT(slotCopy() ) ); |
229 | 229 | ||
230 | QAction *paste = new QAction(tr("Paste"), | 230 | QAction *paste = new QAction(tr("Paste"), |
231 | Resource::loadPixmap("paste"), QString::null, | 231 | Resource::loadPixmap("paste"), QString::null, |
232 | 0, this, 0 ); | 232 | 0, this, 0 ); |
233 | connect( paste, SIGNAL(activated() ), | 233 | connect( paste, SIGNAL(activated() ), |
234 | this, SLOT(slotPaste() ) ); | 234 | this, SLOT(slotPaste() ) ); |
235 | 235 | ||
236 | 236 | ||
237 | newCon->addTo( m_icons ); | 237 | newCon->addTo( m_icons ); |
238 | m_setProfiles->addTo( m_icons ); | 238 | m_setProfiles->addTo( m_icons ); |
239 | paste->addTo( m_icons ); | 239 | paste->addTo( m_icons ); |
240 | m_openKeys->addTo(m_icons); | 240 | m_openKeys->addTo(m_icons); |
241 | m_fullscreen->addTo( m_icons ); | 241 | m_fullscreen->addTo( m_icons ); |
242 | 242 | ||
243 | m_connect->setEnabled( false ); | 243 | m_connect->setEnabled( false ); |
244 | m_disconnect->setEnabled( false ); | 244 | m_disconnect->setEnabled( false ); |
245 | m_terminate->setEnabled( false ); | 245 | m_terminate->setEnabled( false ); |
246 | m_transfer->setEnabled( false ); | 246 | m_transfer->setEnabled( false ); |
247 | m_scripts->setItemEnabled(m_runScript_id, false); | 247 | m_scripts->setItemEnabled(m_runScript_id, false); |
248 | m_recordScript->setEnabled( false ); | 248 | m_recordScript->setEnabled( false ); |
249 | m_saveScript->setEnabled( false ); | 249 | m_saveScript->setEnabled( false ); |
250 | m_fullscreen->setEnabled( false ); | 250 | m_fullscreen->setEnabled( false ); |
251 | m_closewindow->setEnabled( false ); | 251 | m_closewindow->setEnabled( false ); |
252 | m_wrap->setEnabled( false ); | 252 | m_wrap->setEnabled( false ); |
253 | 253 | ||
254 | /* | 254 | /* |
255 | * connect to the menu activation | 255 | * connect to the menu activation |
256 | */ | 256 | */ |
257 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 257 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
258 | this, SLOT(slotProfile( int ) ) ); | 258 | this, SLOT(slotProfile( int ) ) ); |
259 | 259 | ||
260 | m_consoleWindow = new TabWidget( this, "blah"); | 260 | m_consoleWindow = new TabWidget( this, "blah"); |
261 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 261 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
262 | this, SLOT(slotSessionChanged(Session*) ) ); | 262 | this, SLOT(slotSessionChanged(Session*) ) ); |
263 | setCentralWidget( m_consoleWindow ); | 263 | setCentralWidget( m_consoleWindow ); |
264 | 264 | ||
265 | } | 265 | } |
266 | 266 | ||
267 | ProfileManager* MainWindow::manager() { | 267 | ProfileManager* MainWindow::manager() { |
268 | return m_manager; | 268 | return m_manager; |
269 | } | 269 | } |
270 | TabWidget* MainWindow::tabWidget() { | 270 | TabWidget* MainWindow::tabWidget() { |
271 | return m_consoleWindow; | 271 | return m_consoleWindow; |
272 | } | 272 | } |
273 | void MainWindow::populateProfiles() { | 273 | void MainWindow::populateProfiles() { |
274 | m_sessionsPop->clear(); | 274 | m_sessionsPop->clear(); |
275 | Profile::ValueList list = manager()->all(); | 275 | Profile::ValueList list = manager()->all(); |
276 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 276 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
277 | m_sessionsPop->insertItem( (*it).name() ); | 277 | m_sessionsPop->insertItem( (*it).name() ); |
278 | } | 278 | } |
279 | 279 | ||
280 | } | 280 | } |
281 | 281 | ||
282 | void MainWindow::populateScripts() { | 282 | void MainWindow::populateScripts() { |
283 | m_scriptsPop->clear(); | 283 | m_scriptsPop->clear(); |
284 | m_scriptsData.clear(); | 284 | m_scriptsData.clear(); |
285 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | 285 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); |
286 | QListIterator<DocLnk> dit(files.children()); | 286 | QListIterator<DocLnk> dit(files.children()); |
287 | for (; dit.current(); ++dit) { | 287 | for (; dit.current(); ++dit) { |
288 | if (*dit && (*dit)->name().length()>0) { | 288 | if (*dit && (*dit)->name().length()>0) { |
289 | QFileInfo info((*dit)->file()); | 289 | QFileInfo info((*dit)->file()); |
290 | if (info.extension(false) == "script") { | 290 | if (info.extension(false) == "script") { |
291 | m_scriptsData.append(new DocLnk(**dit)); | 291 | m_scriptsData.append(new DocLnk(**dit)); |
292 | m_scriptsPop->insertItem((*dit)->name()); | 292 | m_scriptsPop->insertItem((*dit)->name()); |
293 | } | 293 | } |
294 | } | 294 | } |
295 | } | 295 | } |
296 | 296 | ||
297 | } | 297 | } |
298 | 298 | ||
299 | MainWindow::~MainWindow() { | 299 | MainWindow::~MainWindow() { |
300 | delete m_factory; | 300 | delete m_factory; |
301 | manager()->save(); | 301 | manager()->save(); |
302 | } | 302 | } |
303 | 303 | ||
304 | MetaFactory* MainWindow::factory() { | 304 | MetaFactory* MainWindow::factory() { |
305 | return m_factory; | 305 | return m_factory; |
306 | } | 306 | } |
307 | 307 | ||
308 | Session* MainWindow::currentSession() { | 308 | Session* MainWindow::currentSession() { |
309 | return m_curSession; | 309 | return m_curSession; |
310 | } | 310 | } |
311 | 311 | ||
312 | QList<Session> MainWindow::sessions() { | 312 | QList<Session> MainWindow::sessions() { |
313 | return m_sessions; | 313 | return m_sessions; |
314 | } | 314 | } |
315 | 315 | ||
316 | void MainWindow::slotNew() { | 316 | void MainWindow::slotNew() { |
317 | ProfileEditorDialog dlg(factory() ); | 317 | ProfileEditorDialog dlg(factory() ); |
318 | dlg.showMaximized(); | 318 | dlg.showMaximized(); |
319 | dlg.setCaption( tr("New Connection") ); | 319 | dlg.setCaption( tr("New Connection") ); |
320 | int ret = dlg.exec(); | 320 | int ret = dlg.exec(); |
321 | 321 | ||
322 | if ( ret == QDialog::Accepted ) { | 322 | if ( ret == QDialog::Accepted ) { |
323 | create( dlg.profile() ); | 323 | create( dlg.profile() ); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | void MainWindow::slotRecordScript() { | 327 | void MainWindow::slotRecordScript() { |
328 | if (currentSession()) { | 328 | if (currentSession()) { |
329 | currentSession()->emulationHandler()->startRecording(); | 329 | currentSession()->emulationHandler()->startRecording(); |
330 | m_saveScript->setEnabled(true); | 330 | m_saveScript->setEnabled(true); |
331 | m_recordScript->setEnabled(false); | 331 | m_recordScript->setEnabled(false); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | void MainWindow::slotSaveScript() { | 335 | void MainWindow::slotSaveScript() { |
336 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 336 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
337 | QMap<QString, QStringList> map; | 337 | QMap<QString, QStringList> map; |
338 | QStringList text; | 338 | QStringList text; |
339 | text << "text/plain"; | 339 | text << "text/plain"; |
340 | map.insert(tr("Script"), text ); | 340 | map.insert(tr("Script"), text ); |
341 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 341 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
342 | if (!filename.isEmpty()) { | 342 | if (!filename.isEmpty()) { |
343 | QFileInfo info(filename); | 343 | QFileInfo info(filename); |
344 | if (info.extension(FALSE) != "script") | 344 | if (info.extension(FALSE) != "script") |
345 | filename += ".script"; | 345 | filename += ".script"; |
346 | DocLnk nf; | 346 | DocLnk nf; |
347 | nf.setType("text/plain"); | 347 | nf.setType("text/plain"); |
348 | nf.setFile(filename); | 348 | nf.setFile(filename); |
349 | nf.setName(info.fileName()); | 349 | nf.setName(info.fileName()); |
350 | FileManager fm; | 350 | FileManager fm; |
351 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 351 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
352 | currentSession()->emulationHandler()->clearScript(); | 352 | currentSession()->emulationHandler()->clearScript(); |
353 | m_saveScript->setEnabled(false); | 353 | m_saveScript->setEnabled(false); |
354 | m_recordScript->setEnabled(true); | 354 | m_recordScript->setEnabled(true); |
355 | populateScripts(); | 355 | populateScripts(); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | void MainWindow::slotRunScript(int id) { | 360 | void MainWindow::slotRunScript(int id) { |
361 | if (currentSession()) { | 361 | if (currentSession()) { |
362 | int index = m_scriptsPop->indexOf(id); | 362 | int index = m_scriptsPop->indexOf(id); |
363 | DocLnk *lnk = m_scriptsData.at(index); | 363 | DocLnk *lnk = m_scriptsData.at(index); |
364 | QString filePath = lnk->file(); | 364 | QString filePath = lnk->file(); |
365 | Script script(filePath); | 365 | Script script(filePath); |
366 | currentSession()->emulationHandler()->runScript(&script); | 366 | currentSession()->emulationHandler()->runScript(&script); |
367 | } | 367 | } |
368 | } | 368 | } |
369 | 369 | ||
370 | void MainWindow::slotConnect() { | 370 | void MainWindow::slotConnect() { |
371 | if ( currentSession() ) { | 371 | if ( currentSession() ) { |
372 | bool ret = currentSession()->layer()->open(); | 372 | bool ret = currentSession()->layer()->open(); |
373 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 373 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
374 | QObject::tr("Failed"), | 374 | QObject::tr("Failed"), |
375 | QObject::tr("Connecting failed for this session.")); | 375 | QObject::tr("Connecting failed for this session.")); |
376 | else { | 376 | else { |
377 | m_connect->setEnabled( false ); | 377 | m_connect->setEnabled( false ); |
378 | m_disconnect->setEnabled( true ); | 378 | m_disconnect->setEnabled( true ); |
379 | 379 | ||
380 | // if it does not support file transfer, disable the menu entry | 380 | // if it does not support file transfer, disable the menu entry |
381 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 381 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
382 | m_transfer->setEnabled( false ); | 382 | m_transfer->setEnabled( false ); |
383 | } else { | 383 | } else { |
384 | m_transfer->setEnabled( true ); | 384 | m_transfer->setEnabled( true ); |
385 | } | 385 | } |
386 | 386 | ||
387 | m_recordScript->setEnabled( true ); | 387 | m_recordScript->setEnabled( true ); |
388 | m_scripts->setItemEnabled(m_runScript_id, true); | 388 | m_scripts->setItemEnabled(m_runScript_id, true); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | 392 | ||
393 | void MainWindow::slotDisconnect() { | 393 | void MainWindow::slotDisconnect() { |
394 | if ( currentSession() ) { | 394 | if ( currentSession() ) { |
395 | currentSession()->layer()->close(); | 395 | currentSession()->layer()->close(); |
396 | m_connect->setEnabled( true ); | 396 | m_connect->setEnabled( true ); |
397 | m_disconnect->setEnabled( false ); | 397 | m_disconnect->setEnabled( false ); |
398 | m_transfer->setEnabled( false ); | 398 | m_transfer->setEnabled( false ); |
399 | m_recordScript->setEnabled( false); | 399 | m_recordScript->setEnabled( false); |
400 | m_saveScript->setEnabled( false ); | 400 | m_saveScript->setEnabled( false ); |
401 | m_scripts->setItemEnabled(m_runScript_id, false); | 401 | m_scripts->setItemEnabled(m_runScript_id, false); |
402 | } | 402 | } |
403 | } | 403 | } |
404 | 404 | ||
405 | void MainWindow::slotTerminate() { | 405 | void MainWindow::slotTerminate() { |
406 | if ( currentSession() ) | 406 | if ( currentSession() ) |
407 | currentSession()->layer()->close(); | 407 | currentSession()->layer()->close(); |
408 | 408 | ||
409 | slotClose(); | 409 | slotClose(); |
410 | /* FIXME move to the next session */ | 410 | /* FIXME move to the next session */ |
411 | } | 411 | } |
412 | 412 | ||
413 | |||
414 | |||
415 | |||
416 | |||
417 | |||
413 | void MainWindow::slotQuickLaunch() { | 418 | void MainWindow::slotQuickLaunch() { |
414 | Profile prof = manager()->profile( "default" ); | 419 | Profile prof = manager()->profile( "default" ); |
415 | if ( prof.name() == "default" ) { | 420 | if ( prof.name() == "default" ) { |
416 | create( prof ); | 421 | create( prof ); |
417 | } else { | 422 | } else { |
418 | QMessageBox::warning(this, tr("Failure"),tr("please configure one profile named \"default\"")); | 423 | Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); |
424 | newProf.setAutoConnect( true ); | ||
425 | create( newProf ); | ||
419 | } | 426 | } |
420 | 427 | ||
421 | } | 428 | } |
422 | 429 | ||
423 | void MainWindow::slotConfigure() { | 430 | void MainWindow::slotConfigure() { |
424 | ConfigDialog conf( manager()->all(), factory() ); | 431 | ConfigDialog conf( manager()->all(), factory() ); |
425 | conf.showMaximized(); | 432 | conf.showMaximized(); |
426 | 433 | ||
427 | int ret = conf.exec(); | 434 | int ret = conf.exec(); |
428 | 435 | ||
429 | if ( QDialog::Accepted == ret ) { | 436 | if ( QDialog::Accepted == ret ) { |
430 | manager()->setProfiles( conf.list() ); | 437 | manager()->setProfiles( conf.list() ); |
431 | manager()->save(); | 438 | manager()->save(); |
432 | populateProfiles(); | 439 | populateProfiles(); |
433 | } | 440 | } |
434 | } | 441 | } |
435 | /* | 442 | /* |
436 | * we will remove | 443 | * we will remove |
437 | * this window from the tabwidget | 444 | * this window from the tabwidget |
438 | * remove it from the list | 445 | * remove it from the list |
439 | * delete it | 446 | * delete it |
440 | * and set the currentSession() | 447 | * and set the currentSession() |
441 | */ | 448 | */ |
442 | void MainWindow::slotClose() { | 449 | void MainWindow::slotClose() { |
443 | if (!currentSession() ) | 450 | if (!currentSession() ) |
444 | return; | 451 | return; |
445 | 452 | ||
446 | Session* ses = currentSession(); | 453 | Session* ses = currentSession(); |
447 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 454 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
448 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 455 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
449 | m_curSession = NULL; | 456 | m_curSession = NULL; |
450 | tabWidget()->remove( /*currentSession()*/ses ); | 457 | tabWidget()->remove( /*currentSession()*/ses ); |
451 | /*it's autodelete */ | 458 | /*it's autodelete */ |
452 | m_sessions.remove( ses ); | 459 | m_sessions.remove( ses ); |
453 | qWarning("after remove!!"); | 460 | qWarning("after remove!!"); |
454 | 461 | ||
455 | if (!currentSession() ) { | 462 | if (!currentSession() ) { |
456 | m_connect->setEnabled( false ); | 463 | m_connect->setEnabled( false ); |
457 | m_disconnect->setEnabled( false ); | 464 | m_disconnect->setEnabled( false ); |
458 | m_terminate->setEnabled( false ); | 465 | m_terminate->setEnabled( false ); |
459 | m_transfer->setEnabled( false ); | 466 | m_transfer->setEnabled( false ); |
460 | m_recordScript->setEnabled( false ); | 467 | m_recordScript->setEnabled( false ); |
461 | m_saveScript->setEnabled( false ); | 468 | m_saveScript->setEnabled( false ); |
462 | m_scripts->setItemEnabled(m_runScript_id, false); | 469 | m_scripts->setItemEnabled(m_runScript_id, false); |
463 | m_fullscreen->setEnabled( false ); | 470 | m_fullscreen->setEnabled( false ); |
464 | m_wrap->setEnabled( false ); | 471 | m_wrap->setEnabled( false ); |
465 | m_closewindow->setEnabled( false ); | 472 | m_closewindow->setEnabled( false ); |
466 | } | 473 | } |
467 | 474 | ||
468 | m_kb->loadDefaults(); | 475 | m_kb->loadDefaults(); |
469 | } | 476 | } |
470 | 477 | ||
471 | /* | 478 | /* |
472 | * We will get the name | 479 | * We will get the name |
473 | * Then the profile | 480 | * Then the profile |
474 | * and then we will make a profile | 481 | * and then we will make a profile |
475 | */ | 482 | */ |
476 | void MainWindow::slotProfile( int id) { | 483 | void MainWindow::slotProfile( int id) { |
477 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 484 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
478 | create( prof ); | 485 | create( prof ); |
479 | } | 486 | } |
480 | 487 | ||
481 | 488 | ||
482 | 489 | ||
483 | void MainWindow::create( const Profile& prof ) { | 490 | void MainWindow::create( const Profile& prof ) { |
484 | if(m_curSession) | 491 | if(m_curSession) |
485 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 492 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
486 | 493 | ||
487 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 494 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
488 | 495 | ||
489 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 496 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
490 | { | 497 | { |
491 | QMessageBox::warning(this, | 498 | QMessageBox::warning(this, |
492 | QObject::tr("Session failed"), | 499 | QObject::tr("Session failed"), |
493 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 500 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
494 | //if(ses) delete ses; | 501 | //if(ses) delete ses; |
495 | return; | 502 | return; |
496 | } | 503 | } |
497 | 504 | ||
498 | m_sessions.append( ses ); | 505 | m_sessions.append( ses ); |
499 | tabWidget()->add( ses ); | 506 | tabWidget()->add( ses ); |
500 | tabWidget()->repaint(); | 507 | tabWidget()->repaint(); |
501 | m_curSession = ses; | 508 | m_curSession = ses; |
502 | 509 | ||
503 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 510 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
504 | m_connect->setEnabled( true ); | 511 | m_connect->setEnabled( true ); |
505 | m_disconnect->setEnabled( false ); | 512 | m_disconnect->setEnabled( false ); |
506 | m_terminate->setEnabled( true ); | 513 | m_terminate->setEnabled( true ); |
507 | m_fullscreen->setEnabled( true ); | 514 | m_fullscreen->setEnabled( true ); |
508 | m_wrap->setEnabled( true ); | 515 | m_wrap->setEnabled( true ); |
509 | m_closewindow->setEnabled( true ); | 516 | m_closewindow->setEnabled( true ); |
510 | m_transfer->setEnabled( false ); | 517 | m_transfer->setEnabled( false ); |
511 | m_recordScript->setEnabled( false ); | 518 | m_recordScript->setEnabled( false ); |
512 | m_saveScript->setEnabled( false ); | 519 | m_saveScript->setEnabled( false ); |
513 | m_scripts->setItemEnabled(m_runScript_id, false); | 520 | m_scripts->setItemEnabled(m_runScript_id, false); |
514 | 521 | ||
515 | // is io_layer wants direct connection, then autoconnect | 522 | // is io_layer wants direct connection, then autoconnect |
516 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 523 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
517 | if (prof.autoConnect()) { | 524 | if (prof.autoConnect()) { |
518 | slotConnect(); | 525 | slotConnect(); |
519 | } | 526 | } |
520 | 527 | ||
521 | 528 | ||
522 | QWidget *w = currentSession()->widget(); | 529 | QWidget *w = currentSession()->widget(); |
523 | if(w) w->setFocus(); | 530 | if(w) w->setFocus(); |
524 | 531 | ||
525 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 532 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
526 | m_isWrapped = true; | 533 | m_isWrapped = true; |
527 | } else { | 534 | } else { |
528 | m_isWrapped = false; | 535 | m_isWrapped = false; |
529 | } | 536 | } |
530 | 537 | ||
531 | m_kb->load(currentSession()->profile()); | 538 | m_kb->load(currentSession()->profile()); |
532 | } | 539 | } |
533 | 540 | ||
534 | void MainWindow::slotTransfer() | 541 | void MainWindow::slotTransfer() |
535 | { | 542 | { |
536 | if ( currentSession() ) { | 543 | if ( currentSession() ) { |
537 | Session *mysession = currentSession(); | 544 | Session *mysession = currentSession(); |
538 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); | 545 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); |
539 | mysession->setTransferDialog(&dlg); | 546 | mysession->setTransferDialog(&dlg); |
540 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); | 547 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); |
541 | //dlg.showMaximized(); | 548 | //dlg.showMaximized(); |
542 | currentSession()->widgetStack()->addWidget(&dlg, -1); | 549 | currentSession()->widgetStack()->addWidget(&dlg, -1); |
543 | dlg.show(); | 550 | dlg.show(); |
544 | //dlg.exec(); | 551 | //dlg.exec(); |
545 | while(dlg.isRunning()) qApp->processEvents(); | 552 | while(dlg.isRunning()) qApp->processEvents(); |
546 | mysession->setTransferDialog(0l); | 553 | mysession->setTransferDialog(0l); |
547 | } | 554 | } |
548 | } | 555 | } |
549 | 556 | ||
550 | 557 | ||
551 | void MainWindow::slotOpenKeb(bool state) { | 558 | void MainWindow::slotOpenKeb(bool state) { |
552 | 559 | ||
553 | if (state) m_keyBar->show(); | 560 | if (state) m_keyBar->show(); |
554 | else m_keyBar->hide(); | 561 | else m_keyBar->hide(); |
555 | 562 | ||
556 | } | 563 | } |
557 | 564 | ||
558 | 565 | ||
559 | void MainWindow::slotOpenButtons( bool state ) { | 566 | void MainWindow::slotOpenButtons( bool state ) { |
560 | 567 | ||
561 | if ( state ) { | 568 | if ( state ) { |
562 | m_buttonBar->show(); | 569 | m_buttonBar->show(); |
563 | } else { | 570 | } else { |
564 | m_buttonBar->hide(); | 571 | m_buttonBar->hide(); |
565 | } | 572 | } |
566 | } | 573 | } |
567 | 574 | ||
568 | 575 | ||
569 | 576 | ||
570 | void MainWindow::slotSessionChanged( Session* ses ) { | 577 | void MainWindow::slotSessionChanged( Session* ses ) { |
571 | qWarning("changed!"); | 578 | qWarning("changed!"); |
572 | 579 | ||
573 | if(m_curSession) | 580 | if(m_curSession) |
574 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 581 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
575 | if(ses) | 582 | if(ses) |
576 | if(ses->transferDialog()) ses->transferDialog()->show(); | 583 | if(ses->transferDialog()) ses->transferDialog()->show(); |
577 | 584 | ||
578 | if ( ses ) { | 585 | if ( ses ) { |
579 | m_curSession = ses; | 586 | m_curSession = ses; |
580 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 587 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
581 | if ( m_curSession->layer()->isConnected() ) { | 588 | if ( m_curSession->layer()->isConnected() ) { |
582 | m_connect->setEnabled( false ); | 589 | m_connect->setEnabled( false ); |
583 | m_disconnect->setEnabled( true ); | 590 | m_disconnect->setEnabled( true ); |
584 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); | 591 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); |
585 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); | 592 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); |
586 | m_scripts->setItemEnabled(m_runScript_id, true); | 593 | m_scripts->setItemEnabled(m_runScript_id, true); |
587 | } else { | 594 | } else { |
588 | m_connect->setEnabled( true ); | 595 | m_connect->setEnabled( true ); |
589 | m_disconnect->setEnabled( false ); | 596 | m_disconnect->setEnabled( false ); |
590 | m_recordScript->setEnabled( false ); | 597 | m_recordScript->setEnabled( false ); |
591 | m_saveScript->setEnabled( false ); | 598 | m_saveScript->setEnabled( false ); |
592 | m_scripts->setItemEnabled(m_runScript_id, false); | 599 | m_scripts->setItemEnabled(m_runScript_id, false); |
593 | } | 600 | } |
594 | 601 | ||
595 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 602 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
596 | m_transfer->setEnabled( false ); | 603 | m_transfer->setEnabled( false ); |
597 | } else { | 604 | } else { |
598 | m_transfer->setEnabled( true ); | 605 | m_transfer->setEnabled( true ); |
599 | } | 606 | } |
600 | 607 | ||
601 | QWidget *w = m_curSession->widget(); | 608 | QWidget *w = m_curSession->widget(); |
602 | if(w) w->setFocus(); | 609 | if(w) w->setFocus(); |
603 | 610 | ||
604 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 611 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
605 | m_isWrapped = true; | 612 | m_isWrapped = true; |
606 | } else { | 613 | } else { |
607 | m_isWrapped = false; | 614 | m_isWrapped = false; |
608 | } | 615 | } |
609 | 616 | ||
610 | m_kb->load(currentSession()->profile()); | 617 | m_kb->load(currentSession()->profile()); |
611 | } | 618 | } |
612 | } | 619 | } |
613 | 620 | ||
614 | void MainWindow::slotWrap() | 621 | void MainWindow::slotWrap() |
615 | { | 622 | { |
616 | if(m_curSession) | 623 | if(m_curSession) |
617 | { | 624 | { |
618 | EmulationHandler *e = m_curSession->emulationHandler(); | 625 | EmulationHandler *e = m_curSession->emulationHandler(); |
619 | if(e) | 626 | if(e) |
620 | { | 627 | { |
621 | if(m_isWrapped) | 628 | if(m_isWrapped) |
622 | { | 629 | { |
623 | e->setWrap(80); | 630 | e->setWrap(80); |
624 | m_isWrapped = false; | 631 | m_isWrapped = false; |
625 | } | 632 | } |
626 | else | 633 | else |
627 | { | 634 | { |
628 | e->setWrap(0); | 635 | e->setWrap(0); |
629 | m_isWrapped = true; | 636 | m_isWrapped = true; |
630 | } | 637 | } |
631 | } | 638 | } |
632 | } | 639 | } |
633 | } | 640 | } |
634 | 641 | ||
635 | void MainWindow::slotFullscreen() { | 642 | void MainWindow::slotFullscreen() { |
636 | 643 | ||
637 | 644 | ||
638 | 645 | ||
639 | if ( m_isFullscreen ) { | 646 | if ( m_isFullscreen ) { |
640 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 647 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
641 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 648 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
642 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 649 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
643 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 650 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
644 | 651 | ||
645 | } else { | 652 | } else { |
646 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 653 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
647 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 654 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
648 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 655 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
649 | , QPoint(0,0), false ); | 656 | , QPoint(0,0), false ); |
650 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 657 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
651 | ( m_curSession->widgetStack() )->setFocus(); | 658 | ( m_curSession->widgetStack() )->setFocus(); |
652 | ( m_curSession->widgetStack() )->show(); | 659 | ( m_curSession->widgetStack() )->show(); |
653 | 660 | ||
654 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 661 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
655 | 662 | ||
656 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 663 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
657 | } | 664 | } |
658 | 665 | ||
659 | m_isFullscreen = !m_isFullscreen; | 666 | m_isFullscreen = !m_isFullscreen; |
660 | } | 667 | } |
661 | 668 | ||
662 | 669 | ||
663 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 670 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
664 | 671 | ||
665 | if ( m_curSession ) { | 672 | if ( m_curSession ) { |
666 | 673 | ||
667 | QEvent::Type state; | 674 | QEvent::Type state; |
668 | 675 | ||
669 | if (pressed) state = QEvent::KeyPress; | 676 | if (pressed) state = QEvent::KeyPress; |
670 | else state = QEvent::KeyRelease; | 677 | else state = QEvent::KeyRelease; |
671 | 678 | ||
672 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 679 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
673 | 680 | ||
674 | // is this the best way to do this? cant figure out any other way to work | 681 | // is this the best way to do this? cant figure out any other way to work |
675 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 682 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
676 | ke.ignore(); | 683 | ke.ignore(); |
677 | } | 684 | } |
678 | } | 685 | } |
679 | void MainWindow::slotCopy() { | 686 | void MainWindow::slotCopy() { |
680 | if (!currentSession() ) return; | 687 | if (!currentSession() ) return; |
681 | currentSession()->emulationHandler()->copy(); | 688 | currentSession()->emulationHandler()->copy(); |
682 | } | 689 | } |
683 | void MainWindow::slotPaste() { | 690 | void MainWindow::slotPaste() { |
684 | if (!currentSession() ) return; | 691 | if (!currentSession() ) return; |
685 | currentSession()->emulationHandler()->paste(); | 692 | currentSession()->emulationHandler()->paste(); |
686 | } | 693 | } |
687 | 694 | ||
688 | /* | 695 | /* |
689 | * Save the session | 696 | * Save the session |
690 | */ | 697 | */ |
691 | 698 | ||
692 | void MainWindow::slotSaveSession() { | 699 | void MainWindow::slotSaveSession() { |
693 | if (!currentSession() ) { | 700 | if (!currentSession() ) { |
694 | QMessageBox::information(this, tr("Save Connection"), | 701 | QMessageBox::information(this, tr("Save Connection"), |
695 | tr("<qt>There is no Connection.</qt>"), 1 ); | 702 | tr("<qt>There is no Connection.</qt>"), 1 ); |
696 | return; | 703 | return; |
697 | } | 704 | } |
698 | manager()->add( currentSession()->profile() ); | 705 | manager()->add( currentSession()->profile() ); |
699 | manager()->save(); | 706 | manager()->save(); |
700 | populateProfiles(); | 707 | populateProfiles(); |
701 | } | 708 | } |
702 | void MainWindow::slotSaveHistory() { | 709 | void MainWindow::slotSaveHistory() { |
703 | QMap<QString, QStringList> map; | 710 | QMap<QString, QStringList> map; |
704 | QStringList text; | 711 | QStringList text; |
705 | text << "text/plain"; | 712 | text << "text/plain"; |
706 | map.insert(tr("History"), text ); | 713 | map.insert(tr("History"), text ); |
707 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 714 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
708 | if (filename.isEmpty() ) return; | 715 | if (filename.isEmpty() ) return; |
709 | 716 | ||
710 | QFileInfo info(filename); | 717 | QFileInfo info(filename); |
711 | 718 | ||
712 | DocLnk nf; | 719 | DocLnk nf; |
713 | nf.setType("text/plain"); | 720 | nf.setType("text/plain"); |
714 | nf.setFile(filename); | 721 | nf.setFile(filename); |
715 | nf.setName(info.fileName()); | 722 | nf.setName(info.fileName()); |
716 | 723 | ||
717 | 724 | ||
718 | QFile file(filename); | 725 | QFile file(filename); |
719 | file.open(IO_WriteOnly ); | 726 | file.open(IO_WriteOnly ); |
720 | QTextStream str(&file ); | 727 | QTextStream str(&file ); |
721 | if ( currentSession() ) | 728 | if ( currentSession() ) |
722 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); | 729 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); |
723 | 730 | ||
724 | file.close(); | 731 | file.close(); |
725 | nf.writeLink(); | 732 | nf.writeLink(); |
726 | } | 733 | } |