diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000000000000000000000000000000000..fa045e1f40f5d620a4b94f85e4da6f2f4f489cf2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "winsparkle"] + path = winsparkle + url = git://github.com/vslavik/winsparkle.git diff --git a/RingWinClient.pro b/RingWinClient.pro index 955d9c1a832ac4e97afea96e3b7568f82b11d75a..5f67f8136622a2f31d4193a0fffe7ac1e7201fc5 100644 --- a/RingWinClient.pro +++ b/RingWinClient.pro @@ -13,8 +13,11 @@ win32: QT += winextras VERSION = 0.3.0 GIT_VERSION = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags) +NIGHTLY_VERSION =$$system(date +'%Y%m%d') + DEFINES += VERSION=\\\"$$VERSION\\\" DEFINES += GIT_VERSION=\\\"$$GIT_VERSION\\\" +DEFINES += NIGHTLY_VERSION=\\\"$$NIGHTLY_VERSION\\\" BUILD=$${BUILD} TARGET = Ring @@ -117,6 +120,7 @@ FORMS += mainwindow.ui \ win32: LIBS += -lole32 -luuid -lshlwapi INCLUDEPATH += $${RING}/include/libringclient +INCLUDEPATH += $${RING}/include LIBS += -L$${RING}/lib -lringclient @@ -203,4 +207,14 @@ win32 { INSTALLS += RINGTONES PACKAGING LICENSE RUNTIME LRC_TRANSLATION QTRUNTIME QTDEPSRUNTIME \ QTPLUGINIMAGE QTPLATFORMS LIBSTD + + ENABLE_AUTOUPDATE=$${ENABLE_AUTOUPDATE} + equals (ENABLE_AUTOUPDATE, True) { + DEFINES += ENABLE_AUTOUPDATE + LIBS += -L$${RING}/lib -lWinSparkle + WINSPARKLE.files = $${RING}/bin/WinSparkle.dll $${RING}/bin/libringclient.dll + WINSPARKLE.path = $$OUT_PWD/release + INSTALLS += WINSPARKLE + message("AUTO UPDATES enabled") + } } diff --git a/configurationwidget.cpp b/configurationwidget.cpp index 9ede38becfb65fc1c82429f68a633a74a676efa5..757fe809ffc0a5305708cdd38454d1582292bdc3 100644 --- a/configurationwidget.cpp +++ b/configurationwidget.cpp @@ -30,7 +30,7 @@ #include "accountserializationadapter.h" #include "accountstatedelegate.h" #include "settingskey.h" - +#include "utils.h" #include "accountmodel.h" #include "protocolmodel.h" @@ -39,7 +39,9 @@ #include "ringtonemodel.h" #include "categorizedhistorymodel.h" -#include "utils.h" +#ifdef ENABLE_AUTOUPDATE +#include "winsparkle.h" +#endif ConfigurationWidget::ConfigurationWidget(QWidget *parent) : NavWidget(Nav, parent), @@ -84,10 +86,23 @@ ConfigurationWidget::ConfigurationWidget(QWidget *parent) : } } }); +#ifndef ENABLE_AUTOUPDATE + ui->checkUpdateButton->hide(); + ui->intervalUpdateCheckSpinBox->hide(); + ui->updateDayLabel->hide(); + ui->autoUpdateCheckBox->hide(); +#endif } void ConfigurationWidget::showEvent(QShowEvent *event) { + +#ifdef ENABLE_AUTOUPDATE + if (win_sparkle_get_automatic_check_for_updates()) { + ui->autoUpdateCheckBox->setChecked(true); + } + ui->intervalUpdateCheckSpinBox->setValue(win_sparkle_get_update_check_interval() / 86400); +#endif QWidget::showEvent(event); if (ui->tabWidget->currentIndex() == 1 && CallModel::instance().getActiveCalls().size() == 0) { @@ -215,3 +230,27 @@ ConfigurationWidget::on_closeOrMinCheckBox_toggled(bool checked) { settings_.setValue(SettingsKey::closeOrMinimized, checked); } + +void +ConfigurationWidget::on_checkUpdateButton_clicked() +{ +#ifdef ENABLE_AUTOUPDATE + win_sparkle_check_update_with_ui(); +#endif +} + +void +ConfigurationWidget::on_autoUpdateCheckBox_toggled(bool checked) +{ +#ifdef ENABLE_AUTOUPDATE + win_sparkle_set_automatic_check_for_updates(checked); +#endif +} + +void +ConfigurationWidget::on_intervalUpdateCheckSpinBox_valueChanged(int arg1) +{ +#ifdef ENABLE_AUTOUPDATE + win_sparkle_set_update_check_interval(arg1 * 86400); +#endif +} diff --git a/configurationwidget.h b/configurationwidget.h index ba3c9287953e6c65b0fc92eaa4a1e78eaf003f69..4af55e494e60f29e6ac1d19ddb0f0fda4d526958 100644 --- a/configurationwidget.h +++ b/configurationwidget.h @@ -56,6 +56,9 @@ private slots: void on_clearHistoryButton_clicked(); void on_historyDaySettingsSpinBox_valueChanged(int limit); void on_closeOrMinCheckBox_toggled(bool checked); + void on_checkUpdateButton_clicked(); + void on_autoUpdateCheckBox_toggled(bool checked); + void on_intervalUpdateCheckSpinBox_valueChanged(int arg1); private slots: void accountSelected(QItemSelection itemSel); diff --git a/configurationwidget.ui b/configurationwidget.ui index 3bb5c238af0886d9bac9f0275bc7205b9fc8b780..d02674ad774578a3c4639dfff9419d99fd70b10b 100644 --- a/configurationwidget.ui +++ b/configurationwidget.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>558</width> - <height>391</height> + <height>433</height> </rect> </property> <property name="sizePolicy"> @@ -166,6 +166,80 @@ </property> </widget> </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QCheckBox" name="autoUpdateCheckBox"> + <property name="text"> + <string>Check for update automatically every</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="intervalUpdateCheckSpinBox"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maximumSize"> + <size> + <width>60</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="updateDayLabel"> + <property name="text"> + <string>days</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_5"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QPushButton" name="checkUpdateButton"> + <property name="text"> + <string>Check for updates</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_4"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> <item> <spacer name="verticalSpacer_2"> <property name="orientation"> @@ -464,5 +538,22 @@ <resources> <include location="ressources.qrc"/> </resources> - <connections/> + <connections> + <connection> + <sender>autoUpdateCheckBox</sender> + <signal>toggled(bool)</signal> + <receiver>intervalUpdateCheckSpinBox</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>78</x> + <y>278</y> + </hint> + <hint type="destinationlabel"> + <x>321</x> + <y>279</y> + </hint> + </hints> + </connection> + </connections> </ui> diff --git a/globalsystemtray.h b/globalsystemtray.h index e087749fee7d35ee11982525a24338ef37dcb593..7ab43b3143d55a632c28144fa4952b33fb3cc3c7 100644 --- a/globalsystemtray.h +++ b/globalsystemtray.h @@ -35,4 +35,3 @@ public: private: GlobalSystemTray(); }; - diff --git a/mainwindow.cpp b/mainwindow.cpp index 1e7f1527fdd2be44ff7727be37d0c9e0b5314d8d..0207e1e3af43232b7fc716a0c9e5393865bfda40 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -33,6 +33,10 @@ #include "aboutdialog.h" #include "mainwindowtoolbar.h" +#ifdef ENABLE_AUTOUPDATE +#include "winsparkle.h" +#endif + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), @@ -87,6 +91,21 @@ MainWindow::MainWindow(QWidget *parent) : callWidget, &CallWidget::on_historicButton_clicked); connect(mwToolBar_->getContactListButton(), &QAction::triggered, callWidget, &CallWidget::on_contactButton_clicked); + +#ifdef ENABLE_AUTOUPDATE + win_sparkle_set_appcast_url("http://gpl.savoirfairelinux.net/ring-download/windows/winsparkle-ring.xml"); + win_sparkle_set_app_details(L"Savoir-faire Linux", L"Ring", QString(NIGHTLY_VERSION).toStdWString().c_str()); + win_sparkle_set_shutdown_request_callback([]() {QCoreApplication::exit();}); + win_sparkle_init(); + + if (win_sparkle_get_last_check_time() == -1) { + win_sparkle_set_update_check_interval(7 * 86400); + } + + QObject::connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, [=]() { + win_sparkle_cleanup(); + }); +#endif } MainWindow::~MainWindow() diff --git a/winsparkle b/winsparkle new file mode 160000 index 0000000000000000000000000000000000000000..0e2112bf52ca171062cbb732896be1c9760ff44c --- /dev/null +++ b/winsparkle @@ -0,0 +1 @@ +Subproject commit 0e2112bf52ca171062cbb732896be1c9760ff44c