Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 2dd5ac7f authored by Kurt Hindenburg's avatar Kurt Hindenburg

Update zmodem code/dialog to fix issues

Fix the Cancel button so it actual works.
Add . while transfering data to show progress.

This entire dialog/process needs refactored.
parent 016c440d
......@@ -1300,7 +1300,7 @@ void Session::startZModem(const QString& zmodem, const QString& dir, const QStri
_zmodemProgress = new ZModemDialog(QApplication::activeWindow(), false,
i18n("ZModem Progress"));
connect(_zmodemProgress, &Konsole::ZModemDialog::user1Clicked, this, &Konsole::Session::zmodemFinished);
connect(_zmodemProgress, &Konsole::ZModemDialog::zmodemCancel, this, &Konsole::Session::zmodemFinished);
_zmodemProgress->show();
}
......@@ -1335,7 +1335,7 @@ void Session::zmodemReadStatus()
msg.truncate(0);
}
if (!txt.isEmpty()) {
_zmodemProgress->addProgressText(QString::fromLocal8Bit(txt));
_zmodemProgress->addText(QString::fromLocal8Bit(txt));
}
}
}
......@@ -1345,6 +1345,9 @@ void Session::zmodemReceiveBlock(const char* data, int len)
QByteArray bytes(data, len);
_zmodemProc->write(bytes);
// Provide some feedback to dialog
_zmodemProgress->addProgressText(QStringLiteral("."));
}
void Session::zmodemFinished()
......
......@@ -21,7 +21,7 @@
// KDE
#include <KLocalizedString>
#include <KTextEdit>
#include <QTextEdit>
#include <QDialogButtonBox>
#include <QPushButton>
#include <KGuiItem>
......@@ -36,49 +36,49 @@ ZModemDialog::ZModemDialog(QWidget *aParent, bool modal, const QString &caption)
setModal(modal);
setWindowTitle(caption);
mButtonBox = new QDialogButtonBox(QDialogButtonBox::Close);
mButtonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Close);
auto mainWidget = new QWidget(this);
auto mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
mUser1Button = new QPushButton;
mButtonBox->addButton(mUser1Button, QDialogButtonBox::ActionRole);
mainLayout->addWidget(mButtonBox);
KGuiItem::assign(mUser1Button, KGuiItem(i18n("&Stop")));
mButtonBox->button(QDialogButtonBox::Close)->setDefault(true);
mUser1Button->setShortcut(Qt::Key_Escape);
// Use Cancel here to stop the transfer
mButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(true);
mButtonBox->button(QDialogButtonBox::Close)->setEnabled(false);
_textEdit = new KTextEdit(this);
connect(mButtonBox, &QDialogButtonBox::rejected, this, &Konsole::ZModemDialog::slotCancel);
connect(mButtonBox, &QDialogButtonBox::accepted, this, &Konsole::ZModemDialog::slotClose);
_textEdit = new QTextEdit(this);
_textEdit->setMinimumSize(400, 100);
_textEdit->setReadOnly(true);
mainLayout->addWidget(_textEdit);
connect(this, &Konsole::ZModemDialog::user1Clicked, this,
&Konsole::ZModemDialog::slotUser1Clicked);
connect(mButtonBox->button(QDialogButtonBox::Close),
&QPushButton::clicked, this,
&Konsole::ZModemDialog::slotClose);
addText(QStringLiteral("Note: pressing Cancel will almost certainly cause the terminal to be unusable."));
addText(QStringLiteral("-----------------"));
}
void ZModemDialog::addProgressText(const QString &text)
void ZModemDialog::addText(const QString &text)
{
QTextCursor currentCursor = _textEdit->textCursor();
_textEdit->append(text);
}
currentCursor.insertBlock();
currentCursor.insertText(text);
void ZModemDialog::addProgressText(const QString &text)
{
_textEdit->insertPlainText(text);
}
void ZModemDialog::slotUser1Clicked()
void ZModemDialog::slotCancel()
{
Q_EMIT user1Clicked();
Q_EMIT zmodemCancel();
slotClose();
}
void ZModemDialog::transferDone()
{
mButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
mButtonBox->button(QDialogButtonBox::Close)->setEnabled(true);
mUser1Button->setEnabled(false);
}
void ZModemDialog::slotClose()
......
......@@ -19,10 +19,9 @@
#ifndef ZMODEM_DIALOG_H
#define ZMODEM_DIALOG_H
// KDE
#include <QDialog>
class KTextEdit;
class QTextEdit;
class QDialogButtonBox;
class QPushButton;
namespace Konsole {
......@@ -36,6 +35,11 @@ public:
/**
* Adds a line of text to the progress window
*/
void addText(const QString &);
/**
* Adds a line of text without a new line to the progress window
*/
void addProgressText(const QString &);
/**
......@@ -44,19 +48,18 @@ public:
void transferDone();
Q_SIGNALS:
void user1Clicked();
void zmodemCancel();
private Q_SLOTS:
void slotClose();
void slotUser1Clicked();
void slotCancel();
private:
Q_DISABLE_COPY(ZModemDialog)
void delayedDestruct();
KTextEdit *_textEdit;
QTextEdit *_textEdit;
QDialogButtonBox *mButtonBox;
QPushButton *mUser1Button;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment