Skip to content

Commit

Permalink
#149: Check jyutdictionary.com for updates instead of the Github Re…
Browse files Browse the repository at this point in the history
…leases API (#159)

# Description

This commit checks a JSON file hosted on `jyutdictionary.com` instead of
the Github Releases API. By doing so, I will be better able to control
which OS versions receive which releases, and it would remove the
requirement for the long and weird filename format I'm currently using.

Closes #149.

## Type of change

- [x] New feature (non-breaking change which adds functionality)

# How Has This Been Tested?

Tested on all three supported platforms.

# Checklist:

- [x] My code follows the style guidelines of this project (`black` for
Python
  code, `.clang-format` in the `src/jyut-dict` directory for C++)
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
  • Loading branch information
aaronhktan authored Mar 6, 2024
1 parent 3ba9d11 commit 30a0e4b
Show file tree
Hide file tree
Showing 11 changed files with 272 additions and 211 deletions.
8 changes: 6 additions & 2 deletions src/jyut-dict/components/settings/advancedtab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
#include <QWindow>
#endif

namespace {
constexpr auto AUDIO_DOWNLOAD_URL
= "https://jyutdictionary.com/static/audio/v1/";
}

AdvancedTab::AdvancedTab(QWidget *parent)
: QWidget{parent}
{
Expand Down Expand Up @@ -841,8 +846,7 @@ void AdvancedTab::startAudioDownload(std::shared_ptr<TextToSpeechCallbacks> cbs)
QString zipFile
= QStandardPaths::standardLocations(QStandardPaths::TempLocation).at(0)
+ "/" + TextToSpeech::backendNames[backend];
QUrl url{"https://jyutdictionary.com/static/audio/"
+ TextToSpeech::backendNames[backend] + ".zip"};
QUrl url{AUDIO_DOWNLOAD_URL + TextToSpeech::backendNames[backend] + ".zip"};

_downloader = new Downloader(url, zipFile, this);

Expand Down
4 changes: 2 additions & 2 deletions src/jyut-dict/jyut-dict.pro
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ SOURCES += \
logic/sentence/sourcesentence.cpp \
logic/settings/settings.cpp \
logic/settings/settingsutils.cpp \
logic/update/githubreleasechecker.cpp \
logic/update/jyutdictionaryreleasechecker.cpp \
logic/utils/chineseutils.cpp \
logic/utils/scriptdetector.cpp \
logic/utils/utils.cpp \
Expand Down Expand Up @@ -218,8 +218,8 @@ HEADERS += \
logic/settings/settings.h \
logic/settings/settingsutils.h \
logic/strings/strings.h \
logic/update/githubreleasechecker.h \
logic/update/iupdatechecker.h \
logic/update/jyutdictionaryreleasechecker.h \
logic/utils/chineseutils.h \
logic/utils/qvariantutils.h \
logic/utils/scriptdetector.h \
Expand Down
2 changes: 0 additions & 2 deletions src/jyut-dict/logic/entry/entryspeaker.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef ENTRYSPEAKER_H
#define ENTRYSPEAKER_H

#include <QAudioOutput>
#include <QMediaPlayer>
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
Expand Down Expand Up @@ -98,7 +97,6 @@ class EntrySpeaker
#endif

QTextToSpeech *_tts;
QAudioOutput *_output;
QMediaPlayer *_player;
};

Expand Down
160 changes: 0 additions & 160 deletions src/jyut-dict/logic/update/githubreleasechecker.cpp

This file was deleted.

9 changes: 8 additions & 1 deletion src/jyut-dict/logic/update/iupdatechecker.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef IUPDATECHECKER_H
#define IUPDATECHECKER_H

#include <string>
#include <QObject>

// Interface for release checking

Expand All @@ -11,6 +11,13 @@ class IUpdateChecker
virtual void checkForNewUpdate(void) = 0;

virtual ~IUpdateChecker() = default;

signals:
virtual void foundUpdate(bool updateAvailable,
std::string versionNumber,
std::string url,
std::string description)
= 0;
};

#endif // IUPDATECHECKER_H
Loading

0 comments on commit 30a0e4b

Please sign in to comment.