-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 15290ce..1a5a59f 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,412 +1,412 @@ | |||
1 | #include "TEmulation.h" | 1 | #include "TEmulation.h" |
2 | #include "profileeditordialog.h" | 2 | #include "profileeditordialog.h" |
3 | #include "configdialog.h" | 3 | #include "configdialog.h" |
4 | #include "default.h" | 4 | #include "default.h" |
5 | #include "profilemanager.h" | 5 | #include "profilemanager.h" |
6 | #include "mainwindow.h" | 6 | #include "mainwindow.h" |
7 | #include "tabwidget.h" | 7 | #include "tabwidget.h" |
8 | #include "transferdialog.h" | 8 | #include "transferdialog.h" |
9 | #include "function_keyboard.h" | 9 | #include "function_keyboard.h" |
10 | #include "emulation_handler.h" | 10 | #include "emulation_handler.h" |
11 | #include "script.h" | 11 | #include "script.h" |
12 | #include "fixit.h" | 12 | #include "fixit.h" |
13 | 13 | ||
14 | /* OPIE */ | 14 | /* OPIE */ |
15 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
16 | #include <opie2/ofiledialog.h> | 16 | #include <opie2/ofiledialog.h> |
17 | #include <qpe/filemanager.h> | 17 | #include <qpe/filemanager.h> |
18 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
19 | using namespace Opie::Ui; | 19 | using namespace Opie::Ui; |
20 | 20 | ||
21 | /* QT */ | 21 | /* QT */ |
22 | #include <qaction.h> | 22 | #include <qaction.h> |
23 | #include <qmenubar.h> | 23 | #include <qmenubar.h> |
24 | #include <qtoolbar.h> | 24 | #include <qtoolbar.h> |
25 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
26 | #include <qwhatsthis.h> | 26 | #include <qwhatsthis.h> |
27 | #include <qfileinfo.h> | 27 | #include <qfileinfo.h> |
28 | 28 | ||
29 | /* STD */ | 29 | /* STD */ |
30 | #include <assert.h> | 30 | #include <assert.h> |
31 | 31 | ||
32 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 32 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
33 | #ifdef FSCKED_DISTRI | 33 | #ifdef FSCKED_DISTRI |
34 | FixIt fix; | 34 | FixIt fix; |
35 | fix.fixIt(); | 35 | fix.fixIt(); |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | setCaption(QObject::tr("Opie Console") ); | 38 | setCaption(QObject::tr("Opie Console") ); |
39 | KeyTrans::loadAll(); | 39 | KeyTrans::loadAll(); |
40 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 40 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
41 | KeyTrans* s = KeyTrans::find(i ); | 41 | KeyTrans* s = KeyTrans::find(i ); |
42 | assert( s ); | 42 | assert( s ); |
43 | } | 43 | } |
44 | m_factory = new MetaFactory(); | 44 | m_factory = new MetaFactory(); |
45 | Default def(m_factory); | 45 | Default def(m_factory); |
46 | m_sessions.setAutoDelete( TRUE ); | 46 | m_sessions.setAutoDelete( TRUE ); |
47 | m_curSession = 0; | 47 | m_curSession = 0; |
48 | m_manager = new ProfileManager( m_factory ); | 48 | m_manager = new ProfileManager( m_factory ); |
49 | m_manager->load(); | 49 | m_manager->load(); |
50 | m_scriptsData.setAutoDelete(TRUE); | 50 | m_scriptsData.setAutoDelete(TRUE); |
51 | 51 | ||
52 | initUI(); | 52 | initUI(); |
53 | populateProfiles(); | 53 | populateProfiles(); |
54 | populateScripts(); | 54 | populateScripts(); |
55 | } | 55 | } |
56 | 56 | ||
57 | void MainWindow::initUI() { | 57 | void MainWindow::initUI() { |
58 | 58 | ||
59 | setToolBarsMovable( FALSE ); | 59 | setToolBarsMovable( FALSE ); |
60 | 60 | ||
61 | /* tool bar for the menu */ | 61 | /* tool bar for the menu */ |
62 | m_tool = new QToolBar( this ); | 62 | m_tool = new QToolBar( this ); |
63 | m_tool->setHorizontalStretchable( TRUE ); | 63 | m_tool->setHorizontalStretchable( TRUE ); |
64 | 64 | ||
65 | m_bar = new QMenuBar( m_tool ); | 65 | m_bar = new QMenuBar( m_tool ); |
66 | m_console = new QPopupMenu( this ); | 66 | m_console = new QPopupMenu( this ); |
67 | m_scripts = new QPopupMenu( this ); | 67 | m_scripts = new QPopupMenu( this ); |
68 | m_sessionsPop= new QPopupMenu( this ); | 68 | m_sessionsPop= new QPopupMenu( this ); |
69 | m_scriptsPop = new QPopupMenu( this ); | 69 | m_scriptsPop = new QPopupMenu( this ); |
70 | 70 | ||
71 | /* add a toolbar for icons */ | 71 | /* add a toolbar for icons */ |
72 | m_icons = new QToolBar(this); | 72 | m_icons = new QToolBar(this); |
73 | 73 | ||
74 | /* | 74 | /* |
75 | * the settings action | 75 | * the settings action |
76 | */ | 76 | */ |
77 | m_setProfiles = new QAction(tr("Configure Profiles"), | 77 | m_setProfiles = new QAction(tr("Configure Profiles"), |
78 | Resource::loadPixmap( "SettingsIcon" ), | 78 | Resource::loadPixmap( "SettingsIcon" ), |
79 | QString::null, 0, this, 0); | 79 | QString::null, 0, this, 0); |
80 | m_setProfiles->addTo( m_console ); | 80 | m_setProfiles->addTo( m_console ); |
81 | connect( m_setProfiles, SIGNAL(activated() ), | 81 | connect( m_setProfiles, SIGNAL(activated() ), |
82 | this, SLOT(slotConfigure() ) ); | 82 | this, SLOT(slotConfigure() ) ); |
83 | 83 | ||
84 | m_console->insertSeparator(); | 84 | m_console->insertSeparator(); |
85 | /* | 85 | /* |
86 | * new Action for new sessions | 86 | * new Action for new sessions |
87 | */ | 87 | */ |
88 | QAction* newCon = new QAction(tr("New Profile"), | 88 | QAction* newCon = new QAction(tr("New Profile"), |
89 | Resource::loadPixmap( "new" ), | 89 | Resource::loadPixmap( "new" ), |
90 | QString::null, 0, this, 0); | 90 | QString::null, 0, this, 0); |
91 | newCon->addTo( m_console ); | 91 | newCon->addTo( m_console ); |
92 | connect( newCon, SIGNAL(activated() ), | 92 | connect( newCon, SIGNAL(activated() ), |
93 | this, SLOT(slotNew() ) ); | 93 | this, SLOT(slotNew() ) ); |
94 | 94 | ||
95 | m_console->insertSeparator(); | 95 | m_console->insertSeparator(); |
96 | 96 | ||
97 | QAction *saveCon = new QAction( tr("Save Profile" ), | 97 | QAction *saveCon = new QAction( tr("Save Profile" ), |
98 | Resource::loadPixmap( "save" ), QString::null, | 98 | Resource::loadPixmap( "save" ), QString::null, |
99 | 0, this, 0 ); | 99 | 0, this, 0 ); |
100 | saveCon->addTo( m_console ); | 100 | saveCon->addTo( m_console ); |
101 | connect( saveCon, SIGNAL(activated() ), | 101 | connect( saveCon, SIGNAL(activated() ), |
102 | this, SLOT(slotSaveSession() ) ); | 102 | this, SLOT(slotSaveSession() ) ); |
103 | m_console->insertSeparator(); | 103 | m_console->insertSeparator(); |
104 | 104 | ||
105 | /* | 105 | /* |
106 | * connect action | 106 | * connect action |
107 | */ | 107 | */ |
108 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), | 108 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), |
109 | QString::null, 0, this, 0 ); | 109 | QString::null, 0, this, 0 ); |
110 | m_connect->addTo( m_console ); | 110 | m_connect->addTo( m_console ); |
111 | connect(m_connect, SIGNAL(activated() ), | 111 | connect(m_connect, SIGNAL(activated() ), |
112 | this, SLOT(slotConnect() ) ); | 112 | this, SLOT(slotConnect() ) ); |
113 | 113 | ||
114 | /* | 114 | /* |
115 | * disconnect action | 115 | * disconnect action |
116 | */ | 116 | */ |
117 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), | 117 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), |
118 | QString::null, 0, this, 0 ); | 118 | QString::null, 0, this, 0 ); |
119 | m_disconnect->addTo( m_console ); | 119 | m_disconnect->addTo( m_console ); |
120 | connect(m_disconnect, SIGNAL(activated() ), | 120 | connect(m_disconnect, SIGNAL(activated() ), |
121 | this, SLOT(slotDisconnect() ) ); | 121 | this, SLOT(slotDisconnect() ) ); |
122 | 122 | ||
123 | m_console->insertSeparator(); | 123 | m_console->insertSeparator(); |
124 | 124 | ||
125 | 125 | ||
126 | m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); | 126 | m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); |
127 | m_quickLaunch->addTo( m_icons ); | 127 | m_quickLaunch->addTo( m_icons ); |
128 | connect( m_quickLaunch, SIGNAL( activated() ), | 128 | connect( m_quickLaunch, SIGNAL( activated() ), |
129 | this, SLOT( slotQuickLaunch() ) ); | 129 | this, SLOT( slotQuickLaunch() ) ); |
130 | 130 | ||
131 | QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); | 131 | QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); |
132 | 132 | ||
133 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, | 133 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, |
134 | 0, this, 0 ); | 134 | 0, this, 0 ); |
135 | m_transfer->addTo( m_console ); | 135 | m_transfer->addTo( m_console ); |
136 | connect(m_transfer, SIGNAL(activated() ), | 136 | connect(m_transfer, SIGNAL(activated() ), |
137 | this, SLOT(slotTransfer() ) ); | 137 | this, SLOT(slotTransfer() ) ); |
138 | 138 | ||
139 | 139 | ||
140 | 140 | ||
141 | /* | 141 | /* |
142 | * immediate change of line wrap policy | 142 | * immediate change of line wrap policy |
143 | */ | 143 | */ |
144 | m_isWrapped = true; | 144 | m_isWrapped = true; |
145 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true ); | 145 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true ); |
146 | m_wrap->addTo( m_console ); | 146 | m_wrap->addTo( m_console ); |
147 | m_wrap->setOn( true ); | 147 | m_wrap->setOn( true ); |
148 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); | 148 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); |
149 | 149 | ||
150 | /* | 150 | /* |
151 | * fullscreen | 151 | * fullscreen |
152 | */ | 152 | */ |
153 | m_isFullscreen = false; | 153 | m_isFullscreen = false; |
154 | 154 | ||
155 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 155 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
156 | , QString::null, 0, this, 0, true ); | 156 | , QString::null, 0, this, 0 ); |
157 | m_fullscreen->addTo( m_console ); | 157 | m_fullscreen->addTo( m_console ); |
158 | connect( m_fullscreen, SIGNAL( activated() ), | 158 | connect( m_fullscreen, SIGNAL( activated() ), |
159 | this, SLOT( slotFullscreen() ) ); | 159 | this, SLOT( slotFullscreen() ) ); |
160 | 160 | ||
161 | m_console->insertSeparator(); | 161 | m_console->insertSeparator(); |
162 | 162 | ||
163 | QAction *a = new QAction(); | 163 | QAction *a = new QAction(); |
164 | a->setText( tr("Save history") ); | 164 | a->setText( tr("Save history") ); |
165 | a->addTo( m_console ); | 165 | a->addTo( m_console ); |
166 | connect(a, SIGNAL(activated() ), | 166 | connect(a, SIGNAL(activated() ), |
167 | this, SLOT(slotSaveHistory() ) ); | 167 | this, SLOT(slotSaveHistory() ) ); |
168 | /* | 168 | /* |
169 | * terminate action | 169 | * terminate action |
170 | */ | 170 | */ |
171 | m_terminate = new QAction(); | 171 | m_terminate = new QAction(); |
172 | m_terminate->setText( tr("Terminate") ); | 172 | m_terminate->setText( tr("Terminate") ); |
173 | m_terminate->addTo( m_console ); | 173 | m_terminate->addTo( m_console ); |
174 | connect(m_terminate, SIGNAL(activated() ), | 174 | connect(m_terminate, SIGNAL(activated() ), |
175 | this, SLOT(slotTerminate() ) ); | 175 | this, SLOT(slotTerminate() ) ); |
176 | 176 | ||
177 | m_closewindow = new QAction(); | 177 | m_closewindow = new QAction(); |
178 | m_closewindow->setText( tr("Close Window") ); | 178 | m_closewindow->setText( tr("Close Window") ); |
179 | m_closewindow->addTo( m_console ); | 179 | m_closewindow->addTo( m_console ); |
180 | connect( m_closewindow, SIGNAL(activated() ), | 180 | connect( m_closewindow, SIGNAL(activated() ), |
181 | this, SLOT(slotClose() ) ); | 181 | this, SLOT(slotClose() ) ); |
182 | 182 | ||
183 | 183 | ||
184 | /* | 184 | /* |
185 | * script actions | 185 | * script actions |
186 | */ | 186 | */ |
187 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | 187 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); |
188 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | 188 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); |
189 | 189 | ||
190 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 190 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
191 | m_recordScript->addTo(m_scripts); | 191 | m_recordScript->addTo(m_scripts); |
192 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 192 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
193 | 193 | ||
194 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 194 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
195 | m_saveScript->addTo(m_scripts); | 195 | m_saveScript->addTo(m_scripts); |
196 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 196 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
197 | 197 | ||
198 | 198 | ||
199 | /* | 199 | /* |
200 | * action that open/closes the keyboard | 200 | * action that open/closes the keyboard |
201 | */ | 201 | */ |
202 | m_openKeys = new QAction (tr("Open Keyboard..."), | 202 | m_openKeys = new QAction (tr("Open Keyboard..."), |
203 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 203 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
204 | QString::null, 0, this, 0); | 204 | QString::null, 0, this, 0); |
205 | m_openKeys->setToggleAction(true); | 205 | m_openKeys->setToggleAction(true); |
206 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 206 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
207 | 207 | ||
208 | /* insert the submenu */ | 208 | /* insert the submenu */ |
209 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 209 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
210 | -1, 0); | 210 | -1, 0); |
211 | 211 | ||
212 | /* insert the connection menu */ | 212 | /* insert the connection menu */ |
213 | m_bar->insertItem( tr("Connection"), m_console ); | 213 | m_bar->insertItem( tr("Connection"), m_console ); |
214 | 214 | ||
215 | /* the scripts menu */ | 215 | /* the scripts menu */ |
216 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 216 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
217 | 217 | ||
218 | /* and the keyboard */ | 218 | /* and the keyboard */ |
219 | m_keyBar = new QToolBar(this); | 219 | m_keyBar = new QToolBar(this); |
220 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 220 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
221 | m_keyBar->setHorizontalStretchable( TRUE ); | 221 | m_keyBar->setHorizontalStretchable( TRUE ); |
222 | m_keyBar->hide(); | 222 | m_keyBar->hide(); |
223 | 223 | ||
224 | m_kb = new FunctionKeyboard(m_keyBar); | 224 | m_kb = new FunctionKeyboard(m_keyBar); |
225 | connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), | 225 | connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), |
226 | this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); | 226 | this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); |
227 | 227 | ||
228 | 228 | ||
229 | a = new QAction(tr("Copy"), | 229 | a = new QAction(tr("Copy"), |
230 | Resource::loadPixmap("copy"), QString::null, | 230 | Resource::loadPixmap("copy"), QString::null, |
231 | 0, this, 0 ); | 231 | 0, this, 0 ); |
232 | //a->addTo( m_icons ); | 232 | //a->addTo( m_icons ); |
233 | connect( a, SIGNAL(activated() ), | 233 | connect( a, SIGNAL(activated() ), |
234 | this, SLOT(slotCopy() ) ); | 234 | this, SLOT(slotCopy() ) ); |
235 | 235 | ||
236 | QAction *paste = new QAction(tr("Paste"), | 236 | QAction *paste = new QAction(tr("Paste"), |
237 | Resource::loadPixmap("paste"), QString::null, | 237 | Resource::loadPixmap("paste"), QString::null, |
238 | 0, this, 0 ); | 238 | 0, this, 0 ); |
239 | connect( paste, SIGNAL(activated() ), | 239 | connect( paste, SIGNAL(activated() ), |
240 | this, SLOT(slotPaste() ) ); | 240 | this, SLOT(slotPaste() ) ); |
241 | 241 | ||
242 | 242 | ||
243 | newCon->addTo( m_icons ); | 243 | newCon->addTo( m_icons ); |
244 | //m_setProfiles->addTo( m_icons ); | 244 | //m_setProfiles->addTo( m_icons ); |
245 | paste->addTo( m_icons ); | 245 | paste->addTo( m_icons ); |
246 | m_openKeys->addTo(m_icons); | 246 | m_openKeys->addTo(m_icons); |
247 | m_fullscreen->addTo( m_icons ); | 247 | m_fullscreen->addTo( m_icons ); |
248 | 248 | ||
249 | m_connect->setEnabled( false ); | 249 | m_connect->setEnabled( false ); |
250 | m_disconnect->setEnabled( false ); | 250 | m_disconnect->setEnabled( false ); |
251 | m_terminate->setEnabled( false ); | 251 | m_terminate->setEnabled( false ); |
252 | m_transfer->setEnabled( false ); | 252 | m_transfer->setEnabled( false ); |
253 | m_scripts->setItemEnabled(m_runScript_id, false); | 253 | m_scripts->setItemEnabled(m_runScript_id, false); |
254 | m_recordScript->setEnabled( false ); | 254 | m_recordScript->setEnabled( false ); |
255 | m_saveScript->setEnabled( false ); | 255 | m_saveScript->setEnabled( false ); |
256 | m_fullscreen->setEnabled( false ); | 256 | m_fullscreen->setEnabled( false ); |
257 | m_closewindow->setEnabled( false ); | 257 | m_closewindow->setEnabled( false ); |
258 | m_wrap->setEnabled( false ); | 258 | m_wrap->setEnabled( false ); |
259 | 259 | ||
260 | /* | 260 | /* |
261 | * connect to the menu activation | 261 | * connect to the menu activation |
262 | */ | 262 | */ |
263 | connect( m_sessionsPop, SIGNAL(activated(int) ), | 263 | connect( m_sessionsPop, SIGNAL(activated(int) ), |
264 | this, SLOT(slotProfile(int) ) ); | 264 | this, SLOT(slotProfile(int) ) ); |
265 | 265 | ||
266 | m_consoleWindow = new TabWidget( this, "blah"); | 266 | m_consoleWindow = new TabWidget( this, "blah"); |
267 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 267 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
268 | this, SLOT(slotSessionChanged(Session*) ) ); | 268 | this, SLOT(slotSessionChanged(Session*) ) ); |
269 | setCentralWidget( m_consoleWindow ); | 269 | setCentralWidget( m_consoleWindow ); |
270 | 270 | ||
271 | slotQuickLaunch(); | 271 | slotQuickLaunch(); |
272 | } | 272 | } |
273 | 273 | ||
274 | ProfileManager* MainWindow::manager() { | 274 | ProfileManager* MainWindow::manager() { |
275 | return m_manager; | 275 | return m_manager; |
276 | } | 276 | } |
277 | TabWidget* MainWindow::tabWidget() { | 277 | TabWidget* MainWindow::tabWidget() { |
278 | return m_consoleWindow; | 278 | return m_consoleWindow; |
279 | } | 279 | } |
280 | void MainWindow::populateProfiles() { | 280 | void MainWindow::populateProfiles() { |
281 | m_sessionsPop->clear(); | 281 | m_sessionsPop->clear(); |
282 | Profile::ValueList list = manager()->all(); | 282 | Profile::ValueList list = manager()->all(); |
283 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 283 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
284 | m_sessionsPop->insertItem( (*it).name() ); | 284 | m_sessionsPop->insertItem( (*it).name() ); |
285 | } | 285 | } |
286 | 286 | ||
287 | } | 287 | } |
288 | 288 | ||
289 | void MainWindow::populateScripts() { | 289 | void MainWindow::populateScripts() { |
290 | m_scriptsPop->clear(); | 290 | m_scriptsPop->clear(); |
291 | m_scriptsData.clear(); | 291 | m_scriptsData.clear(); |
292 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | 292 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); |
293 | QListIterator<DocLnk> dit(files.children()); | 293 | QListIterator<DocLnk> dit(files.children()); |
294 | for (; dit.current(); ++dit) { | 294 | for (; dit.current(); ++dit) { |
295 | if (*dit && (*dit)->name().length()>0) { | 295 | if (*dit && (*dit)->name().length()>0) { |
296 | QFileInfo info((*dit)->file()); | 296 | QFileInfo info((*dit)->file()); |
297 | if (info.extension(false) == "script") { | 297 | if (info.extension(false) == "script") { |
298 | m_scriptsData.append(new DocLnk(**dit)); | 298 | m_scriptsData.append(new DocLnk(**dit)); |
299 | m_scriptsPop->insertItem((*dit)->name()); | 299 | m_scriptsPop->insertItem((*dit)->name()); |
300 | } | 300 | } |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | } | 304 | } |
305 | 305 | ||
306 | MainWindow::~MainWindow() { | 306 | MainWindow::~MainWindow() { |
307 | delete m_factory; | 307 | delete m_factory; |
308 | manager()->save(); | 308 | manager()->save(); |
309 | #ifdef FSCKED_DISTRI | 309 | #ifdef FSCKED_DISTRI |
310 | FixIt fix; | 310 | FixIt fix; |
311 | fix.breakIt(); | 311 | fix.breakIt(); |
312 | #endif | 312 | #endif |
313 | } | 313 | } |
314 | 314 | ||
315 | MetaFactory* MainWindow::factory() { | 315 | MetaFactory* MainWindow::factory() { |
316 | return m_factory; | 316 | return m_factory; |
317 | } | 317 | } |
318 | 318 | ||
319 | Session* MainWindow::currentSession() { | 319 | Session* MainWindow::currentSession() { |
320 | return m_curSession; | 320 | return m_curSession; |
321 | } | 321 | } |
322 | 322 | ||
323 | QList<Session> MainWindow::sessions() { | 323 | QList<Session> MainWindow::sessions() { |
324 | return m_sessions; | 324 | return m_sessions; |
325 | } | 325 | } |
326 | 326 | ||
327 | void MainWindow::slotNew() { | 327 | void MainWindow::slotNew() { |
328 | ProfileEditorDialog dlg(factory() ); | 328 | ProfileEditorDialog dlg(factory() ); |
329 | dlg.setCaption( tr("New Connection") ); | 329 | dlg.setCaption( tr("New Connection") ); |
330 | int ret = QPEApplication::execDialog( &dlg ); | 330 | int ret = QPEApplication::execDialog( &dlg ); |
331 | 331 | ||
332 | if ( ret == QDialog::Accepted ) { | 332 | if ( ret == QDialog::Accepted ) { |
333 | create( dlg.profile() ); | 333 | create( dlg.profile() ); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | 336 | ||
337 | void MainWindow::slotRecordScript() { | 337 | void MainWindow::slotRecordScript() { |
338 | if (currentSession()) { | 338 | if (currentSession()) { |
339 | currentSession()->emulationHandler()->startRecording(); | 339 | currentSession()->emulationHandler()->startRecording(); |
340 | m_saveScript->setEnabled(true); | 340 | m_saveScript->setEnabled(true); |
341 | m_recordScript->setEnabled(false); | 341 | m_recordScript->setEnabled(false); |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | void MainWindow::slotSaveScript() { | 345 | void MainWindow::slotSaveScript() { |
346 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 346 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
347 | QMap<QString, QStringList> map; | 347 | QMap<QString, QStringList> map; |
348 | QStringList text; | 348 | QStringList text; |
349 | text << "text/plain"; | 349 | text << "text/plain"; |
350 | map.insert(tr("Script"), text ); | 350 | map.insert(tr("Script"), text ); |
351 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 351 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
352 | if (!filename.isEmpty()) { | 352 | if (!filename.isEmpty()) { |
353 | QFileInfo info(filename); | 353 | QFileInfo info(filename); |
354 | if (info.extension(FALSE) != "script") | 354 | if (info.extension(FALSE) != "script") |
355 | filename += ".script"; | 355 | filename += ".script"; |
356 | DocLnk nf; | 356 | DocLnk nf; |
357 | nf.setType("text/plain"); | 357 | nf.setType("text/plain"); |
358 | nf.setFile(filename); | 358 | nf.setFile(filename); |
359 | nf.setName(info.fileName()); | 359 | nf.setName(info.fileName()); |
360 | FileManager fm; | 360 | FileManager fm; |
361 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 361 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
362 | currentSession()->emulationHandler()->clearScript(); | 362 | currentSession()->emulationHandler()->clearScript(); |
363 | m_saveScript->setEnabled(false); | 363 | m_saveScript->setEnabled(false); |
364 | m_recordScript->setEnabled(true); | 364 | m_recordScript->setEnabled(true); |
365 | populateScripts(); | 365 | populateScripts(); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | } | 368 | } |
369 | 369 | ||
370 | void MainWindow::slotRunScript(int id) { | 370 | void MainWindow::slotRunScript(int id) { |
371 | if (currentSession()) { | 371 | if (currentSession()) { |
372 | int index = m_scriptsPop->indexOf(id); | 372 | int index = m_scriptsPop->indexOf(id); |
373 | DocLnk *lnk = m_scriptsData.at(index); | 373 | DocLnk *lnk = m_scriptsData.at(index); |
374 | QString filePath = lnk->file(); | 374 | QString filePath = lnk->file(); |
375 | Script script(filePath); | 375 | Script script(filePath); |
376 | currentSession()->emulationHandler()->runScript(&script); | 376 | currentSession()->emulationHandler()->runScript(&script); |
377 | } | 377 | } |
378 | } | 378 | } |
379 | 379 | ||
380 | void MainWindow::slotConnect() { | 380 | void MainWindow::slotConnect() { |
381 | if ( currentSession() ) { | 381 | if ( currentSession() ) { |
382 | bool ret = currentSession()->layer()->open(); | 382 | bool ret = currentSession()->layer()->open(); |
383 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 383 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
384 | QObject::tr("Failed"), | 384 | QObject::tr("Failed"), |
385 | QObject::tr("Connecting failed for this session.")); | 385 | QObject::tr("Connecting failed for this session.")); |
386 | else { | 386 | else { |
387 | m_connect->setEnabled( false ); | 387 | m_connect->setEnabled( false ); |
388 | m_disconnect->setEnabled( true ); | 388 | m_disconnect->setEnabled( true ); |
389 | 389 | ||
390 | // if it does not support file transfer, disable the menu entry | 390 | // if it does not support file transfer, disable the menu entry |
391 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 391 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
392 | m_transfer->setEnabled( false ); | 392 | m_transfer->setEnabled( false ); |
393 | } else { | 393 | } else { |
394 | m_transfer->setEnabled( true ); | 394 | m_transfer->setEnabled( true ); |
395 | } | 395 | } |
396 | 396 | ||
397 | m_recordScript->setEnabled( true ); | 397 | m_recordScript->setEnabled( true ); |
398 | m_scripts->setItemEnabled(m_runScript_id, true); | 398 | m_scripts->setItemEnabled(m_runScript_id, true); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | } | 401 | } |
402 | 402 | ||
403 | void MainWindow::slotDisconnect() { | 403 | void MainWindow::slotDisconnect() { |
404 | if ( currentSession() ) { | 404 | if ( currentSession() ) { |
405 | currentSession()->layer()->close(); | 405 | currentSession()->layer()->close(); |
406 | m_connect->setEnabled( true ); | 406 | m_connect->setEnabled( true ); |
407 | m_disconnect->setEnabled( false ); | 407 | m_disconnect->setEnabled( false ); |
408 | m_transfer->setEnabled( false ); | 408 | m_transfer->setEnabled( false ); |
409 | m_recordScript->setEnabled( false); | 409 | m_recordScript->setEnabled( false); |
410 | m_saveScript->setEnabled( false ); | 410 | m_saveScript->setEnabled( false ); |
411 | m_scripts->setItemEnabled(m_runScript_id, false); | 411 | m_scripts->setItemEnabled(m_runScript_id, false); |
412 | } | 412 | } |