score-plugin-packagemanager/PackageManager/View.hpp
1 #pragma once
2 #include <Library/LibrarySettings.hpp>
3 
4 #include <score/application/ApplicationContext.hpp>
5 #include <score/plugins/settingsdelegate/SettingsDelegateView.hpp>
6 
7 #include <QGridLayout>
8 #include <QLabel>
9 #include <QNetworkAccessManager>
10 #include <QProgressBar>
11 #include <QPushButton>
12 #include <QStorageInfo>
13 #include <QTabWidget>
14 #include <QTableView>
15 #include <QWidget>
16 
17 #include <PackageManager/PluginItemModel.hpp>
18 
19 #include <verdigris>
20 class QObject;
21 
22 namespace PM
23 {
24 class PluginSettingsPresenter;
26 {
27  W_OBJECT(PluginSettingsView)
28 public:
30 
31  QTableView* localView() { return m_addonsOnSystem; }
32  QTableView* remoteView() { return m_remoteAddons; }
33 
34  QPushButton& installButton() const { return *m_install; }
35 
36  QWidget* getWidget() override;
37 
38 private:
39  void firstTimeLibraryDownload();
40 
41  void handleAddonList(const QJsonObject&);
42  void handleAddon(const QJsonObject&);
43 
44  PackagesModel* getCurrentModel();
45  int getCurrentRow(const QTableView* t);
46  Package selectedPackage(const PackagesModel* model, int row);
47 
48  void installAddon(const Package& addon);
49  void installLibrary(const Package& addon);
50  void installSDK();
51 
52  void openLink();
53  void install();
54  void install_package(const Package& addon);
55  void uninstall();
56  void checkAll();
57  void update();
58  void updateAll();
59  void on_message(QNetworkReply* rep);
60 
61  void on_packageInstallSuccess(
62  const Package& addon, const QDir& destination, const std::vector<QString>& res);
63  void on_packageInstallFailure(const Package& addon);
64 
65  void refresh();
66  void set_info();
67  void reset_progress();
68  void progress_from_bytes(qint64 bytesReceived, qint64 bytesTotal);
69 
70  QWidget* m_widget{new QWidget};
71 
72  QTableView* m_addonsOnSystem{new QTableView};
73  QTableView* m_remoteAddons{new QTableView};
74 
75  QPushButton* m_link{new QPushButton{tr("Open link")}};
76  QPushButton* m_install{new QPushButton{tr("Install")}};
77  QPushButton* m_uninstall{new QPushButton{tr("Uninstall")}};
78  QPushButton* m_update{new QPushButton{tr("Update")}};
79  QPushButton* m_updateAll{new QPushButton{tr("Update all")}};
80 
81  QProgressBar* m_progress{new QProgressBar};
82  QNetworkAccessManager mgr;
83  int m_addonsToRetrieve = 0;
84 
85  QStorageInfo storage;
86  QLabel* m_storage{new QLabel};
87 
88  bool m_firstTimeCheck{false};
89 };
90 
91 }
Definition: PluginItemModel.hpp:49
Definition: score-plugin-packagemanager/PackageManager/View.hpp:26
Definition: SettingsDelegateView.hpp:18
Definition: PluginItemModel.hpp:24