Purpose

configuration.h
1/*
2 SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#ifndef PURPOSE_CONFIGURATION_H
8#define PURPOSE_CONFIGURATION_H
9
10#include <QJsonArray>
11#include <QJsonObject>
12#include <QObject>
13#include <QUrl>
14#include <purpose/purpose_export.h>
15
16class QJsonObject;
17class KPluginMetaData;
18
19namespace Purpose
20{
21class ConfigurationPrivate;
22class Job;
23
24/**
25 * @brief This class will be in charge of figuring out the job configuration
26 *
27 * Once it's figured out, it can proceed to create the job.
28 *
29 * The object will be destroyed as soon as the job finishes.
30 */
31
32class PURPOSE_EXPORT Configuration : public QObject
33{
34 Q_OBJECT
35
36 /**
37 * Tells whether there's still information to be provided, to be able to run
38 * the job.
39 *
40 * @sa X-Purpose-MandatoryArguments and X-Purpose-AdditionalArguments
41 */
42 Q_PROPERTY(bool isReady READ isReady NOTIFY dataChanged)
43
44 /**
45 * Represents the data the job will have available to perform its task
46 */
47 Q_PROPERTY(QJsonObject data READ data WRITE setData NOTIFY dataChanged)
48
49 /**
50 * Specifies the arguments the config file and the job will be sharing
51 */
52 Q_PROPERTY(QJsonArray neededArguments READ neededArguments CONSTANT)
53
54 /**
55 * Specifies the qml source code to be used, to configure the current job.
56 *
57 * @sa JobController QtQuick component
58 */
59 Q_PROPERTY(QUrl configSourceCode READ configSourceCode CONSTANT)
60
61 /**
62 * @returns the plugin type name to display
63 */
64 Q_PROPERTY(QString pluginTypeName READ pluginTypeName CONSTANT)
65
66 /**
67 * @returns the plugin name to display
68 */
69 Q_PROPERTY(QString pluginName READ pluginName CONSTANT)
70public:
71 Configuration(const QJsonObject &inputData,
72 const QString &pluginTypeName,
73 const QJsonObject &pluginType,
74 const KPluginMetaData &pluginInformation,
75 QObject *parent = nullptr);
76 Configuration(const QJsonObject &inputData, const QString &pluginTypeName, const KPluginMetaData &pluginInformation, QObject *parent = nullptr);
77 ~Configuration() override;
78
79 void setData(const QJsonObject &data);
80 QJsonObject data() const;
81
82 bool isReady() const;
83 QJsonArray neededArguments() const;
84 QUrl configSourceCode() const;
85
86 /**
87 * @returns whether the job will be run in the same process.
88 *
89 * By default it will be true, unless the environment variable KDE_PURPOSE_LOCAL_JOBS is defined
90 */
91 bool useSeparateProcess() const;
92
93 /**
94 * @p separate will specify whether the process will be forced to execute
95 * in-process or in a separate process.
96 */
97 void setUseSeparateProcess(bool separate);
98
99 /**
100 * @returns the configured job ready to be started.
101 *
102 * Before calling it, make sure that all information has been filled by
103 * checking isReady().
104 */
105 Q_SCRIPTABLE Purpose::Job *createJob();
106
107 QString pluginName() const;
108
109 QString pluginTypeName() const;
110
111Q_SIGNALS:
112 void dataChanged();
113
114private:
115 Q_DECLARE_PRIVATE(Configuration)
116 ConfigurationPrivate *const d_ptr;
117};
118
119}
120
121#endif // CONFIGURATION_H
This class will be in charge of figuring out the job configuration.
Job that will actually perform the sharing.
Definition job.h:34
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:06 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.