From d4b0c1feae5a2dd4cf6954c521047c658fe1aace Mon Sep 17 00:00:00 2001 From: Albert S Date: Wed, 29 Jun 2022 17:21:28 +0200 Subject: [PATCH] gui: Add new AboutDialog to show our licenses "paperwork" --- gui/aboutdialog.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++++ gui/aboutdialog.h | 12 ++++++++ gui/gui.pro | 2 ++ 3 files changed, 88 insertions(+) create mode 100644 gui/aboutdialog.cpp create mode 100644 gui/aboutdialog.h diff --git a/gui/aboutdialog.cpp b/gui/aboutdialog.cpp new file mode 100644 index 0000000..834021d --- /dev/null +++ b/gui/aboutdialog.cpp @@ -0,0 +1,74 @@ +#include +#include +#include +#include +#include +#include "aboutdialog.h" +#include "common.h" + +AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent) +{ + QVBoxLayout *layout = new QVBoxLayout(this); + QTabWidget *tabWidget = new QTabWidget(this); + + this->setWindowTitle("About looqs"); + + QHBoxLayout *closeLayout = new QHBoxLayout(); + QPushButton *closeButton = new QPushButton(this); + closeButton->setText("Close"); + closeButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + connect(closeButton, &QPushButton::clicked, this, &QDialog::close); + + closeLayout->setMargin(10); + closeLayout->addStretch(10); + closeLayout->addWidget(closeButton); + + layout->addWidget(tabWidget); + layout->addLayout(closeLayout); + QFrame *frame = new QFrame(this); + QVBoxLayout *aboutLayout = new QVBoxLayout(frame); + frame->setLayout(aboutLayout); + + QLabel *aboutLooqs = new QLabel(this); + QString html = "

looqs

"; + html += "Full-text search with previews for your files

"; + html += "Copyright (c) 2018-2022: Albert Schwarzkopf

"; + html += QString("Version: %1

").arg(Common::versionText()); + html += "Contact: looqs at quitesimple dot org

"; + html += "Website: https://quitesimple.org

"; + html += "Source code: https://github.com/quitesimpleorg/looqs

"; + html += "License: GPLv3

"; + html += "looqs is open source and free of charge in the hope it will be useful. The author(s) do not " + "give any warranty. In the unlikely event of any damage, the author(s) cannot be held responsible. " + "You are using looqs at your own risk

"; + html += "looqs uses third-party libraries, please see the corresponding tab."; + aboutLooqs->setText(html); + aboutLooqs->setTextFormat(Qt::RichText); + + QLabel *logo = new QLabel(this); + QImage image(QString(":/looqs.svg")); + logo->setPixmap(QPixmap::fromImage(image)); + + aboutLayout->addWidget(logo); + aboutLayout->addWidget(aboutLooqs); + + tabWidget->addTab(frame, "About"); + + QFile license(QString(":/LICENSE")); + license.open(QIODevice::ReadOnly); + QString licenseText = license.readAll(); + + QFile thirdPartyLicense(QString(":./LICENSE-3RD-PARTY")); + thirdPartyLicense.open(QIODevice::ReadOnly); + QString thirdPartyLicenseInfo = thirdPartyLicense.readAll(); + + QTextBrowser *licenseTextBrowser = new QTextBrowser(this); + licenseTextBrowser->setText(licenseText); + + QTextBrowser *thirdPartyLicenceTextBrowser = new QTextBrowser(this); + thirdPartyLicenceTextBrowser->setText(thirdPartyLicenseInfo); + + tabWidget->addTab(licenseTextBrowser, "License"); + tabWidget->addTab(thirdPartyLicenceTextBrowser, "Third-party libraries"); +} diff --git a/gui/aboutdialog.h b/gui/aboutdialog.h new file mode 100644 index 0000000..7bd915a --- /dev/null +++ b/gui/aboutdialog.h @@ -0,0 +1,12 @@ +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H +#include + +class AboutDialog : public QDialog +{ + Q_OBJECT + public: + AboutDialog(QWidget *parent = nullptr); +}; + +#endif // ABOUTDIALOG_H diff --git a/gui/gui.pro b/gui/gui.pro index e15f982..60fe30a 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -27,6 +27,7 @@ DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ + aboutdialog.cpp \ ipcpreviewclient.cpp \ ipcpreviewworker.cpp \ ipcserver.cpp \ @@ -44,6 +45,7 @@ SOURCES += \ rendertarget.cpp HEADERS += \ + aboutdialog.h \ ipc.h \ ipcpreviewclient.h \ ipcpreviewworker.h \