-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from oclero/fix-bugs
Improve API
- Loading branch information
Showing
21 changed files
with
1,280 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
server.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"version": "1.1.0", | ||
"date": "01/01/2022", | ||
"checksum": "F7DD0B5215ADBB605C146B934A7E17F5", | ||
"checksum": "f7dd0b5215adbb605c146b934a7e17f5", | ||
"checksumType": "md5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# v1.1.0 | ||
### v1.1.0 | ||
|
||
- Some new feature | ||
- Some fix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
find_package(Qt5 REQUIRED Core Network Widgets) | ||
|
||
add_executable(QtWidgetsUpdaterExample WIN32 MACOSX_BUNDLE) | ||
target_sources(QtWidgetsUpdaterExample PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/resources.qrc | ||
) | ||
target_link_libraries(QtWidgetsUpdaterExample PRIVATE oclero::QtUpdater Qt5::Core Qt5::Network Qt5::Widgets) | ||
|
||
set_target_properties(QtWidgetsUpdaterExample PROPERTIES | ||
INTERNAL_CONSOLE OFF | ||
EXCLUDE_FROM_ALL ON | ||
FOLDER examples | ||
AUTOMOC ON | ||
AUTORCC ON | ||
) | ||
|
||
############# Minimal example ends here ############# | ||
target_deploy_qt(QtWidgetsUpdaterExample) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <QApplication> | ||
#include <QDebug> | ||
#include <QStandardPaths> | ||
#include <QIcon> | ||
|
||
#include <oclero/QtUpdater.hpp> | ||
#include <oclero/QtUpdateController.hpp> | ||
|
||
#include <oclero/QtUpdateWidget.hpp> | ||
|
||
int main(int argc, char* argv[]) { | ||
Q_INIT_RESOURCE(resources); | ||
|
||
QCoreApplication::setApplicationName("QtWidgetsUpdaterExample"); | ||
QCoreApplication::setApplicationVersion("1.0.0"); | ||
QCoreApplication::setOrganizationName("example"); | ||
QApplication app(argc, argv); | ||
QApplication::setWindowIcon(QIcon(":/example/icon.ico")); | ||
|
||
// 1. Create updater backend. | ||
oclero::QtUpdater updater; | ||
updater.setServerUrl("http://localhost:8000/"); | ||
|
||
// 2. Create update dialog controller. | ||
oclero::QtUpdateController updateCtrl(updater); | ||
|
||
// 3. Create and show dialog. | ||
auto* widget = new oclero::QtUpdateWidget(updateCtrl); | ||
widget->show(); | ||
|
||
return app.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<RCC> | ||
<qresource prefix="example"> | ||
<file>icon.ico</file> | ||
</qresource> | ||
</RCC> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#pragma once | ||
|
||
#include <QObject> | ||
#include <QDateTime> | ||
|
||
#include <oclero/QtUpdater.hpp> | ||
|
||
namespace oclero { | ||
/** | ||
* @brief Controller for the Update dialog. Might be used with a QtWidgets-based or QtQuick-based dialog. | ||
*/ | ||
class QtUpdateController : public QObject { | ||
Q_OBJECT | ||
|
||
Q_PROPERTY(State state READ state NOTIFY stateChanged) | ||
Q_PROPERTY(QString currentVersion READ currentVersion NOTIFY currentVersionChanged) | ||
Q_PROPERTY(QDateTime currentVersionDate READ currentVersionDate NOTIFY currentVersionDateChanged) | ||
Q_PROPERTY(QString latestVersion READ latestVersion NOTIFY latestVersionChanged) | ||
Q_PROPERTY(QDateTime latestVersionDate READ latestVersionDate NOTIFY latestVersionDateChanged) | ||
Q_PROPERTY(int downloadProgress READ downloadProgress NOTIFY downloadProgressChanged) | ||
Q_PROPERTY(QString latestVersionChangelog READ latestVersionChangelog NOTIFY latestVersionChangelogChanged) | ||
|
||
public: | ||
enum class State { | ||
None, | ||
Checking, | ||
CheckingFail, | ||
CheckingSuccess, | ||
CheckingUpToDate, | ||
Downloading, | ||
DownloadingFail, | ||
DownloadingSuccess, | ||
Installing, | ||
InstallingFail, | ||
InstallingSuccess, | ||
}; | ||
Q_ENUM(State) | ||
|
||
public: | ||
explicit QtUpdateController(oclero::QtUpdater& updater, QObject* parent = nullptr); | ||
~QtUpdateController() = default; | ||
|
||
State state() const; | ||
QString currentVersion() const; | ||
QDateTime currentVersionDate() const; | ||
QString latestVersion() const; | ||
QDateTime latestVersionDate() const; | ||
QString latestVersionChangelog() const; | ||
int downloadProgress() const; | ||
|
||
private: | ||
void setState(State state); | ||
void setDownloadProgress(int); | ||
|
||
public slots: | ||
void cancel(); | ||
void checkForUpdates(); | ||
void downloadUpdate(); | ||
void installUpdate(); | ||
|
||
signals: | ||
void stateChanged(); | ||
void currentVersionChanged(); | ||
void currentVersionDateChanged(); | ||
void latestVersionChanged(); | ||
void latestVersionDateChanged(); | ||
void latestVersionChangelogChanged(); | ||
void downloadProgressChanged(int); | ||
void manualCheckingRequested(); | ||
void closeDialogRequested(); | ||
void checkForUpdateErrorChanged(QtUpdater::ErrorCode code); | ||
void changelogDownloadErrorChanged(QtUpdater::ErrorCode code); | ||
void updateDownloadErrorChanged(QtUpdater::ErrorCode code); | ||
void updateInstallationErrorChanged(QtUpdater::ErrorCode code); | ||
|
||
private: | ||
oclero::QtUpdater& _updater; | ||
State _state{ State::None }; | ||
int _downloadProgress{ 0 }; | ||
}; | ||
} // namespace oclero |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <QDialog> | ||
#include <QMap> | ||
|
||
#include <oclero/QtUpdateController.hpp> | ||
|
||
class QStackedWidget; | ||
|
||
namespace oclero { | ||
class QtUpdateWidget : public QWidget { | ||
public: | ||
QtUpdateWidget(QtUpdateController& controller, QWidget* parent = nullptr); | ||
~QtUpdateWidget(); | ||
|
||
private: | ||
void setupUi(); | ||
|
||
private: | ||
QtUpdateController& _controller; | ||
QStackedWidget* _stackedWidget{ nullptr }; | ||
QMap<QtUpdateController::State, QWidget*> _pages; | ||
}; | ||
} // namespace oclero |
Oops, something went wrong.