blob: 3e2b2f893860aa72e0e0cbdb57241cd13a9a194e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "utils_global.h"
#include "commandline.h"
#include "process.h"
#include <solutions/tasking/tasktree.h>
#include <QObject>
namespace Utils {
class QTCREATOR_UTILS_EXPORT Unarchiver : public QObject
{
Q_OBJECT
public:
class SourceAndCommand
{
private:
friend class Unarchiver;
SourceAndCommand(const FilePath &sourceFile, const CommandLine &commandTemplate)
: m_sourceFile(sourceFile), m_commandTemplate(commandTemplate) {}
FilePath m_sourceFile;
CommandLine m_commandTemplate;
};
static expected_str<SourceAndCommand> sourceAndCommand(const FilePath &sourceFile);
void setSourceAndCommand(const SourceAndCommand &data) { m_sourceAndCommand = data; }
void setDestDir(const FilePath &destDir) { m_destDir = destDir; }
void start();
signals:
void outputReceived(const QString &output);
void done(bool success);
private:
std::optional<SourceAndCommand> m_sourceAndCommand;
FilePath m_destDir;
std::unique_ptr<Process> m_process;
};
class QTCREATOR_UTILS_EXPORT UnarchiverTaskAdapter : public Tasking::TaskAdapter<Unarchiver>
{
public:
UnarchiverTaskAdapter();
void start() final;
};
using UnarchiverTask = Tasking::CustomTask<UnarchiverTaskAdapter>;
} // namespace Utils
|