-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 16 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 44 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.h | 9 |
4 files changed, 65 insertions, 6 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 0bd6a13..fbeaa74 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,217 +1,233 @@ | |||
1 | 1 | ||
2 | #include <qaction.h> | 2 | #include <qaction.h> |
3 | #include <qmenubar.h> | 3 | #include <qmenubar.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qtoolbar.h> | 6 | #include <qtoolbar.h> |
7 | 7 | ||
8 | #include "profileeditordialog.h" | 8 | #include "profileeditordialog.h" |
9 | #include "configdialog.h" | 9 | #include "configdialog.h" |
10 | #include "default.h" | 10 | #include "default.h" |
11 | #include "metafactory.h" | 11 | #include "metafactory.h" |
12 | #include "profile.h" | 12 | #include "profile.h" |
13 | #include "profilemanager.h" | 13 | #include "profilemanager.h" |
14 | #include "mainwindow.h" | 14 | #include "mainwindow.h" |
15 | #include "tabwidget.h" | 15 | #include "tabwidget.h" |
16 | #include "transferdialog.h" | ||
16 | 17 | ||
17 | MainWindow::MainWindow() { | 18 | MainWindow::MainWindow() { |
18 | m_factory = new MetaFactory(); | 19 | m_factory = new MetaFactory(); |
19 | Default def(m_factory); | 20 | Default def(m_factory); |
20 | m_sessions.setAutoDelete( TRUE ); | 21 | m_sessions.setAutoDelete( TRUE ); |
21 | m_curSession = 0; | 22 | m_curSession = 0; |
22 | m_manager = new ProfileManager( m_factory ); | 23 | m_manager = new ProfileManager( m_factory ); |
23 | m_manager->load(); | 24 | m_manager->load(); |
24 | 25 | ||
25 | initUI(); | 26 | initUI(); |
26 | populateProfiles(); | 27 | populateProfiles(); |
27 | } | 28 | } |
28 | void MainWindow::initUI() { | 29 | void MainWindow::initUI() { |
29 | setToolBarsMovable( FALSE ); | 30 | setToolBarsMovable( FALSE ); |
30 | 31 | ||
31 | m_tool = new QToolBar( this ); | 32 | m_tool = new QToolBar( this ); |
32 | m_tool->setHorizontalStretchable( TRUE ); | 33 | m_tool->setHorizontalStretchable( TRUE ); |
33 | 34 | ||
34 | m_bar = new QMenuBar( m_tool ); | 35 | m_bar = new QMenuBar( m_tool ); |
35 | m_console = new QPopupMenu( this ); | 36 | m_console = new QPopupMenu( this ); |
36 | m_sessionsPop= new QPopupMenu( this ); | 37 | m_sessionsPop= new QPopupMenu( this ); |
37 | m_settings = new QPopupMenu( this ); | 38 | m_settings = new QPopupMenu( this ); |
38 | 39 | ||
39 | /* | 40 | /* |
40 | * new Action for new sessions | 41 | * new Action for new sessions |
41 | */ | 42 | */ |
42 | QAction* a = new QAction(); | 43 | QAction* a = new QAction(); |
43 | a->setText( tr("New Connection") ); | 44 | a->setText( tr("New Connection") ); |
44 | a->addTo( m_console ); | 45 | a->addTo( m_console ); |
45 | connect(a, SIGNAL(activated() ), | 46 | connect(a, SIGNAL(activated() ), |
46 | this, SLOT(slotNew() ) ); | 47 | this, SLOT(slotNew() ) ); |
47 | 48 | ||
48 | /* | 49 | /* |
49 | * connect action | 50 | * connect action |
50 | */ | 51 | */ |
51 | m_connect = new QAction(); | 52 | m_connect = new QAction(); |
52 | m_connect->setText( tr("Connect") ); | 53 | m_connect->setText( tr("Connect") ); |
53 | m_connect->addTo( m_console ); | 54 | m_connect->addTo( m_console ); |
54 | connect(m_connect, SIGNAL(activated() ), | 55 | connect(m_connect, SIGNAL(activated() ), |
55 | this, SLOT(slotConnect() ) ); | 56 | this, SLOT(slotConnect() ) ); |
56 | 57 | ||
57 | /* | 58 | /* |
58 | * disconnect action | 59 | * disconnect action |
59 | */ | 60 | */ |
60 | m_disconnect = new QAction(); | 61 | m_disconnect = new QAction(); |
61 | m_disconnect->setText( tr("Disconnect") ); | 62 | m_disconnect->setText( tr("Disconnect") ); |
62 | m_disconnect->addTo( m_console ); | 63 | m_disconnect->addTo( m_console ); |
63 | connect(m_disconnect, SIGNAL(activated() ), | 64 | connect(m_disconnect, SIGNAL(activated() ), |
64 | this, SLOT(slotDisconnect() ) ); | 65 | this, SLOT(slotDisconnect() ) ); |
65 | 66 | ||
67 | m_transfer = new QAction(); | ||
68 | m_transfer->setText( tr("Transfer file...") ); | ||
69 | m_transfer->addTo( m_console ); | ||
70 | connect(m_transfer, SIGNAL(activated() ), | ||
71 | this, SLOT(slotTransfer() ) ); | ||
72 | |||
66 | /* | 73 | /* |
67 | * terminate action | 74 | * terminate action |
68 | */ | 75 | */ |
69 | m_terminate = new QAction(); | 76 | m_terminate = new QAction(); |
70 | m_terminate->setText( tr("Terminate") ); | 77 | m_terminate->setText( tr("Terminate") ); |
71 | m_terminate->addTo( m_console ); | 78 | m_terminate->addTo( m_console ); |
72 | connect(m_terminate, SIGNAL(activated() ), | 79 | connect(m_terminate, SIGNAL(activated() ), |
73 | this, SLOT(slotTerminate() ) ); | 80 | this, SLOT(slotTerminate() ) ); |
74 | 81 | ||
75 | a = new QAction(); | 82 | a = new QAction(); |
76 | a->setText( tr("Close Window") ); | 83 | a->setText( tr("Close Window") ); |
77 | a->addTo( m_console ); | 84 | a->addTo( m_console ); |
78 | connect(a, SIGNAL(activated() ), | 85 | connect(a, SIGNAL(activated() ), |
79 | this, SLOT(slotClose() ) ); | 86 | this, SLOT(slotClose() ) ); |
80 | 87 | ||
81 | /* | 88 | /* |
82 | * the settings action | 89 | * the settings action |
83 | */ | 90 | */ |
84 | m_setProfiles = new QAction(); | 91 | m_setProfiles = new QAction(); |
85 | m_setProfiles->setText( tr("Configure Profiles") ); | 92 | m_setProfiles->setText( tr("Configure Profiles") ); |
86 | m_setProfiles->addTo( m_settings ); | 93 | m_setProfiles->addTo( m_settings ); |
87 | connect( m_setProfiles, SIGNAL(activated() ), | 94 | connect( m_setProfiles, SIGNAL(activated() ), |
88 | this, SLOT(slotConfigure() ) ); | 95 | this, SLOT(slotConfigure() ) ); |
89 | 96 | ||
90 | /* insert the submenu */ | 97 | /* insert the submenu */ |
91 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 98 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
92 | -1, 0); | 99 | -1, 0); |
93 | 100 | ||
94 | /* insert the connection menu */ | 101 | /* insert the connection menu */ |
95 | m_bar->insertItem( tr("Connection"), m_console ); | 102 | m_bar->insertItem( tr("Connection"), m_console ); |
96 | 103 | ||
97 | /* the settings menu */ | 104 | /* the settings menu */ |
98 | m_bar->insertItem( tr("Settings"), m_settings ); | 105 | m_bar->insertItem( tr("Settings"), m_settings ); |
99 | 106 | ||
100 | /* | 107 | /* |
101 | * connect to the menu activation | 108 | * connect to the menu activation |
102 | */ | 109 | */ |
103 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 110 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
104 | this, SLOT(slotProfile( int ) ) ); | 111 | this, SLOT(slotProfile( int ) ) ); |
105 | 112 | ||
106 | m_consoleWindow = new TabWidget( this, "blah"); | 113 | m_consoleWindow = new TabWidget( this, "blah"); |
107 | setCentralWidget( m_consoleWindow ); | 114 | setCentralWidget( m_consoleWindow ); |
108 | 115 | ||
109 | } | 116 | } |
110 | 117 | ||
111 | ProfileManager* MainWindow::manager() { | 118 | ProfileManager* MainWindow::manager() { |
112 | return m_manager; | 119 | return m_manager; |
113 | } | 120 | } |
114 | TabWidget* MainWindow::tabWidget() { | 121 | TabWidget* MainWindow::tabWidget() { |
115 | return m_consoleWindow; | 122 | return m_consoleWindow; |
116 | } | 123 | } |
117 | void MainWindow::populateProfiles() { | 124 | void MainWindow::populateProfiles() { |
118 | m_sessionsPop->clear(); | 125 | m_sessionsPop->clear(); |
119 | Profile::ValueList list = manager()->all(); | 126 | Profile::ValueList list = manager()->all(); |
120 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 127 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
121 | m_sessionsPop->insertItem( (*it).name() ); | 128 | m_sessionsPop->insertItem( (*it).name() ); |
122 | } | 129 | } |
123 | 130 | ||
124 | } | 131 | } |
125 | MainWindow::~MainWindow() { | 132 | MainWindow::~MainWindow() { |
126 | delete m_factory; | 133 | delete m_factory; |
127 | manager()->save(); | 134 | manager()->save(); |
128 | } | 135 | } |
129 | 136 | ||
130 | MetaFactory* MainWindow::factory() { | 137 | MetaFactory* MainWindow::factory() { |
131 | return m_factory; | 138 | return m_factory; |
132 | } | 139 | } |
133 | 140 | ||
134 | Session* MainWindow::currentSession() { | 141 | Session* MainWindow::currentSession() { |
135 | return m_curSession; | 142 | return m_curSession; |
136 | } | 143 | } |
137 | 144 | ||
138 | QList<Session> MainWindow::sessions() { | 145 | QList<Session> MainWindow::sessions() { |
139 | return m_sessions; | 146 | return m_sessions; |
140 | } | 147 | } |
141 | 148 | ||
142 | void MainWindow::slotNew() { | 149 | void MainWindow::slotNew() { |
143 | qWarning("New Connection"); | 150 | qWarning("New Connection"); |
144 | ProfileEditorDialog dlg(factory() ); | 151 | ProfileEditorDialog dlg(factory() ); |
145 | int ret = dlg.exec(); | 152 | int ret = dlg.exec(); |
146 | 153 | ||
147 | if ( ret == QDialog::Accepted ) { | 154 | if ( ret == QDialog::Accepted ) { |
148 | create( dlg.profile() ); | 155 | create( dlg.profile() ); |
149 | } | 156 | } |
150 | } | 157 | } |
151 | 158 | ||
152 | void MainWindow::slotConnect() { | 159 | void MainWindow::slotConnect() { |
153 | if ( currentSession() ) | 160 | if ( currentSession() ) |
154 | currentSession()->layer()->open(); | 161 | currentSession()->layer()->open(); |
155 | } | 162 | } |
156 | 163 | ||
157 | void MainWindow::slotDisconnect() { | 164 | void MainWindow::slotDisconnect() { |
158 | if ( currentSession() ) | 165 | if ( currentSession() ) |
159 | currentSession()->layer()->close(); | 166 | currentSession()->layer()->close(); |
160 | } | 167 | } |
161 | 168 | ||
162 | void MainWindow::slotTerminate() { | 169 | void MainWindow::slotTerminate() { |
163 | if ( currentSession() ) | 170 | if ( currentSession() ) |
164 | currentSession()->layer()->close(); | 171 | currentSession()->layer()->close(); |
165 | 172 | ||
166 | slotClose(); | 173 | slotClose(); |
167 | /* FIXME move to the next session */ | 174 | /* FIXME move to the next session */ |
168 | } | 175 | } |
169 | 176 | ||
170 | void MainWindow::slotConfigure() { | 177 | void MainWindow::slotConfigure() { |
171 | qWarning("configure"); | 178 | qWarning("configure"); |
172 | ConfigDialog conf( manager()->all(), factory() ); | 179 | ConfigDialog conf( manager()->all(), factory() ); |
173 | conf.showMaximized(); | 180 | conf.showMaximized(); |
174 | 181 | ||
175 | int ret = conf.exec(); | 182 | int ret = conf.exec(); |
176 | 183 | ||
177 | if ( QDialog::Accepted == ret ) { | 184 | if ( QDialog::Accepted == ret ) { |
178 | qWarning("conf %d", conf.list().count() ); | 185 | qWarning("conf %d", conf.list().count() ); |
179 | manager()->setProfiles( conf.list() ); | 186 | manager()->setProfiles( conf.list() ); |
180 | populateProfiles(); | 187 | populateProfiles(); |
181 | } | 188 | } |
182 | } | 189 | } |
183 | /* | 190 | /* |
184 | * we will remove | 191 | * we will remove |
185 | * this window from the tabwidget | 192 | * this window from the tabwidget |
186 | * remove it from the list | 193 | * remove it from the list |
187 | * delete it | 194 | * delete it |
188 | * and set the currentSession() | 195 | * and set the currentSession() |
189 | */ | 196 | */ |
190 | void MainWindow::slotClose() { | 197 | void MainWindow::slotClose() { |
191 | qWarning("close"); | 198 | qWarning("close"); |
192 | if (!currentSession() ) | 199 | if (!currentSession() ) |
193 | return; | 200 | return; |
194 | 201 | ||
195 | tabWidget()->remove( currentSession() ); | 202 | tabWidget()->remove( currentSession() ); |
196 | /*it's autodelete */ | 203 | /*it's autodelete */ |
197 | m_sessions.remove( m_curSession ); | 204 | m_sessions.remove( m_curSession ); |
198 | m_curSession = m_sessions.first(); | 205 | m_curSession = m_sessions.first(); |
199 | tabWidget()->setCurrent( m_curSession ); | 206 | tabWidget()->setCurrent( m_curSession ); |
200 | } | 207 | } |
201 | 208 | ||
202 | /* | 209 | /* |
203 | * We will get the name | 210 | * We will get the name |
204 | * Then the profile | 211 | * Then the profile |
205 | * and then we will make a profile | 212 | * and then we will make a profile |
206 | */ | 213 | */ |
207 | void MainWindow::slotProfile( int id) { | 214 | void MainWindow::slotProfile( int id) { |
208 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 215 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
209 | create( prof ); | 216 | create( prof ); |
210 | } | 217 | } |
211 | void MainWindow::create( const Profile& prof ) { | 218 | void MainWindow::create( const Profile& prof ) { |
212 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 219 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
213 | 220 | ||
214 | m_sessions.append( ses ); | 221 | m_sessions.append( ses ); |
215 | tabWidget()->add( ses ); | 222 | tabWidget()->add( ses ); |
216 | m_curSession = ses; | 223 | m_curSession = ses; |
224 | |||
217 | } | 225 | } |
226 | |||
227 | void MainWindow::slotTransfer() | ||
228 | { | ||
229 | TransferDialog dlg(this); | ||
230 | dlg.showMaximized(); | ||
231 | dlg.exec(); | ||
232 | } | ||
233 | |||
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index 7ef9c26..c8b0b65 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h | |||
@@ -1,93 +1,95 @@ | |||
1 | #ifndef OPIE_MAIN_WINDOW_H | 1 | #ifndef OPIE_MAIN_WINDOW_H |
2 | #define OPIE_MAIN_WINDOW_H | 2 | #define OPIE_MAIN_WINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qlist.h> | 5 | #include <qlist.h> |
6 | 6 | ||
7 | #include "session.h" | 7 | #include "session.h" |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * this is the MainWindow of the new opie console | 10 | * this is the MainWindow of the new opie console |
11 | * it's also the dispatcher between the different | 11 | * it's also the dispatcher between the different |
12 | * actions supported by the gui | 12 | * actions supported by the gui |
13 | */ | 13 | */ |
14 | class QToolBar; | 14 | class QToolBar; |
15 | class QMenuBar; | 15 | class QMenuBar; |
16 | class QAction; | 16 | class QAction; |
17 | class MetaFactory; | 17 | class MetaFactory; |
18 | class TabWidget; | 18 | class TabWidget; |
19 | class ProfileManager; | 19 | class ProfileManager; |
20 | class Profile; | 20 | class Profile; |
21 | class MainWindow : public QMainWindow { | 21 | class MainWindow : public QMainWindow { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | public: | 23 | public: |
24 | MainWindow(); | 24 | MainWindow(); |
25 | ~MainWindow(); | 25 | ~MainWindow(); |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * our factory to generate IOLayer and so on | 28 | * our factory to generate IOLayer and so on |
29 | * | 29 | * |
30 | */ | 30 | */ |
31 | MetaFactory* factory(); | 31 | MetaFactory* factory(); |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * A session contains a QWidget*, | 34 | * A session contains a QWidget*, |
35 | * an IOLayer* and some infos for us | 35 | * an IOLayer* and some infos for us |
36 | */ | 36 | */ |
37 | Session* currentSession(); | 37 | Session* currentSession(); |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * the session list | 40 | * the session list |
41 | */ | 41 | */ |
42 | QList<Session> sessions(); | 42 | QList<Session> sessions(); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * | 45 | * |
46 | */ | 46 | */ |
47 | ProfileManager* manager(); | 47 | ProfileManager* manager(); |
48 | TabWidget* tabWidget(); | 48 | TabWidget* tabWidget(); |
49 | 49 | ||
50 | private slots: | 50 | private slots: |
51 | void slotNew(); | 51 | void slotNew(); |
52 | void slotConnect(); | 52 | void slotConnect(); |
53 | void slotDisconnect(); | 53 | void slotDisconnect(); |
54 | void slotTerminate(); | 54 | void slotTerminate(); |
55 | void slotConfigure(); | 55 | void slotConfigure(); |
56 | void slotClose(); | 56 | void slotClose(); |
57 | void slotProfile(int); | 57 | void slotProfile(int); |
58 | void slotTransfer(); | ||
58 | 59 | ||
59 | private: | 60 | private: |
60 | void initUI(); | 61 | void initUI(); |
61 | void populateProfiles(); | 62 | void populateProfiles(); |
62 | void create( const Profile& ); | 63 | void create( const Profile& ); |
63 | /** | 64 | /** |
64 | * the current session | 65 | * the current session |
65 | */ | 66 | */ |
66 | Session* m_curSession; | 67 | Session* m_curSession; |
67 | 68 | ||
68 | /** | 69 | /** |
69 | * the session list | 70 | * the session list |
70 | */ | 71 | */ |
71 | QList<Session> m_sessions; | 72 | QList<Session> m_sessions; |
72 | 73 | ||
73 | /** | 74 | /** |
74 | * the metafactory | 75 | * the metafactory |
75 | */ | 76 | */ |
76 | MetaFactory* m_factory; | 77 | MetaFactory* m_factory; |
77 | ProfileManager* m_manager; | 78 | ProfileManager* m_manager; |
78 | 79 | ||
79 | TabWidget* m_consoleWindow; | 80 | TabWidget* m_consoleWindow; |
80 | QToolBar* m_tool; | 81 | QToolBar* m_tool; |
81 | QMenuBar* m_bar; | 82 | QMenuBar* m_bar; |
82 | QPopupMenu* m_console; | 83 | QPopupMenu* m_console; |
83 | QPopupMenu* m_settings; | 84 | QPopupMenu* m_settings; |
84 | QPopupMenu* m_sessionsPop; | 85 | QPopupMenu* m_sessionsPop; |
85 | QAction* m_connect; | 86 | QAction* m_connect; |
86 | QAction* m_disconnect; | 87 | QAction* m_disconnect; |
87 | QAction* m_terminate; | 88 | QAction* m_terminate; |
89 | QAction* m_transfer; | ||
88 | QAction* m_setProfiles; | 90 | QAction* m_setProfiles; |
89 | 91 | ||
90 | }; | 92 | }; |
91 | 93 | ||
92 | 94 | ||
93 | #endif | 95 | #endif |
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index 08fb32b..45522a8 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp | |||
@@ -1,92 +1,128 @@ | |||
1 | #include "transferdialog.h" | 1 | #include "transferdialog.h" |
2 | 2 | ||
3 | #include "filetransfer.h" | ||
4 | #include "io_serial.h" | ||
5 | |||
3 | #include "qlayout.h" | 6 | #include "qlayout.h" |
4 | #include "qcombobox.h" | 7 | #include "qcombobox.h" |
5 | #include "qlabel.h" | 8 | #include "qlabel.h" |
6 | #include "qlineedit.h" | 9 | #include "qlineedit.h" |
7 | #include "qpushbutton.h" | 10 | #include "qpushbutton.h" |
8 | #include "qmessagebox.h" | 11 | #include "qmessagebox.h" |
9 | #include "qprogressbar.h" | 12 | #include "qprogressbar.h" |
10 | 13 | ||
11 | #include "opie/ofiledialog.h" | 14 | #include "opie/ofiledialog.h" |
12 | 15 | ||
13 | TransferDialog::TransferDialog(QWidget *parent, const char *name) | 16 | TransferDialog::TransferDialog(QWidget *parent, const char *name) |
14 | : QWidget(parent, name) | 17 | : QDialog(/*parent, name*/NULL, NULL, true) |
15 | { | 18 | { |
16 | QVBoxLayout *vbox; | 19 | QVBoxLayout *vbox; |
17 | QHBoxLayout *hbox, *hbox2; | 20 | QHBoxLayout *hbox, *hbox2; |
18 | QLabel *file, *mode, *progress, *status; | 21 | QLabel *file, *mode, *progress, *status; |
19 | QPushButton *selector, *ok, *cancel; | 22 | QPushButton *selector; |
23 | |||
24 | transfer = NULL; | ||
20 | 25 | ||
21 | file = new QLabel(QObject::tr("Send file"), this); | 26 | file = new QLabel(QObject::tr("Send file"), this); |
22 | mode = new QLabel(QObject::tr("Transfer mode"), this); | 27 | mode = new QLabel(QObject::tr("Transfer mode"), this); |
23 | progress = new QLabel(QObject::tr("Progress"), this); | 28 | progress = new QLabel(QObject::tr("Progress"), this); |
24 | status = new QLabel(QObject::tr("Status"), this); | 29 | status = new QLabel(QObject::tr("Status"), this); |
25 | 30 | ||
26 | statusbar = new QLabel(QObject::tr("ready"), this); | 31 | statusbar = new QLabel(QObject::tr("ready"), this); |
27 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 32 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
28 | 33 | ||
29 | protocol = new QComboBox(this); | 34 | protocol = new QComboBox(this); |
30 | protocol->insertItem("XModem"); | 35 | protocol->insertItem("XModem"); |
31 | protocol->insertItem("YModem"); | 36 | protocol->insertItem("YModem"); |
32 | protocol->insertItem("ZModem"); | 37 | protocol->insertItem("ZModem"); |
33 | 38 | ||
34 | filename = new QLineEdit(this); | 39 | filename = new QLineEdit(this); |
35 | 40 | ||
36 | progressbar = new QProgressBar(this); | 41 | progressbar = new QProgressBar(this); |
37 | progressbar->setProgress(0); | 42 | progressbar->setProgress(0); |
38 | 43 | ||
39 | selector = new QPushButton("...", this); | 44 | selector = new QPushButton("...", this); |
40 | ok = new QPushButton(QObject::tr("OK"), this); | 45 | ok = new QPushButton(QObject::tr("Start transfer"), this); |
41 | cancel = new QPushButton(QObject::tr("Cancel"), this); | 46 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
42 | 47 | ||
43 | vbox = new QVBoxLayout(this, 2); | 48 | vbox = new QVBoxLayout(this, 2); |
44 | vbox->add(file); | 49 | vbox->add(file); |
45 | hbox = new QHBoxLayout(vbox, 0); | 50 | hbox = new QHBoxLayout(vbox, 0); |
46 | hbox->add(filename); | 51 | hbox->add(filename); |
47 | hbox->add(selector); | 52 | hbox->add(selector); |
48 | vbox->add(mode); | 53 | vbox->add(mode); |
49 | vbox->add(protocol); | 54 | vbox->add(protocol); |
50 | vbox->add(progress); | 55 | vbox->add(progress); |
51 | vbox->add(progressbar); | 56 | vbox->add(progressbar); |
52 | vbox->add(status); | 57 | vbox->add(status); |
53 | vbox->add(statusbar); | 58 | vbox->add(statusbar); |
54 | vbox->addStretch(1); | 59 | vbox->addStretch(1); |
55 | hbox2 = new QHBoxLayout(vbox, 2); | 60 | hbox2 = new QHBoxLayout(vbox, 2); |
56 | hbox2->add(ok); | 61 | hbox2->add(ok); |
57 | hbox2->add(cancel); | 62 | hbox2->add(cancel); |
58 | 63 | ||
59 | setCaption(QObject::tr("File transfer")); | 64 | setCaption(QObject::tr("File transfer")); |
60 | show(); | 65 | show(); |
61 | 66 | ||
62 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); | 67 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); |
63 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); | 68 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); |
64 | connect(cancel, SIGNAL(clicked()), SLOT(close())); | 69 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); |
65 | } | 70 | } |
66 | 71 | ||
67 | TransferDialog::~TransferDialog() | 72 | TransferDialog::~TransferDialog() |
68 | { | 73 | { |
69 | } | 74 | } |
70 | 75 | ||
71 | void TransferDialog::slotFilename() | 76 | void TransferDialog::slotFilename() |
72 | { | 77 | { |
73 | QString f; | 78 | QString f; |
74 | 79 | ||
75 | f = OFileDialog::getOpenFileName(0); | 80 | f = OFileDialog::getOpenFileName(0); |
76 | if(!f.isNull()) filename->setText(f); | 81 | if(!f.isNull()) filename->setText(f); |
77 | } | 82 | } |
78 | 83 | ||
79 | void TransferDialog::slotTransfer() | 84 | void TransferDialog::slotTransfer() |
80 | { | 85 | { |
81 | if(filename->text().isEmpty()) | 86 | if(filename->text().isEmpty()) |
82 | { | 87 | { |
83 | QMessageBox::information(this, | 88 | QMessageBox::information(this, |
84 | QObject::tr("Attention"), | 89 | QObject::tr("Attention"), |
85 | QObject::tr("No file has been specified.")); | 90 | QObject::tr("No file has been specified.")); |
86 | return; | 91 | return; |
87 | } | 92 | } |
88 | 93 | ||
94 | ok->setEnabled(false); | ||
95 | |||
89 | statusbar->setText(QObject::tr("Sending...")); | 96 | statusbar->setText(QObject::tr("Sending...")); |
90 | progressbar->setProgress(1); | 97 | progressbar->setProgress(1); |
98 | |||
99 | FileTransfer::Type transfermode = FileTransfer::SX; | ||
100 | if(protocol->currentText() == "YModem") transfermode == FileTransfer::SY; | ||
101 | if(protocol->currentText() == "ZModem") transfermode == FileTransfer::SZ; | ||
102 | |||
103 | // dummy profile | ||
104 | Profile profile("Dummy", "serial", "vt102", Profile::White, Profile::Black, Profile::VT102); | ||
105 | |||
106 | transfer = new FileTransfer(transfermode, new IOSerial(profile)); | ||
107 | transfer->sendFile(filename->text()); | ||
108 | } | ||
109 | |||
110 | void TransferDialog::slotCancel() | ||
111 | { | ||
112 | ok->setEnabled(true); | ||
113 | |||
114 | if(transfer) | ||
115 | { | ||
116 | transfer->cancel(); | ||
117 | delete transfer; | ||
118 | transfer = NULL; | ||
119 | QMessageBox::information(this, | ||
120 | QObject::tr("Cancelled"), | ||
121 | QObject::tr("The file transfer has been cancelled.")); | ||
122 | } | ||
123 | else | ||
124 | { | ||
125 | close(); | ||
126 | } | ||
91 | } | 127 | } |
92 | 128 | ||
diff --git a/noncore/apps/opie-console/transferdialog.h b/noncore/apps/opie-console/transferdialog.h index 4fe17dd..62ae14d 100644 --- a/noncore/apps/opie-console/transferdialog.h +++ b/noncore/apps/opie-console/transferdialog.h | |||
@@ -1,30 +1,35 @@ | |||
1 | #ifndef TRANSFER_DIALOG_H | 1 | #ifndef TRANSFER_DIALOG_H |
2 | #define TRANSFER_DIALOG_H | 2 | #define TRANSFER_DIALOG_H |
3 | 3 | ||
4 | #include "qwidget.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; | ||
11 | class FileTransfer; | ||
10 | 12 | ||
11 | class TransferDialog : public QWidget | 13 | class TransferDialog : public QDialog |
12 | { | 14 | { |
13 | Q_OBJECT | 15 | Q_OBJECT |
14 | public: | 16 | public: |
15 | TransferDialog(QWidget *parent = NULL, const char *name = NULL); | 17 | TransferDialog(QWidget *parent = NULL, const char *name = NULL); |
16 | ~TransferDialog(); | 18 | ~TransferDialog(); |
17 | 19 | ||
18 | public slots: | 20 | public slots: |
19 | void slotFilename(); | 21 | void slotFilename(); |
20 | void slotTransfer(); | 22 | void slotTransfer(); |
23 | void slotCancel(); | ||
21 | 24 | ||
22 | private: | 25 | private: |
23 | QLineEdit *filename; | 26 | QLineEdit *filename; |
24 | QComboBox *protocol; | 27 | QComboBox *protocol; |
25 | QProgressBar *progressbar; | 28 | QProgressBar *progressbar; |
26 | QLabel *statusbar; | 29 | QLabel *statusbar; |
30 | QPushButton *ok, *cancel; | ||
31 | FileTransfer *transfer; | ||
27 | }; | 32 | }; |
28 | 33 | ||
29 | #endif | 34 | #endif |
30 | 35 | ||