Add CommandTask

This commit is contained in:
Florian Märkl 2018-06-22 19:29:42 +02:00
parent e3bd0612d9
commit 8b293bfe8c
4 changed files with 45 additions and 3 deletions

View File

@ -1713,7 +1713,7 @@ QList<QString> CutterCore::getColorThemes()
RCoreTask *CutterCore::startTask(const QString &cmd)
{
RCoreTask *task = r_core_task_new (core_, cmd.toLocal8Bit().constData(), nullptr, nullptr);
RCoreTask *task = r_core_task_new (core_, true, cmd.toLocal8Bit().constData(), nullptr, nullptr);
r_core_task_enqueue(core_, task);
return task;
}

View File

@ -167,7 +167,8 @@ SOURCES += \
widgets/RegistersWidget.cpp \
widgets/BacktraceWidget.cpp \
dialogs/OpenFileDialog.cpp \
utils/StringsTask.cpp
utils/StringsTask.cpp \
utils/CommandTask.cpp
HEADERS += \
Cutter.h \
@ -249,7 +250,8 @@ HEADERS += \
widgets/RegistersWidget.h \
widgets/BacktraceWidget.h \
dialogs/OpenFileDialog.h \
utils/StringsTask.h
utils/StringsTask.h \
utils/CommandTask.h
FORMS += \
dialogs/AboutDialog.ui \

13
src/utils/CommandTask.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "CommandTask.h"
CommandTask::CommandTask(const QString &cmd)
: cmd(cmd)
{
}
void CommandTask::runTask()
{
auto res = Core()->cmdTask(cmd);
emit finished(res);
}

27
src/utils/CommandTask.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef COMMANDTASK_H
#define COMMANDTASK_H
#include "utils/AsyncTask.h"
#include "Cutter.h"
class CommandTask : public AsyncTask
{
Q_OBJECT
public:
CommandTask(const QString &cmd);
QString getTitle() override { return tr("Running Command"); }
signals:
void finished(const QString &result);
protected:
void runTask() override;
private:
QString cmd;
};
#endif //COMMANDTASK_H