sneedmc/launcher/Env.h

64 lines
1.3 KiB
C
Raw Normal View History

#pragma once
#include <memory>
#include "icons/IIconList.h"
#include <QString>
#include <QMap>
#include "QObjectPtr.h"
class QNetworkAccessManager;
class HttpMetaCache;
class BaseVersionList;
class BaseVersion;
namespace Meta
{
class Index;
}
#if defined(ENV)
2018-07-15 12:51:05 +00:00
#undef ENV
#endif
#define ENV (Env::getInstance())
class Env
{
2021-11-20 15:22:22 +00:00
friend class Application;
private:
2018-07-15 12:51:05 +00:00
struct Private;
Env();
~Env();
static void dispose();
public:
2021-11-20 15:22:22 +00:00
static Env* getInstance();
2021-11-17 12:20:10 +00:00
QNetworkAccessManager &network() const;
2018-07-15 12:51:05 +00:00
shared_qobject_ptr<HttpMetaCache> metacache();
2018-07-15 12:51:05 +00:00
std::shared_ptr<IIconList> icons();
2018-07-15 12:51:05 +00:00
/// init the cache. FIXME: possible future hook point
void initHttpMetaCache();
2018-07-15 12:51:05 +00:00
/// Updates the application proxy settings from the settings object.
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password);
2018-07-15 12:51:05 +00:00
void registerIconList(std::shared_ptr<IIconList> iconlist);
2018-07-15 12:51:05 +00:00
shared_qobject_ptr<Meta::Index> metadataIndex();
2018-07-15 12:51:05 +00:00
QString getJarsPath();
void setJarsPath(const QString & path);
bool isFeatureEnabled(const QString & featureName) const;
void enableFeature(const QString & featureName, bool state = true);
void getEnabledFeatures(QSet<QString> & features) const;
void setEnabledFeatures(const QSet<QString> & features) const;
protected:
2018-07-15 12:51:05 +00:00
Private * d;
};