summaryrefslogtreecommitdiff
path: root/noncore
authorjosef <josef>2002-10-12 18:16:45 (UTC)
committer josef <josef>2002-10-12 18:16:45 (UTC)
commit82b04543125d6d856df180c437c8d9f95f41e888 (patch) (unidiff)
treeb09807b9736d07d02dfa8a9dc79d385771be8c1a /noncore
parent9c983d273b055d847cf2d1fa4f5b6e082ce850c9 (diff)
downloadopie-82b04543125d6d856df180c437c8d9f95f41e888.zip
opie-82b04543125d6d856df180c437c8d9f95f41e888.tar.gz
opie-82b04543125d6d856df180c437c8d9f95f41e888.tar.bz2
- embed transferdialog into menu
Diffstat (limited to 'noncore') (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
@@ -1,39 +1,40 @@
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
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;
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}
28void MainWindow::initUI() { 29void 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 /*
@@ -42,48 +43,54 @@ void MainWindow::initUI() {
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
@@ -193,25 +200,34 @@ void MainWindow::slotClose() {
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 */
207void MainWindow::slotProfile( int id) { 214void 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}
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
@@ -34,60 +34,62 @@ public:
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
50private slots: 50private 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
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 /**
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
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
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
67TransferDialog::~TransferDialog() 72TransferDialog::~TransferDialog()
68{ 73{
69} 74}
70 75
71void TransferDialog::slotFilename() 76void 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
79void TransferDialog::slotTransfer() 84void 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
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