From 0c3feec72ebedfd8933d00d94c5f0e648aea3b48 Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com> Date: Tue, 30 Apr 2019 16:30:24 -0400 Subject: [PATCH] updater: add download manager - the download manager is responsible for Jami version verification, installer download, presenting ui for user update event Change-Id: Id71232a8c32675391f9d46b0b5a7658e8a47fc95 --- Version.txt | 1 + downloadbar.cpp | 52 ++++++ downloadbar.h | 41 +++++ downloadbar.ui | 94 ++++++++++ downloadmanger.cpp | 164 +++++++++++++++++ downloadmanger.h | 53 ++++++ jami-qt.pro | 14 +- ring-client-windows.sln | 25 +++ ring-client-windows.vcxproj | 20 +++ ring-client-windows.vcxproj.filters | 29 +++ settingswidget.cpp | 38 +++- stylesheet.css | 34 ++-- updateconfirmdialog.cpp | 46 +++++ updateconfirmdialog.h | 42 +++++ updateconfirmdialog.ui | 268 ++++++++++++++++++++++++++++ 15 files changed, 903 insertions(+), 18 deletions(-) create mode 100644 Version.txt create mode 100644 downloadbar.cpp create mode 100644 downloadbar.h create mode 100644 downloadbar.ui create mode 100644 downloadmanger.cpp create mode 100644 downloadmanger.h create mode 100644 updateconfirmdialog.cpp create mode 100644 updateconfirmdialog.h create mode 100644 updateconfirmdialog.ui diff --git a/Version.txt b/Version.txt new file mode 100644 index 0000000..33dc013 --- /dev/null +++ b/Version.txt @@ -0,0 +1 @@ +20190102542748 \ No newline at end of file diff --git a/downloadbar.cpp b/downloadbar.cpp new file mode 100644 index 0000000..10f73bc --- /dev/null +++ b/downloadbar.cpp @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2019 by Savoir-faire Linux * + * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + **************************************************************************/ + +#include "downloadbar.h" +#include "ui_downloadbar.h" + +updateDownloadDialog::updateDownloadDialog(QWidget* parent) + : QDialog(parent) + , ui(new Ui::updateDownloadDialog) +{ + ui->setupUi(this); + ui->progressBar->setValue(0); + ui->progressBar->setVisible(true); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); +} + +void updateDownloadDialog::setValue(double var) +{ + value_ = var; +} + +void updateDownloadDialog::setMaximum(double var) +{ + maximum_ = var; +} + +updateDownloadDialog::~updateDownloadDialog() +{ + delete ui; +} + +void updateDownloadDialog::update(QString displayText) +{ + int percent = static_cast<int>((1 - ((maximum_ - value_) / maximum_)) * 100); + ui->Statusedit->setText("Speed: " + displayText); + ui->progressBar->setValue(percent); +} diff --git a/downloadbar.h b/downloadbar.h new file mode 100644 index 0000000..d97226c --- /dev/null +++ b/downloadbar.h @@ -0,0 +1,41 @@ +/*************************************************************************** + * Copyright (C) 2019 by Savoir-faire Linux * + * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + **************************************************************************/ + +#pragma once + +#include <QDialog> + +namespace Ui { +class updateDownloadDialog; +} + +class updateDownloadDialog : public QDialog { + Q_OBJECT + +public: + updateDownloadDialog(QWidget* parent = nullptr); + ~updateDownloadDialog(); + void setValue(double var); + void setMaximum(double var); + void update(QString displayText); + +private: + Ui::updateDownloadDialog* ui; + double value_ = 0; + double maximum_ = -1; +}; diff --git a/downloadbar.ui b/downloadbar.ui new file mode 100644 index 0000000..4a6ebba --- /dev/null +++ b/downloadbar.ui @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>updateDownloadDialog</class> + <widget class="QDialog" name="updateDownloadDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>309</width> + <height>121</height> + </rect> + </property> + <property name="windowTitle"> + <string>Update Download</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + <property name="text"> + <string>Update Download Status</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Preferred</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="Statusedit"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + <property name="text"> + <string>Speed: </string> + </property> + </widget> + </item> + <item> + <widget class="QProgressBar" name="progressBar"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="value"> + <number>24</number> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/downloadmanger.cpp b/downloadmanger.cpp new file mode 100644 index 0000000..dee77df --- /dev/null +++ b/downloadmanger.cpp @@ -0,0 +1,164 @@ +/*************************************************************************** + * Copyright (C) 2019 by Savoir-faire Linux * + * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <windows.h> + +#include <QMessageBox> + +#include "downloadbar.h" +#include "downloadmanger.h" + +DownloadManager::DownloadManager(QObject* parent) + : QObject(parent) +{ + //Download it into %TEMP% + downloadpath_ = WinGetEnv("TEMP"); +} + +void DownloadManager::doDownload(const QUrl& url) +{ + QFileInfo fileInfo(url.path()); + QString fileName = fileInfo.fileName(); + + if (fileName.isEmpty()) + fileName = "download"; + + file_.reset(new QFile(downloadpath_ + "/" + fileName)); + if (!file_->open(QIODevice::WriteOnly)) { + QMessageBox::information(0, "Error!", "Unable to Open File Path"); + file_.reset(nullptr); + return; + } + + QNetworkRequest request(url); + // get() method posts a request + // to obtain the contents of the target request + // and returns a new QNetworkReply object + // opened for reading which emits + // the readyRead() signal whenever new data arrives. + currentDownload_ = manager_.get(request); + + downloadTime_.start(); + +#if QT_CONFIG(ssl) + connect(currentDownload_, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrors(QList<QSslError>))); +#endif + //downloadProgress() signal is emitted when data is received + connect(currentDownload_, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64))); + // This signal is emitted when the reply has finished processing. + // After this signal is emitted, + // there will be no more updates to the reply's data or metadata. + connect(currentDownload_, SIGNAL(finished()), this, SLOT(downloadFinished())); + // Whenever more data is received from the network, + // this readyRead() signal is emitted + connect(currentDownload_, SIGNAL(readyRead()), this, SLOT(httpReadyRead())); + + probar_.exec(); +} + +void DownloadManager::downloadFinished() +{ + // donload finished normally + int statusCode = currentDownload_->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + if (statusCode == 404) { + QMessageBox::information(0, "Error!", "DownLoaded Installer Invalid!"); + } + probar_.setMaximum(0); + probar_.setValue(0); + file_->flush(); + file_->close(); + + currentDownload_->deleteLater(); + currentDownload_ = nullptr; + file_.reset(nullptr); + probar_.setValue(0); + probar_.update("0"); + probar_.close(); +} + +void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) +{ + probar_.setMaximum(bytesTotal); + probar_.setValue(bytesReceived); + + int presentTime = downloadTime_.elapsed(); + // calculate the download speed + double speed = (bytesReceived - previousDownloadBytes_) * 1000.0 / (presentTime - previousTime_); + previousTime_ = presentTime; + previousDownloadBytes_ = bytesReceived; + + QString unit; + if (speed < 1024) { + unit = "bytes/sec"; + } else if (speed < 1024 * 1024) { + speed /= 1024; + unit = "kB/s"; + } else { + speed /= 1024 * 1024; + unit = "MB/s"; + } + + probar_.update(QString::number(speed) + " " + unit); +} + +void DownloadManager::httpReadyRead() +{ + // this slot gets called every time the QNetworkReply has new data. + // We read all of its new data and write it into the file. + // That way we use less RAM than when reading it at the finished() + // signal of the QNetworkReply + if (file_) + file_->write(currentDownload_->readAll()); +} + +QString DownloadManager::versionOnline() +{ + QString urlstr = "https://dl.jami.net/windows/testver"; + QUrl url = QUrl::fromEncoded(urlstr.toLocal8Bit()); + doDownload(url); + + QFile file(downloadpath_ + "/" + "testver"); + if (!file.open(QIODevice::ReadOnly)) { + QMessageBox::information(0, "Downloaded Version File Error", file.errorString()); + } + QTextStream in(&file); + QString onlineVersion = in.readLine(); + file.close(); + + return onlineVersion; +} + +void DownloadManager::sslErrors(const QList<QSslError>& sslErrors) +{ +#if QT_CONFIG(ssl) + for (const QSslError& error : sslErrors) + QMessageBox::information(0, "SSL Error ", error.errorString()); +#else + Q_UNUSED(sslErrors); +#endif +} + +const char* DownloadManager::WinGetEnv(const char* name) +{ + const DWORD buffSize = 65535; + static char buffer[buffSize]; + if (GetEnvironmentVariableA(name, buffer, buffSize)) { + return buffer; + } else { + return 0; + } +} diff --git a/downloadmanger.h b/downloadmanger.h new file mode 100644 index 0000000..19a4133 --- /dev/null +++ b/downloadmanger.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2019 by Savoir-faire Linux * + * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + **************************************************************************/ + +#pragma once + +#include <memory> + +#include <QtCore> +#include <QtNetwork> + +#include "downloadbar.h" + +class QSslError; + +class DownloadManager : public QObject { + Q_OBJECT + QNetworkAccessManager manager_; + QNetworkReply* currentDownload_; + updateDownloadDialog probar_; + std::unique_ptr<QFile> file_; + QTime downloadTime_; + int previousTime_ = 0; + qint64 previousDownloadBytes_ = 0; + QString downloadpath_; + + const char* WinGetEnv(const char* name); + +public: + explicit DownloadManager(QObject* parent = nullptr); + void doDownload(const QUrl& url); + QString versionOnline(); + +public slots: + void sslErrors(const QList<QSslError>& sslErrors); + void downloadFinished(); + void downloadProgress(qint64 bytesRead, qint64 totalBytes); + void httpReadyRead(); +}; diff --git a/jami-qt.pro b/jami-qt.pro index bc3bd6e..4d7ea6a 100644 --- a/jami-qt.pro +++ b/jami-qt.pro @@ -62,7 +62,10 @@ HEADERS += ./pixbufmanipulator.h \ ./toggleswitch.h \ ./videooverlay.h \ ./videoview.h \ - ./videowidget.h + ./videowidget.h \ + ./downloadbar.h \ + ./updateconfirmdialog.h \ + ./downloadmanger.h SOURCES += ./advancedsettingswidget.cpp \ ./advancedsipsettingwidget.cpp \ ./avatargraphicsview.cpp \ @@ -108,7 +111,10 @@ SOURCES += ./advancedsettingswidget.cpp \ ./videoview.cpp \ ./videowidget.cpp \ ./webchathelpers.cpp \ - ./windowscontactbackend.cpp + ./windowscontactbackend.cpp \ + ./downloadbar.cpp \ + ./updateconfirmdialog.cpp \ + ./downloadmanger.cpp FORMS += ./aboutdialog.ui \ ./advancedsettingswidget.ui \ ./advancedsipsettingwidget.ui \ @@ -128,5 +134,7 @@ FORMS += ./aboutdialog.ui \ ./ringbutton.ui \ ./settingswidget.ui \ ./videooverlay.ui \ - ./videoview.ui + ./videoview.ui \ + ./downloadbar.ui \ + ./updateconfirmdialog.ui RESOURCES += ressources.qrc diff --git a/ring-client-windows.sln b/ring-client-windows.sln index 7a9fd35..36bec31 100644 --- a/ring-client-windows.sln +++ b/ring-client-windows.sln @@ -135,62 +135,87 @@ Global {79F8DE42-595D-49D9-A66F-55244FD9DCC3}.RelWithDebInfo|x64.Build.0 = ReleaseLib|x64 {79F8DE42-595D-49D9-A66F-55244FD9DCC3}.RelWithDebInfo|x86.ActiveCfg = ReleaseLib|Win32 {79F8DE42-595D-49D9-A66F-55244FD9DCC3}.RelWithDebInfo|x86.Build.0 = ReleaseLib|Win32 + {A604BA33-C1DB-34F6-8584-C429857717A8}.Debug|Any CPU.ActiveCfg = Debug|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.Debug|x64.ActiveCfg = Debug|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.Debug|x64.Build.0 = Debug|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.Debug|x86.ActiveCfg = Debug|x64 + {A604BA33-C1DB-34F6-8584-C429857717A8}.DebugLib_win32|Any CPU.ActiveCfg = RelWithDebInfo|x64 + {A604BA33-C1DB-34F6-8584-C429857717A8}.DebugLib_win32|Any CPU.Build.0 = RelWithDebInfo|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.DebugLib_win32|x64.ActiveCfg = Debug|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.DebugLib_win32|x64.Build.0 = Debug|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.DebugLib_win32|x86.ActiveCfg = MinSizeRel|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.DebugLib_win32|x86.Build.0 = MinSizeRel|x64 + {A604BA33-C1DB-34F6-8584-C429857717A8}.DebugLib|Any CPU.ActiveCfg = RelWithDebInfo|x64 + {A604BA33-C1DB-34F6-8584-C429857717A8}.DebugLib|Any CPU.Build.0 = RelWithDebInfo|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.DebugLib|x64.ActiveCfg = Debug|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.DebugLib|x64.Build.0 = Debug|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.DebugLib|x86.ActiveCfg = MinSizeRel|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.DebugLib|x86.Build.0 = MinSizeRel|x64 + {A604BA33-C1DB-34F6-8584-C429857717A8}.MinSizeRel|Any CPU.ActiveCfg = MinSizeRel|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.MinSizeRel|x64.Build.0 = MinSizeRel|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64 + {A604BA33-C1DB-34F6-8584-C429857717A8}.Release|Any CPU.ActiveCfg = Release|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.Release|x64.ActiveCfg = Release|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.Release|x64.Build.0 = Release|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.Release|x86.ActiveCfg = Release|x64 + {A604BA33-C1DB-34F6-8584-C429857717A8}.ReleaseLib_win32|Any CPU.ActiveCfg = RelWithDebInfo|x64 + {A604BA33-C1DB-34F6-8584-C429857717A8}.ReleaseLib_win32|Any CPU.Build.0 = RelWithDebInfo|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.ReleaseLib_win32|x64.ActiveCfg = Release|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.ReleaseLib_win32|x64.Build.0 = Release|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.ReleaseLib_win32|x86.ActiveCfg = MinSizeRel|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.ReleaseLib_win32|x86.Build.0 = MinSizeRel|x64 + {A604BA33-C1DB-34F6-8584-C429857717A8}.ReleaseLib|Any CPU.ActiveCfg = RelWithDebInfo|x64 + {A604BA33-C1DB-34F6-8584-C429857717A8}.ReleaseLib|Any CPU.Build.0 = RelWithDebInfo|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.ReleaseLib|x64.ActiveCfg = Release|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.ReleaseLib|x64.Build.0 = Release|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.ReleaseLib|x86.ActiveCfg = MinSizeRel|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.ReleaseLib|x86.Build.0 = MinSizeRel|x64 + {A604BA33-C1DB-34F6-8584-C429857717A8}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64 {A604BA33-C1DB-34F6-8584-C429857717A8}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64 + {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.Debug|Any CPU.ActiveCfg = Debug|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.Debug|x64.ActiveCfg = Debug|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.Debug|x64.Build.0 = Debug|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.Debug|x86.ActiveCfg = Debug|x64 + {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.DebugLib_win32|Any CPU.ActiveCfg = RelWithDebInfo|x64 + {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.DebugLib_win32|Any CPU.Build.0 = RelWithDebInfo|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.DebugLib_win32|x64.ActiveCfg = Debug|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.DebugLib_win32|x64.Build.0 = Debug|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.DebugLib_win32|x86.ActiveCfg = MinSizeRel|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.DebugLib_win32|x86.Build.0 = MinSizeRel|x64 + {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.DebugLib|Any CPU.ActiveCfg = RelWithDebInfo|x64 + {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.DebugLib|Any CPU.Build.0 = RelWithDebInfo|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.DebugLib|x64.ActiveCfg = Debug|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.DebugLib|x64.Build.0 = Debug|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.DebugLib|x86.ActiveCfg = MinSizeRel|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.DebugLib|x86.Build.0 = MinSizeRel|x64 + {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.MinSizeRel|Any CPU.ActiveCfg = MinSizeRel|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.MinSizeRel|x64.Build.0 = MinSizeRel|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64 + {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.Release|Any CPU.ActiveCfg = Release|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.Release|x64.ActiveCfg = Release|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.Release|x64.Build.0 = Release|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.Release|x86.ActiveCfg = Release|x64 + {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.ReleaseLib_win32|Any CPU.ActiveCfg = RelWithDebInfo|x64 + {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.ReleaseLib_win32|Any CPU.Build.0 = RelWithDebInfo|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.ReleaseLib_win32|x64.ActiveCfg = Release|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.ReleaseLib_win32|x64.Build.0 = Release|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.ReleaseLib_win32|x86.ActiveCfg = MinSizeRel|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.ReleaseLib_win32|x86.Build.0 = MinSizeRel|x64 + {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.ReleaseLib|Any CPU.ActiveCfg = RelWithDebInfo|x64 + {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.ReleaseLib|Any CPU.Build.0 = RelWithDebInfo|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.ReleaseLib|x64.ActiveCfg = Release|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.ReleaseLib|x64.Build.0 = Release|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.ReleaseLib|x86.ActiveCfg = MinSizeRel|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.ReleaseLib|x86.Build.0 = MinSizeRel|x64 + {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64 {8C3AD0D4-A52C-3EFB-A2C6-04EA3AB5F00E}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64 + {DBBFBC55-1C20-4D21-AE3B-6E8B14C4FE48}.Debug|Any CPU.ActiveCfg = Debug|x64 {DBBFBC55-1C20-4D21-AE3B-6E8B14C4FE48}.Debug|x64.ActiveCfg = Debug|x64 {DBBFBC55-1C20-4D21-AE3B-6E8B14C4FE48}.Debug|x64.Build.0 = Debug|x64 {DBBFBC55-1C20-4D21-AE3B-6E8B14C4FE48}.Debug|x86.ActiveCfg = Debug|x64 diff --git a/ring-client-windows.vcxproj b/ring-client-windows.vcxproj index dc472ce..5a06edd 100644 --- a/ring-client-windows.vcxproj +++ b/ring-client-windows.vcxproj @@ -231,6 +231,8 @@ <ClCompile Include="animationhelpers.cpp" /> <ClCompile Include="currentaccountcombobox.cpp" /> <ClCompile Include="aboutdialog.cpp" /> + <ClCompile Include="downloadbar.cpp" /> + <ClCompile Include="downloadmanger.cpp" /> <ClCompile Include="accountitemdelegate.cpp" /> <ClCompile Include="accountlistmodel.cpp" /> <ClCompile Include="callwidget.cpp"> @@ -300,6 +302,7 @@ <ClCompile Include="utils.cpp" /> <ClCompile Include="videooverlay.cpp" /> <ClCompile Include="videoview.cpp" /> + <ClCompile Include="updateconfirmdialog.cpp" /> <ClCompile Include="videowidget.cpp" /> <ClCompile Include="webchathelpers.cpp" /> <ClCompile Include="windowscontactbackend.cpp" /> @@ -393,6 +396,14 @@ <Define Condition="'$(Configuration)|$(Platform)'=='Release|x64'">_WINDOWS;UNICODE;_UNICODE;WIN32;WIN64;NIGHTLY_VERSION=20180706;ENABLE_AUTOUPDATE;QT_NO_DEBUG;NDEBUG</Define> <Define Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">_WINDOWS;UNICODE;_UNICODE;WIN32;WIN64;NIGHTLY_VERSION=20180706;ENABLE_AUTOUPDATE;QT_NO_DEBUG;NDEBUG</Define> </QtMoc> + <QtMoc Include="downloadbar.h"> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> + </QtMoc> + <QtMoc Include="downloadmanger.h"> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> + </QtMoc> <QtMoc Include="passworddialog.h"> <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName)\.;.\GeneratedFiles;.;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\lrc\src;$(ProjectDir)..\client-windows\winsparkle\include;$(ProjectDir)..\client-windows\qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release;$(QTDIR)\include\QtMultimedia;$(QTDIR)\include\QtMultimediaWidgets</IncludePath> <Define Condition="'$(Configuration)|$(Platform)'=='Release|x64'">_WINDOWS;UNICODE;_UNICODE;WIN32;WIN64;NIGHTLY_VERSION=20180706;ENABLE_AUTOUPDATE;QT_NO_DEBUG;NDEBUG;QT_MULTIMEDIA_LIB;QT_MULTIMEDIAWIDGETS_LIB</Define> @@ -464,6 +475,10 @@ <Define Condition="'$(Configuration)|$(Platform)'=='Release|x64'">_WINDOWS;UNICODE;_UNICODE;WIN32;WIN64;NIGHTLY_VERSION=20180706;ENABLE_AUTOUPDATE;QT_NO_DEBUG;NDEBUG</Define> <Define Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">_WINDOWS;UNICODE;_UNICODE;WIN32;WIN64;NIGHTLY_VERSION=20180706;ENABLE_AUTOUPDATE;QT_NO_DEBUG;NDEBUG</Define> </QtMoc> + <QtMoc Include="updateconfirmdialog.h"> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> + <IncludePath Condition="'$(Configuration)|$(Platform)'=='ReleaseCompile|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> + </QtMoc> <QtMoc Include="settingswidget.h"> <IncludePath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(ProjectDir)..\ring-daemon\contrib\msvc\include;$(ProjectDir)..\daemon\contrib\msvc\include;$(ProjectDir)..\ring-lrc\src;$(ProjectDir)..\lrc\src;$(ProjectDir)winsparkle\include;$(ProjectDir)qrencode-win32\qrencode-win32;$(QTDIR)\include;$(QTDIR)\include\QtSvg;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtWinExtras;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtXml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWebEngineWidgets;$(QTDIR)\include\QtWebChannel;$(QTDIR)\include\QtCore;$(QTDIR)\mkspecs\win32-msvc;.\release</IncludePath> <Define Condition="'$(Configuration)|$(Platform)'=='Release|x64'">_WINDOWS;UNICODE;_UNICODE;WIN32;WIN64;NIGHTLY_VERSION=20180706;ENABLE_AUTOUPDATE;QT_NO_DEBUG;NDEBUG</Define> @@ -589,6 +604,7 @@ <QtUic Include="callwidget.ui"> <SubType>Designer</SubType> </QtUic> + <QtUic Include="downloadbar.ui" /> <QtUic Include="deleteaccountdialog.ui"> <SubType>Designer</SubType> </QtUic> @@ -612,6 +628,7 @@ <QtUic Include="settingswidget.ui"> <SubType>Designer</SubType> </QtUic> + <QtUic Include="updateconfirmdialog.ui" /> <QtUic Include="videooverlay.ui"> </QtUic> <QtUic Include="videoview.ui"> @@ -669,6 +686,9 @@ <ItemGroup> <ResourceCompile Include="ico.rc" /> </ItemGroup> + <ItemGroup> + <Text Include="Version.txt" /> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')"> <Import Project="$(QtMsBuild)\qt.targets" /> diff --git a/ring-client-windows.vcxproj.filters b/ring-client-windows.vcxproj.filters index fe52850..50ad8ec 100644 --- a/ring-client-windows.vcxproj.filters +++ b/ring-client-windows.vcxproj.filters @@ -150,6 +150,12 @@ <ClCompile Include="webchathelpers.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="downloadbar.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="downloadmanger.cpp"> + <Filter>Source Files</Filter> + </ClCompile> <ClCompile Include="animationhelpers.cpp"> <Filter>Source Files</Filter> </ClCompile> @@ -201,6 +207,9 @@ <ClCompile Include="linkdevicedialog.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="updateconfirmdialog.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <QtMoc Include="aboutdialog.h"> @@ -296,6 +305,12 @@ <QtMoc Include="animationhelpers.h"> <Filter>Header Files</Filter> </QtMoc> + <QtMoc Include="downloadbar.h"> + <Filter>Header Files</Filter> + </QtMoc> + <QtMoc Include="downloadmanger.h"> + <Filter>Header Files</Filter> + </QtMoc> <QtMoc Include="passworddialog.h"> <Filter>Header Files</Filter> </QtMoc> @@ -341,6 +356,9 @@ <QtMoc Include="linkdevicedialog.h"> <Filter>Header Files</Filter> </QtMoc> + <QtMoc Include="updateconfirmdialog.h"> + <Filter>Header Files</Filter> + </QtMoc> </ItemGroup> <ItemGroup> <CustomBuild Include="debug\moc_predefs.h.cbt"> @@ -605,6 +623,9 @@ <QtUic Include="advancedsipsettingwidget.ui"> <Filter>Form Files</Filter> </QtUic> + <QtUic Include="downloadbar.ui"> + <Filter>Form Files</Filter> + </QtUic> <QtUic Include="nameregistrationdialog.ui"> <Filter>Form Files</Filter> </QtUic> @@ -617,6 +638,9 @@ <QtUic Include="linkdevicedialog.ui"> <Filter>Form Files</Filter> </QtUic> + <QtUic Include="updateconfirmdialog.ui"> + <Filter>Form Files</Filter> + </QtUic> </ItemGroup> <ItemGroup> <None Include="images\FontAwesome.otf"> @@ -769,4 +793,9 @@ <Filter>Header Files</Filter> </ClInclude> </ItemGroup> + <ItemGroup> + <Text Include="Version.txt"> + <Filter>Resource Files</Filter> + </Text> + </ItemGroup> </Project> \ No newline at end of file diff --git a/settingswidget.cpp b/settingswidget.cpp index ea65874..5dc9889 100644 --- a/settingswidget.cpp +++ b/settingswidget.cpp @@ -35,6 +35,7 @@ #include <QTimer> #include <QtConcurrent/QtConcurrent> +#include "downloadmanger.h" #include "deleteaccountdialog.h" #include "passworddialog.h" #include "nameregistrationdialog.h" @@ -42,6 +43,7 @@ #include "utils.h" #include "deviceitemwidget.h" #include "banneditemwidget.h" +#include "UpdateConfirmDialog.h" #include "api/newdevicemodel.h" #include "audio/inputdevicemodel.h" @@ -516,7 +518,39 @@ void SettingsWidget::setAccEnableSlot(int state) void SettingsWidget::delAccountSlot() { - DeleteAccountDialog delDialog(this); + DownloadManager manager; + UpdateConfirmDialog updatedia; + + QFile file("Version.txt"); + if (!file.open(QIODevice::ReadOnly)) { + QMessageBox::critical(this, "Version File Error", file.errorString()); + } + QTextStream in(&file); + QString localVersion = in.readLine(); + file.close(); + + QString onlineVersion = manager.versionOnline(); + if (onlineVersion != localVersion) { + auto ret = updatedia.exec(); + QThread::sleep(1); + if (ret == QDialog::Accepted) { + QString urlstr = "https://dl.jami.net/windows/test.exe"; + QUrl url = QUrl::fromEncoded(urlstr.toLocal8Bit()); + manager.doDownload(url); + auto args = QString(" /passive /norestart WIXNONUILAUNCH=1"); + auto dir = QString("C:\\Users\\mzhang\\Desktop"); + auto cmd = "powershell " + dir + "\\Jami.msi" + + " /L*V " + dir + "\\jami_install.log" + args; + auto retq = QProcess::startDetached(cmd); + if (retq) { + QApplication::quit(); + } + } + } else { + QMessageBox::information(this, "Update Status", "No New Version Detected"); + } + + /*DeleteAccountDialog delDialog(this); auto ret = delDialog.exec(); if (ret == QDialog::Accepted) { @@ -529,7 +563,7 @@ void SettingsWidget::delAccountSlot() LRCInstance::setSelectedConvId(""); emit NavigationRequested(ScreenEnum::CallScreen); } - } + }*/ } void SettingsWidget::removeDeviceSlot(int index) diff --git a/stylesheet.css b/stylesheet.css index ea385bd..f812a81 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -106,13 +106,15 @@ QPushButton#btnAcceptInvite:pressed, QPushButton#btnIgnoreInvite:pressed, QPushB QPushButton#imBackButton:hover, QPushButton#btnAudioCall:hover, QPushButton#btnVideoCall:hover, QPushButton#sendContactRequestButton:hover, QPushButton#sendButton:hover, QPushButton#sendIMButton:hover, -QPushButton#btnExitSettings:hover, QPushButton#btnDeleteAccept:hover, QPushButton#btnDeleteCancel:hover { +QPushButton#btnExitSettings:hover, QPushButton#btnDeleteAccept:hover, QPushButton#btnDeleteCancel:hover, +QPushButton#btnUpdateAccept:hover, QPushButton#btnUpdateCancel:hover { background-color: rgb(237, 237, 237); } QPushButton#imBackButton:pressed, QPushButton#btnAudioCall:pressed, QPushButton#btnVideoCall:pressed, QPushButton#sendContactRequestButton:pressed, QPushButton#sendButton:pressed, QPushButton#sendIMButton:pressed, -QPushButton#btnExitSettings:pressed, QPushButton#btnDeleteAccept:pressed, QPushButton#btnDeleteCancel:pressed { +QPushButton#btnExitSettings:pressed, QPushButton#btnDeleteAccept:pressed, QPushButton#btnDeleteCancel:pressed, +QPushButton#btnUpdateAccept:pressed, QPushButton#btnUpdateCancel:pressed { background-color: rgb(212, 212, 212); } @@ -251,6 +253,12 @@ QScrollBar::handle:vertical{ background: rgb(77, 77, 77); } +QWidget#messagingPage, QWidget#contactRequestPage, +QDialog#DeleteAccountDialog, QDialog#updateDownloadDialog, +QDialog#UpdateConfirmDialog { + background: rgb(255, 255, 255); +} + QWidget#messagingPage { background: rgb(255, 255, 255); } @@ -274,17 +282,17 @@ QPushButton#dhtImportBtn, QPushButton#fileImportBtn, QPushButton#changePassBtn, color: white; } - QPushButton#nextButton:disabled, QPushButton#playButton:disabled, QPushButton#clearHistoryButton:disabled, - QPushButton#doTransferButton:disabled, QPushButton#photoButton:disabled, - QPushButton#existingPushButton:disabled, QPushButton#newAccountButton:disabled, QPushButton#previousButton:disabled, QPushButton#newSIPAccountButton:disabled, - QPushButton#exportButton:disabled, QPushButton#cancelAddButton:disabled, QPushButton#exportOnRingButton:disabled, - QPushButton#addDeviceButton:disabled, QPushButton#exportEndedOkButton:disabled, QPushButton#errorPushButton:disabled, - QPushButton#registerButton:disabled, QPushButton#acceptCRButton:disabled, QPushButton#discardCRButton:disabled, - QPushButton#deleteCancelBtn:disabled, QPushButton#dhtImportBtn:disabled, QPushButton#fileImportBtn:disabled, - QPushButton#changePassBtn:disabled, QPushButton#confirmChangeBtn:disabled, QPushButton#backButton:disabled { - background: rgba(242, 242, 242, 0.8); - color: grey; - } +QPushButton#nextButton:disabled, QPushButton#playButton:disabled, QPushButton#clearHistoryButton:disabled, +QPushButton#doTransferButton:disabled, QPushButton#photoButton:disabled, +QPushButton#existingPushButton:disabled, QPushButton#newAccountButton:disabled, QPushButton#previousButton:disabled, QPushButton#newSIPAccountButton:disabled, +QPushButton#exportButton:disabled, QPushButton#cancelAddButton:disabled, QPushButton#exportOnRingButton:disabled, +QPushButton#addDeviceButton:disabled, QPushButton#exportEndedOkButton:disabled, QPushButton#errorPushButton:disabled, +QPushButton#registerButton:disabled, QPushButton#acceptCRButton:disabled, QPushButton#discardCRButton:disabled, +QPushButton#deleteCancelBtn:disabled, QPushButton#dhtImportBtn:disabled, QPushButton#fileImportBtn:disabled, +QPushButton#changePassBtn:disabled, QPushButton#confirmChangeBtn:disabled, QPushButton#backButton:disabled { + background: rgba(242, 242, 242, 0.8); + color: grey; +} QPushButton#blockCRButton, QPushButton#debanButton, QPushButton#deleteBanBtn, QPushButton#cancelChangeBtn { diff --git a/updateconfirmdialog.cpp b/updateconfirmdialog.cpp new file mode 100644 index 0000000..b5cb3d3 --- /dev/null +++ b/updateconfirmdialog.cpp @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2019 by Savoir-faire Linux * + * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + **************************************************************************/ +#include "ui_updateconfirmdialog.h" +#include "updateconfirmdialog.h" + +UpdateConfirmDialog::UpdateConfirmDialog(QWidget* parent) + : QDialog(parent) + , ui(new Ui::UpdateConfirmDialog) +{ + ui->setupUi(this); + + connect(ui->btnUpdateAccept, &QPushButton::clicked, this, &UpdateConfirmDialog::on_updateAcceptBtn_clicked); + connect(ui->btnUpdateCancel, &QPushButton::clicked, this, &UpdateConfirmDialog::on_updateCancelBtn_clicked); + + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); +} + +UpdateConfirmDialog::~UpdateConfirmDialog() +{ + delete ui; +} + +void UpdateConfirmDialog::on_updateCancelBtn_clicked() +{ + done(DialogCode::Rejected); +} + +void UpdateConfirmDialog::on_updateAcceptBtn_clicked() +{ + done(DialogCode::Accepted); +} diff --git a/updateconfirmdialog.h b/updateconfirmdialog.h new file mode 100644 index 0000000..c0d8272 --- /dev/null +++ b/updateconfirmdialog.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (C) 2019 by Savoir-faire Linux * + * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + **************************************************************************/ + +#pragma once + +#include <QDialog> + +namespace Ui { +class UpdateConfirmDialog; +} + +class UpdateConfirmDialog : public QDialog { + Q_OBJECT + +public: + UpdateConfirmDialog(QWidget* parent = nullptr); + ~UpdateConfirmDialog(); + +private slots: + void on_updateCancelBtn_clicked(); + void on_updateAcceptBtn_clicked(); +signals: + void deleteAcceptClicked(); + +private: + Ui::UpdateConfirmDialog* ui; +}; diff --git a/updateconfirmdialog.ui b/updateconfirmdialog.ui new file mode 100644 index 0000000..eca7940 --- /dev/null +++ b/updateconfirmdialog.ui @@ -0,0 +1,268 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UpdateConfirmDialog</class> + <widget class="QDialog" name="UpdateConfirmDialog"> + <property name="windowModality"> + <enum>Qt::ApplicationModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>240</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>400</width> + <height>240</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>400</width> + <height>240</height> + </size> + </property> + <property name="windowTitle"> + <string>Update Confirm</string> + </property> + <property name="styleSheet"> + <string notr="true"/> + </property> + <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0"> + <item alignment="Qt::AlignHCenter"> + <widget class="QLabel" name="labelDeletion"> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>40</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + <property name="text"> + <string>New Version Detected, Do you want to update now?</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer_3"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>10</height> + </size> + </property> + </spacer> + </item> + <item alignment="Qt::AlignHCenter"> + <widget class="QLabel" name="labelWarning"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>250</width> + <height>0</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + <property name="styleSheet"> + <string notr="true">color: red;</string> + </property> + <property name="text"> + <string>This update will close your Jami automatically, please be aware of your unsent messages</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="margin"> + <number>3</number> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="btnUpdateAccept"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>130</width> + <height>30</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>130</width> + <height>30</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + <property name="toolTip"> + <string>Permanently delete account</string> + </property> + <property name="styleSheet"> + <string notr="true"/> + </property> + <property name="text"> + <string>Yes</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="btnUpdateCancel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>130</width> + <height>30</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>9</pointsize> + </font> + </property> + <property name="toolTip"> + <string>Cancel account deletion</string> + </property> + <property name="styleSheet"> + <string notr="true"/> + </property> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <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"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>5</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> -- GitLab