Debian Codegraph @

src/core/profilemanagerui.h

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #pragma once
5
6 #include <QObject>
7 #include <QSet>
8 #include <QString>
9 #include <QUrl>
10 #include <QVariantList>
11 #include <memory>
12 #include <string>
13 #include <string_view>
14
15 class IProfileManager;
16 class ISession;
17 class ISysModelUI;
18 class IFileCache;
19
20 class ProfileManagerUI : public QObject
21 {
22 Q_OBJECT
23
24 public:
25 static constexpr std::string_view QMLComponentID{"PROFILE_MANAGER"};
26
27 explicit ProfileManagerUI(QObject *parent = nullptr) noexcept;
28
29 void init(ISession *session, ISysModelUI *sysModelUI);
30
31 Q_INVOKABLE QString defaultIcon() const;
32 Q_INVOKABLE bool isProfileNameInUse(QString const &profileName);
33 Q_INVOKABLE bool isExecutableNameInUse(QString const &executableName);
34 Q_INVOKABLE bool isProfileUnsaved(QString const &profileName);
35 Q_INVOKABLE bool isProfileActive(QString const &profileName);
36
37 Q_INVOKABLE void add(QString const &name, QString const &exe,
38 QString const &icon, QString const &base);
39 Q_INVOKABLE void remove(QString const &name);
40 Q_INVOKABLE void updateInfo(QString const &oldName, QString const &newName,
41 QString const &exe, QString const &icon);
42 Q_INVOKABLE void activate(QString const &name, bool active);
43 Q_INVOKABLE void toggleManualProfile(QString const &name);
44
45 Q_INVOKABLE void loadSettings(QString const &name);
46 Q_INVOKABLE bool loadSettings(QString const &name, QUrl const &path);
47 Q_INVOKABLE void applySettings(QString const &name);
48 Q_INVOKABLE void resetSettings(QString const &name);
49 Q_INVOKABLE void restoreSettings(QString const &name);
50 Q_INVOKABLE void saveSettings(QString const &name);
51 Q_INVOKABLE bool exportProfile(QString const &name, QUrl const &path);
52
53 signals:
54 void initProfiles(QVariantList const &profiles);
55 void profileAdded(QString const &name, QString const &exe,
56 QString const &icon, bool hasCustomIcon, bool isActive);
57 void profileRemoved(QString const &name);
58 void profileChanged(QString const &name);
59 void profileActiveChanged(QString const &name, bool active);
60 void manualProfileToggled(QString const &name, bool active);
61 void profileSaved(QString const &name);
62 void profileInfoChanged(QString const &oldName, QString const &newName,
63 QString const &exe, QString const &icon,
64 bool hasCustomIcon, bool isActive);
65
66 private:
67 std::string cleanIconFilePath(QString iconPath) const;
68 QString toQMLIconPath(std::string const &iconPath) const;
69
70 void addProfileComponet(std::string const &profileName);
71 void addProfileUsedNames(std::string const &profileName);
72 void removeProfileUsedNames(std::string const &profileName);
73
74 ISession *session_{nullptr};
75 IProfileManager *profileManager_{nullptr};
76 ISysModelUI *sysModelUI_{nullptr};
77
78 class ProfileManagerObserver;
79 std::shared_ptr<ProfileManagerObserver> profileManagerObserver_;
80
81 class ManualProfileObserver;
82 std::shared_ptr<ManualProfileObserver> manualProfileObserver_;
83
84 QSet<QString> usedProfileNames_;
85 QSet<QString> usedExecutableNames_;
86
87 static bool const registered_;
88 static char const *const trStrings[];
89 };