Skip to content

Commit

Permalink
feat: New update checker (#370)
Browse files Browse the repository at this point in the history
* New App Updater, fixes #361

Telemetry/UpdateChecker only checks for new updates and sends a signal
with information weather update is available or not. Widgets and custom
dialogs now show chagelogs and direct download button depending upon OS.

It also provides some finer control over the update checker, so user can
see indeterminant progress of the update check and even cancel the
check. The Update UI has been made much cleaner and so has been the
code.

The changelog view supports full markdown formating, with the exeception
that mardown literals like `#` are also shown.

* Revert cmake version to 6.5.0

* Replaces tabs with spaces and add Qt5::Widgets link

* Fix(CI): Linux case sensitive include

* refactor: Improve the update checker and require Qt ^5.14

1. Use the Markdown of QTextEdit introduced in Qt 5.14 instead of the
   markdown_highlighter, hence require Qt ^5.14.
2. Many improvements. It's hard to list all of them, and it's better
   to read the codes.

* feat: show on top instead of raise

* feat(UpdateChecker): show more changelog when update is available

1. The update checker is refactored.
2. Now more changelog is shown. The changelog of a version is shown,
   iff the following are satisfied:
   - This version is valid (i.e. three integers separated by a dot).
   - This version is strictly higher than the current version.
   - One of:
     - This version is the first patch version of a minor version.
     - This version is of the same minor version as the latest release.

Perhaps some other changes are also introduced with the refactor.

Co-authored-by: Yufan You <ouuansteve@gmail.com>
  • Loading branch information
coder3101 and ouuan committed May 28, 2020
1 parent a771a5b commit 77563c3
Show file tree
Hide file tree
Showing 26 changed files with 577 additions and 242 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build_test.yml
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
qt_version: [5.12.8, 5.14.2]
qt_version: [5.14.2]
config:
- {
os: windows-latest,
Expand Down Expand Up @@ -196,7 +196,7 @@ jobs:
path: build/${{ matrix.config.binary }}

- name: Get the version
if: startsWith(github.ref, 'refs/tags') && (matrix.qt_version == '5.12.8')
if: startsWith(github.ref, 'refs/tags') && (matrix.qt_version == '5.14.2')
id: get_version
shell: bash
run: |
Expand All @@ -210,15 +210,15 @@ jobs:
fi
- name: Pack to dmg on Mac
if: matrix.config.os == 'macos-latest' && startsWith(github.ref, 'refs/tags') && (matrix.qt_version == '5.12.8')
if: matrix.config.os == 'macos-latest' && startsWith(github.ref, 'refs/tags') && (matrix.qt_version == '5.14.2')
run: |
cd build
../../Qt/*/*/bin/macdeployqt cpeditor.app
cp ../.ci/mac/cpeditor.icns cpeditor.app/Contents/Resources
hdiutil create -volname cpeditor-${{ steps.get_version.outputs.VERSION }}-x64 -srcfolder cpeditor.app -ov -format UDZO cpeditor-${{ steps.get_version.outputs.VERSION }}-x64.dmg
- name: Release on Mac
if: matrix.config.os == 'macos-latest' && startsWith(github.ref, 'refs/tags') && (matrix.qt_version == '5.12.8')
if: matrix.config.os == 'macos-latest' && startsWith(github.ref, 'refs/tags') && (matrix.qt_version == '5.14.2')
uses: softprops/action-gh-release@v1
with:
draft: true
Expand All @@ -229,13 +229,13 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install innosetup on Windows
if: matrix.config.os == 'windows-latest' && startsWith(github.ref, 'refs/tags') && (matrix.qt_version == '5.12.8')
if: matrix.config.os == 'windows-latest' && startsWith(github.ref, 'refs/tags') && (matrix.qt_version == '5.14.2')
uses: crazy-max/ghaction-chocolatey@v1
with:
args: "install innosetup"

- name: Pack to exe on Windows
if: matrix.config.os == 'windows-latest' && startsWith(github.ref, 'refs/tags') && (matrix.qt_version == '5.12.8')
if: matrix.config.os == 'windows-latest' && startsWith(github.ref, 'refs/tags') && (matrix.qt_version == '5.14.2')
shell: bash
run: |
mkdir build/out
Expand All @@ -244,7 +244,7 @@ jobs:
iscc .ci/win/win-setup.iss -DMyAppVersion=${{ steps.get_version.outputs.VERSION }} -DMyProjectRoot=$(pwd) -DMyOutRoot=$(pwd)/build/out
- name: Release on Windows
if: matrix.config.os == 'windows-latest' && startsWith(github.ref, 'refs/tags') && (matrix.qt_version == '5.12.8')
if: matrix.config.os == 'windows-latest' && startsWith(github.ref, 'refs/tags') && (matrix.qt_version == '5.14.2')
uses: softprops/action-gh-release@v1
with:
draft: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_aur.yml
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Install Qt
if: steps.get_version.outputs.ISSTABLE == 'true'
run: |
sudo add-apt-repository ppa:beineri/opt-qt-5.12.8-xenial -y
sudo add-apt-repository ppa:beineri/opt-qt-5.14.2-xenial -y
sudo apt-get update -qq
sudo apt-get -y install qt512base libgl1-mesa-dev qt512svg qt512imageformats
bash /opt/qt*/bin/qt*-env.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_linux.yml
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Install Qt
run: |
sudo add-apt-repository ppa:beineri/opt-qt-5.12.8-xenial -y
sudo add-apt-repository ppa:beineri/opt-qt-5.14.2-xenial -y
sudo apt-get update -qq
sudo apt-get -y install qt512base libgl1-mesa-dev qt512svg qt512imageformats
bash /opt/qt*/bin/qt*-env.sh
Expand Down
8 changes: 6 additions & 2 deletions CMakeLists.txt
Expand Up @@ -110,8 +110,8 @@ add_executable(cpeditor
src/Settings/ValueWrapper.cpp
src/Settings/ValueWrapper.hpp

src/Telemetry/UpdateNotifier.cpp
src/Telemetry/UpdateNotifier.hpp
src/Telemetry/UpdateChecker.cpp
src/Telemetry/UpdateChecker.hpp

src/Util/FileUtil.cpp
src/Util/FileUtil.hpp
Expand All @@ -128,6 +128,10 @@ add_executable(cpeditor
src/Widgets/TestCaseEdit.hpp
src/Widgets/TestCases.cpp
src/Widgets/TestCases.hpp
src/Widgets/UpdatePresenter.hpp
src/Widgets/UpdatePresenter.cpp
src/Widgets/UpdateProgressDialog.hpp
src/Widgets/UpdateProgressDialog.cpp

src/appwindow.cpp
src/appwindow.hpp
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -17,7 +17,7 @@ You are here to help CP Editor? Awesome, feel free and read the following sectio

**First time to developing?** There's a big difference between developing and competitive programming, but it's not hard. The first thing you should know is Object-Oriented Programming. Basically, you need to know how classes work in C++, and you should know it's a rule to put the class definitions in the `.h`/`.hpp` files, and put the implementation of the functions in the `.cpp` files. The source code of the CP Editor is a good example. Google for what you want to implement is usually helpful. Copy and modify the source codes if you want to implement something similar to an existing feature. If you are looking for an IDE for developing, [VS Code](https://code.visualstudio.com/) is probably a good choice.

**First time to Qt?** Don't be afraid, Qt is not hard to get started. You have to install Qt>=5.12 and CMake>=3.5 first. Linux users may install them using the package manager on your system. Windows users may download Qt [here](https://www.qt.io/offline-installers) and it's recommended to use [Visual Studio](https://visualstudio.microsoft.com/) and install the CMake plugin. Read the [build from source](doc/INSTALL.md#Build-from-source) section to learn how to build. Read the [Qt docs](https://doc.qt.io/) on how to use Qt built-in widgets, how to design the UI and how to use the [signals and slots](https://doc.qt.io/qt-5/signalsandslots.html). Usually, you don't need anything from the std namespace, for example, use `QString` instead of `std::string`.
**First time to Qt?** Don't be afraid, Qt is not hard to get started. You have to install Qt>=5.14 and CMake>=3.5 first. Linux users may install them using the package manager on your system. Windows users may download Qt [here](https://www.qt.io/offline-installers) and it's recommended to use [Visual Studio](https://visualstudio.microsoft.com/) and install the CMake plugin. Read the [build from source](doc/INSTALL.md#Build-from-source) section to learn how to build. Read the [Qt docs](https://doc.qt.io/) on how to use Qt built-in widgets, how to design the UI and how to use the [signals and slots](https://doc.qt.io/qt-5/signalsandslots.html). Usually, you don't need anything from the std namespace, for example, use `QString` instead of `std::string`.

**Don't know where to start?** You can start by looking through the [issues](https://github.com/cpeditor/cpeditor/issues) and find one you are interested in. The [good first issues](https://github.com/cpeditor/cpeditor/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) may be suitable for you. Ask in the [Telegram group](https://t.me/cpeditor) or under the issues if you have any questions.

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING_ru-RU.md
Expand Up @@ -18,7 +18,7 @@
**Впервые в разработке?** Существует большая разница между промышленным и спортивном программированием, но это не так уж и трудно. Первое, что Вы должны знать - это Объектно-Ориентированное Программирование (ООП). Вам нужно знать, как работают классы в C++, что нужно поместить определения классов в `.h`/`.hpp`, а поставить выполнение функции - в `.cpp` файлы. Хорошим примером может служить исходный код CP Editor. Искать в Google/Яндекс то, что Вы хотите реализовать, тоже полезно. Скопируйте и измените исходные коды, если Вы хотите реализовать что-то похожее на существующие функции. Если Вы ищете IDE для разработки, то [VS Code](https://code.visualstudio.com/) - достойный выбор.


**Впервые в Qt?** Не бойтесь, Qt - это просто. Сначала вы должны установить Qt >= 5.12 и CMake >= 3.5. Пользователи Linux могут установить их с помощью диспетчера пакетов в вашей системе. Пользователи Windows могут скачать Qt [здесь](https://www.qt.io/offline-installers), также рекомендовано использовать [Visual Studio](https://visualstudio.microsoft.com/) и скачать плагин CMake. Прочитайте [сборку из исходного кода](doc/INSTALL_ru-RU.md#Сборка-из-исходного-кода), чтобы узнать, как делать build. Прочтите [документы Qt](https://doc.qt.io/) о том, как использовать встроенные виджеты Qt, как проектировать пользовательский интерфейс и как использовать [сигналы и слоты](https://doc.qt.io/qt-5/signalsandslots.html). Обычно Вам не нужно использовать стандартное пространство имен std. Используйте `QString` вместо `std::string`.
**Впервые в Qt?** Не бойтесь, Qt - это просто. Сначала вы должны установить Qt >= 5.14 и CMake >= 3.5. Пользователи Linux могут установить их с помощью диспетчера пакетов в вашей системе. Пользователи Windows могут скачать Qt [здесь](https://www.qt.io/offline-installers), также рекомендовано использовать [Visual Studio](https://visualstudio.microsoft.com/) и скачать плагин CMake. Прочитайте [сборку из исходного кода](doc/INSTALL_ru-RU.md#Сборка-из-исходного-кода), чтобы узнать, как делать build. Прочтите [документы Qt](https://doc.qt.io/) о том, как использовать встроенные виджеты Qt, как проектировать пользовательский интерфейс и как использовать [сигналы и слоты](https://doc.qt.io/qt-5/signalsandslots.html). Обычно Вам не нужно использовать стандартное пространство имен std. Используйте `QString` вместо `std::string`.

**Не знаете, с чего начать?** Вы можете начать с просмотра списка [issues](https://github.com/cpeditor/cpeditor/issues) и найдите то, что Вас интересует. [Good first issues](https://github.com/cpeditor/cpeditor/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22), возможно, Вам подойдет. Спрашивайте в [Телеграм группе](https://t.me/cpeditor) или под issues, если у вас есть какие-либо вопросы.

Expand Down
2 changes: 2 additions & 0 deletions doc/CHANGELOG.md
Expand Up @@ -10,6 +10,8 @@
- Now you can get the git commit hash when executing `cpeditor --version` in the terminal.
- Now the application catches SIGINT, SIGTERM and SIGHUP on Linux/macOS and catches CTRL_C_EVENT, CTRL_BREAK_EVENT and CTRL_CLOSE_EVENT on Windows, it be will gracefully closed when receiving these signals. (#178 and #268) Warning: It's reported that on some environments it doesn't always work.
- Now you can restore the problem URL when opening a file previously with a problem URL, and/or open the old file when parsing an old problem URL. (#199)
- Now editor update also shows changelogs and provides actions to cancel update operation and a directly download button to binaries. (#361)


### Fixed

Expand Down
2 changes: 1 addition & 1 deletion doc/INSTALL.md
Expand Up @@ -43,7 +43,7 @@ You may need to click "Yes" to access Filesystem several times. Apple may report
cd cpeditor
```

2. Install [Qt](https://www.qt.io/download) (5.12 or higher), [CMake](https://cmake.org/download/) (3.12 or higher) and [Python3](https://www.python.org/downloads/).
2. Install [Qt](https://www.qt.io/download) (5.14 or higher), [CMake](https://cmake.org/download/) (3.12 or higher) and [Python3](https://www.python.org/downloads/).
- On some Linux distributions and MacOS, you can install from your package manager. For example, `sudo pacman -S qt5` on Arch Linux, `brew install qt5` on Mac OS.
- You can also download the [offline installer](https://www.qt.io/offline-installers), or download from the [mirrors](https://download.qt.io/static/mirrorlist/). The path from the root of the mirror should be like `/qt/official_releases/qt/5.14/5.14.2/qt-opensource-<platform>-5.14.2.<suffix>` (or other versions).
- You can also use [aqtinstall](https://github.com/miurahr/aqtinstall) to install Qt.
Expand Down
2 changes: 1 addition & 1 deletion doc/INSTALL_ru-RU.md
Expand Up @@ -43,7 +43,7 @@
cd cpeditor
```

2. Установите [Qt](https://www.qt.io/download) (5.12 или выше), [CMake](https://cmake.org/download/) (3.12 или выше) и [Python3](https://www.python.org/downloads/).
2. Установите [Qt](https://www.qt.io/download) (5.14 или выше), [CMake](https://cmake.org/download/) (3.12 или выше) и [Python3](https://www.python.org/downloads/).
- На некоторые дистрибутивы Linux и MacOS, вы можете установить из вашего менеджера пакетов. Например, `sudo pacman-S qt5` на Arch Linux, `brew install qt5` на Mac OS.
- Вы также можете скачать [автономный установщик](https://www.qt.io/offline-installers), или скачать с [зеркал](https://download.qt.io/static/mirrorlist/). Путь от корня зеркала должен быть похож на `/qt/official_releases/qt/5.14/5.14.2/qt-opensource-<platform>-5.14.2.<suffix>` (или другие версии).
- Вы также можете использовать [aqtinstall](https://github.com/miurahr/aqtinstall) чтобы установить Qt.
Expand Down
2 changes: 1 addition & 1 deletion doc/INSTALL_zh-CN.md
Expand Up @@ -45,7 +45,7 @@
cd cpeditor
```

2. 安装 [Qt](https://www.qt.io/download)(5.12 或更高版本), [CMake](https://cmake.org/download/)(3.12 或更高版本)以及 [Python3](https://www.python.org/downloads/)
2. 安装 [Qt](https://www.qt.io/download)(5.14 或更高版本), [CMake](https://cmake.org/download/)(3.12 或更高版本)以及 [Python3](https://www.python.org/downloads/)
- 在一些 Linux g发行版和 MacOS 系统上,你可以直接使用包管理器安装 Qt。例如,在 Arch Linux 上可以使用 `sudo pacman -S qt5`,在 MacOS 上可以使用 `brew install qt5`.=。
- 你还可以下载 [离线安装包](https://www.qt.io/offline-installers), 或者从 [镜像](https://download.qt.io/static/mirrorlist/) 下载。你要下载的文件在镜像中的目录应该是 `/qt/official_releases/qt/5.14/5.14.2/qt-opensource-<platform>-5.14.2.<suffix>` (或其它版本).
- 你还可以使用 [aqtinstall](https://github.com/miurahr/aqtinstall) 来下载并安装。
Expand Down
6 changes: 2 additions & 4 deletions src/Settings/PreferencesWindow.cpp
Expand Up @@ -19,6 +19,7 @@
#include "Settings/AppearancePage.hpp"
#include "Settings/CodeSnippetsPage.hpp"
#include "Settings/PreferencesHomePage.hpp"
#include "Util/Util.hpp"
#include <QApplication>
#include <QCloseEvent>
#include <QHBoxLayout>
Expand Down Expand Up @@ -158,10 +159,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QMainWindow(parent)
void PreferencesWindow::display()
{
bool hidden = isHidden();
show();
setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
activateWindow();
raise();
Util::showWidgetOnTop(this);
if (hidden)
{
switchToPage(homePage);
Expand Down

0 comments on commit 77563c3

Please sign in to comment.