diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cb792f9..1c090ee4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,204 +1,200 @@ cmake_minimum_required(VERSION 3.7.2) if(POLICY CMP0048) cmake_policy(SET CMP0048 NEW) endif(POLICY CMP0048) project( kbibtex VERSION 0.9.50 LANGUAGES CXX ) set(CMAKE_CXX_STANDARD 11) set(QT_MIN_VERSION 5.9.0) # Somewhat arbitrary chosen version number ... set(KF5_MIN_VERSION 5.51) find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) -add_definitions( - -DTRANSLATION_DOMAIN="kbibtex" -) - set( CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_MODULE_PATH} ) set(KDE_INSTALL_DIRS_NO_DEPRECATED TRUE) include(KDEInstallDirs) include(KDECompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) include(ECMGenerateHeaders) include(ECMInstallIcons) include(ECMSetupVersion) include(ECMAddAppIcon) include(GenerateExportHeader) include(ECMQtDeclareLoggingCategory) ecm_setup_version( PROJECT VARIABLE_PREFIX KBIBTEX SOVERSION ${KBIBTEX_VERSION_MAJOR} VERSION_HEADER "${CMAKE_BINARY_DIR}/kbibtex-version.h" PACKAGE_VERSION_FILE "${CMAKE_BINARY_DIR}/KBibTeXConfigVersion.cmake" ) install( FILES ${CMAKE_BINARY_DIR}/kbibtex-version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/KBibTeX # FIXME is "Devel" standard? COMPONENT Devel ) if("${KBIBTEX_VERSION_PATCH}" STREQUAL "") # Patch level is not set for version numbers like "0.9", # so set the patch level manually to 0 set(KBIBTEX_VERSION_PATCH 0) endif() if((${KBIBTEX_VERSION_PATCH} GREATER 50) OR (${KBIBTEX_VERSION_PATCH} EQUAL 50)) # If the version number indicates a pre-release version such as # '0.7.90', i.e. a beta version for the major release 0.8, # increment release version from 0.7 to 0.8 math(EXPR KBIBTEX_RELEASE_VERSION_MINOR "${KBIBTEX_VERSION_MINOR} + 1") set( KBIBTEX_RELEASE_VERSION ${KBIBTEX_VERSION_MAJOR}.${KBIBTEX_RELEASE_VERSION_MINOR} ) else() set( KBIBTEX_RELEASE_VERSION ${KBIBTEX_VERSION_MAJOR}.${KBIBTEX_VERSION_MINOR} ) endif() option( UNITY_BUILD "Compile multiple C++ files in one big, merged file (\"Unity build\")\nSee also http://t-fischer.dreamwidth.org/3054.html" ) if(UNITY_BUILD) message(STATUS "Unity build enabled") else(UNITY_BUILD) message(STATUS "Unity build disabled (default), use option UNITY_BUILD to enable it") endif(UNITY_BUILD) find_package( Qt5 ${QT_MIN_VERSION} CONFIG COMPONENTS Core Widgets Network XmlPatterns Concurrent NetworkAuth OPTIONAL_COMPONENTS WebEngineWidgets WebKitWidgets Test ) add_definitions(-DHAVE_QTWIDGETS) find_package( KF5 ${KF5_MIN_VERSION} MODULE REQUIRED I18n XmlGui KIO IconThemes Parts CoreAddons Service Wallet Crash DocTools TextEditor ) add_definitions(-DHAVE_KF5) find_package( Poppler MODULE REQUIRED Qt5 ) find_package( ICU MODULE OPTIONAL_COMPONENTS uc i18n ) if(ICU_FOUND) add_definitions(-DHAVE_ICU) endif() option( BUILD_TESTING "Build automated and interactive tests" OFF ) if (MSVC) MESSAGE( STATUS "Disabling building tests when using Microsoft Visual Studio C++ compiler" ) # Note to any developer: Try to enable building tests and see which issues you may encounter. # Examples may include: (1) char* texts which exceed the size limit supported by MSVC which # is about 2^16 bytes and (2) characters in strings written in \uXXXX notation not supported # in 1252 encoding as assumed by MSVC for C++ source files. set(BUILD_TESTING OFF) endif() if(NOT BUILD_TESTING AND Qt5Test_FOUND) message(STATUS "Testing is disabled, but can be enabled as the Qt5::Test library is available" ) endif() if(BUILD_TESTING AND NOT Qt5Test_FOUND) message(STATUS "Disabling building tests as Qt5::Test library is not available" ) set(BUILD_TESTING OFF) endif() if(BUILD_TESTING) if (WRITE_RAWDATAFILE) add_definitions(-DWRITE_RAWDATAFILE) endif(WRITE_RAWDATAFILE) set( TESTSET_DIRECTORY "" CACHE PATH "Directory where the local checkout of Git repository 'kbibtex-testset' is located" ) endif() add_subdirectory( config ) add_subdirectory( src ) add_subdirectory( xslt ) add_subdirectory( mime ) if(KF5DocTools_FOUND) add_subdirectory(doc) endif() # macro_optional_add_subdirectory( # po # ) if (ECM_VERSION VERSION_GREATER_EQUAL "5.59.0") install(FILES kbibtex.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}) else() install(FILES kbibtex.categories DESTINATION ${KDE_INSTALL_CONFDIR}) endif() feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/gui/config/entrylayout.cpp b/src/gui/config/entrylayout.cpp index ba1bf7d5..5fc119e5 100644 --- a/src/gui/config/entrylayout.cpp +++ b/src/gui/config/entrylayout.cpp @@ -1,147 +1,150 @@ /*************************************************************************** * Copyright (C) 2004-2019 by Thomas Fischer * * * * This program 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 2 of the License, or * * (at your option) any later version. * * * * This program 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 this program; if not, see . * ***************************************************************************/ #include "entrylayout.h" #include #include #include #include #include #include "logging_gui.h" static const int entryLayoutMaxTabCount = 256; static const int entryLayoutMaxFieldPerTabCount = 256; class EntryLayout::EntryLayoutPrivate { public: EntryLayout *p; EntryLayoutPrivate(EntryLayout *parent) : p(parent) { /// nothing } static QString convert(KBibTeX::FieldInputType fil) { switch (fil) { case KBibTeX::SingleLine : return QStringLiteral("SingleLine"); case KBibTeX::MultiLine : return QStringLiteral("MultiLine"); case KBibTeX::List : return QStringLiteral("List"); case KBibTeX::URL : return QStringLiteral("URL"); case KBibTeX::Month : return QStringLiteral("Month"); case KBibTeX::Edition : return QStringLiteral("Edition"); case KBibTeX::Color : return QStringLiteral("Color"); case KBibTeX::PersonList : return QStringLiteral("PersonList"); case KBibTeX::KeywordList : return QStringLiteral("KeywordList"); case KBibTeX::CrossRef : return QStringLiteral("CrossRef"); case KBibTeX::StarRating : return QStringLiteral("StarRating"); case KBibTeX::UrlList : return QStringLiteral("UrlList"); } return QString(); } static KBibTeX::FieldInputType convert(const QString &text) { if (text == QStringLiteral("List")) return KBibTeX::List; else if (text == QStringLiteral("MultiLine")) return KBibTeX::MultiLine; else if (text == QStringLiteral("URL")) return KBibTeX::URL; else if (text == QStringLiteral("UrlList")) return KBibTeX::UrlList; else if (text == QStringLiteral("Month")) return KBibTeX::Month; else if (text == QStringLiteral("Edition")) return KBibTeX::Edition; else if (text == QStringLiteral("Color")) return KBibTeX::Color; else if (text == QStringLiteral("PersonList")) return KBibTeX::PersonList; else if (text == QStringLiteral("KeywordList")) return KBibTeX::KeywordList; else if (text == QStringLiteral("CrossRef")) return KBibTeX::CrossRef; else if (text == QStringLiteral("StarRating")) return KBibTeX::StarRating; else return KBibTeX::SingleLine; } void load(const QString &style) { p->clear(); const QString stylefile = QStringLiteral("kbibtex/") + style + QStringLiteral(".kbstyle"); KSharedConfigPtr layoutConfig = KSharedConfig::openConfig(stylefile, KConfig::FullConfig, QStandardPaths::GenericDataLocation); static const QString groupName = QStringLiteral("EntryLayoutTab"); const KConfigGroup configGroup(layoutConfig, groupName); const int tabCount = qMin(configGroup.readEntry("count", 0), entryLayoutMaxTabCount); for (int tab = 1; tab <= tabCount; ++tab) { const QString groupName = QString(QStringLiteral("EntryLayoutTab%1")).arg(tab); const KConfigGroup configGroup(layoutConfig, groupName); QSharedPointer etl = QSharedPointer(new EntryTabLayout); etl->identifier = configGroup.readEntry("identifier", QString(QStringLiteral("etl%1")).arg(tab)); etl->uiCaption = i18n(configGroup.readEntry("uiCaption", QString()).toUtf8().constData()); etl->iconName = configGroup.readEntry("iconName", "entry"); etl->columns = configGroup.readEntry("columns", 1); if (etl->uiCaption.isEmpty()) continue; const int fieldCount = qMin(configGroup.readEntry("count", 0), entryLayoutMaxFieldPerTabCount); for (int field = 1; field <= fieldCount; ++field) { SingleFieldLayout sfl; sfl.bibtexLabel = configGroup.readEntry(QString(QStringLiteral("bibtexLabel%1")).arg(field), QString()); sfl.uiLabel = i18n(configGroup.readEntry(QString(QStringLiteral("uiLabel%1")).arg(field), QString()).toUtf8().constData()); sfl.fieldInputLayout = EntryLayoutPrivate::convert(configGroup.readEntry(QString(QStringLiteral("fieldInputLayout%1")).arg(field), "SingleLine")); if (sfl.bibtexLabel.isEmpty() || sfl.uiLabel.isEmpty()) continue; etl->singleFieldLayouts.append(sfl); } - const QString infoMessagePipeSeparated = i18n(configGroup.readEntry("infoMessage", QString()).toUtf8().constData()); - if (!infoMessagePipeSeparated.isEmpty()) - etl->infoMessages = infoMessagePipeSeparated.split(QLatin1Char('|')); + const QString untranslatedInfoMessage = configGroup.readEntry("infoMessage", QString()); + if (!untranslatedInfoMessage.isEmpty()) { + const QString infoMessagePipeSeparated = i18n(untranslatedInfoMessage.toUtf8().constData()); + if (!infoMessagePipeSeparated.isEmpty()) + etl->infoMessages = infoMessagePipeSeparated.split(QLatin1Char('|')); + } p->append(etl); } if (p->isEmpty()) qCWarning(LOG_KBIBTEX_GUI) << "List of entry layouts is empty"; } }; EntryLayout::EntryLayout(const QString &style) : QVector >(), d(new EntryLayoutPrivate(this)) { d->load(style); } EntryLayout::~EntryLayout() { delete d; } const EntryLayout &EntryLayout::instance() { static const EntryLayout singletonBibTeX(QStringLiteral("bibtex")), singletonBibLaTeX(QStringLiteral("biblatex")); return Preferences::instance().bibliographySystem() == Preferences::BibLaTeX ? singletonBibLaTeX : singletonBibTeX; }