QAlphaCloud  0.0.1
Qt bindings for Alpha Cloud
Public Slots | Public Member Functions | Static Public Member Functions | Properties | List of all members
QAlphaCloud::Configuration Class Reference

API configuration. More...

#include <configuration.h>

Inherits QObject.

Public Slots

bool loadFromFile (const QString &path)
 Load configuration from file. More...
 
bool loadFromSettings (QSettings *settings)
 Load configuration from QSettings. More...
 
bool loadDefault ()
 Load the default configuration. More...
 

Public Member Functions

 Configuration (QObject *parent=nullptr)
 Create a configuration. More...
 
Q_REQUIRED_RESULT QUrl apiUrl () const
 
void setApiUrl (const QUrl &apiUrl)
 
void resetApiUrl ()
 Reset API URL to the default.
 
Q_SIGNAL void apiUrlChanged (const QUrl &apiUrl)
 
Q_REQUIRED_RESULT QString appId () const
 
void setAppId (const QString &appId)
 
Q_SIGNAL void appIdChanged (const QString &appId)
 
Q_REQUIRED_RESULT QString appSecret () const
 
void setAppSecret (const QString &appSecret)
 
Q_SIGNAL void appSecretChanged (const QString &appSecret)
 
Q_REQUIRED_RESULT int requestTimeout () const
 
void setRequestTimeout (int requestTimeout)
 
void resetRequestTimeout ()
 
Q_SIGNAL void requestTimeoutChanged (int requestTimeout)
 
bool valid () const
 
Q_SIGNAL void validChanged (bool valid)
 

Static Public Member Functions

static ConfigurationdefaultConfiguration (QObject *parent=nullptr)
 Create a default configuration. More...
 
static QString defaultConfigurationPath ()
 The default configuration path. More...
 

Properties

QUrl apiUrl
 The URL to send requests to. More...
 
QString appId
 The App ID. More...
 
QString appSecret
 The API secret.
 
int requestTimeout
 Request timeout (ms). More...
 
bool valid
 Whether the configuration is valid. More...
 

Detailed Description

API configuration.

This class provides the configuration of your API connector, i.e. the URL, App ID and secret.

Additionally, the request timeout can be configured.

The default configuration can be placed in an INI file ~/.config/Broulik/QAlphaloud:

[Api]
AppId=alpha...
AppSecret=...

Constructor & Destructor Documentation

◆ Configuration()

QAlphaCloud::Configuration::Configuration ( QObject *  parent = nullptr)
explicit

Create a configuration.

It will be empty and invalid.

Parameters
parentThe owner.

Member Function Documentation

◆ defaultConfiguration()

Configuration * QAlphaCloud::Configuration::defaultConfiguration ( QObject *  parent = nullptr)
static

Create a default configuration.

This is typically what you want to pass to the Connector. It will be read from the configuration file.

◆ defaultConfigurationPath()

QString QAlphaCloud::Configuration::defaultConfigurationPath ( )
static

The default configuration path.

This is is "qalphacloud.ini" within the user's configuration directory.

Note
This does not check if this file exists.
Returns
The path to the default configuration file.

◆ loadDefault

bool QAlphaCloud::Configuration::loadDefault ( )
slot

Load the default configuration.

It will be loaded from the configuration file.

Returns
Whether the configuration could be loaded and is valid.

◆ loadFromFile

bool QAlphaCloud::Configuration::loadFromFile ( const QString &  path)
slot

Load configuration from file.

Parameters
pathThe file path
Returns
Whether the configuration could be loaded and is valid.

◆ loadFromSettings

bool QAlphaCloud::Configuration::loadFromSettings ( QSettings *  settings)
slot

Load configuration from QSettings.

Parameters
settingsThe QSettings object
Returns
Whether the configuration could be loaded and is valid.

Property Documentation

◆ apiUrl

QUrl QAlphaCloud::Configuration::apiUrl
readwrite

The URL to send requests to.

Default is the API_URL configure option, which by default is the official API endpoint.

◆ appId

QString QAlphaCloud::Configuration::appId
readwrite

The App ID.

The application ID registered on the API. Typically starts with alpha...

◆ requestTimeout

int QAlphaCloud::Configuration::requestTimeout
readwrite

Request timeout (ms).

Time out requests automatically after ms.

Default is 30,000 (30 seconds).

◆ valid

bool QAlphaCloud::Configuration::valid
read

Whether the configuration is valid.

You cannot make requests with an invalid configuration.


The documentation for this class was generated from the following files: