author | josef <josef> | 2002-10-16 17:25:49 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-16 17:25:49 (UTC) |
commit | 1a305f211913ce4a4d73ed0b36a0be535c0e03ec (patch) (side-by-side diff) | |
tree | 5b6e4a814107750e0edb2b10ab6a04a658f5c4f4 | |
parent | 9a7e223378c2d178f575b14f7632843f39faf461 (diff) | |
download | opie-1a305f211913ce4a4d73ed0b36a0be535c0e03ec.zip opie-1a305f211913ce4a4d73ed0b36a0be535c0e03ec.tar.gz opie-1a305f211913ce4a4d73ed0b36a0be535c0e03ec.tar.bz2 |
- if send/receive child processes exit, clicking on 'cancel' doesn't inform the
user about process cancellation because this is already done at this time.
-rw-r--r-- | noncore/apps/opie-console/transferdialog.cpp | 44 | ||||
-rw-r--r-- | noncore/apps/opie-console/transferdialog.h | 3 |
2 files changed, 34 insertions, 13 deletions
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index 0083cc1..f9a0b87 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp @@ -23,16 +23,18 @@ TransferDialog::TransferDialog(MainWindow *parent, const char *name) 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; + 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); @@ -108,16 +110,19 @@ void TransferDialog::slotTransfer() QMessageBox::information(this, QObject::tr("Attention"), QObject::tr("No file has been specified.")); return; } ok->setEnabled(false); + cleanup(); + m_autocleanup = 0; + if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); else statusbar->setText(QObject::tr("Receiving...")); if(m_transfermode == id_send) { m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); m_lay->sendFile(filename->text()); @@ -133,38 +138,47 @@ void TransferDialog::slotTransfer() connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)), SLOT(slotProgress(const QString&, int, int, int, int, int))); connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); } } +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)) { - if(m_lay) - { - m_lay->cancel(); - delete m_lay; - m_lay = 0l; - } - if(m_recvlay) + cleanup(); + if(m_autocleanup) close(); + else { - m_recvlay->cancel(); - delete m_recvlay; - m_recvlay = 0l; + QMessageBox::information(this, + QObject::tr("Cancelled"), + QObject::tr("The file transfer has been cancelled.")); } - QMessageBox::information(this, - QObject::tr("Cancelled"), - QObject::tr("The file transfer has been cancelled.")); } else { close(); } } void TransferDialog::slotProgress(const QString& file, int progress, int speed, int hours, int minutes, int seconds) @@ -205,30 +219,34 @@ void TransferDialog::slotError(int error, const QString& message) break; case FileTransferLayer::Unknown: default: QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("Unknown error occured.")); break; } + + m_autocleanup = 1; } void TransferDialog::slotSent() { QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been sent.")); ok->setEnabled(true); statusbar->setText(QObject::tr("Ready")); + m_autocleanup = 1; } void TransferDialog::slotReceived(const QString& file) { QMessageBox::information(this, QObject::tr("Sent"), QObject::tr("File has been received as %1.").arg(file)); ok->setEnabled(true); statusbar->setText(QObject::tr("Ready")); + m_autocleanup = 1; } void TransferDialog::slotMode(int id) { if(id == id_send) { selector->setEnabled(true); filename->setEnabled(true); diff --git a/noncore/apps/opie-console/transferdialog.h b/noncore/apps/opie-console/transferdialog.h index de3a5cf..1b27f16 100644 --- a/noncore/apps/opie-console/transferdialog.h +++ b/noncore/apps/opie-console/transferdialog.h @@ -31,21 +31,24 @@ class TransferDialog : public QDialog 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; }; #endif |