| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 2018-2018 CSSlayer <[email protected]> |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 |
* |
| 6 |
*/ |
| 7 |
#include "renamefile.h" |
| 8 |
#include "guicommon.h" |
| 9 |
#include "log.h" |
| 10 |
#include <QDebug> |
| 11 |
#include <QProcess> |
| 12 |
#include <QTemporaryFile> |
| 13 |
#include <fcitx-utils/i18n.h> |
| 14 |
#include <fcitx-utils/standardpaths.h> |
| 15 |
|
| 16 |
namespace fcitx { |
| 17 |
|
| 18 |
RenameFile::RenameFile(const QString &from, const QString &to, QObject *parent) |
| 19 |
: PipelineJob(parent), from_(from), to_(to) {} |
| 20 |
|
| 21 |
void RenameFile::start() { |
| 22 |
bool result = ::rename(from_.toLocal8Bit().constData(), |
| 23 |
to_.toLocal8Bit().constData()) >= 0; |
| 24 |
QMetaObject::invokeMethod(this, "emitFinished", Qt::QueuedConnection, |
| 25 |
Q_ARG(bool, result)); |
| 26 |
} |
| 27 |
|
| 28 |
void RenameFile::abort() {} |
| 29 |
|
| 30 |
void RenameFile::cleanUp() {} |
| 31 |
|
| 32 |
void RenameFile::emitFinished(bool result) { |
| 33 |
if (!result) { |
| 34 |
Q_EMIT message(QMessageBox::Critical, _("Converter crashed.")); |
| 35 |
return; |
| 36 |
} |
| 37 |
Q_EMIT finished(result); |
| 38 |
} |
| 39 |
|
| 40 |
} // namespace fcitx |