From ea11bbf1d6db40e695bd047b6add489228406d36 Mon Sep 17 00:00:00 2001 From: "Ernest C. Suarez" Date: Sun, 21 Nov 2021 06:18:30 +0000 Subject: [PATCH 1/4] Create design of about dialog --- aboutdialog/lxqtaboutdialog.ui | 142 +++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 aboutdialog/lxqtaboutdialog.ui diff --git a/aboutdialog/lxqtaboutdialog.ui b/aboutdialog/lxqtaboutdialog.ui new file mode 100644 index 0000000..97944f1 --- /dev/null +++ b/aboutdialog/lxqtaboutdialog.ui @@ -0,0 +1,142 @@ + + + AboutDialog + + + + 0 + 0 + 400 + 341 + + + + Dialog + + + + + + + + + + + 512 + 512 + + + + + + + + + + + + + <html><head/><body><p><br/></p></body></html> + + + false + + + + + + + + + + + 0 + + + + About + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'FreeSans'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + + + + + + + + Authors + + + + + + + + + + Translators + + + + + + + + + + Thanks to + + + + + + + + + + + + + + + About Qt + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + + + + + + + + + From 32c54d4821010f0d460ab542ec419ae62ec923d4 Mon Sep 17 00:00:00 2001 From: "Ernest C. Suarez" Date: Sun, 21 Nov 2021 06:56:18 +0000 Subject: [PATCH 2/4] Change tabs widgets object name --- aboutdialog/lxqtaboutdialog.ui | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/aboutdialog/lxqtaboutdialog.ui b/aboutdialog/lxqtaboutdialog.ui index 97944f1..665274c 100644 --- a/aboutdialog/lxqtaboutdialog.ui +++ b/aboutdialog/lxqtaboutdialog.ui @@ -50,9 +50,12 @@ - 0 + 3 - + + false + + About @@ -70,7 +73,7 @@ p, li { white-space: pre-wrap; } - + Authors @@ -80,7 +83,7 @@ p, li { white-space: pre-wrap; } - + Translators @@ -90,7 +93,7 @@ p, li { white-space: pre-wrap; } - + Thanks to From eddb00136cb6f7c892b48b50d848599506bf83c2 Mon Sep 17 00:00:00 2001 From: "Ernest C. Suarez" Date: Sun, 21 Nov 2021 07:33:31 +0000 Subject: [PATCH 3/4] Change tabs widgets text browser object name --- aboutdialog/lxqtaboutdialog.ui | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aboutdialog/lxqtaboutdialog.ui b/aboutdialog/lxqtaboutdialog.ui index 665274c..9850cfa 100644 --- a/aboutdialog/lxqtaboutdialog.ui +++ b/aboutdialog/lxqtaboutdialog.ui @@ -50,7 +50,7 @@ - 3 + 0 false @@ -89,7 +89,7 @@ p, li { white-space: pre-wrap; } - + @@ -99,7 +99,7 @@ p, li { white-space: pre-wrap; } - + From a38f32180212e2a97bb75cf0d7438b2dffc17752 Mon Sep 17 00:00:00 2001 From: "Ernest C. Suarez" Date: Sun, 21 Nov 2021 09:47:43 +0000 Subject: [PATCH 4/4] Create about dialog sources --- CMakeLists.txt | 9 ++ aboutdialog/lxqtaboutdialog.cpp | 236 ++++++++++++++++++++++++++++++++ aboutdialog/lxqtaboutdialog.h | 205 +++++++++++++++++++++++++++ aboutdialog/lxqtaboutdialog.ui | 60 ++++---- 4 files changed, 478 insertions(+), 32 deletions(-) create mode 100644 aboutdialog/lxqtaboutdialog.cpp create mode 100644 aboutdialog/lxqtaboutdialog.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ea34128..3c4cc35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,8 @@ set(PUB_HDRS configdialog/lxqtconfigdialogcmdlineoptions.h configdialog/lxqtpageselectwidget.h + aboutdialog/lxqtaboutdialog.h + lxqtpower/lxqtpower.h lxqtnotification.h lxqtautostartentry.h @@ -106,6 +108,8 @@ set(PUBLIC_CLASSES ConfigDialogCmdLineOptions PageSelectWidget + AboutDialog + Power Notification AutostartEntry @@ -134,6 +138,8 @@ set(SRCS configdialog/lxqtconfigdialogcmdlineoptions.cpp configdialog/lxqtpageselectwidget.cpp + aboutdialog/lxqtaboutdialog.cpp + lxqtpower/lxqtpower.cpp lxqtpower/lxqtpowerproviders.cpp lxqtautostartentry.cpp @@ -167,6 +173,8 @@ set(MOCS configdialog/lxqtconfigdialog_p.h configdialog/lxqtpageselectwidget.h + aboutdialog/lxqtaboutdialog.h + lxqtnotification.h lxqtnotification_p.h lxqtpower/lxqtpower.h @@ -190,6 +198,7 @@ endif (BUILD_BACKLIGHT_LINUX_BACKEND) set(FORMS configdialog/lxqtconfigdialog.ui + aboutdialog/lxqtaboutdialog.ui ) set(POLKIT_FILES diff --git a/aboutdialog/lxqtaboutdialog.cpp b/aboutdialog/lxqtaboutdialog.cpp new file mode 100644 index 0000000..e37442c --- /dev/null +++ b/aboutdialog/lxqtaboutdialog.cpp @@ -0,0 +1,236 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXQt - a lightweight, Qt based, desktop toolset + * https://lxqt.org + * + * Copyright: 2021 LXQt team + * Authors: + * Ernest C. Suarez + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include "lxqtaboutdialog.h" +#include "ui_lxqtaboutdialog.h" + +using namespace LXQt; + +AboutDialog::AboutDialog(const QString &appname, + const QString &appversion, + const QString &appdescription, + const QString ©right, + const QString &url, + QWidget *parent ) : + QDialog(parent), + ui(new Ui::AboutDialog) +{ + + setApplicationNameAndVersion(appname, appversion); + setApplicationShortDescription(appdescription); + setCopyright(copyright); + setProjectURL(url); + + + // init gui + init(); +} + +AboutDialog::~AboutDialog() +{ + delete ui; +} + +void AboutDialog::init() +{ + ui->setupUi(this); + // Conecionts + // About Qt + connect(ui->buttonAboutQt, &QPushButton::clicked, qApp, qApp->aboutQt); +} + +void AboutDialog::setupAboutTab() +{ + // Set app name + ui->labelAppName->setText(mAppNameAndVersion); + // Check the license + if(mLicense.isEmpty()) { + mLicense = QStringLiteral("Unknown"); + } + + // Set textbrowser text + QString browserBuffer = QStringLiteral("%1

%2

" + "%3

License: %4").arg( + mAppDesc, mCopyright, mProjectURL, mLicense); + ui->tabAboutTextBrowser->append(browserBuffer); + +} + +void AboutDialog::setupAuthorsTab() +{ + // Check if empty the Authors List + if(mAuthorsList.isEmpty()) { + // Remove the tab Authors + ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabAuthors)); + } else { + for (const auto &author : qAsConst(mAuthorsList)) { + QString buff = QStringLiteral("%1 \n").arg(author); + ui->tabAuthorsTextBrowser->append(buff); + } + } +} + +void AboutDialog::setupTranslatorsTab() +{ + // Check if empty the Trankslators List + if(mTranslatorsList.isEmpty()) { + // Remove the tab Translators + ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabTranslators)); + } else { + for (const auto &translator : qAsConst(mTranslatorsList)) { + QString buff = QStringLiteral("%1 \n").arg(translator); + ui->tabTranslatorsTextBrowser->append(buff); + } + } +} + +void AboutDialog::setupThanksToTab() +{ + // Check if empty the Thanks list + if(mThanksList.isEmpty()) { + // Remove the tab Thanks + ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabThanks)); + } else { + for (const auto &thanks : qAsConst(mThanksList)) { + QString buff = QStringLiteral("%1 \n").arg(thanks); + ui->tabThanksTextBrowser->append(buff); + } + } +} + +void AboutDialog::setApplicationNameAndVersion(const QString &name, + const QString &version) +{ + // Check if the name and version are empty + QString bufname; + QString bufver; + + if(name.isEmpty()) { + // Use the aplication name provide for qt + bufname = qApp->applicationName(); + } else { + bufname = name; + } + + if(version.isEmpty()) { + // if empy, use version 0.1 + bufver = QStringLiteral("0.1"); + } else { + bufver = version; + } + + mAppNameAndVersion = QStringLiteral("%1
%2").arg( + bufname, bufver); + +} + +void AboutDialog::setApplicationShortDescription(const QString &desc) +{ + mAppDesc = desc; +} + +void AboutDialog::setCopyright(const QString ©right) +{ + mCopyright = copyright; +} + +void AboutDialog::setLicense(LicenseKey key) +{ + switch(key) { + case LicenseKey::GPL: + mLicense = QStringLiteral("GPL"); + case LicenseKey::GPL_V2: + mLicense = QStringLiteral("GPL-2.0"); + case LicenseKey::GPL_V3: + mLicense = QStringLiteral("GPL-3.0"); + case LicenseKey::LGPL: + mLicense = QStringLiteral("LGPL"); + case LicenseKey::LGPL_V2: + mLicense = QStringLiteral("LGPL-2.0"); + case LicenseKey::LGPL_V3: + mLicense = QStringLiteral("LGPL-3.0"); + case LicenseKey::BSD: + mLicense = QStringLiteral("BSD-2-Clause"); + case LicenseKey::QPL: + mLicense = QStringLiteral("QPL"); + } + +} + +void AboutDialog::setCustomLicense(const QString &name) +{ + mLicense = name; +} + +void AboutDialog::setProjectURL(const QString &url) +{ + mProjectURL = url; +} + +void AboutDialog::addAuthor(const QString &name) +{ + mAuthorsList.append(name); +} + +void AboutDialog::addAuthorsList(const QStringList authorList) +{ + mAuthorsList.append(authorList); +} + +void AboutDialog::addTranslator(const QString &name) +{ + mTranslatorsList.append(name); +} + +void AboutDialog::addTranslatorsList(const QStringList translatorsList) +{ + mTranslatorsList.append(translatorsList); +} + +void AboutDialog::addThanks(const QString &name) +{ + mThanksList.append(name); +} + +void AboutDialog::addThanksList(const QStringList thanksList) +{ + mThanksList.append(thanksList); +} + +void AboutDialog::configureAboutDialogData() +{ + // Call the setup* methods + // Configure the about tab + setupAboutTab(); + // Configure the authors + setupAuthorsTab(); + // Configure the translators + setupTranslatorsTab(); + // Configure the thanks + setupThanksToTab(); +} + diff --git a/aboutdialog/lxqtaboutdialog.h b/aboutdialog/lxqtaboutdialog.h new file mode 100644 index 0000000..cbd0055 --- /dev/null +++ b/aboutdialog/lxqtaboutdialog.h @@ -0,0 +1,205 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)LGPL2+ + * + * LXQt - a lightweight, Qt based, desktop toolset + * https://lxqt.org + * + * Copyright: 2021 LXQt team + * Authors: + * Ernest C. Suarez + * + * This program or library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * END_COMMON_COPYRIGHT_HEADER */ + +#ifndef LXQTABOUTDIALOG_HPP +#define LXQTABOUTDIALOG_HPP + +#include +#include + +#include "lxqtglobals.h" + +namespace Ui { +class AboutDialog; +} + +namespace LXQt { + +enum LicenseKey { + GPL, + GPL_V2, + GPL_V3, + LGPL, + LGPL_V2, + LGPL_V3, + BSD, + QPL +}; + +/** + * @brief The AboutDialog class provide a standard about dialog for + * all LXQt apps. + */ +class LXQT_API AboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AboutDialog(const QString &appname = QString(), + const QString &appversion = QString(), + const QString &appdescription = QString(), + const QString ©right = QString(), + const QString &url = QString(), + QWidget *parent = nullptr); + + ~AboutDialog(); + + /** + * @brief Set the application name and the version. + * + * @param name + * @param version + */ + void setApplicationNameAndVersion(const QString &name, + const QString &version); + + /** + * @brief Set the application description. + * + * @param desc + */ + void setApplicationShortDescription(const QString &desc); + + /** + * @brief Insert copyright statement. + * + * @param copyright + */ + void setCopyright(const QString ©right); + + /** + * @brief Set a license. + * + * @param key + */ + void setLicense(LicenseKey key); + + /** + * @brief Set a custom license. + * + * @param url + */ + void setCustomLicense(const QString &name); + + /** + * @brief Set the project url. + * + * @param url + */ + void setProjectURL(const QString &url); + + /** + * @brief Add an author. + * + * If any author arent added, this arent show. + * The authors syntax is: + * name + * + * @param name Author name and email + */ + void addAuthor(const QString &name); + + /** + * @brief Add a list of authors. + * + * @param authorList List of authors + */ + void addAuthorsList(const QStringList authorList); + + /** + * @brief Add a translator. + * + * If any translator arent added, this arent show + * + * @param name Translator name and email + */ + void addTranslator(const QString &name); + + /** + * @brief Add a list of translators. + * + * If any translator arent added, this arent show + * + * @param translatorsList List of translators + */ + void addTranslatorsList(const QStringList translatorsList); + + /** + * @brief Add thanks to an contributor. + * + * @param name Contributor name and rason + */ + void addThanks(const QString &name); + + /** + * @brief Add a thanks list of contributors. + * + * @param thanksList List of contributors + */ + void addThanksList(const QStringList thanksList); + + /** + * @brief Configure the about data. + * + * Is olbigatory call it it, After your + * configure the about data + */ + void configureAboutDialogData(); + +private: + /// Init the about dialog ui + void init(); + /// Insert all "about" buffers in About tab + void setupAboutTab(); + /// Insert authors buffer in Authors tab + void setupAuthorsTab(); + /// Insert translator buffer in Translator tab + void setupTranslatorsTab(); + /// Insert thanks list buffer in Thanks To tab + void setupThanksToTab(); + + Ui::AboutDialog *ui; + + // Buffers + // Tab About + QString mAppNameAndVersion; + QString mAppDesc; + QString mCopyright; + QString mProjectURL; + QString mLicense; + // Tab Authors + QStringList mAuthorsList; + // Tab Translators + QStringList mTranslatorsList; + // Tab Thanks + QStringList mThanksList; + +}; + +} // namespace LXQt + +#endif // LXQTABOUTDIALOG_HPP diff --git a/aboutdialog/lxqtaboutdialog.ui b/aboutdialog/lxqtaboutdialog.ui index 9850cfa..6cb2024 100644 --- a/aboutdialog/lxqtaboutdialog.ui +++ b/aboutdialog/lxqtaboutdialog.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 341 + 298 + 342 @@ -17,35 +17,14 @@ - - - - - - 512 - 512 - - - - - - - - - - - - - <html><head/><body><p><br/></p></body></html> - - - false - - - - - - + + + + + + false + + @@ -141,5 +120,22 @@ p, li { white-space: pre-wrap; }
- + + + buttonClose + clicked() + AboutDialog + close() + + + 246 + 318 + + + 148 + 170 + + + +