Skip to content

Commit 04737aa

Browse files
committed
Qt Plugin: use Application name instead of AppImage filename if given.
1 parent a93e268 commit 04737aa

File tree

7 files changed

+109
-6
lines changed

7 files changed

+109
-6
lines changed

docs/ClassQAppImageUpdate.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ All methods in this class is [reentrant](https://doc.qt.io/qt-5/threads-reentran
3939
| **void** | [setIcon(QByteArray)](#void-seticonqbytearray-icon) |
4040
| **void** | [start(short)](#void-startshort-action) |
4141
| **void** | [cancel()](#void-cancel) |
42+
| **void** | [setApplicationName(const QString&)](#void-setapplicationname-qstring) |
4243
| **void** | [setAppImage(const QString&)](#void-setappimageconst-qstring) |
4344
| **void** | [setAppImage(QFile \*)](#void-setappimageqfile-) |
4445
| **void** | [setShowLog(bool)](#void-setshowlogbool) |
@@ -199,6 +200,15 @@ Cancels the update.
199200
Emits **canceled(short action)** signal when cancel was successfull.
200201

201202

203+
### void setApplicationName(const QString&)
204+
<p align="right"> <code>[SLOT]</code> </p>
205+
206+
Set a application name to use when display GUI dialogs if required.
207+
208+
> NOTE: This is optional. By default the GUI dialogs uses the AppImage filename.
209+
210+
211+
202212
### void setAppImage(const QString&)
203213
<p align="right"> <code>[SLOT]</code> </p>
204214

docs/PluginInterface.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ I'm not sure about other Qt bindings, So help is much welcomed.
2929
| [setIcon(QByteArray)](#seticonqbytearray-icon) | Set Icon for GUI Update. |
3030
| [start(short)](#startshort-action) | Starts the given action. |
3131
| [cancel()](#cancel) | Cancels current update process. |
32+
| [setApplicationName(QString)](#setapplicationnameqstring) | Sets the Application Name in GUI dialogs. |
3233
| [setAppImagePath(QString)](#setappimagepathqstring) | Assume the given string as path to AppImage to update. |
3334
| [setAppImageFile(QFile\*)](#setappimagefileqfile) | Assume the given QFile as the AppImage to update. |
3435
| [setShowLog(bool)](#setshowlogbool) | If the given boolean is true then prints log. |
@@ -170,6 +171,15 @@ One has to use **getConstant(QString)** method to get a constant.
170171
Cancels the current action.
171172
Emits **canceled(short)** signal when cancel for a action was successfull.
172173

174+
175+
### setApplicationName(QString)
176+
<p align="right"> <code>[SLOT]</code> </p>
177+
178+
Sets the given string as the Application Name which will be used in GUI dialogs.
179+
180+
> NOTE: This is optional and by default the updater uses the AppImage filename.
181+
182+
173183
### setAppImagePath(QString)
174184
<p align="right"> <code>[SLOT]</code> </p>
175185

include/qappimageupdateinterface.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
class QAppImageUpdateInterface {
1111
public Q_SLOTS:
12+
virtual void setApplicationName(const QString&) = 0;
1213
virtual void setGuiFlag(int) = 0;
1314
virtual void setIcon(QByteArray) = 0;
1415
virtual void setAppImagePath(const QString&) = 0;

include/qappimageupdateinterfaceimpl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class QAppImageUpdateInterfaceImpl : public QObject, QAppImageUpdateInterface {
2121
QAppImageUpdateInterfaceImpl(QObject *parent = nullptr);
2222
~QAppImageUpdateInterfaceImpl();
2323
public Q_SLOTS:
24+
void setApplicationName(const QString&);
2425
void setIcon(QByteArray);
2526
void setGuiFlag(int);
2627
void setAppImagePath(const QString&);

scripts/docker_build.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Run it like so,
2+
# docker run -v $PWD:/docker-share -it ubuntu:xenial bash scripts/docker_build.sh
3+
# To get libQAppImageUpdate.so Qt Plugin.
4+
5+
# Install dependencies
6+
apt update
7+
apt upgrade -y
8+
apt install software-properties-common build-essential libarchive13 libarchive-dev wget expat -y
9+
add-apt-repository ppa:beineri/opt-qt563-xenial -y
10+
apt-get update -qq
11+
apt install libgl1-mesa-dev xvfb qt56base -y
12+
13+
cd /docker-share/
14+
rm -rf build
15+
mkdir build
16+
cd build
17+
18+
# Build OpenSSL Static version
19+
wget "https://www.openssl.org/source/openssl-1.1.1j.tar.gz"
20+
tar -xf openssl-1.1.1j.tar.gz
21+
cd openssl-1.1.1j
22+
./config no-shared --prefix=/usr/ --openssldir=/usr/
23+
make -j$(nproc)
24+
make install -j$(nproc)
25+
cd ..
26+
27+
# Install CURL
28+
wget "https://curl.se/download/curl-7.75.0.tar.gz"
29+
tar -xf curl-7.75.0.tar.gz
30+
cd curl-7.75.0
31+
,/configure
32+
make -j$(nproc)
33+
make install -j$(nproc)
34+
cd ..
35+
36+
# Install CMake 3.19.6
37+
wget "https://github.com/Kitware/CMake/releases/download/v3.19.6/cmake-3.19.6.tar.gz"
38+
tar -xf cmake-3.19.6.tar.gz
39+
cd cmake-3.19.6
40+
./bootstrap
41+
make -j$(nproc)
42+
make install -j$(nproc)
43+
cd ..
44+
45+
# Install Boost libraries
46+
wget "https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.tar.gz"
47+
tar -xf boost_1_75_0.tar.gz
48+
cd boost_1_75_0
49+
./bootstrap.sh
50+
cp b2 /usr/bin/
51+
echo "using gcc ;" > ~/user-config.jam
52+
export BOOST_ROOT=$PWD
53+
export BOOST_BUILD_PATH=$PWD/tools/build
54+
BOOST_ROOT=$PWD BOOST_BUILD_PATH=$PWD/tools/build b2 cxxflags="-std=c++14" variant=release link=static install -j$(nproc) --with-system --with-chrono --with-random > /dev/null
55+
cd ..
56+
57+
# Install Torrent Rasterbar
58+
wget "https://github.com/arvidn/libtorrent/releases/download/libtorrent-1.2.8/libtorrent-rasterbar-1.2.8.tar.gz"
59+
tar -xvf libtorrent-rasterbar-1.2.8.tar.gz
60+
cd libtorrent-rasterbar-1.2.8
61+
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON .
62+
make -j$(nproc)
63+
make install -j$(nproc)
64+
cd ..
65+
66+
# Now Build QAppImageUpdate Qt Plugin.
67+
source /opt/qt56/bin/qt56-env.sh
68+
cmake -DDECENTRALIZED_UPDATE_ENABLED=ON -DBUILD_AS_PLUGIN=ON ..
69+
make -j$(nproc)
70+
71+
cp libQAppImageUpdate.* ..
72+
cd ..
73+
rm -rf build

src/qappimageupdate_p.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,9 @@ void QAppImageUpdatePrivate::handleGUIUpdateCheck(QJsonObject info) {
871871
bool showNoUpdateDialog = n_GuiFlag & GuiFlag::NotifyWhenNoUpdateIsAvailable;
872872
bool noConfirmTorrentUsage = n_GuiFlag & GuiFlag::NoConfirmTorrentUsage;
873873
m_UpdaterDialog->setWindowTitle(QString::fromUtf8("Updating ") +
874-
QFileInfo(localAppImagePath).baseName());
874+
(m_ApplicationName.isEmpty() ?
875+
QFileInfo(localAppImagePath).baseName() :
876+
m_ApplicationName));
875877

876878
bool isUpdateAvailable = (localAppImageSHA1Hash != remoteTargetFileSHA1Hash);
877879

@@ -886,7 +888,8 @@ void QAppImageUpdatePrivate::handleGUIUpdateCheck(QJsonObject info) {
886888
box.setText(
887889
QString::fromUtf8(
888890
"It seems that the author of ") +
889-
QFileInfo(localAppImagePath).baseName() +
891+
(m_ApplicationName.isEmpty() ? QFileInfo(localAppImagePath).baseName() :
892+
m_ApplicationName) +
890893
QString::fromUtf8(" supports decentralized update via Bittorrent.") +
891894
QString::fromUtf8(
892895
" Do you agree to <b>use Bittorrent for decentralized update?</b> This is completely optional.") +
@@ -923,8 +926,9 @@ void QAppImageUpdatePrivate::handleGUIUpdateCheck(QJsonObject info) {
923926
QMessageBox box(m_UpdaterDialog.data());
924927
box.setWindowTitle(QString::fromUtf8("No Updates Available!"));
925928
box.setText(
926-
QString::fromUtf8("You are currently using the lastest version of ") +
927-
QFileInfo(localAppImagePath).fileName() +
929+
QString::fromUtf8("You are currently using the lastest version of ") +\
930+
(m_ApplicationName.isEmpty() ? QFileInfo(localAppImagePath).fileName()
931+
: m_ApplicationName ) +
928932
QString::fromUtf8("."));
929933
box.exec();
930934
}
@@ -1135,7 +1139,7 @@ void QAppImageUpdatePrivate::handleGUIUpdateError(short ecode) {
11351139
box.setWindowTitle(QString::fromUtf8("Update Failed"));
11361140
box.setIcon(QMessageBox::Critical);
11371141
box.setText(QString::fromUtf8("Update failed for '") +
1138-
QFileInfo(m_CurrentAppImagePath).fileName() +
1142+
(m_ApplicationName.isEmpty() ? QFileInfo(m_CurrentAppImagePath).fileName() : m_ApplicationName) +
11391143
QString::fromUtf8("': ") + errorString);
11401144
box.exec();
11411145
}
@@ -1223,7 +1227,7 @@ void QAppImageUpdatePrivate::handleGUIUpdateFinished(QJsonObject info, QString o
12231227
QString::fromUtf8("New version is saved at: ") +
12241228
result["NewVersionPath"].toString());
12251229
box.setText(QString::fromUtf8("Update completed successfully for <b>") +
1226-
currentAppImageName +
1230+
(m_ApplicationName.isEmpty() ? currentAppImageName : m_ApplicationName) +
12271231
QString::fromUtf8("</b>, do you want to launch the new version? View details for more information."));
12281232
box.addButton(QMessageBox::Yes);
12291233
box.addButton(QMessageBox::No);

src/qappimageupdateinterfaceimpl.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ QAppImageUpdateInterfaceImpl::QAppImageUpdateInterfaceImpl(QObject *parent)
3232
QAppImageUpdateInterfaceImpl::~QAppImageUpdateInterfaceImpl() {
3333
}
3434

35+
void QAppImageUpdateInterfaceImpl::setApplicationName(const QString &a) {
36+
m_Private->setApplicationName(a);
37+
}
38+
3539
void QAppImageUpdateInterfaceImpl::setIcon(QByteArray icon) {
3640
m_Private->setIcon(icon);
3741
}

0 commit comments

Comments
 (0)