From 09255a1d9c81e07427181d3a0bbce5ba73583dd6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 23 May 2022 16:40:39 +0200 Subject: [PATCH] [libcalamares] Add a more extensible About message - make the years easier to update without annoying translators - make the maintainers extensible. --- src/libcalamares/CMakeLists.txt | 1 + src/libcalamares/CalamaresAbout.cpp | 73 +++++++++++++++++++++++++++++ src/libcalamares/CalamaresAbout.h | 23 +++++++++ 3 files changed, 97 insertions(+) create mode 100644 src/libcalamares/CalamaresAbout.cpp create mode 100644 src/libcalamares/CalamaresAbout.h diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index 2cf0342ec..95081bb5e 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -24,6 +24,7 @@ set( OPTIONAL_PRIVATE_LIBRARIES "" ) set( OPTIONAL_PUBLIC_LIBRARIES "" ) set( libSources + CalamaresAbout.cpp CppJob.cpp GlobalStorage.cpp Job.cpp diff --git a/src/libcalamares/CalamaresAbout.cpp b/src/libcalamares/CalamaresAbout.cpp new file mode 100644 index 000000000..be2c4ea5c --- /dev/null +++ b/src/libcalamares/CalamaresAbout.cpp @@ -0,0 +1,73 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2022 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#include "CalamaresAbout.h" + +#include + +static const char s_header[] + = QT_TRANSLATE_NOOP( "AboutData", "

%1


%2
for %3


" ); + +static const char s_footer[] + = QT_TRANSLATE_NOOP( "AboutData", + "Thanks to the Calamares team " + "and the Calamares " + "translators team.

" + "Calamares " + "development is sponsored by
" + "Blue Systems - " + "Liberating Software." ); + +struct Maintainer +{ + unsigned int start; + unsigned int end; + const char* name; + const char* email; + QString text() const + { + //: Copyright year-year Name + return QCoreApplication::translate( "AboutData", "Copyright %1-%2 %3 <%4>
" ) + .arg( start ) + .arg( end ) + .arg( name ) + .arg( email ); + } +}; + +static constexpr const Maintainer maintainers[] = { + { 2014, 2017, "Teo Mrnjavac", "teo@kde.org" }, + { 2017, 2022, "Adriaan de Groot", "groot@kde.org" }, +}; + +static QString +aboutMaintainers() +{ + return std::accumulate( std::cbegin( maintainers ), + std::cend( maintainers ), + QString(), + []( QString& s, const Maintainer& m ) + { + s += m.text(); + return s; + } ); +} + +const QString +Calamares::aboutString() +{ + return QCoreApplication::translate( "AboutData", s_header ) + aboutMaintainers() + + QCoreApplication::translate( "AboutData", s_footer ); +} + +const QString +Calamares::aboutStringUntranslated() +{ + return QString( s_header ) + aboutMaintainers() + QString( s_footer ); +} diff --git a/src/libcalamares/CalamaresAbout.h b/src/libcalamares/CalamaresAbout.h new file mode 100644 index 000000000..47a1a8c4a --- /dev/null +++ b/src/libcalamares/CalamaresAbout.h @@ -0,0 +1,23 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2022 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#ifndef CALAMARES_CALAMARESABOUT_H +#define CALAMARES_CALAMARESABOUT_H + +#include "DllMacro.h" + +#include + +namespace Calamares +{ +DLLEXPORT const QString aboutStringUntranslated(); +DLLEXPORT const QString aboutString(); +} // namespace Calamares + +#endif