1
0
Fork 0
mirror of https://gitlab.com/niansa/qcommsy.git synced 2025-03-06 20:53:33 +01:00

Show build ID (build date and time hash) and git version in info screen

This commit is contained in:
niansa 2020-09-23 17:43:52 +02:00
parent e1c1f26cce
commit 9f5861b9f9
3 changed files with 77 additions and 2 deletions

View file

@ -32,8 +32,10 @@ FORMS += \
overview.ui \
postView.ui
LIBS += -lcurlpp -lcurl
LIBS += -lgumbo
LIBS += -lcurlpp -lcurl \
-lgumbo
DEFINES += GIT_CURRENT_SHA1="\\\"$(shell git -C \""$$_PRO_FILE_PWD_"\" describe)\\\""
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin

View file

@ -11,6 +11,7 @@
#include <string>
#include <vector>
#include <functional>
#include <QMainWindow>
#include <QApplication>
@ -121,6 +122,8 @@ void _UILoader::infoWindow() {
"<b>App frontend:</b> " QCommsy_NAME " version " QCommsy_VERSION "<br />"
"<b>Authentication backend:</b> " libCommsyAuth_NAME " version " libCommsyAuth_VERSION "<br />"
"<b>Scrapping backend:</b> " libCommsy_NAME " version " libCommsy_VERSION "<br />"
"<b>Git version:</b> " GIT_CURRENT_SHA1 "<br />"
"<b>Build ID:</b> " + QString::number(std::hash<std::string>{}(__DATE__ __TIME__)) + "<br />"
);
thisui->buildDateInfo->setText(
"Build date:\n"

70
ui_loader.hpp Normal file
View file

@ -0,0 +1,70 @@
class _UILoader {
libCommsy *connector = nullptr;
libCommsyAuth *auther = nullptr;
bool cacheInvalidate = true;
public:
void failureWindow();
void overviewWindow(bool catchInvalidRoomError = true);
void loginWindow(const QString& failure = "");
void infoWindow();
void postViewWindow(commsyPost *thispost, QString description);
void offlineWindow();
_UILoader () {
auther = new libCommsyAuth();
}
void reconnect() {
// Destroy old connector
if (connector != nullptr) {
if (not cacheInvalidate) {
return;
}
delete connector;
connector = nullptr;
}
cacheInvalidate = false;
// Connect to commsy
connector = new libCommsy(settings->value("server_url").toString().toStdString(), settings->value("server_sid").toString().toStdString(), settings->value("server_room").toString().toStdString());
}
void logout() {
settings->remove("server_sid");
}
void downloadAndOpenFile(QNetworkRequest mNetReq, const QString& filename) {
auto mNetMan = new QNetworkAccessManager();
// Set SID in request so we're authenticated TODO: think about a cleaner way
mNetReq.setRawHeader("Cookie", "SID=" + settings->value("server_sid").toString().toUtf8());
// Connect to downloading
w->connect(mNetMan, &QNetworkAccessManager::finished, [this, mNetMan, filename] (QNetworkReply *mNetReply) {
// Save and open downloaded file
{
// Initialise
QString destPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + '/' + filename;
QFile destFile(destPath);
// Write downloaded data to file
if (!destFile.open(QIODevice::WriteOnly)) {
return failureWindow();
}
destFile.write(mNetReply->readAll());
destFile.close();
// Open file in some application
//QDesktopServices::openUrl(destPath);
QDesktopServices::openUrl(QUrl::fromLocalFile(destPath));
}
// Clean up
mNetMan->deleteLater();
});
// Start download
mNetMan->get(mNetReq);
}
};