summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp16
-rw-r--r--noncore/apps/opie-console/mainwindow.h2
-rw-r--r--noncore/apps/opie-console/transferdialog.cpp44
-rw-r--r--noncore/apps/opie-console/transferdialog.h9
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
@@ -10,12 +10,13 @@
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
17MainWindow::MainWindow() { 18MainWindow::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;
@@ -60,12 +61,18 @@ void MainWindow::initUI() {
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 );
@@ -211,7 +218,16 @@ void MainWindow::slotProfile( int id) {
211void MainWindow::create( const Profile& prof ) { 218void 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
227void 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
@@ -52,12 +52,13 @@ private slots:
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
59private: 60private:
60 void initUI(); 61 void initUI();
61 void populateProfiles(); 62 void populateProfiles();
62 void create( const Profile& ); 63 void create( const Profile& );
63 /** 64 /**
@@ -82,12 +83,13 @@ private:
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,25 +1,30 @@
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
13TransferDialog::TransferDialog(QWidget *parent, const char *name) 16TransferDialog::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
@@ -34,13 +39,13 @@ TransferDialog::TransferDialog(QWidget *parent, const char *name)
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);
@@ -58,13 +63,13 @@ TransferDialog::TransferDialog(QWidget *parent, const char *name)
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
67TransferDialog::~TransferDialog() 72TransferDialog::~TransferDialog()
68{ 73{
69} 74}
70 75
@@ -83,10 +88,41 @@ void TransferDialog::slotTransfer()
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
110void 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
6class QLineEdit; 6class QLineEdit;
7class QComboBox; 7class QComboBox;
8class QProgressBar; 8class QProgressBar;
9class QLabel; 9class QLabel;
10class QPushButton;
11class FileTransfer;
10 12
11class TransferDialog : public QWidget 13class 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