From ad39882c17bfd7d96cbcfd3873d4dd332722e84f Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Thu, 20 Jan 2022 18:28:06 -0700 Subject: [PATCH] At the PO template (translation) framework. --- CMakeLists.txt | 14 +- COPYING | 2 +- po/privacybrowser.pot | 175 ++++++++++++++++++ src/CMakeLists.txt | 12 +- src/PrivacyBrowserPCSettings.kcfgc | 6 - src/icons/privacy_browser.svg | 146 +++++---------- src/licenses/GPLv3+.txt | 2 - src/main.cpp | 2 +- src/mainwindow.cpp | 5 +- src/privacybrowserpcview.cpp | 16 +- ...cyBrowserPCSettings.kcfg => settings.kcfg} | 0 src/settings.kcfgc | 29 +++ update_po_template | 32 ++++ 13 files changed, 316 insertions(+), 125 deletions(-) create mode 100644 po/privacybrowser.pot delete mode 100644 src/PrivacyBrowserPCSettings.kcfgc rename src/{PrivacyBrowserPCSettings.kcfg => settings.kcfg} (100%) create mode 100644 src/settings.kcfgc create mode 100755 update_po_template diff --git a/CMakeLists.txt b/CMakeLists.txt index ca98f35..29c01f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,27 +15,37 @@ # You should have received a copy of the GNU General Public License # along with Privacy Browser PC. If not, see . + +# Set the minimum CMake version. cmake_minimum_required(VERSION 3.16) +# Name the project. project(privacybrowser) # Set the minimum framework versions. set(QT_MIN_VERSION "5.15.0") set(KDE_FRAMEWORKS_MIN_VERSION "5.83.0") +# Load the Extra CMake Modules that correspond to the KDE Frameworks version. find_package(ECM ${KDE_FRAMEWORKS_MIN_VERSION} REQUIRED NO_MODULE) + +# Set the CMake module path. set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) +# Include the KDE modules. include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) +# Include the Extra CMake Modules. include(ECMInstallIcons) include(ECMQtDeclareLoggingCategory) include(FeatureSummary) +# Load the Qt components. find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets) +# Load the KDE Frameworks components. find_package(KF5 ${KDE_FRAMEWORKS_MIN_VERSION} REQUIRED COMPONENTS ConfigWidgets CoreAddons @@ -46,11 +56,13 @@ find_package(KF5 ${KDE_FRAMEWORKS_MIN_VERSION} REQUIRED COMPONENTS XmlGui ) +# Add the subdirectories. add_subdirectory(doc) add_subdirectory(src) -# Make it possible to use the po files fetched by the fetch-translations step +# Make it possible to use the PO files fetched by the fetch-translations step. ki18n_install(po) kdoctools_install(po) +# Generate a summary. feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/COPYING b/COPYING index 49e01c8..3b01333 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -Privacy Browser PC copyright © 2022 Soren Stoutner . +Privacy Browser PC copyright © 2016-2017,2021-2022 Soren Stoutner . This file is part of Privacy Browser PC . diff --git a/po/privacybrowser.pot b/po/privacybrowser.pot new file mode 100644 index 0000000..18f6b42 --- /dev/null +++ b/po/privacybrowser.pot @@ -0,0 +1,175 @@ +# Copyright © 2022 Soren Stoutner . +# +# This file is part of Privacy Browser PC . +# +# Privacy Browser PC is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Privacy Browser PC 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Privacy Browser PC. If not, see . + + +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-01-20 17:18-0700\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/privacybrowserpcview.cpp:44 +#, kde-format +msgid "This project is %1 days old" +msgstr "" + +#: src/mainwindow.cpp:38 +#, kde-format +msgctxt "@action" +msgid "Switch Colors" +msgstr "" + +#: src/mainwindow.cpp:74 +#, kde-format +msgctxt "@title:tab" +msgid "General" +msgstr "" + +#: src/main.cpp:44 +#, kde-format +msgid "Privacy Browser" +msgstr "" + +#: src/main.cpp:47 +#, kde-format +msgid "Soren Stoutner" +msgstr "" + +#: src/main.cpp:47 +#, kde-format +msgid "Principal developer" +msgstr "" + +#: src/main.cpp:51 +#, kde-format +msgid "Copyright © 2016-2017,2021-2022 Soren Stoutner " +msgstr "" + +#: src/main.cpp:56 +#, kde-format +msgid "A web browser that respects your privacy." +msgstr "" + +#: rc.cpp:3 +#, kde-format +msgid "Background color:" +msgstr "" + +#: rc.cpp:6 +#, kde-format +msgid "Choose a new background color" +msgstr "" + +#: rc.cpp:9 +#, kde-format +msgid "" +"\n" +"

Change the background color by clicking here and choose the " +"new color in the color dialog.

" +msgstr "" + +#: rc.cpp:15 +#, kde-format +msgid "Foreground color:" +msgstr "" + +#: rc.cpp:18 +#, kde-format +msgid "Choose a new foreground color" +msgstr "" + +#: rc.cpp:21 +#, kde-format +msgid "" +"\n" +"

Change the foreground color by clicking here and choose the " +"new color in the color dialog.

" +msgstr "" + +#: rc.cpp:27 +#, kde-format +msgid "Project age:" +msgstr "" + +#: rc.cpp:30 +#, kde-format +msgid "Set the project age (in days)" +msgstr "" + +#: rc.cpp:33 +#, kde-format +msgid "Change the project age (in days) by choosing a new number of days." +msgstr "" + +#: rc.cpp:36 +#, kde-format +msgid "color of the background" +msgstr "" + +#: rc.cpp:39 +#, kde-format +msgid "color of the foreground" +msgstr "" + +#: rc.cpp:42 +#, kde-format +msgid "age of the project" +msgstr "" + +#: rc.cpp:45 +#, kde-format +msgid "hello, world" +msgstr "" + +#: rc.cpp:48 +#, kde-format +msgid "Main Toolbar" +msgstr "" + +#: rc.cpp:49 +#, kde-format +msgctxt "NAME OF TRANSLATORS" +msgid "Your names" +msgstr "" + +#: rc.cpp:50 +#, kde-format +msgctxt "EMAIL OF TRANSLATORS" +msgid "Your emails" +msgstr "" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 077ff05..e251e06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,26 +15,34 @@ # You should have received a copy of the GNU General Public License # along with Privacy Browser PC. If not, see . + # Create the executable and add the resources. add_executable(privacybrowser resources.qrc) +# List the sources to include in the executable. target_sources(privacybrowser PRIVATE main.cpp mainwindow.cpp privacybrowserpcview.cpp ) +# Add the Qt logging category. ecm_qt_declare_logging_category(privacybrowser - HEADER privacybrowserpcdebug.h + HEADER privacybrowserdebug.h IDENTIFIER PRIVACYBROWSER CATEGORY_NAME "privacybrowser" ) -kconfig_add_kcfg_files(privacybrowser PrivacyBrowserPCSettings.kcfgc) + +# Include the KConfig controller file. +kconfig_add_kcfg_files(privacybrowser settings.kcfgc) + +# Use KDE Frameworks to handle internationalization of the following UI files. ki18n_wrap_ui(privacybrowser privacybrowserpcview.ui settings.ui ) + target_link_libraries(privacybrowser KF5::CoreAddons KF5::I18n diff --git a/src/PrivacyBrowserPCSettings.kcfgc b/src/PrivacyBrowserPCSettings.kcfgc deleted file mode 100644 index aae44b6..0000000 --- a/src/PrivacyBrowserPCSettings.kcfgc +++ /dev/null @@ -1,6 +0,0 @@ -# Code generation options for kconfig_compiler -File=PrivacyBrowserPCSettings.kcfg -ClassName=PrivacyBrowserPCSettings -Singleton=true -# will create the necessary code for setting those variables -Mutators=colorBackground,colorForeground diff --git a/src/icons/privacy_browser.svg b/src/icons/privacy_browser.svg index 5d39ed4..428d507 100644 --- a/src/icons/privacy_browser.svg +++ b/src/icons/privacy_browser.svg @@ -1,105 +1,47 @@ + + + - - - - image/svg+xml - - - - - - - - - - - - - - - - - - + xmlns="http://www.w3.org/2000/svg" + viewBox="0 0 256 256" > + + + + + + + + + + + + + + + diff --git a/src/licenses/GPLv3+.txt b/src/licenses/GPLv3+.txt index 49e01c8..5bb31d5 100644 --- a/src/licenses/GPLv3+.txt +++ b/src/licenses/GPLv3+.txt @@ -1,5 +1,3 @@ -Privacy Browser PC copyright © 2022 Soren Stoutner . - This file is part of Privacy Browser PC . Privacy Browser PC is free software: you can redistribute it and/or diff --git a/src/main.cpp b/src/main.cpp index 4f84887..5605cdf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) // Populate additional about data info. aboutData.setBugAddress("https://redmine.stoutner.com/projects/privacy-browser-pc/issues"); - aboutData.setCopyrightStatement(i18n("Copyright © 2022 Soren Stoutner ")); + aboutData.setCopyrightStatement(i18n("Copyright © 2016-2017,2021-2022 Soren Stoutner ")); aboutData.setDesktopFileName(QStringLiteral("com.stoutner.privacybrowser")); aboutData.setHomepage(QStringLiteral("https://www.stoutner.com/privacy-browser-pc/")); aboutData.setLicenseTextFile(":/licenses/GPLv3+.txt"); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 739fca9..d0c4e1b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -20,7 +20,8 @@ // Application headers. #include "mainwindow.h" #include "privacybrowserpcview.h" -#include "privacybrowserpcdebug.h" +#include "privacybrowserdebug.h" +#include "settings.h" // KDE Frameworks headers. #include @@ -67,7 +68,7 @@ void MainWindow::settingsConfigure() return; } - KConfigDialog *dialog = new KConfigDialog(this, QStringLiteral("settings"), PrivacyBrowserPCSettings::self()); + KConfigDialog *dialog = new KConfigDialog(this, QStringLiteral("settings"), Settings::self()); QWidget *generalSettingsPage = new QWidget; m_settings.setupUi(generalSettingsPage); dialog->addPage(generalSettingsPage, i18nc("@title:tab", "General"), QStringLiteral("package_setting")); diff --git a/src/privacybrowserpcview.cpp b/src/privacybrowserpcview.cpp index 84e5eed..8369f99 100644 --- a/src/privacybrowserpcview.cpp +++ b/src/privacybrowserpcview.cpp @@ -7,8 +7,8 @@ // application headers #include "privacybrowserpcview.h" -#include "PrivacyBrowserPCSettings.h" -#include "privacybrowserpcdebug.h" +#include "settings.h" +#include "privacybrowserdebug.h" PrivacyBrowserPCView::PrivacyBrowserPCView(QWidget *parent) @@ -25,9 +25,9 @@ PrivacyBrowserPCView::~PrivacyBrowserPCView() void PrivacyBrowserPCView::switchColors() { // switch the foreground/background colors of the label - QColor color = PrivacyBrowserPCSettings::colorBackground(); - PrivacyBrowserPCSettings::setColorBackground(PrivacyBrowserPCSettings::colorForeground()); - PrivacyBrowserPCSettings::setColorForeground(color); + QColor color = Settings::colorBackground(); + Settings::setColorBackground(Settings::colorForeground()); + Settings::setColorForeground(color); handleSettingsChanged(); } @@ -36,11 +36,11 @@ void PrivacyBrowserPCView::handleSettingsChanged() { qCDebug(PRIVACYBROWSER) << "PrivacyBrowserPCView::handleSettingsChanged()"; QPalette palette = m_ui.templateLabel->palette(); - palette.setColor(QPalette::Window, PrivacyBrowserPCSettings::colorBackground()); - palette.setColor(QPalette::WindowText, PrivacyBrowserPCSettings::colorForeground()); + palette.setColor(QPalette::Window, Settings::colorBackground()); + palette.setColor(QPalette::WindowText, Settings::colorForeground()); m_ui.templateLabel->setPalette(palette); // i18n : internationalization - m_ui.templateLabel->setText(i18n("This project is %1 days old", PrivacyBrowserPCSettings::ageInDays())); + m_ui.templateLabel->setText(i18n("This project is %1 days old", Settings::ageInDays())); } diff --git a/src/PrivacyBrowserPCSettings.kcfg b/src/settings.kcfg similarity index 100% rename from src/PrivacyBrowserPCSettings.kcfg rename to src/settings.kcfg diff --git a/src/settings.kcfgc b/src/settings.kcfgc new file mode 100644 index 0000000..4f3b929 --- /dev/null +++ b/src/settings.kcfgc @@ -0,0 +1,29 @@ +# Copyright © 2022 Soren Stoutner . +# +# This file is part of Privacy Browser PC . +# +# Privacy Browser PC is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Privacy Browser PC 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Privacy Browser PC. If not, see . + + +# Specify the KConfig file. +File=settings.kcfg + +# Specify the class name, which will be used to autogenerate .cpp and .h files. +ClassName=Settings + +# Make the generated class a singleton. TODO, the default is false. This may not be needed. +Singleton=true + +# Create code for mutating (making changes to) the listed variables. TODO, the default is false. These may not be needed. +Mutators=colorBackground,colorForeground diff --git a/update_po_template b/update_po_template new file mode 100755 index 0000000..38aa12c --- /dev/null +++ b/update_po_template @@ -0,0 +1,32 @@ +#! /usr/bin/env bash + +# Copyright © 2022 Soren Stoutner . +# +# This file is part of Privacy Browser PC . +# +# Privacy Browser PC is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Privacy Browser PC 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Privacy Browser PC. If not, see . + + +# Extract the strings from the UI and RC files and add them to a temporary .app file. +extractrc `find -name \*.ui -o -name \*.rc -o -name \*.kcfg` >> rc.cpp + +# Add the names of the translators. +echo 'i18nc("NAME OF TRANSLATORS", "Your names");' >> rc.cpp +echo 'i18nc("EMAIL OF TRANSLATORS", "Your emails");' >> rc.cpp + +# Extract all the string to a PO template file. +xgettext --c++ --kde --from-code=UTF-8 -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 -kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 -kkli18n:1 -kkli18nc:1c,2 -kkli18np:1,2 -kkli18ncp:1c,2,3 -kI18N_NOOP:1 -kI18NC_NOOP:1c,2 `find . -name \*.cpp` -o po/privacybrowser.pot + +# Remove the temporary .app file. +rm -f rc.cpp -- 2.43.0