-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,39 +1,40 @@ #include <qaction.h> #include <qmenubar.h> #include <qlabel.h> #include <qpopupmenu.h> #include <qtoolbar.h> #include "profileeditordialog.h" #include "configdialog.h" #include "default.h" #include "metafactory.h" #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); m_sessions.setAutoDelete( TRUE ); m_curSession = 0; m_manager = new ProfileManager( m_factory ); m_manager->load(); initUI(); populateProfiles(); } void MainWindow::initUI() { setToolBarsMovable( FALSE ); m_tool = new QToolBar( this ); m_tool->setHorizontalStretchable( TRUE ); m_bar = new QMenuBar( m_tool ); m_console = new QPopupMenu( this ); m_sessionsPop= new QPopupMenu( this ); m_settings = new QPopupMenu( this ); /* @@ -42,48 +43,54 @@ void MainWindow::initUI() { QAction* a = new QAction(); a->setText( tr("New Connection") ); a->addTo( m_console ); connect(a, SIGNAL(activated() ), this, SLOT(slotNew() ) ); /* * connect action */ m_connect = new QAction(); m_connect->setText( tr("Connect") ); m_connect->addTo( m_console ); connect(m_connect, SIGNAL(activated() ), this, SLOT(slotConnect() ) ); /* * disconnect action */ m_disconnect = new QAction(); m_disconnect->setText( tr("Disconnect") ); 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(); m_terminate->setText( tr("Terminate") ); m_terminate->addTo( m_console ); connect(m_terminate, SIGNAL(activated() ), this, SLOT(slotTerminate() ) ); a = new QAction(); a->setText( tr("Close Window") ); a->addTo( m_console ); connect(a, SIGNAL(activated() ), this, SLOT(slotClose() ) ); /* * the settings action */ m_setProfiles = new QAction(); m_setProfiles->setText( tr("Configure Profiles") ); m_setProfiles->addTo( m_settings ); connect( m_setProfiles, SIGNAL(activated() ), this, SLOT(slotConfigure() ) ); @@ -193,25 +200,34 @@ void MainWindow::slotClose() { return; tabWidget()->remove( currentSession() ); /*it's autodelete */ m_sessions.remove( m_curSession ); m_curSession = m_sessions.first(); tabWidget()->setCurrent( m_curSession ); } /* * We will get the name * Then the profile * and then we will make a profile */ void MainWindow::slotProfile( int id) { Profile prof = manager()->profile( m_sessionsPop->text( id) ); create( prof ); } void MainWindow::create( const Profile& prof ) { Session *ses = manager()->fromProfile( prof, tabWidget() ); 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 @@ -34,60 +34,62 @@ public: * A session contains a QWidget*, * an IOLayer* and some infos for us */ Session* currentSession(); /** * the session list */ QList<Session> sessions(); /** * */ ProfileManager* manager(); TabWidget* tabWidget(); private slots: void slotNew(); void slotConnect(); void slotDisconnect(); void slotTerminate(); void slotConfigure(); void slotClose(); void slotProfile(int); + void slotTransfer(); private: void initUI(); void populateProfiles(); void create( const Profile& ); /** * the current session */ Session* m_curSession; /** * the session list */ QList<Session> m_sessions; /** * the metafactory */ MetaFactory* m_factory; ProfileManager* m_manager; TabWidget* m_consoleWindow; QToolBar* m_tool; QMenuBar* m_bar; QPopupMenu* m_console; QPopupMenu* m_settings; QPopupMenu* m_sessionsPop; QAction* m_connect; QAction* m_disconnect; QAction* m_terminate; + QAction* m_transfer; QAction* m_setProfiles; }; #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 @@ #include "transferdialog.h" +#include "filetransfer.h" +#include "io_serial.h" + #include "qlayout.h" #include "qcombobox.h" #include "qlabel.h" #include "qlineedit.h" #include "qpushbutton.h" #include "qmessagebox.h" #include "qprogressbar.h" #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); status = new QLabel(QObject::tr("Status"), this); statusbar = new QLabel(QObject::tr("ready"), this); statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); protocol = new QComboBox(this); protocol->insertItem("XModem"); protocol->insertItem("YModem"); protocol->insertItem("ZModem"); filename = new QLineEdit(this); 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); hbox = new QHBoxLayout(vbox, 0); hbox->add(filename); hbox->add(selector); vbox->add(mode); vbox->add(protocol); vbox->add(progress); vbox->add(progressbar); vbox->add(status); vbox->add(statusbar); vbox->addStretch(1); hbox2 = new QHBoxLayout(vbox, 2); hbox2->add(ok); hbox2->add(cancel); setCaption(QObject::tr("File transfer")); 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() { } void TransferDialog::slotFilename() { QString f; f = OFileDialog::getOpenFileName(0); if(!f.isNull()) filename->setText(f); } void TransferDialog::slotTransfer() { if(filename->text().isEmpty()) { QMessageBox::information(this, QObject::tr("Attention"), 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,30 +1,35 @@ #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); ~TransferDialog(); public slots: void slotFilename(); void slotTransfer(); + void slotCancel(); private: QLineEdit *filename; QComboBox *protocol; QProgressBar *progressbar; QLabel *statusbar; + QPushButton *ok, *cancel; + FileTransfer *transfer; }; #endif |