Loading...
Searching...
No Matches
DefaultLibrary.hpp
1#pragma once
2#include <QObject>
3#include <QString>
4#include <QUuid>
5
6#include <score_lib_base_export.h>
7
8#include <functional>
9#include <verdigris>
10
11namespace score
12{
27class SCORE_LIB_BASE_EXPORT DefaultLibrary final : public QObject
28{
29 W_OBJECT(DefaultLibrary)
30
31public:
32 enum class State
33 {
34 Current,
35 Missing,
36 UpdateAvailable,
37 Installing,
38 Failed
39 };
40
41 static DefaultLibrary& instance();
42
44 static QUuid key();
46 static QString folder();
48 static int installedVersion();
49
50 State state() const;
52 int availableVersion() const noexcept { return m_available; }
54 qint64 downloadSize() const noexcept { return m_size; }
56 double progress() const noexcept { return m_progress; }
57 const QString& error() const noexcept { return m_error; }
58
60 void setAvailable(int version, qint64 bytes);
62 void setInstaller(std::function<void()> installer);
63
64 bool canInstall() const noexcept { return bool(m_installer); }
66 void install();
67
69 void setProgress(qint64 received, qint64 total);
70 void setFinished(bool ok, const QString& error = {});
71
74 bool offeredInView() const noexcept { return m_views > 0; }
75 void addView() noexcept { m_views++; }
76 void removeView() noexcept { m_views--; }
77
80 bool reportedInView() const noexcept { return m_installing && m_fromView && m_views > 0; }
81
82 void changed() E_SIGNAL(SCORE_LIB_BASE_EXPORT, changed)
83
84private:
86
87 std::function<void()> m_installer;
88 QString m_error;
89 qint64 m_size{};
90 double m_progress{-1.};
91 int m_available{-1};
92 int m_views{};
93 bool m_installing{};
94 bool m_fromView{};
95 bool m_failed{};
96};
97}
Whether the default library package is installed, and up to date.
Definition DefaultLibrary.hpp:28
bool reportedInView() const noexcept
Definition DefaultLibrary.hpp:80
qint64 downloadSize() const noexcept
In bytes, 0 when unknown.
Definition DefaultLibrary.hpp:54
int availableVersion() const noexcept
-1 until the package list has been fetched.
Definition DefaultLibrary.hpp:52
double progress() const noexcept
Between 0 and 1 while installing, negative when the total is unknown.
Definition DefaultLibrary.hpp:56
bool offeredInView() const noexcept
Definition DefaultLibrary.hpp:74
Utilities for OSSIA data structures.
Definition DeviceInterface.hpp:35
Base toolkit upon which the software is built.
Definition Application.cpp:83
STL namespace.