author | josef <josef> | 2002-10-26 11:38:42 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-26 11:38:42 (UTC) |
commit | 2dc92ada34785bbfff8ca1202e4d53eb0606c362 (patch) (unidiff) | |
tree | c92a92b5cbb1d80962821212b9157260a9faa0f6 | |
parent | 65ada01d36dc25f053a09222e8abdb21f2fc3a2a (diff) | |
download | opie-2dc92ada34785bbfff8ca1202e4d53eb0606c362.zip opie-2dc92ada34785bbfff8ca1202e4d53eb0606c362.tar.gz opie-2dc92ada34785bbfff8ca1202e4d53eb0606c362.tar.bz2 |
- nonmodal file transfer (doesn't work yet!)
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 24 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.cpp | 10 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.h | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 15 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.h | 2 |
5 files changed, 46 insertions, 10 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index c44b359..5f6dc12 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,710 +1,720 @@ | |||
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 | #include <qfileinfo.h> | 11 | #include <qfileinfo.h> |
12 | 12 | ||
13 | #include <qpe/resource.h> | 13 | #include <qpe/resource.h> |
14 | #include <qpe/qpeapplication.h> | 14 | #include <qpe/qpeapplication.h> |
15 | #include <qpe/filemanager.h> | 15 | #include <qpe/filemanager.h> |
16 | #include <qpe/mimetype.h> | 16 | #include <qpe/mimetype.h> |
17 | 17 | ||
18 | #include <opie/ofiledialog.h> | 18 | #include <opie/ofiledialog.h> |
19 | 19 | ||
20 | #include "keytrans.h" | 20 | #include "keytrans.h" |
21 | #include "profileeditordialog.h" | 21 | #include "profileeditordialog.h" |
22 | #include "configdialog.h" | 22 | #include "configdialog.h" |
23 | #include "default.h" | 23 | #include "default.h" |
24 | #include "metafactory.h" | 24 | #include "metafactory.h" |
25 | #include "profile.h" | 25 | #include "profile.h" |
26 | #include "profilemanager.h" | 26 | #include "profilemanager.h" |
27 | #include "mainwindow.h" | 27 | #include "mainwindow.h" |
28 | #include "tabwidget.h" | 28 | #include "tabwidget.h" |
29 | #include "transferdialog.h" | 29 | #include "transferdialog.h" |
30 | #include "function_keyboard.h" | 30 | #include "function_keyboard.h" |
31 | #include "emulation_handler.h" | 31 | #include "emulation_handler.h" |
32 | #include "script.h" | 32 | #include "script.h" |
33 | 33 | ||
34 | static char * filesave_xpm[] = { | 34 | static char * filesave_xpm[] = { |
35 | "16 16 78 1", | 35 | "16 16 78 1", |
36 | " c None", | 36 | " c None", |
37 | ". c #343434", | 37 | ". c #343434", |
38 | "+ c #A0A0A0", | 38 | "+ c #A0A0A0", |
39 | "@ c #565656", | 39 | "@ c #565656", |
40 | "# c #9E9E9E", | 40 | "# c #9E9E9E", |
41 | "$ c #525252", | 41 | "$ c #525252", |
42 | "% c #929292", | 42 | "% c #929292", |
43 | "& c #676767", | 43 | "& c #676767", |
44 | "* c #848484", | 44 | "* c #848484", |
45 | "= c #666666", | 45 | "= c #666666", |
46 | "- c #D8D8D8", | 46 | "- c #D8D8D8", |
47 | "; c #FFFFFF", | 47 | "; c #FFFFFF", |
48 | "> c #DBDBDB", | 48 | "> c #DBDBDB", |
49 | ", c #636363", | 49 | ", c #636363", |
50 | "' c #989898", | 50 | "' c #989898", |
51 | ") c #2D2D2D", | 51 | ") c #2D2D2D", |
52 | "! c #909090", | 52 | "! c #909090", |
53 | "~ c #AEAEAE", | 53 | "~ c #AEAEAE", |
54 | "{ c #EAEAEA", | 54 | "{ c #EAEAEA", |
55 | "] c #575757", | 55 | "] c #575757", |
56 | "^ c #585858", | 56 | "^ c #585858", |
57 | "/ c #8A8A8A", | 57 | "/ c #8A8A8A", |
58 | "( c #828282", | 58 | "( c #828282", |
59 | "_ c #6F6F6F", | 59 | "_ c #6F6F6F", |
60 | ": c #C9C9C9", | 60 | ": c #C9C9C9", |
61 | "< c #050505", | 61 | "< c #050505", |
62 | "[ c #292929", | 62 | "[ c #292929", |
63 | "} c #777777", | 63 | "} c #777777", |
64 | "| c #616161", | 64 | "| c #616161", |
65 | "1 c #3A3A3A", | 65 | "1 c #3A3A3A", |
66 | "2 c #BEBEBE", | 66 | "2 c #BEBEBE", |
67 | "3 c #2C2C2C", | 67 | "3 c #2C2C2C", |
68 | "4 c #7C7C7C", | 68 | "4 c #7C7C7C", |
69 | "5 c #F6F6F6", | 69 | "5 c #F6F6F6", |
70 | "6 c #FCFCFC", | 70 | "6 c #FCFCFC", |
71 | "7 c #6B6B6B", | 71 | "7 c #6B6B6B", |
72 | "8 c #959595", | 72 | "8 c #959595", |
73 | "9 c #4F4F4F", | 73 | "9 c #4F4F4F", |
74 | "0 c #808080", | 74 | "0 c #808080", |
75 | "a c #767676", | 75 | "a c #767676", |
76 | "b c #818181", | 76 | "b c #818181", |
77 | "c c #B8B8B8", | 77 | "c c #B8B8B8", |
78 | "d c #FBFBFB", | 78 | "d c #FBFBFB", |
79 | "e c #F9F9F9", | 79 | "e c #F9F9F9", |
80 | "f c #CCCCCC", | 80 | "f c #CCCCCC", |
81 | "g c #030303", | 81 | "g c #030303", |
82 | "h c #737373", | 82 | "h c #737373", |
83 | "i c #7A7A7A", | 83 | "i c #7A7A7A", |
84 | "j c #7E7E7E", | 84 | "j c #7E7E7E", |
85 | "k c #6A6A6A", | 85 | "k c #6A6A6A", |
86 | "l c #FAFAFA", | 86 | "l c #FAFAFA", |
87 | "m c #505050", | 87 | "m c #505050", |
88 | "n c #9D9D9D", | 88 | "n c #9D9D9D", |
89 | "o c #333333", | 89 | "o c #333333", |
90 | "p c #7B7B7B", | 90 | "p c #7B7B7B", |
91 | "q c #787878", | 91 | "q c #787878", |
92 | "r c #696969", | 92 | "r c #696969", |
93 | "s c #494949", | 93 | "s c #494949", |
94 | "t c #555555", | 94 | "t c #555555", |
95 | "u c #949494", | 95 | "u c #949494", |
96 | "v c #E6E6E6", | 96 | "v c #E6E6E6", |
97 | "w c #424242", | 97 | "w c #424242", |
98 | "x c #515151", | 98 | "x c #515151", |
99 | "y c #535353", | 99 | "y c #535353", |
100 | "z c #3E3E3E", | 100 | "z c #3E3E3E", |
101 | "A c #D4D4D4", | 101 | "A c #D4D4D4", |
102 | "B c #0C0C0C", | 102 | "B c #0C0C0C", |
103 | "C c #353535", | 103 | "C c #353535", |
104 | "D c #474747", | 104 | "D c #474747", |
105 | "E c #ECECEC", | 105 | "E c #ECECEC", |
106 | "F c #919191", | 106 | "F c #919191", |
107 | "G c #7D7D7D", | 107 | "G c #7D7D7D", |
108 | "H c #000000", | 108 | "H c #000000", |
109 | "I c #404040", | 109 | "I c #404040", |
110 | "J c #858585", | 110 | "J c #858585", |
111 | "K c #323232", | 111 | "K c #323232", |
112 | "L c #D0D0D0", | 112 | "L c #D0D0D0", |
113 | "M c #1C1C1C", | 113 | "M c #1C1C1C", |
114 | " ...+ ", | 114 | " ...+ ", |
115 | " @#$%&..+ ", | 115 | " @#$%&..+ ", |
116 | " .*=-;;>,..+ ", | 116 | " .*=-;;>,..+ ", |
117 | " ')!~;;;;;;{]..", | 117 | " ')!~;;;;;;{]..", |
118 | " ^/(-;;;;;;;_:<", | 118 | " ^/(-;;;;;;;_:<", |
119 | " [}|;;;;;;;{12$", | 119 | " [}|;;;;;;;{12$", |
120 | " #34-55;;;;678$+", | 120 | " #34-55;;;;678$+", |
121 | " 90ab=c;dd;e1fg ", | 121 | " 90ab=c;dd;e1fg ", |
122 | " [ahij((kbl0mn$ ", | 122 | " [ahij((kbl0mn$ ", |
123 | " op^q^^7r&]s/$+ ", | 123 | " op^q^^7r&]s/$+ ", |
124 | "@btu;vbwxy]zAB ", | 124 | "@btu;vbwxy]zAB ", |
125 | "CzDEvEv;;DssF$ ", | 125 | "CzDEvEv;;DssF$ ", |
126 | "G.H{E{E{IxsJ$+ ", | 126 | "G.H{E{E{IxsJ$+ ", |
127 | " +...vEKxzLM ", | 127 | " +...vEKxzLM ", |
128 | " +...z]n$ ", | 128 | " +...z]n$ ", |
129 | " +... "}; | 129 | " +... "}; |
130 | 130 | ||
131 | 131 | ||
132 | 132 | ||
133 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 133 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
134 | KeyTrans::loadAll(); | 134 | KeyTrans::loadAll(); |
135 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 135 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
136 | KeyTrans* s = KeyTrans::find(i ); | 136 | KeyTrans* s = KeyTrans::find(i ); |
137 | assert( s ); | 137 | assert( s ); |
138 | } | 138 | } |
139 | m_factory = new MetaFactory(); | 139 | m_factory = new MetaFactory(); |
140 | Default def(m_factory); | 140 | Default def(m_factory); |
141 | m_sessions.setAutoDelete( TRUE ); | 141 | m_sessions.setAutoDelete( TRUE ); |
142 | m_curSession = 0; | 142 | m_curSession = 0; |
143 | m_manager = new ProfileManager( m_factory ); | 143 | m_manager = new ProfileManager( m_factory ); |
144 | m_manager->load(); | 144 | m_manager->load(); |
145 | m_scriptsData.setAutoDelete(TRUE); | 145 | m_scriptsData.setAutoDelete(TRUE); |
146 | 146 | ||
147 | initUI(); | 147 | initUI(); |
148 | populateProfiles(); | 148 | populateProfiles(); |
149 | populateScripts(); | 149 | populateScripts(); |
150 | } | 150 | } |
151 | void MainWindow::initUI() { | 151 | void MainWindow::initUI() { |
152 | setToolBarsMovable( FALSE ); | 152 | setToolBarsMovable( FALSE ); |
153 | 153 | ||
154 | /* tool bar for the menu */ | 154 | /* tool bar for the menu */ |
155 | m_tool = new QToolBar( this ); | 155 | m_tool = new QToolBar( this ); |
156 | m_tool->setHorizontalStretchable( TRUE ); | 156 | m_tool->setHorizontalStretchable( TRUE ); |
157 | 157 | ||
158 | m_bar = new QMenuBar( m_tool ); | 158 | m_bar = new QMenuBar( m_tool ); |
159 | m_console = new QPopupMenu( this ); | 159 | m_console = new QPopupMenu( this ); |
160 | m_scripts = new QPopupMenu( this ); | 160 | m_scripts = new QPopupMenu( this ); |
161 | m_sessionsPop= new QPopupMenu( this ); | 161 | m_sessionsPop= new QPopupMenu( this ); |
162 | m_scriptsPop = new QPopupMenu( this ); | 162 | m_scriptsPop = new QPopupMenu( this ); |
163 | 163 | ||
164 | /* add a toolbar for icons */ | 164 | /* add a toolbar for icons */ |
165 | m_icons = new QToolBar(this); | 165 | m_icons = new QToolBar(this); |
166 | 166 | ||
167 | /* | 167 | /* |
168 | * the settings action | 168 | * the settings action |
169 | */ | 169 | */ |
170 | m_setProfiles = new QAction(tr("Configure Profiles"), | 170 | m_setProfiles = new QAction(tr("Configure Profiles"), |
171 | Resource::loadPixmap( "SettingsIcon" ), | 171 | Resource::loadPixmap( "SettingsIcon" ), |
172 | QString::null, 0, this, 0); | 172 | QString::null, 0, this, 0); |
173 | m_setProfiles->addTo( m_console ); | 173 | m_setProfiles->addTo( m_console ); |
174 | connect( m_setProfiles, SIGNAL(activated() ), | 174 | connect( m_setProfiles, SIGNAL(activated() ), |
175 | this, SLOT(slotConfigure() ) ); | 175 | this, SLOT(slotConfigure() ) ); |
176 | 176 | ||
177 | m_console->insertSeparator(); | 177 | m_console->insertSeparator(); |
178 | /* | 178 | /* |
179 | * new Action for new sessions | 179 | * new Action for new sessions |
180 | */ | 180 | */ |
181 | QAction* newCon = new QAction(tr("New Connection"), | 181 | QAction* newCon = new QAction(tr("New Connection"), |
182 | Resource::loadPixmap( "new" ), | 182 | Resource::loadPixmap( "new" ), |
183 | QString::null, 0, this, 0); | 183 | QString::null, 0, this, 0); |
184 | newCon->addTo( m_console ); | 184 | newCon->addTo( m_console ); |
185 | connect( newCon, SIGNAL(activated() ), | 185 | connect( newCon, SIGNAL(activated() ), |
186 | this, SLOT(slotNew() ) ); | 186 | this, SLOT(slotNew() ) ); |
187 | 187 | ||
188 | m_console->insertSeparator(); | 188 | m_console->insertSeparator(); |
189 | 189 | ||
190 | QAction *saveCon = new QAction(tr("Save Connection"), | 190 | QAction *saveCon = new QAction(tr("Save Connection"), |
191 | QPixmap( ( const char** ) filesave_xpm ) , QString::null, | 191 | QPixmap( ( const char** ) filesave_xpm ) , QString::null, |
192 | 0, this, 0 ); | 192 | 0, this, 0 ); |
193 | saveCon->addTo( m_console ); | 193 | saveCon->addTo( m_console ); |
194 | connect( saveCon, SIGNAL(activated() ), | 194 | connect( saveCon, SIGNAL(activated() ), |
195 | this, SLOT(slotSaveSession() ) ); | 195 | this, SLOT(slotSaveSession() ) ); |
196 | m_console->insertSeparator(); | 196 | m_console->insertSeparator(); |
197 | 197 | ||
198 | /* | 198 | /* |
199 | * connect action | 199 | * connect action |
200 | */ | 200 | */ |
201 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), | 201 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), |
202 | QString::null, 0, this, 0 ); | 202 | QString::null, 0, this, 0 ); |
203 | m_connect->addTo( m_console ); | 203 | m_connect->addTo( m_console ); |
204 | connect(m_connect, SIGNAL(activated() ), | 204 | connect(m_connect, SIGNAL(activated() ), |
205 | this, SLOT(slotConnect() ) ); | 205 | this, SLOT(slotConnect() ) ); |
206 | 206 | ||
207 | /* | 207 | /* |
208 | * disconnect action | 208 | * disconnect action |
209 | */ | 209 | */ |
210 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), | 210 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), |
211 | QString::null, 0, this, 0 ); | 211 | QString::null, 0, this, 0 ); |
212 | m_disconnect->addTo( m_console ); | 212 | m_disconnect->addTo( m_console ); |
213 | connect(m_disconnect, SIGNAL(activated() ), | 213 | connect(m_disconnect, SIGNAL(activated() ), |
214 | this, SLOT(slotDisconnect() ) ); | 214 | this, SLOT(slotDisconnect() ) ); |
215 | 215 | ||
216 | m_console->insertSeparator(); | 216 | m_console->insertSeparator(); |
217 | 217 | ||
218 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, | 218 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, |
219 | 0, this, 0 ); | 219 | 0, this, 0 ); |
220 | m_transfer->addTo( m_console ); | 220 | m_transfer->addTo( m_console ); |
221 | connect(m_transfer, SIGNAL(activated() ), | 221 | connect(m_transfer, SIGNAL(activated() ), |
222 | this, SLOT(slotTransfer() ) ); | 222 | this, SLOT(slotTransfer() ) ); |
223 | 223 | ||
224 | 224 | ||
225 | /* | 225 | /* |
226 | * fullscreen | 226 | * fullscreen |
227 | */ | 227 | */ |
228 | m_isFullscreen = false; | 228 | m_isFullscreen = false; |
229 | 229 | ||
230 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 230 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
231 | , QString::null, 0, this, 0); | 231 | , QString::null, 0, this, 0); |
232 | m_fullscreen->addTo( m_console ); | 232 | m_fullscreen->addTo( m_console ); |
233 | connect( m_fullscreen, SIGNAL( activated() ), | 233 | connect( m_fullscreen, SIGNAL( activated() ), |
234 | this, SLOT( slotFullscreen() ) ); | 234 | this, SLOT( slotFullscreen() ) ); |
235 | 235 | ||
236 | m_console->insertSeparator(); | 236 | m_console->insertSeparator(); |
237 | /* | 237 | /* |
238 | * terminate action | 238 | * terminate action |
239 | */ | 239 | */ |
240 | m_terminate = new QAction(); | 240 | m_terminate = new QAction(); |
241 | m_terminate->setText( tr("Terminate") ); | 241 | m_terminate->setText( tr("Terminate") ); |
242 | m_terminate->addTo( m_console ); | 242 | m_terminate->addTo( m_console ); |
243 | connect(m_terminate, SIGNAL(activated() ), | 243 | connect(m_terminate, SIGNAL(activated() ), |
244 | this, SLOT(slotTerminate() ) ); | 244 | this, SLOT(slotTerminate() ) ); |
245 | 245 | ||
246 | m_closewindow = new QAction(); | 246 | m_closewindow = new QAction(); |
247 | m_closewindow->setText( tr("Close Window") ); | 247 | m_closewindow->setText( tr("Close Window") ); |
248 | m_closewindow->addTo( m_console ); | 248 | m_closewindow->addTo( m_console ); |
249 | connect( m_closewindow, SIGNAL(activated() ), | 249 | connect( m_closewindow, SIGNAL(activated() ), |
250 | this, SLOT(slotClose() ) ); | 250 | this, SLOT(slotClose() ) ); |
251 | 251 | ||
252 | 252 | ||
253 | /* | 253 | /* |
254 | * script actions | 254 | * script actions |
255 | */ | 255 | */ |
256 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | 256 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); |
257 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | 257 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); |
258 | 258 | ||
259 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 259 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
260 | m_recordScript->addTo(m_scripts); | 260 | m_recordScript->addTo(m_scripts); |
261 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 261 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
262 | 262 | ||
263 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 263 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
264 | m_saveScript->addTo(m_scripts); | 264 | m_saveScript->addTo(m_scripts); |
265 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 265 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
266 | 266 | ||
267 | 267 | ||
268 | /* | 268 | /* |
269 | * action that open/closes the keyboard | 269 | * action that open/closes the keyboard |
270 | */ | 270 | */ |
271 | m_openKeys = new QAction (tr("Open Keyboard..."), | 271 | m_openKeys = new QAction (tr("Open Keyboard..."), |
272 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 272 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
273 | QString::null, 0, this, 0); | 273 | QString::null, 0, this, 0); |
274 | m_openKeys->setToggleAction(true); | 274 | m_openKeys->setToggleAction(true); |
275 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 275 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
276 | 276 | ||
277 | /* insert the submenu */ | 277 | /* insert the submenu */ |
278 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 278 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
279 | -1, 0); | 279 | -1, 0); |
280 | 280 | ||
281 | /* insert the connection menu */ | 281 | /* insert the connection menu */ |
282 | m_bar->insertItem( tr("Connection"), m_console ); | 282 | m_bar->insertItem( tr("Connection"), m_console ); |
283 | 283 | ||
284 | /* the scripts menu */ | 284 | /* the scripts menu */ |
285 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 285 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
286 | 286 | ||
287 | /* and the keyboard */ | 287 | /* and the keyboard */ |
288 | m_keyBar = new QToolBar(this); | 288 | m_keyBar = new QToolBar(this); |
289 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 289 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
290 | m_keyBar->setHorizontalStretchable( TRUE ); | 290 | m_keyBar->setHorizontalStretchable( TRUE ); |
291 | m_keyBar->hide(); | 291 | m_keyBar->hide(); |
292 | 292 | ||
293 | m_kb = new FunctionKeyboard(m_keyBar); | 293 | m_kb = new FunctionKeyboard(m_keyBar); |
294 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 294 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
295 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); | 295 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
296 | 296 | ||
297 | 297 | ||
298 | QAction *a = new QAction(tr("Copy"), | 298 | QAction *a = new QAction(tr("Copy"), |
299 | Resource::loadPixmap("copy"), QString::null, | 299 | Resource::loadPixmap("copy"), QString::null, |
300 | 0, this, 0 ); | 300 | 0, this, 0 ); |
301 | //a->addTo( m_icons ); | 301 | //a->addTo( m_icons ); |
302 | connect( a, SIGNAL(activated() ), | 302 | connect( a, SIGNAL(activated() ), |
303 | this, SLOT(slotCopy() ) ); | 303 | this, SLOT(slotCopy() ) ); |
304 | 304 | ||
305 | QAction *paste = new QAction(tr("Paste"), | 305 | QAction *paste = new QAction(tr("Paste"), |
306 | Resource::loadPixmap("paste"), QString::null, | 306 | Resource::loadPixmap("paste"), QString::null, |
307 | 0, this, 0 ); | 307 | 0, this, 0 ); |
308 | connect( paste, SIGNAL(activated() ), | 308 | connect( paste, SIGNAL(activated() ), |
309 | this, SLOT(slotPaste() ) ); | 309 | this, SLOT(slotPaste() ) ); |
310 | 310 | ||
311 | 311 | ||
312 | newCon->addTo( m_icons ); | 312 | newCon->addTo( m_icons ); |
313 | m_setProfiles->addTo( m_icons ); | 313 | m_setProfiles->addTo( m_icons ); |
314 | paste->addTo( m_icons ); | 314 | paste->addTo( m_icons ); |
315 | m_openKeys->addTo(m_icons); | 315 | m_openKeys->addTo(m_icons); |
316 | m_fullscreen->addTo( m_icons ); | 316 | m_fullscreen->addTo( m_icons ); |
317 | 317 | ||
318 | m_connect->setEnabled( false ); | 318 | m_connect->setEnabled( false ); |
319 | m_disconnect->setEnabled( false ); | 319 | m_disconnect->setEnabled( false ); |
320 | m_terminate->setEnabled( false ); | 320 | m_terminate->setEnabled( false ); |
321 | m_transfer->setEnabled( false ); | 321 | m_transfer->setEnabled( false ); |
322 | m_scripts->setItemEnabled(m_runScript_id, false); | 322 | m_scripts->setItemEnabled(m_runScript_id, false); |
323 | m_recordScript->setEnabled( false ); | 323 | m_recordScript->setEnabled( false ); |
324 | m_saveScript->setEnabled( false ); | 324 | m_saveScript->setEnabled( false ); |
325 | m_fullscreen->setEnabled( false ); | 325 | m_fullscreen->setEnabled( false ); |
326 | m_closewindow->setEnabled( false ); | 326 | m_closewindow->setEnabled( false ); |
327 | 327 | ||
328 | /* | 328 | /* |
329 | * connect to the menu activation | 329 | * connect to the menu activation |
330 | */ | 330 | */ |
331 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 331 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
332 | this, SLOT(slotProfile( int ) ) ); | 332 | this, SLOT(slotProfile( int ) ) ); |
333 | 333 | ||
334 | m_consoleWindow = new TabWidget( this, "blah"); | 334 | m_consoleWindow = new TabWidget( this, "blah"); |
335 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 335 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
336 | this, SLOT(slotSessionChanged(Session*) ) ); | 336 | this, SLOT(slotSessionChanged(Session*) ) ); |
337 | setCentralWidget( m_consoleWindow ); | 337 | setCentralWidget( m_consoleWindow ); |
338 | 338 | ||
339 | } | 339 | } |
340 | 340 | ||
341 | ProfileManager* MainWindow::manager() { | 341 | ProfileManager* MainWindow::manager() { |
342 | return m_manager; | 342 | return m_manager; |
343 | } | 343 | } |
344 | TabWidget* MainWindow::tabWidget() { | 344 | TabWidget* MainWindow::tabWidget() { |
345 | return m_consoleWindow; | 345 | return m_consoleWindow; |
346 | } | 346 | } |
347 | void MainWindow::populateProfiles() { | 347 | void MainWindow::populateProfiles() { |
348 | m_sessionsPop->clear(); | 348 | m_sessionsPop->clear(); |
349 | Profile::ValueList list = manager()->all(); | 349 | Profile::ValueList list = manager()->all(); |
350 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 350 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
351 | m_sessionsPop->insertItem( (*it).name() ); | 351 | m_sessionsPop->insertItem( (*it).name() ); |
352 | } | 352 | } |
353 | 353 | ||
354 | } | 354 | } |
355 | 355 | ||
356 | void MainWindow::populateScripts() { | 356 | void MainWindow::populateScripts() { |
357 | m_scriptsPop->clear(); | 357 | m_scriptsPop->clear(); |
358 | m_scriptsData.clear(); | 358 | m_scriptsData.clear(); |
359 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | 359 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); |
360 | QListIterator<DocLnk> dit(files.children()); | 360 | QListIterator<DocLnk> dit(files.children()); |
361 | for (; dit.current(); ++dit) { | 361 | for (; dit.current(); ++dit) { |
362 | if (*dit && (*dit)->name().length()>0) { | 362 | if (*dit && (*dit)->name().length()>0) { |
363 | QFileInfo info((*dit)->file()); | 363 | QFileInfo info((*dit)->file()); |
364 | if (info.extension(false) == "script") { | 364 | if (info.extension(false) == "script") { |
365 | m_scriptsData.append(new DocLnk(**dit)); | 365 | m_scriptsData.append(new DocLnk(**dit)); |
366 | m_scriptsPop->insertItem((*dit)->name()); | 366 | m_scriptsPop->insertItem((*dit)->name()); |
367 | } | 367 | } |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | } | 371 | } |
372 | 372 | ||
373 | MainWindow::~MainWindow() { | 373 | MainWindow::~MainWindow() { |
374 | delete m_factory; | 374 | delete m_factory; |
375 | manager()->save(); | 375 | manager()->save(); |
376 | } | 376 | } |
377 | 377 | ||
378 | MetaFactory* MainWindow::factory() { | 378 | MetaFactory* MainWindow::factory() { |
379 | return m_factory; | 379 | return m_factory; |
380 | } | 380 | } |
381 | 381 | ||
382 | Session* MainWindow::currentSession() { | 382 | Session* MainWindow::currentSession() { |
383 | return m_curSession; | 383 | return m_curSession; |
384 | } | 384 | } |
385 | 385 | ||
386 | QList<Session> MainWindow::sessions() { | 386 | QList<Session> MainWindow::sessions() { |
387 | return m_sessions; | 387 | return m_sessions; |
388 | } | 388 | } |
389 | 389 | ||
390 | void MainWindow::slotNew() { | 390 | void MainWindow::slotNew() { |
391 | ProfileEditorDialog dlg(factory() ); | 391 | ProfileEditorDialog dlg(factory() ); |
392 | dlg.showMaximized(); | 392 | dlg.showMaximized(); |
393 | dlg.setCaption( tr("New Connection") ); | 393 | dlg.setCaption( tr("New Connection") ); |
394 | int ret = dlg.exec(); | 394 | int ret = dlg.exec(); |
395 | 395 | ||
396 | if ( ret == QDialog::Accepted ) { | 396 | if ( ret == QDialog::Accepted ) { |
397 | create( dlg.profile() ); | 397 | create( dlg.profile() ); |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | void MainWindow::slotRecordScript() { | 401 | void MainWindow::slotRecordScript() { |
402 | if (currentSession()) { | 402 | if (currentSession()) { |
403 | currentSession()->emulationHandler()->startRecording(); | 403 | currentSession()->emulationHandler()->startRecording(); |
404 | m_saveScript->setEnabled(true); | 404 | m_saveScript->setEnabled(true); |
405 | m_recordScript->setEnabled(false); | 405 | m_recordScript->setEnabled(false); |
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
409 | void MainWindow::slotSaveScript() { | 409 | void MainWindow::slotSaveScript() { |
410 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 410 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
411 | QMap<QString, QStringList> map; | 411 | QMap<QString, QStringList> map; |
412 | QStringList text; | 412 | QStringList text; |
413 | text << "text/plain"; | 413 | text << "text/plain"; |
414 | map.insert(tr("Script"), text ); | 414 | map.insert(tr("Script"), text ); |
415 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 415 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
416 | if (!filename.isEmpty()) { | 416 | if (!filename.isEmpty()) { |
417 | QFileInfo info(filename); | 417 | QFileInfo info(filename); |
418 | if (info.extension(FALSE) != "script") | 418 | if (info.extension(FALSE) != "script") |
419 | filename += ".script"; | 419 | filename += ".script"; |
420 | DocLnk nf; | 420 | DocLnk nf; |
421 | nf.setType("text/plain"); | 421 | nf.setType("text/plain"); |
422 | nf.setFile(filename); | 422 | nf.setFile(filename); |
423 | nf.setName(info.fileName()); | 423 | nf.setName(info.fileName()); |
424 | FileManager fm; | 424 | FileManager fm; |
425 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 425 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
426 | currentSession()->emulationHandler()->clearScript(); | 426 | currentSession()->emulationHandler()->clearScript(); |
427 | m_saveScript->setEnabled(false); | 427 | m_saveScript->setEnabled(false); |
428 | m_recordScript->setEnabled(true); | 428 | m_recordScript->setEnabled(true); |
429 | populateScripts(); | 429 | populateScripts(); |
430 | } | 430 | } |
431 | } | 431 | } |
432 | } | 432 | } |
433 | 433 | ||
434 | void MainWindow::slotRunScript(int id) { | 434 | void MainWindow::slotRunScript(int id) { |
435 | if (currentSession()) { | 435 | if (currentSession()) { |
436 | int index = m_scriptsPop->indexOf(id); | 436 | int index = m_scriptsPop->indexOf(id); |
437 | DocLnk *lnk = m_scriptsData.at(index); | 437 | DocLnk *lnk = m_scriptsData.at(index); |
438 | QString filePath = lnk->file(); | 438 | QString filePath = lnk->file(); |
439 | Script script(filePath); | 439 | Script script(filePath); |
440 | currentSession()->emulationHandler()->runScript(&script); | 440 | currentSession()->emulationHandler()->runScript(&script); |
441 | } | 441 | } |
442 | } | 442 | } |
443 | 443 | ||
444 | void MainWindow::slotConnect() { | 444 | void MainWindow::slotConnect() { |
445 | if ( currentSession() ) { | 445 | if ( currentSession() ) { |
446 | bool ret = currentSession()->layer()->open(); | 446 | bool ret = currentSession()->layer()->open(); |
447 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 447 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
448 | QObject::tr("Failed"), | 448 | QObject::tr("Failed"), |
449 | QObject::tr("Connecting failed for this session.")); | 449 | QObject::tr("Connecting failed for this session.")); |
450 | else { | 450 | else { |
451 | m_connect->setEnabled( false ); | 451 | m_connect->setEnabled( false ); |
452 | m_disconnect->setEnabled( true ); | 452 | m_disconnect->setEnabled( true ); |
453 | m_transfer->setEnabled( true ); | 453 | m_transfer->setEnabled( true ); |
454 | m_recordScript->setEnabled( true ); | 454 | m_recordScript->setEnabled( true ); |
455 | m_scripts->setItemEnabled(m_runScript_id, true); | 455 | m_scripts->setItemEnabled(m_runScript_id, true); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | void MainWindow::slotDisconnect() { | 460 | void MainWindow::slotDisconnect() { |
461 | if ( currentSession() ) { | 461 | if ( currentSession() ) { |
462 | currentSession()->layer()->close(); | 462 | currentSession()->layer()->close(); |
463 | m_connect->setEnabled( true ); | 463 | m_connect->setEnabled( true ); |
464 | m_disconnect->setEnabled( false ); | 464 | m_disconnect->setEnabled( false ); |
465 | m_transfer->setEnabled( false ); | 465 | m_transfer->setEnabled( false ); |
466 | m_recordScript->setEnabled( false); | 466 | m_recordScript->setEnabled( false); |
467 | m_saveScript->setEnabled( false ); | 467 | m_saveScript->setEnabled( false ); |
468 | m_scripts->setItemEnabled(m_runScript_id, false); | 468 | m_scripts->setItemEnabled(m_runScript_id, false); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | 471 | ||
472 | void MainWindow::slotTerminate() { | 472 | void MainWindow::slotTerminate() { |
473 | if ( currentSession() ) | 473 | if ( currentSession() ) |
474 | currentSession()->layer()->close(); | 474 | currentSession()->layer()->close(); |
475 | 475 | ||
476 | slotClose(); | 476 | slotClose(); |
477 | /* FIXME move to the next session */ | 477 | /* FIXME move to the next session */ |
478 | } | 478 | } |
479 | 479 | ||
480 | void MainWindow::slotConfigure() { | 480 | void MainWindow::slotConfigure() { |
481 | ConfigDialog conf( manager()->all(), factory() ); | 481 | ConfigDialog conf( manager()->all(), factory() ); |
482 | conf.showMaximized(); | 482 | conf.showMaximized(); |
483 | 483 | ||
484 | int ret = conf.exec(); | 484 | int ret = conf.exec(); |
485 | 485 | ||
486 | if ( QDialog::Accepted == ret ) { | 486 | if ( QDialog::Accepted == ret ) { |
487 | manager()->setProfiles( conf.list() ); | 487 | manager()->setProfiles( conf.list() ); |
488 | manager()->save(); | 488 | manager()->save(); |
489 | populateProfiles(); | 489 | populateProfiles(); |
490 | } | 490 | } |
491 | } | 491 | } |
492 | /* | 492 | /* |
493 | * we will remove | 493 | * we will remove |
494 | * this window from the tabwidget | 494 | * this window from the tabwidget |
495 | * remove it from the list | 495 | * remove it from the list |
496 | * delete it | 496 | * delete it |
497 | * and set the currentSession() | 497 | * and set the currentSession() |
498 | */ | 498 | */ |
499 | void MainWindow::slotClose() { | 499 | void MainWindow::slotClose() { |
500 | if (!currentSession() ) | 500 | if (!currentSession() ) |
501 | return; | 501 | return; |
502 | 502 | ||
503 | Session* ses = currentSession(); | 503 | Session* ses = currentSession(); |
504 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 504 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
505 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 505 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
506 | m_curSession = NULL; | 506 | m_curSession = NULL; |
507 | tabWidget()->remove( /*currentSession()*/ses ); | 507 | tabWidget()->remove( /*currentSession()*/ses ); |
508 | /*it's autodelete */ | 508 | /*it's autodelete */ |
509 | m_sessions.remove( ses ); | 509 | m_sessions.remove( ses ); |
510 | qWarning("after remove!!"); | 510 | qWarning("after remove!!"); |
511 | 511 | ||
512 | if (!currentSession() ) { | 512 | if (!currentSession() ) { |
513 | m_connect->setEnabled( false ); | 513 | m_connect->setEnabled( false ); |
514 | m_disconnect->setEnabled( false ); | 514 | m_disconnect->setEnabled( false ); |
515 | m_terminate->setEnabled( false ); | 515 | m_terminate->setEnabled( false ); |
516 | m_transfer->setEnabled( false ); | 516 | m_transfer->setEnabled( false ); |
517 | m_recordScript->setEnabled( false ); | 517 | m_recordScript->setEnabled( false ); |
518 | m_saveScript->setEnabled( false ); | 518 | m_saveScript->setEnabled( false ); |
519 | m_scripts->setItemEnabled(m_runScript_id, false); | 519 | m_scripts->setItemEnabled(m_runScript_id, false); |
520 | m_fullscreen->setEnabled( false ); | 520 | m_fullscreen->setEnabled( false ); |
521 | m_closewindow->setEnabled( false ); | 521 | m_closewindow->setEnabled( false ); |
522 | } | 522 | } |
523 | 523 | ||
524 | m_kb->loadDefaults(); | 524 | m_kb->loadDefaults(); |
525 | } | 525 | } |
526 | 526 | ||
527 | /* | 527 | /* |
528 | * We will get the name | 528 | * We will get the name |
529 | * Then the profile | 529 | * Then the profile |
530 | * and then we will make a profile | 530 | * and then we will make a profile |
531 | */ | 531 | */ |
532 | void MainWindow::slotProfile( int id) { | 532 | void MainWindow::slotProfile( int id) { |
533 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 533 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
534 | create( prof ); | 534 | create( prof ); |
535 | } | 535 | } |
536 | void MainWindow::create( const Profile& prof ) { | 536 | void MainWindow::create( const Profile& prof ) { |
537 | if(m_curSession) | ||
538 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | ||
539 | |||
537 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 540 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
538 | 541 | ||
539 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 542 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
540 | { | 543 | { |
541 | QMessageBox::warning(this, | 544 | QMessageBox::warning(this, |
542 | QObject::tr("Session failed"), | 545 | QObject::tr("Session failed"), |
543 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 546 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
544 | //if(ses) delete ses; | 547 | //if(ses) delete ses; |
545 | return; | 548 | return; |
546 | } | 549 | } |
547 | 550 | ||
548 | m_sessions.append( ses ); | 551 | m_sessions.append( ses ); |
549 | tabWidget()->add( ses ); | 552 | tabWidget()->add( ses ); |
550 | tabWidget()->repaint(); | 553 | tabWidget()->repaint(); |
551 | m_curSession = ses; | 554 | m_curSession = ses; |
552 | 555 | ||
553 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 556 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
554 | m_connect->setEnabled( true ); | 557 | m_connect->setEnabled( true ); |
555 | m_disconnect->setEnabled( false ); | 558 | m_disconnect->setEnabled( false ); |
556 | m_terminate->setEnabled( true ); | 559 | m_terminate->setEnabled( true ); |
557 | m_fullscreen->setEnabled( true ); | 560 | m_fullscreen->setEnabled( true ); |
558 | m_closewindow->setEnabled( true ); | 561 | m_closewindow->setEnabled( true ); |
559 | m_transfer->setEnabled( false ); | 562 | m_transfer->setEnabled( false ); |
560 | m_recordScript->setEnabled( false ); | 563 | m_recordScript->setEnabled( false ); |
561 | m_saveScript->setEnabled( false ); | 564 | m_saveScript->setEnabled( false ); |
562 | m_scripts->setItemEnabled(m_runScript_id, false); | 565 | m_scripts->setItemEnabled(m_runScript_id, false); |
563 | 566 | ||
564 | // is io_layer wants direct connection, then autoconnect | 567 | // is io_layer wants direct connection, then autoconnect |
565 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 568 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
566 | if (prof.autoConnect()) { | 569 | if (prof.autoConnect()) { |
567 | slotConnect(); | 570 | slotConnect(); |
568 | } | 571 | } |
569 | 572 | ||
570 | 573 | ||
571 | 574 | ||
572 | QWidget *w = currentSession()->widget(); | 575 | QWidget *w = currentSession()->widget(); |
573 | if(w) w->setFocus(); | 576 | if(w) w->setFocus(); |
574 | 577 | ||
575 | m_kb->load(currentSession()->profile()); | 578 | m_kb->load(currentSession()->profile()); |
576 | } | 579 | } |
577 | 580 | ||
578 | void MainWindow::slotTransfer() | 581 | void MainWindow::slotTransfer() |
579 | { | 582 | { |
580 | if ( currentSession() ) { | 583 | if ( currentSession() ) { |
581 | TransferDialog dlg(currentSession()->widgetStack(), this); | 584 | Session *mysession = currentSession(); |
582 | dlg.showMaximized(); | 585 | TransferDialog dlg(mysession->widgetStack(), this); |
586 | mysession->setTransferDialog(&dlg); | ||
587 | dlg.show(); | ||
588 | //dlg.showMaximized(); | ||
583 | //currentSession()->widgetStack()->add(dlg); | 589 | //currentSession()->widgetStack()->add(dlg); |
584 | dlg.exec(); | 590 | //dlg.exec(); |
591 | while(dlg.isRunning()) qApp->processEvents(); | ||
592 | mysession->setTransferDialog(0l); | ||
585 | } | 593 | } |
586 | } | 594 | } |
587 | 595 | ||
588 | 596 | ||
589 | void MainWindow::slotOpenKeb(bool state) { | 597 | void MainWindow::slotOpenKeb(bool state) { |
590 | 598 | ||
591 | if (state) m_keyBar->show(); | 599 | if (state) m_keyBar->show(); |
592 | else m_keyBar->hide(); | 600 | else m_keyBar->hide(); |
593 | 601 | ||
594 | } | 602 | } |
595 | 603 | ||
596 | 604 | ||
597 | void MainWindow::slotOpenButtons( bool state ) { | 605 | void MainWindow::slotOpenButtons( bool state ) { |
598 | 606 | ||
599 | if ( state ) { | 607 | if ( state ) { |
600 | m_buttonBar->show(); | 608 | m_buttonBar->show(); |
601 | } else { | 609 | } else { |
602 | m_buttonBar->hide(); | 610 | m_buttonBar->hide(); |
603 | } | 611 | } |
604 | } | 612 | } |
605 | 613 | ||
606 | 614 | ||
607 | 615 | ||
608 | void MainWindow::slotSessionChanged( Session* ses ) { | 616 | void MainWindow::slotSessionChanged( Session* ses ) { |
609 | qWarning("changed!"); | 617 | qWarning("changed!"); |
618 | |||
619 | if(m_curSession) | ||
620 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | ||
621 | if(ses) | ||
622 | if(ses->transferDialog()) ses->transferDialog()->show(); | ||
623 | |||
610 | if ( ses ) { | 624 | if ( ses ) { |
611 | m_curSession = ses; | 625 | m_curSession = ses; |
612 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 626 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
613 | if ( m_curSession->layer()->isConnected() ) { | 627 | if ( m_curSession->layer()->isConnected() ) { |
614 | m_connect->setEnabled( false ); | 628 | m_connect->setEnabled( false ); |
615 | m_disconnect->setEnabled( true ); | 629 | m_disconnect->setEnabled( true ); |
616 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); | 630 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); |
617 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); | 631 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); |
618 | m_scripts->setItemEnabled(m_runScript_id, true); | 632 | m_scripts->setItemEnabled(m_runScript_id, true); |
619 | } else { | 633 | } else { |
620 | m_connect->setEnabled( true ); | 634 | m_connect->setEnabled( true ); |
621 | m_disconnect->setEnabled( false ); | 635 | m_disconnect->setEnabled( false ); |
622 | m_recordScript->setEnabled( false ); | 636 | m_recordScript->setEnabled( false ); |
623 | m_saveScript->setEnabled( false ); | 637 | m_saveScript->setEnabled( false ); |
624 | m_scripts->setItemEnabled(m_runScript_id, false); | 638 | m_scripts->setItemEnabled(m_runScript_id, false); |
625 | } | 639 | } |
626 | 640 | ||
627 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 641 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
628 | m_transfer->setEnabled( false ); | 642 | m_transfer->setEnabled( false ); |
629 | } else { | 643 | } else { |
630 | m_transfer->setEnabled( true ); | 644 | m_transfer->setEnabled( true ); |
631 | } | 645 | } |
632 | 646 | ||
633 | |||
634 | |||
635 | |||
636 | |||
637 | QWidget *w = m_curSession->widget(); | 647 | QWidget *w = m_curSession->widget(); |
638 | if(w) w->setFocus(); | 648 | if(w) w->setFocus(); |
639 | 649 | ||
640 | m_kb->load(currentSession()->profile()); | 650 | m_kb->load(currentSession()->profile()); |
641 | } | 651 | } |
642 | } | 652 | } |
643 | 653 | ||
644 | void MainWindow::slotFullscreen() { | 654 | void MainWindow::slotFullscreen() { |
645 | 655 | ||
646 | 656 | ||
647 | 657 | ||
648 | if ( m_isFullscreen ) { | 658 | if ( m_isFullscreen ) { |
649 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 659 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
650 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 660 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
651 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 661 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
652 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 662 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
653 | 663 | ||
654 | } else { | 664 | } else { |
655 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 665 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
656 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 666 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
657 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 667 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
658 | , QPoint(0,0), false ); | 668 | , QPoint(0,0), false ); |
659 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 669 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
660 | ( m_curSession->widgetStack() )->setFocus(); | 670 | ( m_curSession->widgetStack() )->setFocus(); |
661 | ( m_curSession->widgetStack() )->show(); | 671 | ( m_curSession->widgetStack() )->show(); |
662 | 672 | ||
663 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 673 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
664 | 674 | ||
665 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 675 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
666 | } | 676 | } |
667 | 677 | ||
668 | m_isFullscreen = !m_isFullscreen; | 678 | m_isFullscreen = !m_isFullscreen; |
669 | } | 679 | } |
670 | 680 | ||
671 | 681 | ||
672 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 682 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
673 | 683 | ||
674 | if ( m_curSession ) { | 684 | if ( m_curSession ) { |
675 | 685 | ||
676 | QEvent::Type state; | 686 | QEvent::Type state; |
677 | 687 | ||
678 | if (pressed) state = QEvent::KeyPress; | 688 | if (pressed) state = QEvent::KeyPress; |
679 | else state = QEvent::KeyRelease; | 689 | else state = QEvent::KeyRelease; |
680 | 690 | ||
681 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 691 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
682 | 692 | ||
683 | // is this the best way to do this? cant figure out any other way to work | 693 | // is this the best way to do this? cant figure out any other way to work |
684 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 694 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
685 | ke.ignore(); | 695 | ke.ignore(); |
686 | } | 696 | } |
687 | } | 697 | } |
688 | void MainWindow::slotCopy() { | 698 | void MainWindow::slotCopy() { |
689 | if (!currentSession() ) return; | 699 | if (!currentSession() ) return; |
690 | currentSession()->emulationHandler()->copy(); | 700 | currentSession()->emulationHandler()->copy(); |
691 | } | 701 | } |
692 | void MainWindow::slotPaste() { | 702 | void MainWindow::slotPaste() { |
693 | if (!currentSession() ) return; | 703 | if (!currentSession() ) return; |
694 | currentSession()->emulationHandler()->paste(); | 704 | currentSession()->emulationHandler()->paste(); |
695 | } | 705 | } |
696 | 706 | ||
697 | /* | 707 | /* |
698 | * Save the session | 708 | * Save the session |
699 | */ | 709 | */ |
700 | 710 | ||
701 | void MainWindow::slotSaveSession() { | 711 | void MainWindow::slotSaveSession() { |
702 | if (!currentSession() ) { | 712 | if (!currentSession() ) { |
703 | QMessageBox::information(this, tr("Save Connection"), | 713 | QMessageBox::information(this, tr("Save Connection"), |
704 | tr("<qt>There is no Connection.</qt>"), 1 ); | 714 | tr("<qt>There is no Connection.</qt>"), 1 ); |
705 | return; | 715 | return; |
706 | } | 716 | } |
707 | manager()->add( currentSession()->profile() ); | 717 | manager()->add( currentSession()->profile() ); |
708 | manager()->save(); | 718 | manager()->save(); |
709 | populateProfiles(); | 719 | populateProfiles(); |
710 | } | 720 | } |
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp index c166d95..4f52584 100644 --- a/noncore/apps/opie-console/session.cpp +++ b/noncore/apps/opie-console/session.cpp | |||
@@ -1,107 +1,117 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include "profile.h" | 3 | #include "profile.h" |
4 | #include "io_layer.h" | 4 | #include "io_layer.h" |
5 | #include "file_layer.h" | 5 | #include "file_layer.h" |
6 | #include "emulation_handler.h" | 6 | #include "emulation_handler.h" |
7 | #include "session.h" | 7 | #include "session.h" |
8 | 8 | ||
9 | 9 | ||
10 | Session::Session() { | 10 | Session::Session() { |
11 | m_widget = 0l; | 11 | m_widget = 0l; |
12 | m_layer = 0l; | 12 | m_layer = 0l; |
13 | m_emu = 0l; | 13 | m_emu = 0l; |
14 | m_transfer = 0l; | ||
14 | } | 15 | } |
15 | Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) | 16 | Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) |
16 | : m_name( na ), m_widget( widget ), m_layer( lay ) | 17 | : m_name( na ), m_widget( widget ), m_layer( lay ) |
17 | { | 18 | { |
18 | // m_widLay = 0l; | 19 | // m_widLay = 0l; |
19 | // m_emLay = 0l; | 20 | // m_emLay = 0l; |
20 | m_emu = 0l; | 21 | m_emu = 0l; |
21 | } | 22 | } |
22 | Session::~Session() { | 23 | Session::~Session() { |
23 | delete m_layer; | 24 | delete m_layer; |
24 | delete m_emu; | 25 | delete m_emu; |
25 | delete m_widget; | 26 | delete m_widget; |
26 | /* the widget layer should be deleted by the m_widget */ | 27 | /* the widget layer should be deleted by the m_widget */ |
27 | } | 28 | } |
28 | QString Session::name()const { | 29 | QString Session::name()const { |
29 | return m_name; | 30 | return m_name; |
30 | } | 31 | } |
31 | QWidgetStack* Session::widgetStack() { | 32 | QWidgetStack* Session::widgetStack() { |
32 | return m_widget; | 33 | return m_widget; |
33 | } | 34 | } |
34 | IOLayer* Session::layer() { | 35 | IOLayer* Session::layer() { |
35 | return m_layer; | 36 | return m_layer; |
36 | } | 37 | } |
37 | EmulationHandler* Session::emulationHandler() { | 38 | EmulationHandler* Session::emulationHandler() { |
38 | return m_emu; | 39 | return m_emu; |
39 | } | 40 | } |
40 | QWidget* Session::widget() { | 41 | QWidget* Session::widget() { |
41 | if (!m_emu ) | 42 | if (!m_emu ) |
42 | return 0l; | 43 | return 0l; |
43 | 44 | ||
44 | return m_emu->widget(); | 45 | return m_emu->widget(); |
45 | } | 46 | } |
46 | Profile Session::profile()const { | 47 | Profile Session::profile()const { |
47 | return m_prof; | 48 | return m_prof; |
48 | } | 49 | } |
49 | /* | 50 | /* |
50 | WidgetLayer* Session::emulationWidget() { | 51 | WidgetLayer* Session::emulationWidget() { |
51 | return m_widLay; | 52 | return m_widLay; |
52 | } | 53 | } |
53 | */ | 54 | */ |
54 | void Session::connect() { | 55 | void Session::connect() { |
55 | if ( !m_layer || !m_emu ) | 56 | if ( !m_layer || !m_emu ) |
56 | return; | 57 | return; |
57 | 58 | ||
58 | QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), | 59 | QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), |
59 | m_emu, SLOT(recv(const QByteArray&) ) ); | 60 | m_emu, SLOT(recv(const QByteArray&) ) ); |
60 | QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), | 61 | QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), |
61 | m_layer, SLOT(send(const QByteArray&) ) ); | 62 | m_layer, SLOT(send(const QByteArray&) ) ); |
62 | QObject::connect(m_emu, SIGNAL(changeSize(int, int) ), | 63 | QObject::connect(m_emu, SIGNAL(changeSize(int, int) ), |
63 | m_layer, SLOT(setSize(int, int) ) ); | 64 | m_layer, SLOT(setSize(int, int) ) ); |
64 | } | 65 | } |
65 | 66 | ||
66 | void Session::disconnect() { | 67 | void Session::disconnect() { |
67 | 68 | ||
68 | if ( !m_layer || !m_emu ) | 69 | if ( !m_layer || !m_emu ) |
69 | return; | 70 | return; |
70 | 71 | ||
71 | QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), | 72 | QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), |
72 | m_emu, SLOT(recv(const QByteArray&) ) ); | 73 | m_emu, SLOT(recv(const QByteArray&) ) ); |
73 | QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), | 74 | QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), |
74 | m_layer, SLOT(send(const QByteArray&) ) ); | 75 | m_layer, SLOT(send(const QByteArray&) ) ); |
75 | } | 76 | } |
76 | 77 | ||
77 | void Session::setName( const QString& na){ | 78 | void Session::setName( const QString& na){ |
78 | m_name = na; | 79 | m_name = na; |
79 | } | 80 | } |
80 | 81 | ||
81 | void Session::setWidgetStack( QWidgetStack* wid ) { | 82 | void Session::setWidgetStack( QWidgetStack* wid ) { |
82 | delete m_emu; | 83 | delete m_emu; |
83 | m_emu = 0l; | 84 | m_emu = 0l; |
84 | delete m_widget; | 85 | delete m_widget; |
85 | /* the EmulationLayer was destroyed... */ | 86 | /* the EmulationLayer was destroyed... */ |
86 | 87 | ||
87 | m_widget = wid; | 88 | m_widget = wid; |
88 | } | 89 | } |
89 | void Session::setIOLayer( IOLayer* lay ) { | 90 | void Session::setIOLayer( IOLayer* lay ) { |
90 | delete m_layer; | 91 | delete m_layer; |
91 | m_layer = lay; | 92 | m_layer = lay; |
92 | } | 93 | } |
93 | 94 | ||
94 | void Session::setEmulationHandler( EmulationHandler* lay ) { | 95 | void Session::setEmulationHandler( EmulationHandler* lay ) { |
95 | delete m_emu; | 96 | delete m_emu; |
96 | m_emu = lay; | 97 | m_emu = lay; |
97 | } | 98 | } |
98 | void Session::setProfile( const Profile& prof ) { | 99 | void Session::setProfile( const Profile& prof ) { |
99 | m_prof = prof; | 100 | m_prof = prof; |
100 | } | 101 | } |
101 | /* | 102 | /* |
102 | void Session::setEmulationWidget( WidgetLayer* lay ) { | 103 | void Session::setEmulationWidget( WidgetLayer* lay ) { |
103 | delete m_widLay; | 104 | delete m_widLay; |
104 | m_widLay = lay; | 105 | m_widLay = lay; |
105 | } | 106 | } |
106 | */ | 107 | */ |
108 | void Session::setTransferDialog(QWidget *d) | ||
109 | { | ||
110 | m_transfer = d; | ||
111 | } | ||
112 | |||
113 | QWidget *Session::transferDialog() | ||
114 | { | ||
115 | return m_transfer; | ||
116 | } | ||
107 | 117 | ||
diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h index f60a6c0..d69224a 100644 --- a/noncore/apps/opie-console/session.h +++ b/noncore/apps/opie-console/session.h | |||
@@ -1,77 +1,80 @@ | |||
1 | #ifndef OPIE_SESSION_H | 1 | #ifndef OPIE_SESSION_H |
2 | #define OPIE_SESSION_H | 2 | #define OPIE_SESSION_H |
3 | 3 | ||
4 | #include <qwidgetstack.h> | 4 | #include <qwidgetstack.h> |
5 | 5 | ||
6 | #include "profile.h" | 6 | #include "profile.h" |
7 | 7 | ||
8 | class IOLayer; | 8 | class IOLayer; |
9 | class EmulationHandler; | 9 | class EmulationHandler; |
10 | /** | 10 | /** |
11 | * This is a Session. A session contains | 11 | * This is a Session. A session contains |
12 | * a QWidget pointer and a IOLayer | 12 | * a QWidget pointer and a IOLayer |
13 | * Imagine a session like a collection of what | 13 | * Imagine a session like a collection of what |
14 | * is needed to show your widget in a tab ;) | 14 | * is needed to show your widget in a tab ;) |
15 | */ | 15 | */ |
16 | class Session { | 16 | class Session { |
17 | public: | 17 | public: |
18 | /** | 18 | /** |
19 | * c'tor with widget and layer | 19 | * c'tor with widget and layer |
20 | * ownership get's transfered | 20 | * ownership get's transfered |
21 | */ | 21 | */ |
22 | Session(); | 22 | Session(); |
23 | Session( const QString&, QWidgetStack* widget, IOLayer* ); | 23 | Session( const QString&, QWidgetStack* widget, IOLayer* ); |
24 | ~Session(); | 24 | ~Session(); |
25 | 25 | ||
26 | /** | 26 | /** |
27 | * return the name of the session | 27 | * return the name of the session |
28 | */ | 28 | */ |
29 | QString name()const; | 29 | QString name()const; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * return the widgetstack | 32 | * return the widgetstack |
33 | * this is used to be semi modal | 33 | * this is used to be semi modal |
34 | * for FileTransfer | 34 | * for FileTransfer |
35 | * | 35 | * |
36 | * semi modal == SessionModal | 36 | * semi modal == SessionModal |
37 | */ | 37 | */ |
38 | QWidgetStack* widgetStack(); | 38 | QWidgetStack* widgetStack(); |
39 | QWidget* widget(); | 39 | QWidget* widget(); |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * return the layer | 42 | * return the layer |
43 | */ | 43 | */ |
44 | IOLayer* layer(); | 44 | IOLayer* layer(); |
45 | 45 | ||
46 | EmulationHandler* emulationHandler(); | 46 | EmulationHandler* emulationHandler(); |
47 | Profile profile()const; | 47 | Profile profile()const; |
48 | 48 | ||
49 | /* | 49 | /* |
50 | * connects the data flow from | 50 | * connects the data flow from |
51 | * the IOLayer to the EmulationLayer | 51 | * the IOLayer to the EmulationLayer |
52 | */ | 52 | */ |
53 | void connect(); | 53 | void connect(); |
54 | 54 | ||
55 | /* | 55 | /* |
56 | * disconnect the dataflow | 56 | * disconnect the dataflow |
57 | * this will be done for ft | 57 | * this will be done for ft |
58 | */ | 58 | */ |
59 | void disconnect(); | 59 | void disconnect(); |
60 | 60 | ||
61 | void setWidgetStack( QWidgetStack* widget ); | 61 | void setWidgetStack( QWidgetStack* widget ); |
62 | void setEmulationHandler( EmulationHandler* lay ); | 62 | void setEmulationHandler( EmulationHandler* lay ); |
63 | void setIOLayer( IOLayer* ); | 63 | void setIOLayer( IOLayer* ); |
64 | void setName( const QString& ); | 64 | void setName( const QString& ); |
65 | void setProfile( const Profile& ); | 65 | void setProfile( const Profile& ); |
66 | 66 | ||
67 | void setTransferDialog(QWidget *d); | ||
68 | QWidget *transferDialog(); | ||
69 | |||
67 | private: | 70 | private: |
68 | QString m_name; | 71 | QString m_name; |
69 | QWidgetStack* m_widget; | 72 | QWidgetStack* m_widget; |
70 | IOLayer* m_layer; | 73 | IOLayer* m_layer; |
71 | EmulationHandler* m_emu; | 74 | EmulationHandler* m_emu; |
72 | bool m_connected : 1; | 75 | bool m_connected : 1; |
73 | Profile m_prof; | 76 | Profile m_prof; |
74 | 77 | QWidget *m_transfer; | |
75 | }; | 78 | }; |
76 | 79 | ||
77 | #endif | 80 | #endif |
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index 75c4c72..0af1911 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp | |||
@@ -1,266 +1,277 @@ | |||
1 | #include <qlayout.h> | 1 | #include <qlayout.h> |
2 | #include <qcombobox.h> | 2 | #include <qcombobox.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qpushbutton.h> | 5 | #include <qpushbutton.h> |
6 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | #include <qprogressbar.h> | 7 | #include <qprogressbar.h> |
8 | #include <qradiobutton.h> | 8 | #include <qradiobutton.h> |
9 | #include <qbuttongroup.h> | 9 | #include <qbuttongroup.h> |
10 | 10 | ||
11 | #include <opie/ofiledialog.h> | 11 | #include <opie/ofiledialog.h> |
12 | 12 | ||
13 | #include "file_layer.h" | 13 | #include "file_layer.h" |
14 | #include "receive_layer.h" | 14 | #include "receive_layer.h" |
15 | #include "metafactory.h" | 15 | #include "metafactory.h" |
16 | #include "mainwindow.h" | 16 | #include "mainwindow.h" |
17 | 17 | ||
18 | #include "transferdialog.h" | 18 | #include "transferdialog.h" |
19 | 19 | ||
20 | TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *) | 20 | TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *) |
21 | : QDialog(parent, 0l, true), m_win(mainwindow) | 21 | : QDialog(parent, 0l, false), m_win(mainwindow) |
22 | { | 22 | { |
23 | m_lay = 0l; | 23 | m_lay = 0l; |
24 | m_recvlay = 0l; | 24 | m_recvlay = 0l; |
25 | QVBoxLayout *vbox, *vbox2; | 25 | QVBoxLayout *vbox, *vbox2; |
26 | QHBoxLayout *hbox, *hbox2, *hbox3; | 26 | QHBoxLayout *hbox, *hbox2, *hbox3; |
27 | QLabel *file, *mode, *progress, *status; | 27 | QLabel *file, *mode, *progress, *status; |
28 | QButtonGroup *group; | 28 | QButtonGroup *group; |
29 | QRadioButton *mode_send, *mode_receive; | 29 | QRadioButton *mode_send, *mode_receive; |
30 | 30 | ||
31 | m_autocleanup = 0; | 31 | m_autocleanup = 0; |
32 | m_running = true; | ||
32 | 33 | ||
33 | group = new QButtonGroup(QObject::tr("Transfer mode"), this); | 34 | group = new QButtonGroup(QObject::tr("Transfer mode"), this); |
34 | mode_send = new QRadioButton(QObject::tr("Send"), group); | 35 | mode_send = new QRadioButton(QObject::tr("Send"), group); |
35 | mode_receive = new QRadioButton(QObject::tr("Receive"), group); | 36 | mode_receive = new QRadioButton(QObject::tr("Receive"), group); |
36 | group->insert(mode_send, id_send); | 37 | group->insert(mode_send, id_send); |
37 | group->insert(mode_receive, id_receive); | 38 | group->insert(mode_receive, id_receive); |
38 | vbox2 = new QVBoxLayout(group, 2); | 39 | vbox2 = new QVBoxLayout(group, 2); |
39 | vbox2->addSpacing(10); | 40 | vbox2->addSpacing(10); |
40 | hbox3 = new QHBoxLayout(vbox2, 2); | 41 | hbox3 = new QHBoxLayout(vbox2, 2); |
41 | hbox3->add(mode_send); | 42 | hbox3->add(mode_send); |
42 | hbox3->add(mode_receive); | 43 | hbox3->add(mode_receive); |
43 | mode_send->setChecked(true); | 44 | mode_send->setChecked(true); |
44 | m_transfermode = id_send; | 45 | m_transfermode = id_send; |
45 | 46 | ||
46 | file = new QLabel(QObject::tr("Send file"), this); | 47 | file = new QLabel(QObject::tr("Send file"), this); |
47 | mode = new QLabel(QObject::tr("Transfer protocol"), this); | 48 | mode = new QLabel(QObject::tr("Transfer protocol"), this); |
48 | progress = new QLabel(QObject::tr("Progress"), this); | 49 | progress = new QLabel(QObject::tr("Progress"), this); |
49 | status = new QLabel(QObject::tr("Status"), this); | 50 | status = new QLabel(QObject::tr("Status"), this); |
50 | 51 | ||
51 | statusbar = new QLabel(QObject::tr("Ready"), this); | 52 | statusbar = new QLabel(QObject::tr("Ready"), this); |
52 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 53 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
53 | 54 | ||
54 | protocol = new QComboBox(this); | 55 | protocol = new QComboBox(this); |
55 | QStringList list = m_win->factory()->fileTransferLayers(); | 56 | QStringList list = m_win->factory()->fileTransferLayers(); |
56 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) | 57 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) |
57 | protocol->insertItem((*it)); | 58 | protocol->insertItem((*it)); |
58 | 59 | ||
59 | filename = new QLineEdit(this); | 60 | filename = new QLineEdit(this); |
60 | 61 | ||
61 | progressbar = new QProgressBar(this); | 62 | progressbar = new QProgressBar(this); |
62 | progressbar->setProgress(0); | 63 | progressbar->setProgress(0); |
63 | 64 | ||
64 | selector = new QPushButton("...", this); | 65 | selector = new QPushButton("...", this); |
65 | ok = new QPushButton(QObject::tr("Start transfer"), this); | 66 | ok = new QPushButton(QObject::tr("Start transfer"), this); |
66 | cancel = new QPushButton(QObject::tr("Cancel"), this); | 67 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
67 | 68 | ||
68 | vbox = new QVBoxLayout(this, 2); | 69 | vbox = new QVBoxLayout(this, 2); |
69 | vbox->add(group); | 70 | vbox->add(group); |
70 | vbox->add(file); | 71 | vbox->add(file); |
71 | hbox = new QHBoxLayout(vbox, 0); | 72 | hbox = new QHBoxLayout(vbox, 0); |
72 | hbox->add(filename); | 73 | hbox->add(filename); |
73 | hbox->add(selector); | 74 | hbox->add(selector); |
74 | vbox->add(mode); | 75 | vbox->add(mode); |
75 | vbox->add(protocol); | 76 | vbox->add(protocol); |
76 | vbox->add(progress); | 77 | vbox->add(progress); |
77 | vbox->add(progressbar); | 78 | vbox->add(progressbar); |
78 | vbox->add(status); | 79 | vbox->add(status); |
79 | vbox->add(statusbar); | 80 | vbox->add(statusbar); |
80 | vbox->addStretch(1); | 81 | vbox->addStretch(1); |
81 | hbox2 = new QHBoxLayout(vbox, 2); | 82 | hbox2 = new QHBoxLayout(vbox, 2); |
82 | hbox2->add(ok); | 83 | hbox2->add(ok); |
83 | hbox2->add(cancel); | 84 | hbox2->add(cancel); |
84 | 85 | ||
85 | setCaption(QObject::tr("File transfer")); | 86 | setCaption(QObject::tr("File transfer")); |
86 | show(); | 87 | show(); |
87 | 88 | ||
88 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); | 89 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); |
89 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); | 90 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); |
90 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); | 91 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); |
91 | connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int))); | 92 | connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int))); |
92 | } | 93 | } |
93 | 94 | ||
94 | TransferDialog::~TransferDialog() | 95 | TransferDialog::~TransferDialog() |
95 | { | 96 | { |
96 | } | 97 | } |
97 | 98 | ||
98 | void TransferDialog::slotFilename() | 99 | void TransferDialog::slotFilename() |
99 | { | 100 | { |
100 | QString f; | 101 | QString f; |
101 | 102 | ||
102 | f = OFileDialog::getOpenFileName(0); | 103 | f = OFileDialog::getOpenFileName(0); |
103 | if(!f.isNull()) filename->setText(f); | 104 | if(!f.isNull()) filename->setText(f); |
104 | } | 105 | } |
105 | 106 | ||
106 | void TransferDialog::slotTransfer() | 107 | void TransferDialog::slotTransfer() |
107 | { | 108 | { |
108 | if((m_transfermode == id_send) && (filename->text().isEmpty())) | 109 | if((m_transfermode == id_send) && (filename->text().isEmpty())) |
109 | { | 110 | { |
110 | QMessageBox::information(this, | 111 | QMessageBox::information(this, |
111 | QObject::tr("Attention"), | 112 | QObject::tr("Attention"), |
112 | QObject::tr("No file has been specified.")); | 113 | QObject::tr("No file has been specified.")); |
113 | return; | 114 | return; |
114 | } | 115 | } |
115 | 116 | ||
116 | ok->setEnabled(false); | 117 | ok->setEnabled(false); |
117 | 118 | ||
118 | cleanup(); | 119 | cleanup(); |
119 | m_autocleanup = 0; | 120 | m_autocleanup = 0; |
120 | 121 | ||
121 | if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); | 122 | if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); |
122 | else statusbar->setText(QObject::tr("Receiving...")); | 123 | else statusbar->setText(QObject::tr("Receiving...")); |
123 | 124 | ||
124 | if(m_transfermode == id_send) | 125 | if(m_transfermode == id_send) |
125 | { | 126 | { |
126 | m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); | 127 | m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); |
127 | m_lay->sendFile(filename->text()); | 128 | m_lay->sendFile(filename->text()); |
128 | 129 | ||
129 | connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), | 130 | connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), |
130 | SLOT(slotProgress(const QString&, int, int, int, int, int))); | 131 | SLOT(slotProgress(const QString&, int, int, int, int, int))); |
131 | connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); | 132 | connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); |
132 | connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); | 133 | connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); |
133 | } | 134 | } |
134 | else | 135 | else |
135 | { | 136 | { |
136 | m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer()); | 137 | m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer()); |
137 | m_recvlay->receive(); | 138 | m_recvlay->receive(); |
138 | 139 | ||
139 | connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)), | 140 | connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)), |
140 | SLOT(slotProgress(const QString&, int, int, int, int, int))); | 141 | SLOT(slotProgress(const QString&, int, int, int, int, int))); |
141 | connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); | 142 | connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); |
142 | connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); | 143 | connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); |
143 | } | 144 | } |
144 | } | 145 | } |
145 | 146 | ||
146 | void TransferDialog::cleanup() | 147 | void TransferDialog::cleanup() |
147 | { | 148 | { |
148 | if(m_lay) | 149 | if(m_lay) |
149 | { | 150 | { |
150 | m_lay->cancel(); | 151 | m_lay->cancel(); |
151 | delete m_lay; | 152 | delete m_lay; |
152 | m_lay = 0l; | 153 | m_lay = 0l; |
153 | } | 154 | } |
154 | if(m_recvlay) | 155 | if(m_recvlay) |
155 | { | 156 | { |
156 | m_recvlay->cancel(); | 157 | m_recvlay->cancel(); |
157 | delete m_recvlay; | 158 | delete m_recvlay; |
158 | m_recvlay = 0l; | 159 | m_recvlay = 0l; |
159 | } | 160 | } |
160 | } | 161 | } |
161 | 162 | ||
162 | void TransferDialog::slotCancel() | 163 | void TransferDialog::slotCancel() |
163 | { | 164 | { |
164 | ok->setEnabled(true); | 165 | ok->setEnabled(true); |
165 | statusbar->setText(QObject::tr("Ready")); | 166 | statusbar->setText(QObject::tr("Ready")); |
166 | 167 | ||
167 | if((m_lay) || (m_recvlay)) | 168 | if((m_lay) || (m_recvlay)) |
168 | { | 169 | { |
169 | cleanup(); | 170 | cleanup(); |
170 | if(m_autocleanup) close(); | 171 | if(m_autocleanup) |
172 | { | ||
173 | m_running = false; | ||
174 | close(); | ||
175 | } | ||
171 | else | 176 | else |
172 | { | 177 | { |
173 | QMessageBox::information(this, | 178 | QMessageBox::information(this, |
174 | QObject::tr("Cancelled"), | 179 | QObject::tr("Cancelled"), |
175 | QObject::tr("The file transfer has been cancelled.")); | 180 | QObject::tr("The file transfer has been cancelled.")); |
176 | } | 181 | } |
177 | } | 182 | } |
178 | else | 183 | else |
179 | { | 184 | { |
185 | m_running = false; | ||
180 | close(); | 186 | close(); |
181 | } | 187 | } |
182 | } | 188 | } |
183 | 189 | ||
184 | void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int ) | 190 | void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int ) |
185 | { | 191 | { |
186 | progressbar->setProgress(progress); | 192 | progressbar->setProgress(progress); |
187 | } | 193 | } |
188 | 194 | ||
189 | void TransferDialog::slotError(int error, const QString& ) | 195 | void TransferDialog::slotError(int error, const QString& ) |
190 | { | 196 | { |
191 | statusbar->setText(QObject::tr("Ready")); | 197 | statusbar->setText(QObject::tr("Ready")); |
192 | 198 | ||
193 | switch(error) | 199 | switch(error) |
194 | { | 200 | { |
195 | case FileTransferLayer::NotSupported: | 201 | case FileTransferLayer::NotSupported: |
196 | QMessageBox::critical(this, | 202 | QMessageBox::critical(this, |
197 | QObject::tr("Error"), | 203 | QObject::tr("Error"), |
198 | QObject::tr("Operation not supported.")); | 204 | QObject::tr("Operation not supported.")); |
199 | break; | 205 | break; |
200 | case FileTransferLayer::StartError: | 206 | case FileTransferLayer::StartError: |
201 | QMessageBox::critical(this, | 207 | QMessageBox::critical(this, |
202 | QObject::tr("Error"), | 208 | QObject::tr("Error"), |
203 | QObject::tr("Transfer could not be started.")); | 209 | QObject::tr("Transfer could not be started.")); |
204 | break; | 210 | break; |
205 | case FileTransferLayer::NoError: | 211 | case FileTransferLayer::NoError: |
206 | QMessageBox::critical(this, | 212 | QMessageBox::critical(this, |
207 | QObject::tr("Error"), | 213 | QObject::tr("Error"), |
208 | QObject::tr("No error.")); | 214 | QObject::tr("No error.")); |
209 | break; | 215 | break; |
210 | case FileTransferLayer::Undefined: | 216 | case FileTransferLayer::Undefined: |
211 | QMessageBox::critical(this, | 217 | QMessageBox::critical(this, |
212 | QObject::tr("Error"), | 218 | QObject::tr("Error"), |
213 | QObject::tr("Undefined error occured.")); | 219 | QObject::tr("Undefined error occured.")); |
214 | break; | 220 | break; |
215 | case FileTransferLayer::Incomplete: | 221 | case FileTransferLayer::Incomplete: |
216 | QMessageBox::critical(this, | 222 | QMessageBox::critical(this, |
217 | QObject::tr("Error"), | 223 | QObject::tr("Error"), |
218 | QObject::tr("Incomplete transfer.")); | 224 | QObject::tr("Incomplete transfer.")); |
219 | break; | 225 | break; |
220 | case FileTransferLayer::Unknown: | 226 | case FileTransferLayer::Unknown: |
221 | default: | 227 | default: |
222 | QMessageBox::critical(this, | 228 | QMessageBox::critical(this, |
223 | QObject::tr("Error"), | 229 | QObject::tr("Error"), |
224 | QObject::tr("Unknown error occured.")); | 230 | QObject::tr("Unknown error occured.")); |
225 | break; | 231 | break; |
226 | } | 232 | } |
227 | 233 | ||
228 | m_autocleanup = 1; | 234 | m_autocleanup = 1; |
229 | } | 235 | } |
230 | 236 | ||
231 | void TransferDialog::slotSent() | 237 | void TransferDialog::slotSent() |
232 | { | 238 | { |
233 | progressbar->setProgress(100); | 239 | progressbar->setProgress(100); |
234 | QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); | 240 | QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); |
235 | ok->setEnabled(true); | 241 | ok->setEnabled(true); |
236 | progressbar->setProgress(0); | 242 | progressbar->setProgress(0); |
237 | statusbar->setText(QObject::tr("Ready")); | 243 | statusbar->setText(QObject::tr("Ready")); |
238 | m_autocleanup = 1; | 244 | m_autocleanup = 1; |
239 | } | 245 | } |
240 | 246 | ||
241 | void TransferDialog::slotReceived(const QString& ) | 247 | void TransferDialog::slotReceived(const QString& ) |
242 | { | 248 | { |
243 | progressbar->setProgress(100); | 249 | progressbar->setProgress(100); |
244 | QMessageBox::information(this, QObject::tr("Received"), QObject::tr("File has been received.")); | 250 | QMessageBox::information(this, QObject::tr("Received"), QObject::tr("File has been received.")); |
245 | //QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file)); | 251 | //QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file)); |
246 | ok->setEnabled(true); | 252 | ok->setEnabled(true); |
247 | progressbar->setProgress(0); | 253 | progressbar->setProgress(0); |
248 | statusbar->setText(QObject::tr("Ready")); | 254 | statusbar->setText(QObject::tr("Ready")); |
249 | m_autocleanup = 1; | 255 | m_autocleanup = 1; |
250 | } | 256 | } |
251 | 257 | ||
252 | void TransferDialog::slotMode(int id) | 258 | void TransferDialog::slotMode(int id) |
253 | { | 259 | { |
254 | if(id == id_send) | 260 | if(id == id_send) |
255 | { | 261 | { |
256 | selector->setEnabled(true); | 262 | selector->setEnabled(true); |
257 | filename->setEnabled(true); | 263 | filename->setEnabled(true); |
258 | } | 264 | } |
259 | else | 265 | else |
260 | { | 266 | { |
261 | selector->setEnabled(false); | 267 | selector->setEnabled(false); |
262 | filename->setEnabled(false); | 268 | filename->setEnabled(false); |
263 | } | 269 | } |
264 | m_transfermode = id; | 270 | m_transfermode = id; |
265 | } | 271 | } |
266 | 272 | ||
273 | bool TransferDialog::isRunning() | ||
274 | { | ||
275 | return m_running; | ||
276 | } | ||
277 | |||
diff --git a/noncore/apps/opie-console/transferdialog.h b/noncore/apps/opie-console/transferdialog.h index d87be6a..23691e0 100644 --- a/noncore/apps/opie-console/transferdialog.h +++ b/noncore/apps/opie-console/transferdialog.h | |||
@@ -1,54 +1,56 @@ | |||
1 | #ifndef TRANSFER_DIALOG_H | 1 | #ifndef TRANSFER_DIALOG_H |
2 | #define TRANSFER_DIALOG_H | 2 | #define TRANSFER_DIALOG_H |
3 | 3 | ||
4 | #include "qdialog.h" | 4 | #include "qdialog.h" |
5 | 5 | ||
6 | class QLineEdit; | 6 | class QLineEdit; |
7 | class QComboBox; | 7 | class QComboBox; |
8 | class QProgressBar; | 8 | class QProgressBar; |
9 | class QLabel; | 9 | class QLabel; |
10 | class QPushButton; | 10 | class QPushButton; |
11 | class MainWindow; | 11 | class MainWindow; |
12 | class FileTransferLayer; | 12 | class FileTransferLayer; |
13 | class ReceiveLayer; | 13 | class ReceiveLayer; |
14 | 14 | ||
15 | class TransferDialog : public QDialog | 15 | class TransferDialog : public QDialog |
16 | { | 16 | { |
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | public: | 18 | public: |
19 | TransferDialog(QWidget *parent = 0l, MainWindow *mainwindow = 0l, const char *name = 0l); | 19 | TransferDialog(QWidget *parent = 0l, MainWindow *mainwindow = 0l, const char *name = 0l); |
20 | ~TransferDialog(); | 20 | ~TransferDialog(); |
21 | bool isRunning(); | ||
21 | 22 | ||
22 | public slots: | 23 | public slots: |
23 | void slotFilename(); | 24 | void slotFilename(); |
24 | void slotTransfer(); | 25 | void slotTransfer(); |
25 | void slotCancel(); | 26 | void slotCancel(); |
26 | void slotProgress(const QString&, int, int, int, int, int); | 27 | void slotProgress(const QString&, int, int, int, int, int); |
27 | void slotError(int error, const QString& message); | 28 | void slotError(int error, const QString& message); |
28 | void slotSent(); | 29 | void slotSent(); |
29 | void slotReceived(const QString& file); | 30 | void slotReceived(const QString& file); |
30 | void slotMode(int id); | 31 | void slotMode(int id); |
31 | 32 | ||
32 | private: | 33 | private: |
33 | enum Modes | 34 | enum Modes |
34 | { | 35 | { |
35 | id_send, | 36 | id_send, |
36 | id_receive | 37 | id_receive |
37 | }; | 38 | }; |
38 | 39 | ||
39 | void cleanup(); | 40 | void cleanup(); |
40 | 41 | ||
41 | QLineEdit *filename; | 42 | QLineEdit *filename; |
42 | QComboBox *protocol; | 43 | QComboBox *protocol; |
43 | QProgressBar *progressbar; | 44 | QProgressBar *progressbar; |
44 | QLabel *statusbar; | 45 | QLabel *statusbar; |
45 | QPushButton *ok, *cancel, *selector; | 46 | QPushButton *ok, *cancel, *selector; |
46 | MainWindow* m_win; | 47 | MainWindow* m_win; |
47 | FileTransferLayer* m_lay; | 48 | FileTransferLayer* m_lay; |
48 | ReceiveLayer *m_recvlay; | 49 | ReceiveLayer *m_recvlay; |
49 | int m_transfermode; | 50 | int m_transfermode; |
50 | int m_autocleanup; | 51 | int m_autocleanup; |
52 | bool m_running; | ||
51 | }; | 53 | }; |
52 | 54 | ||
53 | #endif | 55 | #endif |
54 | 56 | ||