Skip to content

Commit

Permalink
Build for Linux and Qt 5.9
Browse files Browse the repository at this point in the history
- Modify project file to deploy on Ubuntu.
- Modify QJsonValue to use .toObject().value() for compatibility with Qt 5.9.
  • Loading branch information
aaronhktan committed Jun 18, 2019
1 parent c759a65 commit 4c5bb67
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
19 changes: 16 additions & 3 deletions src/jyut-dict/jyut-dict.pro
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ win32: {
RC_ICONS = resources/icon/icon.ico
}

#unix:!macx {
# # Move files to appropriate locations on desktop to install the program
# binfile.files += $$system_path($$OUT_PWD)/"Jyut Dictionary"
# binfile.path = /opt/jyut-dict/
# shortcutfiles.files += platform/linux/jyut-dict.desktop
# shortcutfiles.path = /usr/share/applications/
# icon.files += resources/icon/variant_3/icon.svg
# icon.path = /opt/jyut-dict/
# INSTALLS += binfile
# INSTALLS += shortcutfiles
# INSTALLS += icon
#}

unix|win32:!macx {
# Copy dictionary database to the build directory
copydata.commands = $(COPY_DIR) \"$$system_path($$PWD/resources/db/eng.db)\" \"$$system_path($$OUT_PWD)\"
Expand All @@ -120,6 +133,6 @@ unix|win32:!macx {
}

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
#qnx: target.path = /tmp/$${TARGET}/bin
#else: unix:!android: target.path = /opt/$${TARGET}/bin
#!isEmpty(target.path): INSTALLS += target
10 changes: 6 additions & 4 deletions src/jyut-dict/logic/update/githubreleasechecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ bool GithubReleaseChecker::parseJSON(const std::string &data,
{
QJsonDocument doc = QJsonDocument::fromJson(QString{data.c_str()}.toUtf8());
for (QJsonValue entry : doc.array()) {
std::string release_name = entry["name"].toString().toStdString();
std::string release_name = entry.toObject().value("name")
.toString().toStdString();

// Regex has three capturing groups:
// The first is for platform, which is one string of any characters
Expand Down Expand Up @@ -121,8 +122,9 @@ bool GithubReleaseChecker::parseJSON(const std::string &data,
if (std::stoi(current_version.at(i)) < std::stoi(new_version.at(i))) {
// Check each browser download url for a compatible file extension
// Set the url to the first one that matches
for (QJsonValue file : entry["assets"].toArray()) {
std::string download_url = file["browser_download_url"].toString().toStdString();
for (QJsonValue file : entry.toObject().value("assets").toArray()) {
std::string download_url = file.toObject().value("browser_download_url")
.toString().toStdString();
if (std::any_of(Utils::ASSET_FORMATS.begin(),
Utils::ASSET_FORMATS.end(),
[&](std::string substring) {
Expand All @@ -133,7 +135,7 @@ bool GithubReleaseChecker::parseJSON(const std::string &data,
&& download_url.find(Utils::PLATFORM_NAME) != std::string::npos) {
url = download_url;
versionNumber = version;
description = entry["body"].toString().toStdString();
description = entry.toObject().value("body").toString().toStdString();
updateAvailable = true;
return true;
}
Expand Down

0 comments on commit 4c5bb67

Please sign in to comment.