Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F22067772
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
8 KB
Subscribers
None
View Options
diff --git a/src/commands/checksumcreatefilescommand.cpp b/src/commands/checksumcreatefilescommand.cpp
index 91122af70..3f5f6dba2 100644
--- a/src/commands/checksumcreatefilescommand.cpp
+++ b/src/commands/checksumcreatefilescommand.cpp
@@ -1,170 +1,170 @@
/* -*- mode: c++; c-basic-offset:4 -*-
commands/checksumcreatefilescommand.cpp
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kleopatra.h>
#include "checksumcreatefilescommand.h"
#include "command_p.h"
#include <crypto/createchecksumscontroller.h>
#include <utils/filedialog.h>
#include <Libkleo/Stl_Util>
#include <KLocalizedString>
#include "kleopatra_debug.h"
#include <exception>
using namespace Kleo;
using namespace Kleo::Commands;
using namespace Kleo::Crypto;
class ChecksumCreateFilesCommand::Private : public Command::Private
{
friend class ::Kleo::Commands::ChecksumCreateFilesCommand;
ChecksumCreateFilesCommand *q_func() const
{
return static_cast<ChecksumCreateFilesCommand *>(q);
}
public:
explicit Private(ChecksumCreateFilesCommand *qq, KeyListController *c);
~Private() override;
QStringList selectFiles() const;
void init();
private:
void slotControllerDone()
{
finished();
}
void slotControllerError(int, const QString &)
{
finished();
}
private:
QStringList files;
std::shared_ptr<const ExecutionContext> shared_qq;
CreateChecksumsController controller;
};
ChecksumCreateFilesCommand::Private *ChecksumCreateFilesCommand::d_func()
{
return static_cast<Private *>(d.get());
}
const ChecksumCreateFilesCommand::Private *ChecksumCreateFilesCommand::d_func() const
{
return static_cast<const Private *>(d.get());
}
#define d d_func()
#define q q_func()
ChecksumCreateFilesCommand::Private::Private(ChecksumCreateFilesCommand *qq, KeyListController *c)
: Command::Private(qq, c),
files(),
shared_qq(qq, [](ChecksumCreateFilesCommand*){}),
controller()
{
controller.setAllowAddition(true);
}
ChecksumCreateFilesCommand::Private::~Private()
{
qCDebug(KLEOPATRA_LOG);
}
ChecksumCreateFilesCommand::ChecksumCreateFilesCommand(KeyListController *c)
: Command(new Private(this, c))
{
d->init();
}
ChecksumCreateFilesCommand::ChecksumCreateFilesCommand(QAbstractItemView *v, KeyListController *c)
: Command(v, new Private(this, c))
{
d->init();
}
ChecksumCreateFilesCommand::ChecksumCreateFilesCommand(const QStringList &files, KeyListController *c)
: Command(new Private(this, c))
{
d->init();
d->files = files;
}
ChecksumCreateFilesCommand::ChecksumCreateFilesCommand(const QStringList &files, QAbstractItemView *v, KeyListController *c)
: Command(v, new Private(this, c))
{
d->init();
d->files = files;
}
void ChecksumCreateFilesCommand::Private::init()
{
controller.setExecutionContext(shared_qq);
- connect(&controller, SIGNAL(done()), q, SLOT(slotControllerDone()));
- connect(&controller, SIGNAL(error(int,QString)), q, SLOT(slotControllerError(int,QString)));
+ connect(&controller, &Crypto::Controller::done, q, [this]() { slotControllerDone(); });
+ connect(&controller, &Crypto::Controller::error, q, [this](int err, const QString &details) { slotControllerError(err,details); });
}
ChecksumCreateFilesCommand::~ChecksumCreateFilesCommand()
{
qCDebug(KLEOPATRA_LOG);
}
void ChecksumCreateFilesCommand::setFiles(const QStringList &files)
{
d->files = files;
}
void ChecksumCreateFilesCommand::doStart()
{
try {
if (d->files.empty()) {
d->files = d->selectFiles();
}
if (d->files.empty()) {
d->finished();
return;
}
d->controller.setFiles(d->files);
d->controller.start();
} catch (const std::exception &e) {
d->information(i18n("An error occurred: %1",
QString::fromLocal8Bit(e.what())),
i18n("Create Checksum Files Error"));
d->finished();
}
}
void ChecksumCreateFilesCommand::doCancel()
{
qCDebug(KLEOPATRA_LOG);
d->controller.cancel();
}
QStringList ChecksumCreateFilesCommand::Private::selectFiles() const
{
return FileDialog::getOpenFileNames(parentWidgetOrView(), i18n("Select One or More Files to Create Checksums For"), QStringLiteral("chk"));
}
#undef d
#undef q
#include "moc_checksumcreatefilescommand.cpp"
diff --git a/src/crypto/controller.cpp b/src/crypto/controller.cpp
index 3064bbad8..abf2c1c43 100644
--- a/src/crypto/controller.cpp
+++ b/src/crypto/controller.cpp
@@ -1,79 +1,79 @@
/* -*- mode: c++; c-basic-offset:4 -*-
crypto/controller.cpp
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <config-kleopatra.h>
#include "controller.h"
using namespace Kleo;
using namespace Kleo::Crypto;
class Controller::Private
{
friend class ::Kleo::Crypto::Controller;
Controller *const q;
public:
explicit Private(Controller *qq)
: q(qq)
{
}
private:
int lastError = 0;
QString lastErrorString;
};
Controller::Controller(QObject *parent)
: QObject(parent), ExecutionContextUser(), d(new Private(this))
{
}
Controller::Controller(const std::shared_ptr<const ExecutionContext> &ctx, QObject *parent)
: QObject(parent), ExecutionContextUser(ctx), d(new Private(this))
{
}
Controller::~Controller() {}
void Controller::taskDone(const std::shared_ptr<const Task::Result> &result)
{
const Task *task = qobject_cast<const Task *>(sender());
Q_ASSERT(task);
doTaskDone(task, result);
}
void Controller::doTaskDone(const Task *, const std::shared_ptr<const Task::Result> &) {}
void Controller::connectTask(const std::shared_ptr<Task> &task)
{
Q_ASSERT(task);
connect(task.get(), &Task::result, this, &Controller::taskDone);
}
void Controller::setLastError(int err, const QString &msg)
{
d->lastError = err;
d->lastErrorString = msg;
}
void Controller::emitDoneOrError()
{
if (d->lastError) {
- Q_EMIT error(d->lastError, d->lastErrorString);
+ Q_EMIT error(d->lastError, d->lastErrorString, QPrivateSignal{});
d->lastError = 0;
d->lastErrorString = QString();
} else {
- done();
+ Q_EMIT done(QPrivateSignal{});
}
}
diff --git a/src/crypto/controller.h b/src/crypto/controller.h
index ab3d51250..493ad1c9c 100644
--- a/src/crypto/controller.h
+++ b/src/crypto/controller.h
@@ -1,66 +1,75 @@
/* -*- mode: c++; c-basic-offset:4 -*-
crypto/controller.h
This file is part of Kleopatra, the KDE keymanager
SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QObject>
#include <crypto/task.h>
#include <utils/pimpl_ptr.h>
#include <utils/types.h>
#include <memory>
namespace Kleo
{
namespace Crypto
{
class Controller : public QObject, protected ExecutionContextUser
{
Q_OBJECT
public:
explicit Controller(QObject *parent = nullptr);
explicit Controller(const std::shared_ptr<const ExecutionContext> &cmd, QObject *parent = nullptr);
~Controller() override;
using ExecutionContextUser::setExecutionContext;
Q_SIGNALS:
void progress(int current, int total, const QString &what);
protected:
void emitDoneOrError();
void setLastError(int err, const QString &details);
void connectTask(const std::shared_ptr<Task> &task);
virtual void doTaskDone(const Task *task, const std::shared_ptr<const Task::Result> &result);
protected Q_SLOTS:
void taskDone(const std::shared_ptr<const Kleo::Crypto::Task::Result> &);
Q_SIGNALS:
-
-#ifndef Q_MOC_RUN
-# ifndef DOXYGEN_SHOULD_SKIP_THIS
-private: // don't tell moc or doxygen, but those signals are in fact private
-# endif
-#endif
- void error(int err, const QString &details);
- void done();
+ /**
+ * Private signal, you can connect to it, but derived classes cannot emit it.
+ */
+ void error(int err, const QString &details
+ # ifndef DOXYGEN_SHOULD_SKIP_THIS
+ , QPrivateSignal
+ #endif
+ );
+
+ /**
+ * Private signal, you can connect to it, but derived classes cannot emit it.
+ */
+ void done(
+ # ifndef DOXYGEN_SHOULD_SKIP_THIS
+ QPrivateSignal
+ #endif
+ );
private:
class Private;
kdtools::pimpl_ptr<Private> d;
};
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Apr 22, 3:57 AM (4 h, 26 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
53/af/c888e323c0f78b6ab27773ff1e76
Attached To
rKLEOPATRA Kleopatra
Event Timeline
Log In to Comment