From 7782ed0e23762d4601e72d665e5e6bae9628d33e Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Fri, 25 Dec 2020 13:36:34 +0800 Subject: [PATCH] chore: adjust dir structure, add translator name list --- CMakeLists.txt | 4 +-- app/aboutdialog.cpp | 29 ++++++++++-------- app/main.cpp | 5 +-- {icons => assets/icons}/app-icon.ico | Bin {icons => assets/icons}/app-icon.svg | 0 {icons => assets/icons}/go-next.svg | 0 {icons => assets/icons}/go-previous.svg | 0 .../icons}/object-rotate-right.svg | 0 .../icons}/view-background-checkerboard.svg | 0 {icons => assets/icons}/view-fullscreen.svg | 0 {icons => assets/icons}/window-close.svg | 0 {icons => assets/icons}/zoom-in.svg | 0 {icons => assets/icons}/zoom-original.svg | 0 {icons => assets/icons}/zoom-out.svg | 0 .../pineapple-pictures.rc | 0 assets/plain/translators.html | 6 ++++ resources.qrc => assets/resources.qrc | 1 + pineapple-pictures.pro | 4 +-- 18 files changed, 31 insertions(+), 18 deletions(-) rename {icons => assets/icons}/app-icon.ico (100%) rename {icons => assets/icons}/app-icon.svg (100%) rename {icons => assets/icons}/go-next.svg (100%) rename {icons => assets/icons}/go-previous.svg (100%) rename {icons => assets/icons}/object-rotate-right.svg (100%) rename {icons => assets/icons}/view-background-checkerboard.svg (100%) rename {icons => assets/icons}/view-fullscreen.svg (100%) rename {icons => assets/icons}/window-close.svg (100%) rename {icons => assets/icons}/zoom-in.svg (100%) rename {icons => assets/icons}/zoom-original.svg (100%) rename {icons => assets/icons}/zoom-out.svg (100%) rename pineapple-pictures.rc => assets/pineapple-pictures.rc (100%) create mode 100644 assets/plain/translators.html rename resources.qrc => assets/resources.qrc (89%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e282ce..05f7d31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ set (PPIC_HEADER_FILES ) set (PPIC_QRC_FILES - resources.qrc + assets/resources.qrc ) set (PPIC_RC_FILES @@ -76,7 +76,7 @@ set (PPIC_CPP_FILES_FOR_I18N ${PPIC_CPP_FILES}) qt5_create_translation(PPIC_QM_FILES ${PPIC_CPP_FILES_FOR_I18N} ${PPIC_TS_FILES}) if (WIN32) - list(APPEND PPIC_RC_FILES pineapple-pictures.rc) + list(APPEND PPIC_RC_FILES assets/pineapple-pictures.rc) endif () add_executable (${EXE_NAME} diff --git a/app/aboutdialog.cpp b/app/aboutdialog.cpp index 54eba01..64b2e03 100644 --- a/app/aboutdialog.cpp +++ b/app/aboutdialog.cpp @@ -8,6 +8,7 @@ #include #include #include +#include AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent) @@ -21,7 +22,7 @@ AboutDialog::AboutDialog(QWidget *parent) { this->setWindowTitle(tr("About")); - QStringList helpStr { + const QStringList helpStr { QStringLiteral("

%1

").arg(tr("Launch application with image file path as argument to load the file.")), QStringLiteral("

%1

").arg(tr("Drag and drop image file onto the window is also supported.")), QStringLiteral("

%1

").arg(tr("Context menu option explanation:")), @@ -37,7 +38,7 @@ AboutDialog::AboutDialog(QWidget *parent) QStringLiteral("") }; - QStringList aboutStr { + const QStringList aboutStr { QStringLiteral("

"), qApp->applicationDisplayName(), #ifdef GIT_DESCRIBE_VERSION_STRING @@ -53,22 +54,26 @@ AboutDialog::AboutDialog(QWidget *parent) QStringLiteral("
") }; - QStringList specialThanksStr { + QFile translaterHtml(":/plain/translators.html"); + bool canOpenFile = translaterHtml.open(QIODevice::ReadOnly); + const QByteArray & translatorList = canOpenFile ? translaterHtml.readAll() : ""; + + const QStringList specialThanksStr { QStringLiteral("

%1

%3

%4

").arg( tr("Contributors"), QStringLiteral("https://github.com/BLumia/pineapple-pictures/graphs/contributors"), tr("List of contributors on GitHub"), tr("Thanks to all people who contributed to this project.") ), -#if 0 - QStringLiteral("

%1

%2

").arg( + + QStringLiteral("

%1

%2

%3").arg( tr("Translators"), - tr("I would like to thank the following people who volunteered to translate this application.") - ), -#endif + tr("I would like to thank the following people who volunteered to translate this application."), + translatorList + ) }; - QStringList licenseStr { + const QStringList licenseStr { QStringLiteral("

%1

").arg(tr("Your Rights")), QStringLiteral("

%1

%2

  • %3
  • %4
  • %5
  • %6
").arg( tr("%1 is released under the MIT License."), // %1 @@ -82,7 +87,7 @@ AboutDialog::AboutDialog(QWidget *parent) QStringLiteral("
%2
") }; - QString mitLicense(QStringLiteral(R"(Expat/MIT License + const QString mitLicense(QStringLiteral(R"(Expat/MIT License Copyright (c) 2020 BLumia @@ -105,9 +110,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. )")); - QStringList thirdPartyLibsStr { + const QStringList thirdPartyLibsStr { QStringLiteral("

%1

").arg(tr("Third-party Libraries used by %1")), - tr("%1 is built on the following free software libraries:"), + tr("%1 is built on the following free software libraries:", "Free as in freedom"), QStringLiteral("
    "), #ifdef HAVE_EXIV2_VERSION QStringLiteral("
  • %2: %3
  • ").arg("https://www.exiv2.org/", "Exiv2", "GPLv2"), diff --git a/app/main.cpp b/app/main.cpp index 71da5e0..0655b4a 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -21,8 +21,9 @@ int main(int argc, char *argv[]) #else qmDir = QT_STRINGIFY(QM_FILE_INSTALL_DIR); #endif - translator.load(QString("PineapplePictures_%1").arg(QLocale::system().name()), qmDir); - a.installTranslator(&translator); + if (translator.load(QString("PineapplePictures_%1").arg(QLocale::system().name()), qmDir)) { + a.installTranslator(&translator); + } a.setApplicationName("Pineapple Pictures"); a.setApplicationDisplayName(QCoreApplication::translate("main", "Pineapple Pictures")); diff --git a/icons/app-icon.ico b/assets/icons/app-icon.ico similarity index 100% rename from icons/app-icon.ico rename to assets/icons/app-icon.ico diff --git a/icons/app-icon.svg b/assets/icons/app-icon.svg similarity index 100% rename from icons/app-icon.svg rename to assets/icons/app-icon.svg diff --git a/icons/go-next.svg b/assets/icons/go-next.svg similarity index 100% rename from icons/go-next.svg rename to assets/icons/go-next.svg diff --git a/icons/go-previous.svg b/assets/icons/go-previous.svg similarity index 100% rename from icons/go-previous.svg rename to assets/icons/go-previous.svg diff --git a/icons/object-rotate-right.svg b/assets/icons/object-rotate-right.svg similarity index 100% rename from icons/object-rotate-right.svg rename to assets/icons/object-rotate-right.svg diff --git a/icons/view-background-checkerboard.svg b/assets/icons/view-background-checkerboard.svg similarity index 100% rename from icons/view-background-checkerboard.svg rename to assets/icons/view-background-checkerboard.svg diff --git a/icons/view-fullscreen.svg b/assets/icons/view-fullscreen.svg similarity index 100% rename from icons/view-fullscreen.svg rename to assets/icons/view-fullscreen.svg diff --git a/icons/window-close.svg b/assets/icons/window-close.svg similarity index 100% rename from icons/window-close.svg rename to assets/icons/window-close.svg diff --git a/icons/zoom-in.svg b/assets/icons/zoom-in.svg similarity index 100% rename from icons/zoom-in.svg rename to assets/icons/zoom-in.svg diff --git a/icons/zoom-original.svg b/assets/icons/zoom-original.svg similarity index 100% rename from icons/zoom-original.svg rename to assets/icons/zoom-original.svg diff --git a/icons/zoom-out.svg b/assets/icons/zoom-out.svg similarity index 100% rename from icons/zoom-out.svg rename to assets/icons/zoom-out.svg diff --git a/pineapple-pictures.rc b/assets/pineapple-pictures.rc similarity index 100% rename from pineapple-pictures.rc rename to assets/pineapple-pictures.rc diff --git a/assets/plain/translators.html b/assets/plain/translators.html new file mode 100644 index 0000000..26bc6c8 --- /dev/null +++ b/assets/plain/translators.html @@ -0,0 +1,6 @@ +
      +
    • French: J. Lavoie, K. Herbert
    • +
    • German: K. Herbert, J. Lavoie
    • +
    • Norwegian Bokmål: Allan Nordhøy
    • +
    • Russian: Artem
    • +
    \ No newline at end of file diff --git a/resources.qrc b/assets/resources.qrc similarity index 89% rename from resources.qrc rename to assets/resources.qrc index 89fa435..82d4976 100644 --- a/resources.qrc +++ b/assets/resources.qrc @@ -10,5 +10,6 @@ icons/window-close.svg icons/go-next.svg icons/go-previous.svg + plain/translators.html diff --git a/pineapple-pictures.pro b/pineapple-pictures.pro index 724fd00..8a81769 100644 --- a/pineapple-pictures.pro +++ b/pineapple-pictures.pro @@ -57,11 +57,11 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target RESOURCES += \ - resources.qrc + assets/resources.qrc # Generate from svg: # magick convert -background none app-icon.svg -define icon:auto-resize="16,32,48,64,128,256" app-icon.ico -RC_ICONS = icons/app-icon.ico +RC_ICONS = assets/icons/app-icon.ico # Windows only, for rc file (we're not going to use the .rc file in this repo) QMAKE_TARGET_PRODUCT = Pineapple Pictures