-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 @@ -12,8 +12,9 @@ #include "profile.h" #include "profilemanager.h" #include "mainwindow.h" #include "tabwidget.h" +#include "transferdialog.h" MainWindow::MainWindow() { m_factory = new MetaFactory(); Default def(m_factory); @@ -62,8 +63,14 @@ void MainWindow::initUI() { m_disconnect->addTo( m_console ); connect(m_disconnect, SIGNAL(activated() ), this, SLOT(slotDisconnect() ) ); + m_transfer = new QAction(); + m_transfer->setText( tr("Transfer file...") ); + m_transfer->addTo( m_console ); + connect(m_transfer, SIGNAL(activated() ), + this, SLOT(slotTransfer() ) ); + /* * terminate action */ m_terminate = new QAction(); @@ -213,5 +220,14 @@ void MainWindow::create( const Profile& prof ) { m_sessions.append( ses ); tabWidget()->add( ses ); m_curSession = ses; + } + +void MainWindow::slotTransfer() +{ + TransferDialog dlg(this); + dlg.showMaximized(); + dlg.exec(); +} + 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 @@ -54,8 +54,9 @@ private slots: void slotTerminate(); void slotConfigure(); void slotClose(); void slotProfile(int); + void slotTransfer(); private: void initUI(); void populateProfiles(); @@ -84,8 +85,9 @@ private: QPopupMenu* m_sessionsPop; QAction* m_connect; QAction* m_disconnect; QAction* m_terminate; + QAction* m_transfer; QAction* m_setProfiles; }; 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,6 +1,9 @@ #include "transferdialog.h" +#include "filetransfer.h" +#include "io_serial.h" + #include "qlayout.h" #include "qcombobox.h" #include "qlabel.h" #include "qlineedit.h" @@ -10,14 +13,16 @@ #include "opie/ofiledialog.h" TransferDialog::TransferDialog(QWidget *parent, const char *name) -: QWidget(parent, name) +: QDialog(/*parent, name*/NULL, NULL, true) { QVBoxLayout *vbox; QHBoxLayout *hbox, *hbox2; QLabel *file, *mode, *progress, *status; - QPushButton *selector, *ok, *cancel; + QPushButton *selector; + + transfer = NULL; file = new QLabel(QObject::tr("Send file"), this); mode = new QLabel(QObject::tr("Transfer mode"), this); progress = new QLabel(QObject::tr("Progress"), this); @@ -36,9 +41,9 @@ TransferDialog::TransferDialog(QWidget *parent, const char *name) progressbar = new QProgressBar(this); progressbar->setProgress(0); selector = new QPushButton("...", this); - ok = new QPushButton(QObject::tr("OK"), this); + ok = new QPushButton(QObject::tr("Start transfer"), this); cancel = new QPushButton(QObject::tr("Cancel"), this); vbox = new QVBoxLayout(this, 2); vbox->add(file); @@ -60,9 +65,9 @@ TransferDialog::TransferDialog(QWidget *parent, const char *name) show(); connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); - connect(cancel, SIGNAL(clicked()), SLOT(close())); + connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); } TransferDialog::~TransferDialog() { @@ -85,8 +90,39 @@ void TransferDialog::slotTransfer() QObject::tr("No file has been specified.")); return; } + ok->setEnabled(false); + statusbar->setText(QObject::tr("Sending...")); progressbar->setProgress(1); + + FileTransfer::Type transfermode = FileTransfer::SX; + if(protocol->currentText() == "YModem") transfermode == FileTransfer::SY; + if(protocol->currentText() == "ZModem") transfermode == FileTransfer::SZ; + + // dummy profile + Profile profile("Dummy", "serial", "vt102", Profile::White, Profile::Black, Profile::VT102); + + transfer = new FileTransfer(transfermode, new IOSerial(profile)); + transfer->sendFile(filename->text()); +} + +void TransferDialog::slotCancel() +{ + ok->setEnabled(true); + + if(transfer) + { + transfer->cancel(); + delete transfer; + transfer = NULL; + QMessageBox::information(this, + QObject::tr("Cancelled"), + QObject::tr("The file transfer has been cancelled.")); + } + else + { + close(); + } } 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,15 +1,17 @@ #ifndef TRANSFER_DIALOG_H #define TRANSFER_DIALOG_H -#include "qwidget.h" +#include "qdialog.h" class QLineEdit; class QComboBox; class QProgressBar; class QLabel; +class QPushButton; +class FileTransfer; -class TransferDialog : public QWidget +class TransferDialog : public QDialog { Q_OBJECT public: TransferDialog(QWidget *parent = NULL, const char *name = NULL); @@ -17,14 +19,17 @@ class TransferDialog : public QWidget public slots: void slotFilename(); void slotTransfer(); + void slotCancel(); private: QLineEdit *filename; QComboBox *protocol; QProgressBar *progressbar; QLabel *statusbar; + QPushButton *ok, *cancel; + FileTransfer *transfer; }; #endif |