summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-26 11:38:42 (UTC)
committer josef <josef>2002-10-26 11:38:42 (UTC)
commit2dc92ada34785bbfff8ca1202e4d53eb0606c362 (patch) (unidiff)
treec92a92b5cbb1d80962821212b9157260a9faa0f6
parent65ada01d36dc25f053a09222e8abdb21f2fc3a2a (diff)
downloadopie-2dc92ada34785bbfff8ca1202e4d53eb0606c362.zip
opie-2dc92ada34785bbfff8ca1202e4d53eb0606c362.tar.gz
opie-2dc92ada34785bbfff8ca1202e4d53eb0606c362.tar.bz2
- nonmodal file transfer (doesn't work yet!)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp24
-rw-r--r--noncore/apps/opie-console/session.cpp10
-rw-r--r--noncore/apps/opie-console/session.h5
-rw-r--r--noncore/apps/opie-console/transferdialog.cpp15
-rw-r--r--noncore/apps/opie-console/transferdialog.h2
5 files changed, 46 insertions, 10 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index c44b359..5f6dc12 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -521,32 +521,35 @@ void MainWindow::slotClose() {
521 m_closewindow->setEnabled( false ); 521 m_closewindow->setEnabled( false );
522 } 522 }
523 523
524 m_kb->loadDefaults(); 524 m_kb->loadDefaults();
525} 525}
526 526
527/* 527/*
528 * We will get the name 528 * We will get the name
529 * Then the profile 529 * Then the profile
530 * and then we will make a profile 530 * and then we will make a profile
531 */ 531 */
532void MainWindow::slotProfile( int id) { 532void MainWindow::slotProfile( int id) {
533 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 533 Profile prof = manager()->profile( m_sessionsPop->text( id) );
534 create( prof ); 534 create( prof );
535} 535}
536void MainWindow::create( const Profile& prof ) { 536void MainWindow::create( const Profile& prof ) {
537 if(m_curSession)
538 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
539
537 Session *ses = manager()->fromProfile( prof, tabWidget() ); 540 Session *ses = manager()->fromProfile( prof, tabWidget() );
538 541
539 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 542 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
540 { 543 {
541 QMessageBox::warning(this, 544 QMessageBox::warning(this,
542 QObject::tr("Session failed"), 545 QObject::tr("Session failed"),
543 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 546 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
544 //if(ses) delete ses; 547 //if(ses) delete ses;
545 return; 548 return;
546 } 549 }
547 550
548 m_sessions.append( ses ); 551 m_sessions.append( ses );
549 tabWidget()->add( ses ); 552 tabWidget()->add( ses );
550 tabWidget()->repaint(); 553 tabWidget()->repaint();
551 m_curSession = ses; 554 m_curSession = ses;
552 555
@@ -565,88 +568,95 @@ void MainWindow::create( const Profile& prof ) {
565 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 568 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
566 if (prof.autoConnect()) { 569 if (prof.autoConnect()) {
567 slotConnect(); 570 slotConnect();
568 } 571 }
569 572
570 573
571 574
572 QWidget *w = currentSession()->widget(); 575 QWidget *w = currentSession()->widget();
573 if(w) w->setFocus(); 576 if(w) w->setFocus();
574 577
575 m_kb->load(currentSession()->profile()); 578 m_kb->load(currentSession()->profile());
576} 579}
577 580
578void MainWindow::slotTransfer() 581void MainWindow::slotTransfer()
579{ 582{
580 if ( currentSession() ) { 583 if ( currentSession() ) {
581 TransferDialog dlg(currentSession()->widgetStack(), this); 584 Session *mysession = currentSession();
582 dlg.showMaximized(); 585 TransferDialog dlg(mysession->widgetStack(), this);
586 mysession->setTransferDialog(&dlg);
587 dlg.show();
588 //dlg.showMaximized();
583 //currentSession()->widgetStack()->add(dlg); 589 //currentSession()->widgetStack()->add(dlg);
584 dlg.exec(); 590 //dlg.exec();
591 while(dlg.isRunning()) qApp->processEvents();
592 mysession->setTransferDialog(0l);
585 } 593 }
586} 594}
587 595
588 596
589void MainWindow::slotOpenKeb(bool state) { 597void MainWindow::slotOpenKeb(bool state) {
590 598
591 if (state) m_keyBar->show(); 599 if (state) m_keyBar->show();
592 else m_keyBar->hide(); 600 else m_keyBar->hide();
593 601
594} 602}
595 603
596 604
597void MainWindow::slotOpenButtons( bool state ) { 605void MainWindow::slotOpenButtons( bool state ) {
598 606
599 if ( state ) { 607 if ( state ) {
600 m_buttonBar->show(); 608 m_buttonBar->show();
601 } else { 609 } else {
602 m_buttonBar->hide(); 610 m_buttonBar->hide();
603 } 611 }
604} 612}
605 613
606 614
607 615
608void MainWindow::slotSessionChanged( Session* ses ) { 616void MainWindow::slotSessionChanged( Session* ses ) {
609 qWarning("changed!"); 617 qWarning("changed!");
618
619 if(m_curSession)
620 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
621 if(ses)
622 if(ses->transferDialog()) ses->transferDialog()->show();
623
610 if ( ses ) { 624 if ( ses ) {
611 m_curSession = ses; 625 m_curSession = ses;
612 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 626 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
613 if ( m_curSession->layer()->isConnected() ) { 627 if ( m_curSession->layer()->isConnected() ) {
614 m_connect->setEnabled( false ); 628 m_connect->setEnabled( false );
615 m_disconnect->setEnabled( true ); 629 m_disconnect->setEnabled( true );
616 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 630 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
617 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 631 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
618 m_scripts->setItemEnabled(m_runScript_id, true); 632 m_scripts->setItemEnabled(m_runScript_id, true);
619 } else { 633 } else {
620 m_connect->setEnabled( true ); 634 m_connect->setEnabled( true );
621 m_disconnect->setEnabled( false ); 635 m_disconnect->setEnabled( false );
622 m_recordScript->setEnabled( false ); 636 m_recordScript->setEnabled( false );
623 m_saveScript->setEnabled( false ); 637 m_saveScript->setEnabled( false );
624 m_scripts->setItemEnabled(m_runScript_id, false); 638 m_scripts->setItemEnabled(m_runScript_id, false);
625 } 639 }
626 640
627 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 641 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
628 m_transfer->setEnabled( false ); 642 m_transfer->setEnabled( false );
629 } else { 643 } else {
630 m_transfer->setEnabled( true ); 644 m_transfer->setEnabled( true );
631 } 645 }
632 646
633
634
635
636
637 QWidget *w = m_curSession->widget(); 647 QWidget *w = m_curSession->widget();
638 if(w) w->setFocus(); 648 if(w) w->setFocus();
639 649
640 m_kb->load(currentSession()->profile()); 650 m_kb->load(currentSession()->profile());
641 } 651 }
642} 652}
643 653
644void MainWindow::slotFullscreen() { 654void MainWindow::slotFullscreen() {
645 655
646 656
647 657
648 if ( m_isFullscreen ) { 658 if ( m_isFullscreen ) {
649 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 659 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
650 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 660 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
651 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 661 ( m_curSession->emulationHandler() )->cornerButton()->hide();
652 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 662 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp
index c166d95..4f52584 100644
--- a/noncore/apps/opie-console/session.cpp
+++ b/noncore/apps/opie-console/session.cpp
@@ -1,29 +1,30 @@
1 1
2 2
3#include "profile.h" 3#include "profile.h"
4#include "io_layer.h" 4#include "io_layer.h"
5#include "file_layer.h" 5#include "file_layer.h"
6#include "emulation_handler.h" 6#include "emulation_handler.h"
7#include "session.h" 7#include "session.h"
8 8
9 9
10Session::Session() { 10Session::Session() {
11 m_widget = 0l; 11 m_widget = 0l;
12 m_layer = 0l; 12 m_layer = 0l;
13 m_emu = 0l; 13 m_emu = 0l;
14 m_transfer = 0l;
14} 15}
15Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) 16Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay)
16 : m_name( na ), m_widget( widget ), m_layer( lay ) 17 : m_name( na ), m_widget( widget ), m_layer( lay )
17{ 18{
18// m_widLay = 0l; 19// m_widLay = 0l;
19// m_emLay = 0l; 20// m_emLay = 0l;
20 m_emu = 0l; 21 m_emu = 0l;
21} 22}
22Session::~Session() { 23Session::~Session() {
23 delete m_layer; 24 delete m_layer;
24 delete m_emu; 25 delete m_emu;
25 delete m_widget; 26 delete m_widget;
26 /* the widget layer should be deleted by the m_widget */ 27 /* the widget layer should be deleted by the m_widget */
27} 28}
28QString Session::name()const { 29QString Session::name()const {
29 return m_name; 30 return m_name;
@@ -91,17 +92,26 @@ void Session::setIOLayer( IOLayer* lay ) {
91 m_layer = lay; 92 m_layer = lay;
92} 93}
93 94
94void Session::setEmulationHandler( EmulationHandler* lay ) { 95void Session::setEmulationHandler( EmulationHandler* lay ) {
95 delete m_emu; 96 delete m_emu;
96 m_emu = lay; 97 m_emu = lay;
97} 98}
98void Session::setProfile( const Profile& prof ) { 99void Session::setProfile( const Profile& prof ) {
99 m_prof = prof; 100 m_prof = prof;
100} 101}
101/* 102/*
102void Session::setEmulationWidget( WidgetLayer* lay ) { 103void Session::setEmulationWidget( WidgetLayer* lay ) {
103 delete m_widLay; 104 delete m_widLay;
104 m_widLay = lay; 105 m_widLay = lay;
105} 106}
106*/ 107*/
108void Session::setTransferDialog(QWidget *d)
109{
110 m_transfer = d;
111}
112
113QWidget *Session::transferDialog()
114{
115 return m_transfer;
116}
107 117
diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h
index f60a6c0..d69224a 100644
--- a/noncore/apps/opie-console/session.h
+++ b/noncore/apps/opie-console/session.h
@@ -51,27 +51,30 @@ public:
51 * the IOLayer to the EmulationLayer 51 * the IOLayer to the EmulationLayer
52 */ 52 */
53 void connect(); 53 void connect();
54 54
55 /* 55 /*
56 * disconnect the dataflow 56 * disconnect the dataflow
57 * this will be done for ft 57 * this will be done for ft
58 */ 58 */
59 void disconnect(); 59 void disconnect();
60 60
61 void setWidgetStack( QWidgetStack* widget ); 61 void setWidgetStack( QWidgetStack* widget );
62 void setEmulationHandler( EmulationHandler* lay ); 62 void setEmulationHandler( EmulationHandler* lay );
63 void setIOLayer( IOLayer* ); 63 void setIOLayer( IOLayer* );
64 void setName( const QString& ); 64 void setName( const QString& );
65 void setProfile( const Profile& ); 65 void setProfile( const Profile& );
66 66
67 void setTransferDialog(QWidget *d);
68 QWidget *transferDialog();
69
67private: 70private:
68 QString m_name; 71 QString m_name;
69 QWidgetStack* m_widget; 72 QWidgetStack* m_widget;
70 IOLayer* m_layer; 73 IOLayer* m_layer;
71 EmulationHandler* m_emu; 74 EmulationHandler* m_emu;
72 bool m_connected : 1; 75 bool m_connected : 1;
73 Profile m_prof; 76 Profile m_prof;
74 77 QWidget *m_transfer;
75}; 78};
76 79
77#endif 80#endif
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp
index 75c4c72..0af1911 100644
--- a/noncore/apps/opie-console/transferdialog.cpp
+++ b/noncore/apps/opie-console/transferdialog.cpp
@@ -5,43 +5,44 @@
5#include <qpushbutton.h> 5#include <qpushbutton.h>
6#include <qmessagebox.h> 6#include <qmessagebox.h>
7#include <qprogressbar.h> 7#include <qprogressbar.h>
8#include <qradiobutton.h> 8#include <qradiobutton.h>
9#include <qbuttongroup.h> 9#include <qbuttongroup.h>
10 10
11#include <opie/ofiledialog.h> 11#include <opie/ofiledialog.h>
12 12
13#include "file_layer.h" 13#include "file_layer.h"
14#include "receive_layer.h" 14#include "receive_layer.h"
15#include "metafactory.h" 15#include "metafactory.h"
16#include "mainwindow.h" 16#include "mainwindow.h"
17 17
18#include "transferdialog.h" 18#include "transferdialog.h"
19 19
20TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *) 20TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *)
21: QDialog(parent, 0l, true), m_win(mainwindow) 21: QDialog(parent, 0l, false), m_win(mainwindow)
22{ 22{
23 m_lay = 0l; 23 m_lay = 0l;
24 m_recvlay = 0l; 24 m_recvlay = 0l;
25 QVBoxLayout *vbox, *vbox2; 25 QVBoxLayout *vbox, *vbox2;
26 QHBoxLayout *hbox, *hbox2, *hbox3; 26 QHBoxLayout *hbox, *hbox2, *hbox3;
27 QLabel *file, *mode, *progress, *status; 27 QLabel *file, *mode, *progress, *status;
28 QButtonGroup *group; 28 QButtonGroup *group;
29 QRadioButton *mode_send, *mode_receive; 29 QRadioButton *mode_send, *mode_receive;
30 30
31 m_autocleanup = 0; 31 m_autocleanup = 0;
32 m_running = true;
32 33
33 group = new QButtonGroup(QObject::tr("Transfer mode"), this); 34 group = new QButtonGroup(QObject::tr("Transfer mode"), this);
34 mode_send = new QRadioButton(QObject::tr("Send"), group); 35 mode_send = new QRadioButton(QObject::tr("Send"), group);
35 mode_receive = new QRadioButton(QObject::tr("Receive"), group); 36 mode_receive = new QRadioButton(QObject::tr("Receive"), group);
36 group->insert(mode_send, id_send); 37 group->insert(mode_send, id_send);
37 group->insert(mode_receive, id_receive); 38 group->insert(mode_receive, id_receive);
38 vbox2 = new QVBoxLayout(group, 2); 39 vbox2 = new QVBoxLayout(group, 2);
39 vbox2->addSpacing(10); 40 vbox2->addSpacing(10);
40 hbox3 = new QHBoxLayout(vbox2, 2); 41 hbox3 = new QHBoxLayout(vbox2, 2);
41 hbox3->add(mode_send); 42 hbox3->add(mode_send);
42 hbox3->add(mode_receive); 43 hbox3->add(mode_receive);
43 mode_send->setChecked(true); 44 mode_send->setChecked(true);
44 m_transfermode = id_send; 45 m_transfermode = id_send;
45 46
46 file = new QLabel(QObject::tr("Send file"), this); 47 file = new QLabel(QObject::tr("Send file"), this);
47 mode = new QLabel(QObject::tr("Transfer protocol"), this); 48 mode = new QLabel(QObject::tr("Transfer protocol"), this);
@@ -154,42 +155,47 @@ void TransferDialog::cleanup()
154 if(m_recvlay) 155 if(m_recvlay)
155 { 156 {
156 m_recvlay->cancel(); 157 m_recvlay->cancel();
157 delete m_recvlay; 158 delete m_recvlay;
158 m_recvlay = 0l; 159 m_recvlay = 0l;
159 } 160 }
160} 161}
161 162
162void TransferDialog::slotCancel() 163void TransferDialog::slotCancel()
163{ 164{
164 ok->setEnabled(true); 165 ok->setEnabled(true);
165 statusbar->setText(QObject::tr("Ready")); 166 statusbar->setText(QObject::tr("Ready"));
166 167
167 if((m_lay) || (m_recvlay)) 168 if((m_lay) || (m_recvlay))
168 { 169 {
169 cleanup(); 170 cleanup();
170 if(m_autocleanup) close(); 171 if(m_autocleanup)
172 {
173 m_running = false;
174 close();
175 }
171 else 176 else
172 { 177 {
173 QMessageBox::information(this, 178 QMessageBox::information(this,
174 QObject::tr("Cancelled"), 179 QObject::tr("Cancelled"),
175 QObject::tr("The file transfer has been cancelled.")); 180 QObject::tr("The file transfer has been cancelled."));
176 } 181 }
177 } 182 }
178 else 183 else
179 { 184 {
185 m_running = false;
180 close(); 186 close();
181 } 187 }
182} 188}
183 189
184void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int ) 190void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int )
185{ 191{
186 progressbar->setProgress(progress); 192 progressbar->setProgress(progress);
187} 193}
188 194
189void TransferDialog::slotError(int error, const QString& ) 195void TransferDialog::slotError(int error, const QString& )
190{ 196{
191 statusbar->setText(QObject::tr("Ready")); 197 statusbar->setText(QObject::tr("Ready"));
192 198
193 switch(error) 199 switch(error)
194 { 200 {
195 case FileTransferLayer::NotSupported: 201 case FileTransferLayer::NotSupported:
@@ -251,16 +257,21 @@ void TransferDialog::slotReceived(const QString& )
251 257
252void TransferDialog::slotMode(int id) 258void TransferDialog::slotMode(int id)
253{ 259{
254 if(id == id_send) 260 if(id == id_send)
255 { 261 {
256 selector->setEnabled(true); 262 selector->setEnabled(true);
257 filename->setEnabled(true); 263 filename->setEnabled(true);
258 } 264 }
259 else 265 else
260 { 266 {
261 selector->setEnabled(false); 267 selector->setEnabled(false);
262 filename->setEnabled(false); 268 filename->setEnabled(false);
263 } 269 }
264 m_transfermode = id; 270 m_transfermode = id;
265} 271}
266 272
273bool TransferDialog::isRunning()
274{
275 return m_running;
276}
277
diff --git a/noncore/apps/opie-console/transferdialog.h b/noncore/apps/opie-console/transferdialog.h
index d87be6a..23691e0 100644
--- a/noncore/apps/opie-console/transferdialog.h
+++ b/noncore/apps/opie-console/transferdialog.h
@@ -5,50 +5,52 @@
5 5
6class QLineEdit; 6class QLineEdit;
7class QComboBox; 7class QComboBox;
8class QProgressBar; 8class QProgressBar;
9class QLabel; 9class QLabel;
10class QPushButton; 10class QPushButton;
11class MainWindow; 11class MainWindow;
12class FileTransferLayer; 12class FileTransferLayer;
13class ReceiveLayer; 13class ReceiveLayer;
14 14
15class TransferDialog : public QDialog 15class TransferDialog : public QDialog
16{ 16{
17 Q_OBJECT 17 Q_OBJECT
18 public: 18 public:
19 TransferDialog(QWidget *parent = 0l, MainWindow *mainwindow = 0l, const char *name = 0l); 19 TransferDialog(QWidget *parent = 0l, MainWindow *mainwindow = 0l, const char *name = 0l);
20 ~TransferDialog(); 20 ~TransferDialog();
21 bool isRunning();
21 22
22 public slots: 23 public slots:
23 void slotFilename(); 24 void slotFilename();
24 void slotTransfer(); 25 void slotTransfer();
25 void slotCancel(); 26 void slotCancel();
26 void slotProgress(const QString&, int, int, int, int, int); 27 void slotProgress(const QString&, int, int, int, int, int);
27 void slotError(int error, const QString& message); 28 void slotError(int error, const QString& message);
28 void slotSent(); 29 void slotSent();
29 void slotReceived(const QString& file); 30 void slotReceived(const QString& file);
30 void slotMode(int id); 31 void slotMode(int id);
31 32
32 private: 33 private:
33 enum Modes 34 enum Modes
34 { 35 {
35 id_send, 36 id_send,
36 id_receive 37 id_receive
37 }; 38 };
38 39
39 void cleanup(); 40 void cleanup();
40 41
41 QLineEdit *filename; 42 QLineEdit *filename;
42 QComboBox *protocol; 43 QComboBox *protocol;
43 QProgressBar *progressbar; 44 QProgressBar *progressbar;
44 QLabel *statusbar; 45 QLabel *statusbar;
45 QPushButton *ok, *cancel, *selector; 46 QPushButton *ok, *cancel, *selector;
46 MainWindow* m_win; 47 MainWindow* m_win;
47 FileTransferLayer* m_lay; 48 FileTransferLayer* m_lay;
48 ReceiveLayer *m_recvlay; 49 ReceiveLayer *m_recvlay;
49 int m_transfermode; 50 int m_transfermode;
50 int m_autocleanup; 51 int m_autocleanup;
52 bool m_running;
51}; 53};
52 54
53#endif 55#endif
54 56