mirror of
https://github.com/KDE/konsole.git
synced 2026-01-01 19:58:09 -05:00
* speeds up incremental builds as changes to a header will not always need the full mocs_compilation.cpp for all the target's headers rebuild, while having a moc file sourced into a source file only adds minor extra costs, due to small own code and the used headers usually already covered by the source file, being for the same class/struct * seems to not slow down clean builds, due to empty mocs_compilation.cpp resulting in those quickly processed, while the minor extra cost of the sourced moc files does not outweigh that in summary. Measured times actually improved by some percent points. (ideally CMake would just skip empty mocs_compilation.cpp & its object file one day) * enables compiler to see all methods of a class in same compilation unit to do some sanity checks * potentially more inlining in general, due to more in the compilation unit * allows to keep using more forward declarations in the header, as with the moc code being sourced into the cpp file there definitions can be ensured and often are already for the needs of the normal class methods
88 lines
2.1 KiB
C++
88 lines
2.1 KiB
C++
/*
|
|
* SPDX-FileCopyrightText: 2002 Waldo Bastian <bastian@kde.org>
|
|
*
|
|
* SPDX-License-Identifier: LGPL-2.0-only
|
|
**/
|
|
|
|
// Own
|
|
#include "ZModemDialog.h"
|
|
|
|
// KDE
|
|
#include <KTextEdit>
|
|
#include <QDialogButtonBox>
|
|
#include <QPushButton>
|
|
#include <QVBoxLayout>
|
|
|
|
using Konsole::ZModemDialog;
|
|
|
|
ZModemDialog::ZModemDialog(QWidget *aParent, bool modal, const QString &caption)
|
|
: QDialog(aParent)
|
|
, _textEdit(nullptr)
|
|
, mButtonBox(nullptr)
|
|
{
|
|
setObjectName(QStringLiteral("zmodem_progress"));
|
|
setModal(modal);
|
|
setWindowTitle(caption);
|
|
|
|
mButtonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Close);
|
|
auto mainWidget = new QWidget(this);
|
|
auto mainLayout = new QVBoxLayout;
|
|
setLayout(mainLayout);
|
|
mainLayout->addWidget(mainWidget);
|
|
mainLayout->addWidget(mButtonBox);
|
|
|
|
// Use Cancel here to stop the transfer
|
|
mButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(true);
|
|
mButtonBox->button(QDialogButtonBox::Close)->setEnabled(false);
|
|
|
|
connect(mButtonBox, &QDialogButtonBox::rejected, this, &Konsole::ZModemDialog::slotCancel);
|
|
connect(mButtonBox, &QDialogButtonBox::accepted, this, &Konsole::ZModemDialog::slotClose);
|
|
|
|
_textEdit = new KTextEdit(this);
|
|
_textEdit->setMinimumSize(400, 100);
|
|
_textEdit->setReadOnly(true);
|
|
mainLayout->addWidget(_textEdit);
|
|
|
|
addText(QStringLiteral("Note: pressing Cancel will almost certainly cause the terminal to be unusable."));
|
|
addText(QStringLiteral("-----------------"));
|
|
}
|
|
|
|
void ZModemDialog::addText(const QString &text)
|
|
{
|
|
_textEdit->append(text);
|
|
}
|
|
|
|
void ZModemDialog::addProgressText(const QString &text)
|
|
{
|
|
_textEdit->insertPlainText(text);
|
|
}
|
|
|
|
void ZModemDialog::slotCancel()
|
|
{
|
|
Q_EMIT zmodemCancel();
|
|
slotClose();
|
|
}
|
|
|
|
void ZModemDialog::transferDone()
|
|
{
|
|
mButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
|
|
mButtonBox->button(QDialogButtonBox::Close)->setEnabled(true);
|
|
}
|
|
|
|
void ZModemDialog::slotClose()
|
|
{
|
|
delayedDestruct();
|
|
accept();
|
|
}
|
|
|
|
void ZModemDialog::delayedDestruct()
|
|
{
|
|
if (isVisible()) {
|
|
hide();
|
|
}
|
|
|
|
deleteLater();
|
|
}
|
|
|
|
#include "moc_ZModemDialog.cpp"
|