DBLSQD Qt SDK
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | List of all members
dblsqd::UpdateDialog Class Reference

A dialog class for displaying and downloading update information. More...

Inheritance diagram for dblsqd::UpdateDialog:
Inheritance graph
[legend]
Collaboration diagram for dblsqd::UpdateDialog:
Collaboration graph
[legend]

Public Types

enum  Type { OnUpdateAvailable, OnLastWindowClosed, Manual, ManualChangelog }
 This flag determines the if and when the UpdateDialog is displayed automatically. More...
 

Public Slots

void onButtonInstall ()
 Default handler for the install button. More...
 
void onButtonCustomInstall ()
 
void skip ()
 Skips the latest retrieved Release. More...
 
void showIfUpdatesAvailable ()
 Shows the dialog if there are available updates.
 
void showIfUpdatesAvailableOrQuit ()
 Shows the dialog if there are updates available or quits the application.
 

Signals

void ready ()
 
void installButtonClicked (QAbstractButton *button, QString filePath)
 
void linkActivated (QString link)
 

Public Member Functions

 UpdateDialog (Feed *feed, int=OnUpdateAvailable, QWidget *parent=0, QSettings *settings=new QSettings())
 Constructs a new UpdateDialog. More...
 
void setIcon (QString fileName)
 
void setIcon (QPixmap pixmap)
 Sets the icon displayed in the update window.
 
void addInstallButton (QAbstractButton *button)
 Adds a custom button for handling update installation. More...
 
void setMinVersion (QString version)
 Sets the minimum version to be displayed in the changelog. Defaults to QApplication::applicationVersion() if not set. More...
 
void setMaxVersion (QString version)
 Sets the maximum version to be displayed in the changelog. More...
 
void setPreviousVersion (QString version)
 Convenience method for setting minimum and maximum version to be displayed in the changelog. maximumVersion is set to QApplication::applicationVersion() More...
 
void setOpenExternalLinks (bool open)
 
bool openExternalLinks ()
 

Static Public Member Functions

static bool autoDownloadEnabled (QVariant defaultValue, QSettings *settings=new QSettings)
 Returns true if automatic downloads are enabled. More...
 
static bool autoDownloadEnabled (QSettings *settings=new QSettings())
 
static void enableAutoDownload (bool enabled, QSettings *settings=new QSettings)
 Enables or disables automatic downloads.
 

Detailed Description

A dialog class for displaying and downloading update information.

UpdateDialog is a drop-in class for adding a fully-functional auto-update component to an existing application.

The most simple integration is possible with just three lines of code:

dblsqd::Feed* feed = new dblsqd::Feed();
feed->setUrl("https://feeds.dblsqd.com/:app_token");
dblsqd::UpdateDialog* updateDialog = new dblsqd::UpdateDialog(feed);

The update dialog can also display an application icon which can be set with setIcon().

Member Enumeration Documentation

◆ Type

This flag determines the if and when the UpdateDialog is displayed automatically.

OnUpdateAvailable: Automatically display the dialog as soon as the Feed has been downloaded and parsed and if there is a newer version than the current version returned by QCoreApplication::applicationVersion().

OnLastWindowClosed: If there is a newer version available than the current version returned by QCoreApplication::applicationVersion(), the update dialog is displayed when QGuiApplication emits the lastWindowClosed() event. Note that when this flag is used, QGuiApplication::setQuitOnLastWindowClosed(false) will be called.

Manual: The dialog is only displayed when explicitly requested via show() or exec(). Note that update information might not be available instantly after constructing an UpdateDialog.

ManualChangelog: The dialog is only displayed when explicitly requested via show() or exec(). Instead of the full update interface, only the changelog will be shown.

Constructor & Destructor Documentation

◆ UpdateDialog()

dblsqd::UpdateDialog::UpdateDialog ( Feed feed,
int  type = OnUpdateAvailable,
QWidget *  parent = 0,
QSettings *  settings = new QSettings() 
)
explicit

Constructs a new UpdateDialog.

A Feed object needs to be constructed first and passed to this constructor. Feed::load() does not need to be called on the Feed object.

The given UpdateDialog::Type flag determines when/if the dialog is shown automatically.

UpdateDialog uses QSettings to save information such as when a release was skipped by the users. If you want to use a specially initialized QSettings object, you may also pass it to this constructor.

Member Function Documentation

◆ addInstallButton()

void dblsqd::UpdateDialog::addInstallButton ( QAbstractButton *  button)

Adds a custom button for handling update installation.

Parameters
buttonWhen the custom button is clicked after an update has been downloaded or when downloading an update that was started by clicking the button has finished, installButtonClicked(QAbstractButton* button, QString filePath) is emitted.

◆ autoDownloadEnabled() [1/2]

bool dblsqd::UpdateDialog::autoDownloadEnabled ( QVariant  defaultValue,
QSettings *  settings = new QSettings 
)
static

Returns true if automatic downloads are enabled.

If defaultValue is provided, it is stored if no other value has previously been set.

◆ autoDownloadEnabled() [2/2]

bool dblsqd::UpdateDialog::autoDownloadEnabled ( QSettings *  settings = new QSettings())
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ onButtonInstall

void dblsqd::UpdateDialog::onButtonInstall ( )
slot

Default handler for the install button.

Closes the dialog if no other action (such as downloading or installing a Release) is required first.

◆ openExternalLinks()

bool dblsqd::UpdateDialog::openExternalLinks ( )

UpdateExternalLinks

Determines if links in the changelog should be opened automatically by QDesktopServices::openUrl() when a user clicks on them. If set to false, the linkActivated() signal is emitted instead.

The default value is true.

◆ setMaxVersion()

void dblsqd::UpdateDialog::setMaxVersion ( QString  version)

Sets the maximum version to be displayed in the changelog.

Parameters
version

◆ setMinVersion()

void dblsqd::UpdateDialog::setMinVersion ( QString  version)

Sets the minimum version to be displayed in the changelog. Defaults to QApplication::applicationVersion() if not set.

Parameters
version

◆ setOpenExternalLinks()

void dblsqd::UpdateDialog::setOpenExternalLinks ( bool  open)

◆ setPreviousVersion()

void dblsqd::UpdateDialog::setPreviousVersion ( QString  previousVersion)

Convenience method for setting minimum and maximum version to be displayed in the changelog. maximumVersion is set to QApplication::applicationVersion()

Parameters
previousVersion

◆ skip

void dblsqd::UpdateDialog::skip ( )
slot

Skips the latest retrieved Release.

If a release has been skipped, UpdateDialog will not be displayed automatically when using Type::OnUpdateAvailable or Type::OnLastWindowClosed.


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