blob: e4d609886bb48499b98b756736ab60800d6703d2 (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QT_STYLEGENERATOR_CALLBACK
#define QT_STYLEGENERATOR_CALLBACK
#include <QQmlApplicationEngine>
class StyleGenerator;
class Bridge : public QObject {
Q_OBJECT
Q_PROPERTY(QString targetDirectory MEMBER m_targetDirectory NOTIFY targetDirectoryChanged)
Q_PROPERTY(QString figmaUrlOrId MEMBER m_figmaUrlOrId NOTIFY figmaUrlOrIdChanged)
Q_PROPERTY(QString figmaToken MEMBER m_figmaToken NOTIFY figmaTokenChanged)
Q_PROPERTY(bool sanity MEMBER m_sanity NOTIFY sanityChanged)
public:
Bridge(bool guiMode);
~Bridge();
Q_INVOKABLE void generate();
Q_INVOKABLE void stop();
Q_INVOKABLE QString toLocalFile(const QUrl &url) const;
Q_INVOKABLE QString howToText();
Q_INVOKABLE QStringList availableControls() const;
Q_INVOKABLE QStringList selectedControls() const;
Q_INVOKABLE void selectControl(const QString &control, bool select);
Q_INVOKABLE bool isImageFormatSelected(const QString &format) const;
Q_INVOKABLE void selectImageFormat(const QString &format, bool select);
Q_INVOKABLE QStringList availableFallbackStyles() const;
Q_INVOKABLE QString selectedFallbackStyle() const;
Q_INVOKABLE void selectFallbackStyle(const QString &style);
signals:
void targetDirectoryChanged();
void figmaUrlOrIdChanged();
void figmaTokenChanged();
void verboseChanged();
void sanityChanged();
void generatingChanged();
void overwriteQmlChanged();
void progressToChanged(int to) const;
void progressLabelChanged(const QString &label) const;
void progress() const;
void error(const QString &msg) const;
void warning(const QString &msg) const;
void debug(const QString &msg) const;
void started() const;
void finished() const;
void figmaFileNameChanged(const QString &name) const;
public:
std::unique_ptr<QThread> m_generatorThread;
std::unique_ptr<StyleGenerator> m_generator;
QString m_targetDirectory;
QString m_figmaUrlOrId;
QString m_fileId;
QString m_figmaToken;
QString m_controlToGenerate;
QString m_selectedFallbackStyle;
QStringList m_selectedControls;
QStringList m_selectedImageFormats;
bool m_sanity = false;
bool m_guiMode = false;
private:
QString m_progressLabel;
int m_progress = 0;
};
#endif // QT_STYLEGENERATOR_CALLBACK
|