-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 24 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.cpp | 10 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.h | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 15 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.h | 2 |
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 @@ -513,148 +513,158 @@ void MainWindow::slotClose() { m_connect->setEnabled( false ); m_disconnect->setEnabled( false ); m_terminate->setEnabled( false ); m_transfer->setEnabled( false ); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); m_fullscreen->setEnabled( false ); m_closewindow->setEnabled( false ); } m_kb->loadDefaults(); } /* * 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 ) { + if(m_curSession) + if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); + Session *ses = manager()->fromProfile( prof, tabWidget() ); if((!ses) || (!ses->layer()) || (!ses->widgetStack())) { QMessageBox::warning(this, QObject::tr("Session failed"), QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); //if(ses) delete ses; return; } m_sessions.append( ses ); tabWidget()->add( ses ); tabWidget()->repaint(); m_curSession = ses; // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it m_connect->setEnabled( true ); m_disconnect->setEnabled( false ); m_terminate->setEnabled( true ); m_fullscreen->setEnabled( true ); m_closewindow->setEnabled( true ); m_transfer->setEnabled( false ); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); // is io_layer wants direct connection, then autoconnect //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { if (prof.autoConnect()) { slotConnect(); } QWidget *w = currentSession()->widget(); if(w) w->setFocus(); m_kb->load(currentSession()->profile()); } void MainWindow::slotTransfer() { if ( currentSession() ) { - TransferDialog dlg(currentSession()->widgetStack(), this); - dlg.showMaximized(); + Session *mysession = currentSession(); + TransferDialog dlg(mysession->widgetStack(), this); + mysession->setTransferDialog(&dlg); + dlg.show(); + //dlg.showMaximized(); //currentSession()->widgetStack()->add(dlg); - dlg.exec(); + //dlg.exec(); + while(dlg.isRunning()) qApp->processEvents(); + mysession->setTransferDialog(0l); } } void MainWindow::slotOpenKeb(bool state) { if (state) m_keyBar->show(); else m_keyBar->hide(); } void MainWindow::slotOpenButtons( bool state ) { if ( state ) { m_buttonBar->show(); } else { m_buttonBar->hide(); } } void MainWindow::slotSessionChanged( Session* ses ) { qWarning("changed!"); + + if(m_curSession) + if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); + if(ses) + if(ses->transferDialog()) ses->transferDialog()->show(); + if ( ses ) { m_curSession = ses; qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); if ( m_curSession->layer()->isConnected() ) { m_connect->setEnabled( false ); m_disconnect->setEnabled( true ); m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); m_scripts->setItemEnabled(m_runScript_id, true); } else { m_connect->setEnabled( true ); m_disconnect->setEnabled( false ); m_recordScript->setEnabled( false ); m_saveScript->setEnabled( false ); m_scripts->setItemEnabled(m_runScript_id, false); } if ( ( m_curSession->layer() )->supports()[1] == 0 ) { m_transfer->setEnabled( false ); } else { m_transfer->setEnabled( true ); } - - - - QWidget *w = m_curSession->widget(); if(w) w->setFocus(); m_kb->load(currentSession()->profile()); } } void MainWindow::slotFullscreen() { if ( m_isFullscreen ) { ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); ( m_curSession->emulationHandler() )->cornerButton()->hide(); disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); } else { savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop , QPoint(0,0), false ); ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); ( m_curSession->widgetStack() )->setFocus(); 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,37 +1,38 @@ #include "profile.h" #include "io_layer.h" #include "file_layer.h" #include "emulation_handler.h" #include "session.h" Session::Session() { m_widget = 0l; m_layer = 0l; m_emu = 0l; + m_transfer = 0l; } Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) : m_name( na ), m_widget( widget ), m_layer( lay ) { // m_widLay = 0l; // m_emLay = 0l; m_emu = 0l; } Session::~Session() { delete m_layer; delete m_emu; delete m_widget; /* the widget layer should be deleted by the m_widget */ } QString Session::name()const { return m_name; } QWidgetStack* Session::widgetStack() { return m_widget; } IOLayer* Session::layer() { return m_layer; } EmulationHandler* Session::emulationHandler() { @@ -83,25 +84,34 @@ void Session::setWidgetStack( QWidgetStack* wid ) { m_emu = 0l; delete m_widget; /* the EmulationLayer was destroyed... */ m_widget = wid; } void Session::setIOLayer( IOLayer* lay ) { delete m_layer; m_layer = lay; } void Session::setEmulationHandler( EmulationHandler* lay ) { delete m_emu; m_emu = lay; } void Session::setProfile( const Profile& prof ) { m_prof = prof; } /* void Session::setEmulationWidget( WidgetLayer* lay ) { delete m_widLay; m_widLay = lay; } */ +void Session::setTransferDialog(QWidget *d) +{ + m_transfer = d; +} + +QWidget *Session::transferDialog() +{ + return m_transfer; +} 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 @@ -43,35 +43,38 @@ public: */ IOLayer* layer(); EmulationHandler* emulationHandler(); Profile profile()const; /* * connects the data flow from * the IOLayer to the EmulationLayer */ void connect(); /* * disconnect the dataflow * this will be done for ft */ void disconnect(); void setWidgetStack( QWidgetStack* widget ); void setEmulationHandler( EmulationHandler* lay ); void setIOLayer( IOLayer* ); void setName( const QString& ); void setProfile( const Profile& ); + void setTransferDialog(QWidget *d); + QWidget *transferDialog(); + private: QString m_name; QWidgetStack* m_widget; IOLayer* m_layer; EmulationHandler* m_emu; bool m_connected : 1; Profile m_prof; - + QWidget *m_transfer; }; #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 @@ -1,55 +1,56 @@ #include <qlayout.h> #include <qcombobox.h> #include <qlabel.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qmessagebox.h> #include <qprogressbar.h> #include <qradiobutton.h> #include <qbuttongroup.h> #include <opie/ofiledialog.h> #include "file_layer.h" #include "receive_layer.h" #include "metafactory.h" #include "mainwindow.h" #include "transferdialog.h" TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const char *) -: QDialog(parent, 0l, true), m_win(mainwindow) +: QDialog(parent, 0l, false), m_win(mainwindow) { m_lay = 0l; m_recvlay = 0l; QVBoxLayout *vbox, *vbox2; QHBoxLayout *hbox, *hbox2, *hbox3; QLabel *file, *mode, *progress, *status; QButtonGroup *group; QRadioButton *mode_send, *mode_receive; m_autocleanup = 0; + m_running = true; group = new QButtonGroup(QObject::tr("Transfer mode"), this); mode_send = new QRadioButton(QObject::tr("Send"), group); mode_receive = new QRadioButton(QObject::tr("Receive"), group); group->insert(mode_send, id_send); group->insert(mode_receive, id_receive); vbox2 = new QVBoxLayout(group, 2); vbox2->addSpacing(10); hbox3 = new QHBoxLayout(vbox2, 2); hbox3->add(mode_send); hbox3->add(mode_receive); mode_send->setChecked(true); m_transfermode = id_send; file = new QLabel(QObject::tr("Send file"), this); mode = new QLabel(QObject::tr("Transfer protocol"), 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); QStringList list = m_win->factory()->fileTransferLayers(); @@ -146,58 +147,63 @@ void TransferDialog::slotTransfer() void TransferDialog::cleanup() { if(m_lay) { m_lay->cancel(); delete m_lay; m_lay = 0l; } if(m_recvlay) { m_recvlay->cancel(); delete m_recvlay; m_recvlay = 0l; } } void TransferDialog::slotCancel() { ok->setEnabled(true); statusbar->setText(QObject::tr("Ready")); if((m_lay) || (m_recvlay)) { cleanup(); - if(m_autocleanup) close(); + if(m_autocleanup) + { + m_running = false; + close(); + } else { QMessageBox::information(this, QObject::tr("Cancelled"), QObject::tr("The file transfer has been cancelled.")); } } else { + m_running = false; close(); } } void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int ) { progressbar->setProgress(progress); } void TransferDialog::slotError(int error, const QString& ) { statusbar->setText(QObject::tr("Ready")); switch(error) { case FileTransferLayer::NotSupported: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Operation not supported.")); break; case FileTransferLayer::StartError: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Transfer could not be started.")); @@ -243,24 +249,29 @@ void TransferDialog::slotReceived(const QString& ) progressbar->setProgress(100); QMessageBox::information(this, QObject::tr("Received"), QObject::tr("File has been received.")); //QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file)); ok->setEnabled(true); progressbar->setProgress(0); statusbar->setText(QObject::tr("Ready")); m_autocleanup = 1; } void TransferDialog::slotMode(int id) { if(id == id_send) { selector->setEnabled(true); filename->setEnabled(true); } else { selector->setEnabled(false); filename->setEnabled(false); } m_transfermode = id; } +bool TransferDialog::isRunning() +{ + return m_running; +} + 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 @@ -1,54 +1,56 @@ #ifndef TRANSFER_DIALOG_H #define TRANSFER_DIALOG_H #include "qdialog.h" class QLineEdit; class QComboBox; class QProgressBar; class QLabel; class QPushButton; class MainWindow; class FileTransferLayer; class ReceiveLayer; class TransferDialog : public QDialog { Q_OBJECT public: TransferDialog(QWidget *parent = 0l, MainWindow *mainwindow = 0l, const char *name = 0l); ~TransferDialog(); + bool isRunning(); public slots: void slotFilename(); void slotTransfer(); void slotCancel(); void slotProgress(const QString&, int, int, int, int, int); void slotError(int error, const QString& message); void slotSent(); void slotReceived(const QString& file); void slotMode(int id); private: enum Modes { id_send, id_receive }; void cleanup(); QLineEdit *filename; QComboBox *protocol; QProgressBar *progressbar; QLabel *statusbar; QPushButton *ok, *cancel, *selector; MainWindow* m_win; FileTransferLayer* m_lay; ReceiveLayer *m_recvlay; int m_transfermode; int m_autocleanup; + bool m_running; }; #endif |