diff --git a/mobile/sailfishos/bibsearch.pro b/mobile/sailfishos/bibsearch.pro index 65c84b7f..c6da525e 100644 --- a/mobile/sailfishos/bibsearch.pro +++ b/mobile/sailfishos/bibsearch.pro @@ -1,107 +1,109 @@ TARGET = harbour-bibsearch CONFIG += sailfishapp SOURCES += src/main.cpp src/searchenginelist.cpp \ src/bibliographymodel.cpp ../../src/data/value.cpp \ ../../src/data/entry.cpp ../../src/data/macro.cpp \ ../../src/data/comment.cpp ../../src/data/file.cpp \ ../../src/data/preamble.cpp ../../src/data/element.cpp \ ../../src/networking/internalnetworkaccessmanager.cpp \ ../../src/networking/onlinesearch/onlinesearchabstract.cpp \ ../../src/networking/onlinesearch/onlinesearchbibsonomy.cpp \ ../../src/networking/onlinesearch/onlinesearchacmportal.cpp \ ../../src/networking/onlinesearch/onlinesearchsciencedirect.cpp \ ../../src/networking/onlinesearch/onlinesearchgooglescholar.cpp \ ../../src/networking/onlinesearch/onlinesearchjstor.cpp \ ../../src/networking/onlinesearch/onlinesearchspringerlink.cpp \ ../../src/networking/onlinesearch/onlinesearchieeexplore.cpp \ ../../src/networking/onlinesearch/onlinesearcharxiv.cpp \ ../../src/networking/onlinesearch/onlinesearchingentaconnect.cpp \ ../../src/networking/onlinesearch/onlinesearchpubmed.cpp \ - ../../src/global/preferences.cpp ../../src/global/kbibtex.cpp \ + ../../src/global/kbibtex.cpp \ ../../src/io/encoderxml.cpp ../../src/io/encoder.cpp \ ../../src/io/encoderlatex.cpp \ ../../src/io/fileimporter.cpp \ ../../src/io/fileimporterbibtex.cpp \ ../../src/io/textencoder.cpp ../../src/io/xsltransform.cpp \ + ../../src/config/preferences.cpp \ ../../src/config/bibtexfields.cpp \ ../../src/config/bibtexentries.cpp \ ../../src/config/logging_config.cpp \ ../../src/networking/logging_networking.cpp \ ../../src/data/logging_data.cpp ../../src/io/logging_io.cpp HEADERS += src/bibliographymodel.h src/searchenginelist.h \ src/kbibtexnamespace.h ../../src/data/entry.h \ ../../src/data/macro.h ../../src/data/comment.h \ ../../src/data/file.h ../../src/data/preamble.h \ ../../src/data/value.h ../../src/data/element.h \ ../../src/networking/internalnetworkaccessmanager.h \ ../../src/networking/onlinesearch/onlinesearchabstract.h \ ../../src/networking/onlinesearch/onlinesearchbibsonomy.h \ ../../src/networking/onlinesearch/onlinesearchacmportal.h \ ../../src/networking/onlinesearch/onlinesearchsciencedirect.h \ ../../src/networking/onlinesearch/onlinesearchgooglescholar.h \ ../../src/networking/onlinesearch/onlinesearchjstor.h \ ../../src/networking/onlinesearch/onlinesearcharxiv.h \ ../../src/networking/onlinesearch/onlinesearchingentaconnect.h \ ../../src/networking/onlinesearch/onlinesearchspringerlink.h \ ../../src/networking/onlinesearch/onlinesearchieeexplore.h \ ../../src/networking/onlinesearch/onlinesearchpubmed.h \ - ../../src/global/preferences.h ../../src/global/kbibtex.h \ + ../../src/global/kbibtex.h \ ../../src/io/encoderxml.h ../../src/io/encoder.h \ ../../src/io/encoderlatex.h ../../src/io/fileimporter.h \ ../../src/io/fileimporterbibtex.h \ ../../src/io/textencoder.h ../../src/io/xsltransform.h \ + ../../src/config/preferences.h \ ../../src/config/bibtexfields.h ../../src/config/bibtexentries.h OTHER_FILES += qml/pages/SearchForm.qml qml/pages/EntryView.qml \ qml/pages/AboutPage.qml qml/pages/BibliographyListView.qml \ qml/cover/CoverPage.qml qml/BibSearch.qml \ qml/pages/AboutPage.qml qml/pages/SearchEngineListView.qml \ rpm/$${TARGET}.spec \ rpm/$${TARGET}.yaml \ translations/*.ts \ $${TARGET}.desktop RESOURCES += sailfishos_res.qrc QT += xmlpatterns DEFINES += KBIBTEXGLOBAL_EXPORT= KBIBTEXCONFIG_EXPORT= KBIBTEXDATA_EXPORT= KBIBTEXIO_EXPORT= KBIBTEXNETWORKING_EXPORT= -INCLUDEPATH += ../../src/global $${OUT_PWD}/src/global ../../src/data ../../src/networking ../../src/networking/onlinesearch ../../src/io ../../src/config +INCLUDEPATH += ../../src/global $${OUT_PWD}/src/global ../../src/config $${OUT_PWD}/src/config ../../src/data ../../src/networking ../../src/networking/onlinesearch ../../src/io CONFIG += sailfishapp_i18n sailfishapp_i18n_idbased TRANSLATIONS += \ translations/$${TARGET}-de.ts \ translations/$${TARGET}-en.ts DISTFILES += \ qml/pages/BibliographyListView.qml \ qml/pages/EntryView.qml \ qml/pages/SearchForm.qml \ qml/pages/SettingsPage.qml \ qml/pages/AboutPage.qml xslt.files = ../../xslt/pam2bibtex.xsl ../../xslt/ieeexploreapiv1-to-bibtex.xsl \ ../../xslt/arxiv2bibtex.xsl ../../xslt/pubmed2bibtex.xsl xslt.path = /usr/share/$${TARGET} INSTALLS += xslt icon86.files = icons/86/$${TARGET}.png icon86.path = /usr/share/icons/hicolor/86x86/apps/ INSTALLS += icon86 icon108.files = icons/108/$${TARGET}.png icon108.path = /usr/share/icons/hicolor/108x108/apps/ INSTALLS += icon108 icon128.files = icons/128/$${TARGET}.png icon128.path = /usr/share/icons/hicolor/128x128/apps/ INSTALLS += icon128 icon172.files = icons/172/$${TARGET}.png icon172.path = /usr/share/icons/hicolor/172x172/apps/ INSTALLS += icon172 icon256.files = icons/256/$${TARGET}.png icon256.path = /usr/share/icons/hicolor/256x256/apps/ INSTALLS += icon256 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 860db12f..afa4b801 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,89 +1,87 @@ # "Unity build" found at # https://cheind.wordpress.com/2009/12/10/reducing-compilation-time-unity-builds/ function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME) set(files ${${SOURCE_VARIABLE_NAME}}) # Generate a unique filename for the unity build translation unit set(unit_build_file ${CMAKE_CURRENT_BINARY_DIR}/ub_${UB_SUFFIX}.cpp) # Exclude all translation units from compilation set_source_files_properties(${files} PROPERTIES HEADER_FILE_ONLY true) # Open the ub file file(WRITE ${unit_build_file} "// Unity Build generated by CMake\n") # Add include statement for each translation unit foreach(source_file ${files}) file(APPEND ${unit_build_file} "#include <${source_file}>\n") endforeach(source_file) # Complement list of translation units with the name of ub set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${unit_build_file} PARENT_SCOPE) endfunction(enable_unity_build) if(Qt5WebEngineWidgets_FOUND) add_definitions( -DHAVE_WEBENGINEWIDGETS ) endif(Qt5WebEngineWidgets_FOUND) if(Qt5WebKitWidgets_FOUND) add_definitions( -DHAVE_WEBKITWIDGETS ) endif(Qt5WebKitWidgets_FOUND) if(Qt5WebEngineWidgets_FOUND) if(Qt5WebKitWidgets_FOUND) message(STATUS "Found both QtWebEngine and QtWebKit, preferring to use QtWebEngine") else(Qt5WebKitWidgets_FOUND) message(STATUS "Found QtWebEngine, but not QtWebKit, therefore going to use QtWebEngine") endif(Qt5WebKitWidgets_FOUND) else(Qt5WebEngineWidgets_FOUND) if(Qt5WebKitWidgets_FOUND) message(STATUS "Found QtWebKit, but not QtWebEngine, therefore going to use QtWebKit") else(Qt5WebKitWidgets_FOUND) message(STATUS "Found neither QtWebEngine nor QtWebKit, therefore trying to locate a KPart for HTML data") endif(Qt5WebKitWidgets_FOUND) endif(Qt5WebEngineWidgets_FOUND) add_subdirectory(global) -add_subdirectory( - config -) +add_subdirectory(config) add_subdirectory( data ) add_subdirectory( io ) add_subdirectory( processing ) add_subdirectory( networking ) add_subdirectory( gui ) add_subdirectory( program ) add_subdirectory( parts ) if( BUILD_TESTING ) add_subdirectory( test ) endif( BUILD_TESTING ) # install( # FILES # kbibtexnamespace.h # DESTINATION # ${INCLUDE_INSTALL_DIR}/kbibtex # COMPONENT # development # ) diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt index 2e1a6a00..dc57791c 100644 --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -1,50 +1,86 @@ -# KBibTeXConfig library - set( kbibtexconfig_LIB_SRCS notificationhub.cpp bibtexentries.cpp bibtexfields.cpp preferences.cpp logging_config.cpp ) -set( - kbibtexconfig_HDRS - notificationhub.h - bibtexentries.h - bibtexfields.h -) - if(UNITY_BUILD) enable_unity_build(kbibtexconfig kbibtexconfig_LIB_SRCS) endif(UNITY_BUILD) -add_library( - kbibtexconfig +add_library(kbibtexconfig SHARED ${kbibtexconfig_LIB_SRCS} ) -target_link_libraries( kbibtexconfig - Qt5::Core - KF5::I18n - KF5::XmlGui - kbibtexglobal -) +generate_export_header(kbibtexconfig) +add_library(KBibTeX::Config ALIAS kbibtexconfig) -set_target_properties( - kbibtexconfig +set_target_properties(kbibtexconfig PROPERTIES EXPORT_NAME "kbibtexconfig" VERSION ${KBIBTEX_RELEASE_VERSION} SOVERSION ${KBIBTEX_SOVERSION} ) +target_include_directories(kbibtexconfig + INTERFACE + $ +) + +target_link_libraries(kbibtexconfig + PUBLIC + Qt5::Core + KBibTeX::Global + PRIVATE + KF5::ConfigCore + KF5::ConfigGui + KF5::I18n +) + install( - TARGETS - kbibtexconfig - ${INSTALL_TARGETS_DEFAULT_ARGS} + TARGETS kbibtexconfig + EXPORT kbibtexconfig-targets + ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} +) + +set_target_properties(kbibtexconfig PROPERTIES + EXPORT_NAME "Config" +) + +ecm_generate_headers(kbibtexconfig_HEADERS + HEADER_NAMES + BibTeXEntries + BibTeXFields + NotificationHub + Preferences + REQUIRED_HEADERS kbibtexconfig_HEADERS +) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/kbibtexconfig_export.h + ${kbibtexconfig_HEADERS} + DESTINATION ${KDE_INSTALL_INCLUDEDIR}/KBibTeX/config + COMPONENT Devel ) -generate_export_header( kbibtexconfig ) +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/KBibTeXConfig-configVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY ExactVersion +) + +configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/KBibTeXConfig-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/KBibTeXConfig-config.cmake + INSTALL_DESTINATION ${KDE_INSTALL_LIBDIR}/cmake/KBibTeX +) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/KBibTeXConfig-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/KBibTeXConfig-configVersion.cmake + DESTINATION ${KDE_INSTALL_LIBDIR}/cmake/KBibTeX +) diff --git a/src/config/bibtexentries.h b/src/config/bibtexentries.h index b756c227..48988f18 100644 --- a/src/config/bibtexentries.h +++ b/src/config/bibtexentries.h @@ -1,82 +1,82 @@ /*************************************************************************** * Copyright (C) 2004-2018 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 . * ***************************************************************************/ #ifndef KBIBTEX_CONFIG_BIBTEXENTRIES_H #define KBIBTEX_CONFIG_BIBTEXENTRIES_H -#ifdef HAVE_KF5 -#include "kbibtexconfig_export.h" -#endif // HAVE_KF5 - #include #include -#include "kbibtex.h" +#include + +#ifdef HAVE_KF5 +#include "kbibtexconfig_export.h" +#endif // HAVE_KF5 typedef struct { QString upperCamelCase; QString upperCamelCaseAlt; QString label; QStringList requiredItems; QStringList optionalItems; } EntryDescription; bool operator==(const EntryDescription &a, const EntryDescription &b); uint qHash(const EntryDescription &a); /** @author Thomas Fischer */ class KBIBTEXCONFIG_EXPORT BibTeXEntries : public QVector { public: virtual ~BibTeXEntries(); /** * Only one instance of this class has to be used * @return the class's singleton */ static const BibTeXEntries &instance(); /** * Change the casing of a given entry name to one of the predefine formats. * */ /** * Change the casing of a given entry name to one of the predefine formats. * @param name entry name to format * @param casing can be any of the predefined formats such as lower camel case or upper case * @return returns the formatted entry name if possible or the "name" parameter's value as fall-back */ QString format(const QString &name, KBibTeX::Casing casing) const; /** * Returns the given entry name's i18n'ized, human-readable label, * for example "Journal Article" for entry name "article". * @param name entry name to look up the label for * @return the label for the entry if available, else an empty string */ QString label(const QString &name) const; private: explicit BibTeXEntries(const QVector &other); class BibTeXEntriesPrivate; BibTeXEntriesPrivate *d; }; #endif // KBIBTEX_CONFIG_BIBTEXENTRIES_H diff --git a/src/config/bibtexfields.h b/src/config/bibtexfields.h index 47a9c1e4..336ae0e9 100644 --- a/src/config/bibtexfields.h +++ b/src/config/bibtexfields.h @@ -1,104 +1,104 @@ /*************************************************************************** * 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 . * ***************************************************************************/ #ifndef KBIBTEX_CONFIG_BIBTEXFIELDS_H #define KBIBTEX_CONFIG_BIBTEXFIELDS_H -#ifdef HAVE_KF5 -#include "kbibtexconfig_export.h" -#endif // HAVE_KF5 - #include #include -#include "kbibtex.h" +#include + +#ifdef HAVE_KF5 +#include "kbibtexconfig_export.h" +#endif // HAVE_KF5 typedef struct { /** * Name of this field in 'upper camel case', e.g. 'BookTitle', but not * 'booktitle', 'BOOKTITLE', or 'BoOkTiTlE'. */ QString upperCamelCase; /** * The 'alternative' field name is used to create 'meta fields', such as * 'author' or 'editor' combined. It shall not be used to define aliases * such as 'pdf' to be an alias for 'file'. */ QString upperCamelCaseAlt; /** * List of aliases for a field. Empty for most fields. Alias for BibLaTeX * must be explictly mentioned in BibLaTeX's official documentation, see * section 'Field Aliases'. * Field aliases shall not be used as alternative field names. */ QStringList upperCamelCaseAliases; /** * Localized (translated) name of this field. */ QString label; KBibTeX::TypeFlag preferredTypeFlag; KBibTeX::TypeFlags typeFlags; int defaultWidth; QMap visible; bool defaultVisible; bool typeIndependent; } FieldDescription; bool operator==(const FieldDescription &a, const FieldDescription &b); uint qHash(const FieldDescription &a); /** @author Thomas Fischer */ class KBIBTEXCONFIG_EXPORT BibTeXFields : public QVector { public: BibTeXFields(const BibTeXFields &other) = delete; BibTeXFields &operator= (const BibTeXFields &other) = delete; ~BibTeXFields(); /** * Only one instance of this class has to be used * @return the class's singleton */ static BibTeXFields &instance(); #ifdef HAVE_KF5 void save(); void resetToDefaults(const QString &treeViewName); #endif // HAVE_KF5 /** * Change the casing of a given field name to one of the predefine formats. */ QString format(const QString &name, KBibTeX::Casing casing) const; static KBibTeX::TypeFlag typeFlagFromString(const QString &typeFlagString); static KBibTeX::TypeFlags typeFlagsFromString(const QString &typeFlagsString); static QString typeFlagToString(KBibTeX::TypeFlag typeFlag); static QString typeFlagsToString(KBibTeX::TypeFlags typeFlags); const FieldDescription find(const QString &name) const; private: explicit BibTeXFields(const QString &style, const QVector &other); class BibTeXFieldsPrivate; BibTeXFieldsPrivate *d; }; #endif // KBIBTEX_CONFIG_BIBTEXFIELDS_H diff --git a/src/config/cmake/KBibTeXConfig-config.cmake.in b/src/config/cmake/KBibTeXConfig-config.cmake.in new file mode 100644 index 00000000..b886271c --- /dev/null +++ b/src/config/cmake/KBibTeXConfig-config.cmake.in @@ -0,0 +1,30 @@ +@PACKAGE_INIT@ + +find_package( + Qt5 @QT_MIN_VERSION@ + CONFIG + REQUIRED + Core +) + +find_package( + KF5 @KF5_MIN_VERSION@ + CONFIG + REQUIRED + ConfigCore + ConfigGui + I18n +) + +find_package( + KBibTeX @PROJECT_VERSION@ EXACT + CONFIG + REQUIRED + Global +) + +if(NOT TARGET KBibTeX::Config) + include("${KBibTeXConfig_CMAKE_DIR}/KBibTeXConfig-targets.cmake") +endif() + +set(KBibTeXConfig_LIBRARIES KBibTeX::Config) diff --git a/src/config/preferences.cpp b/src/config/preferences.cpp index ef49d364..9c727d45 100644 --- a/src/config/preferences.cpp +++ b/src/config/preferences.cpp @@ -1,1255 +1,1255 @@ /*************************************************************************** * 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 . * ***************************************************************************/ /// This file has been automatically generated using the script 'preferences-generator.py' /// based on configuration data from file 'preferences.json'. If there are any problems or /// bugs, you need to fix those two files and re-generated both 'preferences.h' and /// 'preferences.cpp'. Manual changes in this file will be overwritten the next time the /// script will be run. You have been warned. -#include "preferences.h" +#include #include #ifdef HAVE_KF5 #include #include #include #include #else // HAVE_KF5 #define i18n(text) QStringLiteral(text) #define i18nc(comment,text) QStringLiteral(text) #endif // HAVE_KF5 #ifdef HAVE_KF5 -#include "notificationhub.h" +#include #endif // HAVE_KF5 #include #include class Preferences::Private { public: #ifdef HAVE_KF5 KSharedConfigPtr config; KConfigWatcher::Ptr watcher; bool dirtyFlagBibliographySystem; Preferences::BibliographySystem cachedBibliographySystem; bool dirtyFlagPersonNameFormat; QString cachedPersonNameFormat; bool dirtyFlagCopyReferenceCommand; QString cachedCopyReferenceCommand; bool dirtyFlagPageSize; QPageSize::PageSizeId cachedPageSize; bool dirtyFlagBackupScope; Preferences::BackupScope cachedBackupScope; bool dirtyFlagNumberOfBackups; int cachedNumberOfBackups; bool dirtyFlagIdSuggestionFormatStrings; QStringList cachedIdSuggestionFormatStrings; bool dirtyFlagActiveIdSuggestionFormatString; QString cachedActiveIdSuggestionFormatString; bool dirtyFlagLyXUseAutomaticPipeDetection; bool cachedLyXUseAutomaticPipeDetection; bool dirtyFlagLyXPipePath; QString cachedLyXPipePath; bool dirtyFlagBibTeXEncoding; QString cachedBibTeXEncoding; bool dirtyFlagBibTeXStringDelimiter; QString cachedBibTeXStringDelimiter; bool dirtyFlagBibTeXQuoteComment; Preferences::QuoteComment cachedBibTeXQuoteComment; bool dirtyFlagBibTeXKeywordCasing; KBibTeX::Casing cachedBibTeXKeywordCasing; bool dirtyFlagBibTeXProtectCasing; bool cachedBibTeXProtectCasing; bool dirtyFlagBibTeXListSeparator; QString cachedBibTeXListSeparator; bool dirtyFlagLaTeXBabelLanguage; QString cachedLaTeXBabelLanguage; bool dirtyFlagBibTeXBibliographyStyle; QString cachedBibTeXBibliographyStyle; bool dirtyFlagFileViewDoubleClickAction; Preferences::FileViewDoubleClickAction cachedFileViewDoubleClickAction; bool dirtyFlagColorCodes; QVector> cachedColorCodes; #endif // HAVE_KF5 Private(Preferences *) { #ifdef HAVE_KF5 config = KSharedConfig::openConfig(QStringLiteral("kbibtexrc")); watcher = KConfigWatcher::create(config); dirtyFlagBibliographySystem = true; cachedBibliographySystem = Preferences::defaultBibliographySystem; dirtyFlagPersonNameFormat = true; cachedPersonNameFormat = Preferences::defaultPersonNameFormat; dirtyFlagCopyReferenceCommand = true; cachedCopyReferenceCommand = Preferences::defaultCopyReferenceCommand; dirtyFlagPageSize = true; cachedPageSize = Preferences::defaultPageSize; dirtyFlagBackupScope = true; cachedBackupScope = Preferences::defaultBackupScope; dirtyFlagNumberOfBackups = true; cachedNumberOfBackups = Preferences::defaultNumberOfBackups; dirtyFlagIdSuggestionFormatStrings = true; cachedIdSuggestionFormatStrings = Preferences::defaultIdSuggestionFormatStrings; dirtyFlagActiveIdSuggestionFormatString = true; cachedActiveIdSuggestionFormatString = Preferences::defaultActiveIdSuggestionFormatString; dirtyFlagLyXUseAutomaticPipeDetection = true; cachedLyXUseAutomaticPipeDetection = Preferences::defaultLyXUseAutomaticPipeDetection; dirtyFlagLyXPipePath = true; cachedLyXPipePath = Preferences::defaultLyXPipePath; dirtyFlagBibTeXEncoding = true; cachedBibTeXEncoding = Preferences::defaultBibTeXEncoding; dirtyFlagBibTeXStringDelimiter = true; cachedBibTeXStringDelimiter = Preferences::defaultBibTeXStringDelimiter; dirtyFlagBibTeXQuoteComment = true; cachedBibTeXQuoteComment = Preferences::defaultBibTeXQuoteComment; dirtyFlagBibTeXKeywordCasing = true; cachedBibTeXKeywordCasing = Preferences::defaultBibTeXKeywordCasing; dirtyFlagBibTeXProtectCasing = true; cachedBibTeXProtectCasing = Preferences::defaultBibTeXProtectCasing; dirtyFlagBibTeXListSeparator = true; cachedBibTeXListSeparator = Preferences::defaultBibTeXListSeparator; dirtyFlagLaTeXBabelLanguage = true; cachedLaTeXBabelLanguage = Preferences::defaultLaTeXBabelLanguage; dirtyFlagBibTeXBibliographyStyle = true; cachedBibTeXBibliographyStyle = Preferences::defaultBibTeXBibliographyStyle; dirtyFlagFileViewDoubleClickAction = true; cachedFileViewDoubleClickAction = Preferences::defaultFileViewDoubleClickAction; dirtyFlagColorCodes = true; cachedColorCodes = Preferences::defaultColorCodes; #endif // HAVE_KF5 } #ifdef HAVE_KF5 inline bool validateValueForBibliographySystem(const Preferences::BibliographySystem valueToBeChecked) { for (QVector>::ConstIterator it = Preferences::availableBibliographySystems.constBegin(); it != Preferences::availableBibliographySystems.constEnd(); ++it) if (it->first == valueToBeChecked) return true; return false; } inline bool validateValueForPersonNameFormat(const QString &valueToBeChecked) { return valueToBeChecked.contains(QStringLiteral("%f")) && valueToBeChecked.contains(QStringLiteral("%l")) && valueToBeChecked.contains(QStringLiteral("%s")); } inline bool validateValueForCopyReferenceCommand(const QString &valueToBeChecked) { return Preferences::availableCopyReferenceCommands.contains(valueToBeChecked); } inline bool validateValueForPageSize(const QPageSize::PageSizeId valueToBeChecked) { for (QVector>::ConstIterator it = Preferences::availablePageSizes.constBegin(); it != Preferences::availablePageSizes.constEnd(); ++it) if (it->first == valueToBeChecked) return true; return false; } inline bool validateValueForBackupScope(const Preferences::BackupScope valueToBeChecked) { for (QVector>::ConstIterator it = Preferences::availableBackupScopes.constBegin(); it != Preferences::availableBackupScopes.constEnd(); ++it) if (it->first == valueToBeChecked) return true; return false; } inline bool validateValueForNumberOfBackups(const int valueToBeChecked) { return valueToBeChecked >= 0; } inline bool validateValueForIdSuggestionFormatStrings(const QStringList &valueToBeChecked) { return !valueToBeChecked.isEmpty() && (valueToBeChecked.front().contains(QLatin1Char('A')) || valueToBeChecked.front().contains(QLatin1Char('a')) || valueToBeChecked.front().contains(QLatin1Char('y')) || valueToBeChecked.front().contains(QLatin1Char('Y')) || valueToBeChecked.front().contains(QLatin1Char('T'))); } inline bool validateValueForActiveIdSuggestionFormatString(const QString &valueToBeChecked) { Q_UNUSED(valueToBeChecked) return true; } inline bool validateValueForLyXUseAutomaticPipeDetection(const bool valueToBeChecked) { Q_UNUSED(valueToBeChecked) return true; } inline bool validateValueForLyXPipePath(const QString &valueToBeChecked) { return valueToBeChecked.startsWith(QLatin1Char('/')); } inline bool validateValueForBibTeXEncoding(const QString &valueToBeChecked) { return Preferences::availableBibTeXEncodings.contains(valueToBeChecked); } inline bool validateValueForBibTeXStringDelimiter(const QString &valueToBeChecked) { return Preferences::availableBibTeXStringDelimiters.contains(valueToBeChecked); } inline bool validateValueForBibTeXQuoteComment(const Preferences::QuoteComment valueToBeChecked) { for (QVector>::ConstIterator it = Preferences::availableBibTeXQuoteComments.constBegin(); it != Preferences::availableBibTeXQuoteComments.constEnd(); ++it) if (it->first == valueToBeChecked) return true; return false; } inline bool validateValueForBibTeXKeywordCasing(const KBibTeX::Casing valueToBeChecked) { for (QVector>::ConstIterator it = Preferences::availableBibTeXKeywordCasings.constBegin(); it != Preferences::availableBibTeXKeywordCasings.constEnd(); ++it) if (it->first == valueToBeChecked) return true; return false; } inline bool validateValueForBibTeXProtectCasing(const bool valueToBeChecked) { Q_UNUSED(valueToBeChecked) return true; } inline bool validateValueForBibTeXListSeparator(const QString &valueToBeChecked) { return Preferences::availableBibTeXListSeparators.contains(valueToBeChecked); } inline bool validateValueForLaTeXBabelLanguage(const QString &valueToBeChecked) { return !valueToBeChecked.isEmpty(); } inline bool validateValueForBibTeXBibliographyStyle(const QString &valueToBeChecked) { return !valueToBeChecked.isEmpty(); } inline bool validateValueForFileViewDoubleClickAction(const Preferences::FileViewDoubleClickAction valueToBeChecked) { for (QVector>::ConstIterator it = Preferences::availableFileViewDoubleClickActions.constBegin(); it != Preferences::availableFileViewDoubleClickActions.constEnd(); ++it) if (it->first == valueToBeChecked) return true; return false; } inline bool validateValueForColorCodes(const QVector> &valueToBeChecked) { static const QColor white(Qt::white), black(Qt::black); for (QVector>::ConstIterator it = valueToBeChecked.constBegin(); it != valueToBeChecked.constEnd(); ++it) if (it->first == white || it->first == black || it->second.isEmpty()) return false; return true; } QVector> readEntryColorCodes(const KConfigGroup &configGroup, const QString &key) const { const QString rawEntry = configGroup.readEntry(key, QString()); if (rawEntry.isEmpty()) return Preferences::defaultColorCodes; const QStringList pairs = rawEntry.split(QStringLiteral("\0\0"), QString::SkipEmptyParts); if (pairs.isEmpty()) return Preferences::defaultColorCodes; QVector> result; for (const QString &pair : pairs) { const QStringList colorLabelPair = pair.split(QStringLiteral("\0"), QString::SkipEmptyParts); if (colorLabelPair.length() != 2) return Preferences::defaultColorCodes; result.append(qMakePair(QColor(colorLabelPair[0]), colorLabelPair[1])); } return result; } void writeEntryColorCodes(KConfigGroup &configGroup, const QString &key, const QVector> &valueToBeWritten) { QString rawEntry; for (QVector>::ConstIterator it = valueToBeWritten.constBegin(); it != valueToBeWritten.constEnd(); ++it) { if (!rawEntry.isEmpty()) rawEntry.append(QStringLiteral("\0\0")); rawEntry = rawEntry.append(it->first.name(QColor::HexRgb)).append(QStringLiteral("\0")).append(it->second); } configGroup.writeEntry(key, rawEntry, KConfig::Notify); } #endif // HAVE_KF5 }; Preferences &Preferences::instance() { static Preferences singleton; return singleton; } Preferences::Preferences() : d(new Preferences::Private(this)) { #ifdef HAVE_KF5 QObject::connect(d->watcher.data(), &KConfigWatcher::configChanged, QCoreApplication::instance(), [this](const KConfigGroup &group, const QByteArrayList &names) { QSet eventsToPublish; if (group.name() == QStringLiteral("General") && names.contains("BibliographySystem")) { /// Configuration setting BibliographySystem got changed by another Preferences instance"; d->dirtyFlagBibliographySystem = true; eventsToPublish.insert(NotificationHub::EventBibliographySystemChanged); } if (group.name() == QStringLiteral("General") && names.contains("PersonNameFormat")) { /// Configuration setting PersonNameFormat got changed by another Preferences instance"; d->dirtyFlagPersonNameFormat = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("LaTeX") && names.contains("CopyReferenceCommand")) { /// Configuration setting CopyReferenceCommand got changed by another Preferences instance"; d->dirtyFlagCopyReferenceCommand = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("General") && names.contains("PageSize")) { /// Configuration setting PageSize got changed by another Preferences instance"; d->dirtyFlagPageSize = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("InputOutput") && names.contains("BackupScope")) { /// Configuration setting BackupScope got changed by another Preferences instance"; d->dirtyFlagBackupScope = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("InputOutput") && names.contains("NumberOfBackups")) { /// Configuration setting NumberOfBackups got changed by another Preferences instance"; d->dirtyFlagNumberOfBackups = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("IdSuggestions") && names.contains("IdSuggestionFormatStrings")) { /// Configuration setting IdSuggestionFormatStrings got changed by another Preferences instance"; d->dirtyFlagIdSuggestionFormatStrings = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("IdSuggestions") && names.contains("ActiveIdSuggestionFormatString")) { /// Configuration setting ActiveIdSuggestionFormatString got changed by another Preferences instance"; d->dirtyFlagActiveIdSuggestionFormatString = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("LyX") && names.contains("LyXUseAutomaticPipeDetection")) { /// Configuration setting LyXUseAutomaticPipeDetection got changed by another Preferences instance"; d->dirtyFlagLyXUseAutomaticPipeDetection = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("LyX") && names.contains("LyXPipePath")) { /// Configuration setting LyXPipePath got changed by another Preferences instance"; d->dirtyFlagLyXPipePath = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("FileExporterBibTeX") && names.contains("BibTeXEncoding")) { /// Configuration setting BibTeXEncoding got changed by another Preferences instance"; d->dirtyFlagBibTeXEncoding = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("FileExporterBibTeX") && names.contains("BibTeXStringDelimiter")) { /// Configuration setting BibTeXStringDelimiter got changed by another Preferences instance"; d->dirtyFlagBibTeXStringDelimiter = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("FileExporterBibTeX") && names.contains("BibTeXQuoteComment")) { /// Configuration setting BibTeXQuoteComment got changed by another Preferences instance"; d->dirtyFlagBibTeXQuoteComment = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("FileExporterBibTeX") && names.contains("BibTeXKeywordCasing")) { /// Configuration setting BibTeXKeywordCasing got changed by another Preferences instance"; d->dirtyFlagBibTeXKeywordCasing = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("FileExporterBibTeX") && names.contains("BibTeXProtectCasing")) { /// Configuration setting BibTeXProtectCasing got changed by another Preferences instance"; d->dirtyFlagBibTeXProtectCasing = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("FileExporterBibTeX") && names.contains("BibTeXListSeparator")) { /// Configuration setting BibTeXListSeparator got changed by another Preferences instance"; d->dirtyFlagBibTeXListSeparator = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("FileExporterLaTeXbased") && names.contains("LaTeXBabelLanguage")) { /// Configuration setting LaTeXBabelLanguage got changed by another Preferences instance"; d->dirtyFlagLaTeXBabelLanguage = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("FileExporterLaTeXbased") && names.contains("BibTeXBibliographyStyle")) { /// Configuration setting BibTeXBibliographyStyle got changed by another Preferences instance"; d->dirtyFlagBibTeXBibliographyStyle = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("User Interface") && names.contains("FileViewDoubleClickAction")) { /// Configuration setting FileViewDoubleClickAction got changed by another Preferences instance"; d->dirtyFlagFileViewDoubleClickAction = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } if (group.name() == QStringLiteral("Color Labels") && names.contains("ColorCodes")) { /// Configuration setting ColorCodes got changed by another Preferences instance"; d->dirtyFlagColorCodes = true; eventsToPublish.insert(NotificationHub::EventConfigurationChanged); } for (const int eventId : eventsToPublish) NotificationHub::publishEvent(eventId); }); #endif // HAVE_KF5 } Preferences::~Preferences() { delete d; } const QVector> Preferences::availableBibliographySystems {{Preferences::BibTeX, i18n("BibTeX")}, {Preferences::BibLaTeX, i18n("BibLaTeX")}}; const Preferences::BibliographySystem Preferences::defaultBibliographySystem = Preferences::availableBibliographySystems.front().first; Preferences::BibliographySystem Preferences::bibliographySystem() { #ifdef HAVE_KF5 if (d->dirtyFlagBibliographySystem) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("General")); const Preferences::BibliographySystem valueFromConfig = static_cast(configGroup.readEntry(QStringLiteral("BibliographySystem"), static_cast(Preferences::defaultBibliographySystem))); if (d->validateValueForBibliographySystem(valueFromConfig)) { d->cachedBibliographySystem = valueFromConfig; d->dirtyFlagBibliographySystem = false; } else { /// Configuration file setting for BibliographySystem has an invalid value, using default as fallback setBibliographySystem(Preferences::defaultBibliographySystem); } } return d->cachedBibliographySystem; #else // HAVE_KF5 return defaultBibliographySystem; #endif // HAVE_KF5 } bool Preferences::setBibliographySystem(const Preferences::BibliographySystem newValue) { #ifdef HAVE_KF5 if (!d->validateValueForBibliographySystem(newValue)) return false; d->dirtyFlagBibliographySystem = false; d->cachedBibliographySystem = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("General")); const Preferences::BibliographySystem valueFromConfig = static_cast(configGroup.readEntry(QStringLiteral("BibliographySystem"), static_cast(Preferences::defaultBibliographySystem))); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("BibliographySystem"), static_cast(newValue), KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QString Preferences::personNameFormatLastFirst = QStringLiteral("<%l><, %s><, %f>"); const QString Preferences::personNameFormatFirstLast = QStringLiteral("<%f ><%l>< %s>"); const QString Preferences::defaultPersonNameFormat = Preferences::personNameFormatLastFirst; const QString &Preferences::personNameFormat() { #ifdef HAVE_KF5 if (d->dirtyFlagPersonNameFormat) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("General")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("PersonNameFormat"), Preferences::defaultPersonNameFormat); if (d->validateValueForPersonNameFormat(valueFromConfig)) { d->cachedPersonNameFormat = valueFromConfig; d->dirtyFlagPersonNameFormat = false; } else { /// Configuration file setting for PersonNameFormat has an invalid value, using default as fallback setPersonNameFormat(Preferences::defaultPersonNameFormat); } } return d->cachedPersonNameFormat; #else // HAVE_KF5 return defaultPersonNameFormat; #endif // HAVE_KF5 } bool Preferences::setPersonNameFormat(const QString &newValue) { #ifdef HAVE_KF5 if (!d->validateValueForPersonNameFormat(newValue)) return false; d->dirtyFlagPersonNameFormat = false; d->cachedPersonNameFormat = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("General")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("PersonNameFormat"), Preferences::defaultPersonNameFormat); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("PersonNameFormat"), newValue, KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QStringList Preferences::availableCopyReferenceCommands {QStringLiteral("cite"), QStringLiteral("citealt"), QStringLiteral("citeauthor"), QStringLiteral("citeauthor*"), QStringLiteral("citeyear"), QStringLiteral("citeyearpar"), QStringLiteral("shortcite"), QStringLiteral("citet"), QStringLiteral("citet*"), QStringLiteral("citep"), QStringLiteral("citep*")}; const QString Preferences::defaultCopyReferenceCommand = Preferences::availableCopyReferenceCommands.front(); const QString &Preferences::copyReferenceCommand() { #ifdef HAVE_KF5 if (d->dirtyFlagCopyReferenceCommand) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("LaTeX")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("CopyReferenceCommand"), Preferences::defaultCopyReferenceCommand); if (d->validateValueForCopyReferenceCommand(valueFromConfig)) { d->cachedCopyReferenceCommand = valueFromConfig; d->dirtyFlagCopyReferenceCommand = false; } else { /// Configuration file setting for CopyReferenceCommand has an invalid value, using default as fallback setCopyReferenceCommand(Preferences::defaultCopyReferenceCommand); } } return d->cachedCopyReferenceCommand; #else // HAVE_KF5 return defaultCopyReferenceCommand; #endif // HAVE_KF5 } bool Preferences::setCopyReferenceCommand(const QString &newValue) { #ifdef HAVE_KF5 QString sanitizedNewValue = newValue; const QString lowerSanitizedNewValue = sanitizedNewValue.toLower(); for (const QString &knownCopyReferenceCommand : availableCopyReferenceCommands) if (knownCopyReferenceCommand.toLower() == lowerSanitizedNewValue) { sanitizedNewValue = knownCopyReferenceCommand; break; } if (!d->validateValueForCopyReferenceCommand(sanitizedNewValue)) return false; d->dirtyFlagCopyReferenceCommand = false; d->cachedCopyReferenceCommand = sanitizedNewValue; static KConfigGroup configGroup(d->config, QStringLiteral("LaTeX")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("CopyReferenceCommand"), Preferences::defaultCopyReferenceCommand); if (valueFromConfig == sanitizedNewValue) return false; configGroup.writeEntry(QStringLiteral("CopyReferenceCommand"), sanitizedNewValue, KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QVector> Preferences::availablePageSizes {{QPageSize::A4, QStringLiteral("a4paper")}, {QPageSize::Letter, QStringLiteral("letter")}, {QPageSize::Legal, QStringLiteral("legal")}}; const QPageSize::PageSizeId Preferences::defaultPageSize = Preferences::availablePageSizes.front().first; QPageSize::PageSizeId Preferences::pageSize() { #ifdef HAVE_KF5 if (d->dirtyFlagPageSize) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("General")); const QPageSize::PageSizeId valueFromConfig = static_cast(configGroup.readEntry(QStringLiteral("PageSize"), static_cast(Preferences::defaultPageSize))); if (d->validateValueForPageSize(valueFromConfig)) { d->cachedPageSize = valueFromConfig; d->dirtyFlagPageSize = false; } else { /// Configuration file setting for PageSize has an invalid value, using default as fallback setPageSize(Preferences::defaultPageSize); } } return d->cachedPageSize; #else // HAVE_KF5 return defaultPageSize; #endif // HAVE_KF5 } bool Preferences::setPageSize(const QPageSize::PageSizeId newValue) { #ifdef HAVE_KF5 if (!d->validateValueForPageSize(newValue)) return false; d->dirtyFlagPageSize = false; d->cachedPageSize = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("General")); const QPageSize::PageSizeId valueFromConfig = static_cast(configGroup.readEntry(QStringLiteral("PageSize"), static_cast(Preferences::defaultPageSize))); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("PageSize"), static_cast(newValue), KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QVector> Preferences::availableBackupScopes {{Preferences::NoBackup, i18n("No backups")}, {Preferences::LocalOnly, i18n("Local files only")}, {Preferences::BothLocalAndRemote, i18n("Both local and remote files")}}; const Preferences::BackupScope Preferences::defaultBackupScope = Preferences::availableBackupScopes.front().first; Preferences::BackupScope Preferences::backupScope() { #ifdef HAVE_KF5 if (d->dirtyFlagBackupScope) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("InputOutput")); const Preferences::BackupScope valueFromConfig = static_cast(configGroup.readEntry(QStringLiteral("BackupScope"), static_cast(Preferences::defaultBackupScope))); if (d->validateValueForBackupScope(valueFromConfig)) { d->cachedBackupScope = valueFromConfig; d->dirtyFlagBackupScope = false; } else { /// Configuration file setting for BackupScope has an invalid value, using default as fallback setBackupScope(Preferences::defaultBackupScope); } } return d->cachedBackupScope; #else // HAVE_KF5 return defaultBackupScope; #endif // HAVE_KF5 } bool Preferences::setBackupScope(const Preferences::BackupScope newValue) { #ifdef HAVE_KF5 if (!d->validateValueForBackupScope(newValue)) return false; d->dirtyFlagBackupScope = false; d->cachedBackupScope = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("InputOutput")); const Preferences::BackupScope valueFromConfig = static_cast(configGroup.readEntry(QStringLiteral("BackupScope"), static_cast(Preferences::defaultBackupScope))); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("BackupScope"), static_cast(newValue), KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const int Preferences::defaultNumberOfBackups = 5; int Preferences::numberOfBackups() { #ifdef HAVE_KF5 if (d->dirtyFlagNumberOfBackups) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("InputOutput")); const int valueFromConfig = configGroup.readEntry(QStringLiteral("NumberOfBackups"), Preferences::defaultNumberOfBackups); if (d->validateValueForNumberOfBackups(valueFromConfig)) { d->cachedNumberOfBackups = valueFromConfig; d->dirtyFlagNumberOfBackups = false; } else { /// Configuration file setting for NumberOfBackups has an invalid value, using default as fallback setNumberOfBackups(Preferences::defaultNumberOfBackups); } } return d->cachedNumberOfBackups; #else // HAVE_KF5 return defaultNumberOfBackups; #endif // HAVE_KF5 } bool Preferences::setNumberOfBackups(const int newValue) { #ifdef HAVE_KF5 if (!d->validateValueForNumberOfBackups(newValue)) return false; d->dirtyFlagNumberOfBackups = false; d->cachedNumberOfBackups = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("InputOutput")); const int valueFromConfig = configGroup.readEntry(QStringLiteral("NumberOfBackups"), Preferences::defaultNumberOfBackups); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("NumberOfBackups"), newValue, KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QStringList Preferences::defaultIdSuggestionFormatStrings {QStringLiteral("A"), QStringLiteral("A2|y"), QStringLiteral("A3|y"), QStringLiteral("A4|y|\":|T5"), QStringLiteral("al|\":|T"), QStringLiteral("al|y"), QStringLiteral("al|Y"), QStringLiteral("Al\"-|\"-|y"), QStringLiteral("Al\"+|Y"), QStringLiteral("al|y|T"), QStringLiteral("al|Y|T3"), QStringLiteral("al|Y|T3l"), QStringLiteral("a|\":|Y|\":|T1"), QStringLiteral("a|y"), QStringLiteral("A|\":|Y")}; const QStringList &Preferences::idSuggestionFormatStrings() { #ifdef HAVE_KF5 if (d->dirtyFlagIdSuggestionFormatStrings) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("IdSuggestions")); const QStringList valueFromConfig = configGroup.readEntry(QStringLiteral("IdSuggestionFormatStrings"), Preferences::defaultIdSuggestionFormatStrings); if (d->validateValueForIdSuggestionFormatStrings(valueFromConfig)) { d->cachedIdSuggestionFormatStrings = valueFromConfig; d->dirtyFlagIdSuggestionFormatStrings = false; } else { /// Configuration file setting for IdSuggestionFormatStrings has an invalid value, using default as fallback setIdSuggestionFormatStrings(Preferences::defaultIdSuggestionFormatStrings); } } return d->cachedIdSuggestionFormatStrings; #else // HAVE_KF5 return defaultIdSuggestionFormatStrings; #endif // HAVE_KF5 } bool Preferences::setIdSuggestionFormatStrings(const QStringList &newValue) { #ifdef HAVE_KF5 if (!d->validateValueForIdSuggestionFormatStrings(newValue)) return false; d->dirtyFlagIdSuggestionFormatStrings = false; d->cachedIdSuggestionFormatStrings = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("IdSuggestions")); const QStringList valueFromConfig = configGroup.readEntry(QStringLiteral("IdSuggestionFormatStrings"), Preferences::defaultIdSuggestionFormatStrings); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("IdSuggestionFormatStrings"), newValue, KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QString Preferences::defaultActiveIdSuggestionFormatString {}; const QString &Preferences::activeIdSuggestionFormatString() { #ifdef HAVE_KF5 if (d->dirtyFlagActiveIdSuggestionFormatString) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("IdSuggestions")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("ActiveIdSuggestionFormatString"), Preferences::defaultActiveIdSuggestionFormatString); if (d->validateValueForActiveIdSuggestionFormatString(valueFromConfig)) { d->cachedActiveIdSuggestionFormatString = valueFromConfig; d->dirtyFlagActiveIdSuggestionFormatString = false; } else { /// Configuration file setting for ActiveIdSuggestionFormatString has an invalid value, using default as fallback setActiveIdSuggestionFormatString(Preferences::defaultActiveIdSuggestionFormatString); } } return d->cachedActiveIdSuggestionFormatString; #else // HAVE_KF5 return defaultActiveIdSuggestionFormatString; #endif // HAVE_KF5 } bool Preferences::setActiveIdSuggestionFormatString(const QString &newValue) { #ifdef HAVE_KF5 if (!d->validateValueForActiveIdSuggestionFormatString(newValue)) return false; d->dirtyFlagActiveIdSuggestionFormatString = false; d->cachedActiveIdSuggestionFormatString = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("IdSuggestions")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("ActiveIdSuggestionFormatString"), Preferences::defaultActiveIdSuggestionFormatString); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("ActiveIdSuggestionFormatString"), newValue, KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const bool Preferences::defaultLyXUseAutomaticPipeDetection = true; bool Preferences::lyXUseAutomaticPipeDetection() { #ifdef HAVE_KF5 if (d->dirtyFlagLyXUseAutomaticPipeDetection) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("LyX")); const bool valueFromConfig = configGroup.readEntry(QStringLiteral("LyXUseAutomaticPipeDetection"), Preferences::defaultLyXUseAutomaticPipeDetection); if (d->validateValueForLyXUseAutomaticPipeDetection(valueFromConfig)) { d->cachedLyXUseAutomaticPipeDetection = valueFromConfig; d->dirtyFlagLyXUseAutomaticPipeDetection = false; } else { /// Configuration file setting for LyXUseAutomaticPipeDetection has an invalid value, using default as fallback setLyXUseAutomaticPipeDetection(Preferences::defaultLyXUseAutomaticPipeDetection); } } return d->cachedLyXUseAutomaticPipeDetection; #else // HAVE_KF5 return defaultLyXUseAutomaticPipeDetection; #endif // HAVE_KF5 } bool Preferences::setLyXUseAutomaticPipeDetection(const bool newValue) { #ifdef HAVE_KF5 if (!d->validateValueForLyXUseAutomaticPipeDetection(newValue)) return false; d->dirtyFlagLyXUseAutomaticPipeDetection = false; d->cachedLyXUseAutomaticPipeDetection = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("LyX")); const bool valueFromConfig = configGroup.readEntry(QStringLiteral("LyXUseAutomaticPipeDetection"), Preferences::defaultLyXUseAutomaticPipeDetection); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("LyXUseAutomaticPipeDetection"), newValue, KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QString Preferences::defaultLyXPipePath = QDir::homePath() + QStringLiteral("/.lyxpipe.in"); const QString &Preferences::lyXPipePath() { #ifdef HAVE_KF5 if (d->dirtyFlagLyXPipePath) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("LyX")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("LyXPipePath"), Preferences::defaultLyXPipePath); if (d->validateValueForLyXPipePath(valueFromConfig)) { d->cachedLyXPipePath = valueFromConfig; d->dirtyFlagLyXPipePath = false; } else { /// Configuration file setting for LyXPipePath has an invalid value, using default as fallback setLyXPipePath(Preferences::defaultLyXPipePath); } } return d->cachedLyXPipePath; #else // HAVE_KF5 return defaultLyXPipePath; #endif // HAVE_KF5 } bool Preferences::setLyXPipePath(const QString &newValue) { #ifdef HAVE_KF5 QString sanitizedNewValue = newValue; if (sanitizedNewValue.endsWith(QStringLiteral(".out"))) sanitizedNewValue = sanitizedNewValue.left(sanitizedNewValue.length() - 4); if (!sanitizedNewValue.endsWith(QStringLiteral(".in"))) sanitizedNewValue = sanitizedNewValue.append(QStringLiteral(".in")); if (!d->validateValueForLyXPipePath(sanitizedNewValue)) return false; d->dirtyFlagLyXPipePath = false; d->cachedLyXPipePath = sanitizedNewValue; static KConfigGroup configGroup(d->config, QStringLiteral("LyX")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("LyXPipePath"), Preferences::defaultLyXPipePath); if (valueFromConfig == sanitizedNewValue) return false; configGroup.writeEntry(QStringLiteral("LyXPipePath"), sanitizedNewValue, KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QStringList Preferences::availableBibTeXEncodings {QStringLiteral("LaTeX"), QStringLiteral("US-ASCII"), QStringLiteral("ISO-8859-1"), QStringLiteral("ISO-8859-2"), QStringLiteral("ISO-8859-3"), QStringLiteral("ISO-8859-4"), QStringLiteral("ISO-8859-5"), QStringLiteral("ISO-8859-6"), QStringLiteral("ISO-8859-7"), QStringLiteral("ISO-8859-8"), QStringLiteral("ISO-8859-9"), QStringLiteral("ISO-8859-10"), QStringLiteral("ISO-8859-13"), QStringLiteral("ISO-8859-14"), QStringLiteral("ISO-8859-15"), QStringLiteral("ISO-8859-16"), QStringLiteral("UTF-8"), QStringLiteral("UTF-16"), QStringLiteral("UTF-16BE"), QStringLiteral("UTF-16LE"), QStringLiteral("UTF-32"), QStringLiteral("UTF-32BE"), QStringLiteral("UTF-32LE"), QStringLiteral("KOI8-R"), QStringLiteral("KOI8-U"), QStringLiteral("Big5"), QStringLiteral("Big5-HKSCS"), QStringLiteral("GB18030"), QStringLiteral("EUC-JP"), QStringLiteral("EUC-KR"), QStringLiteral("ISO 2022-JP"), QStringLiteral("Shift-JIS"), QStringLiteral("Windows-1250"), QStringLiteral("Windows-1251"), QStringLiteral("Windows-1252"), QStringLiteral("Windows-1253"), QStringLiteral("Windows-1254"), QStringLiteral("Windows-1255"), QStringLiteral("Windows-1256"), QStringLiteral("Windows-1257"), QStringLiteral("Windows-1258")}; const QString Preferences::defaultBibTeXEncoding = QStringLiteral("UTF-8"); const QString &Preferences::bibTeXEncoding() { #ifdef HAVE_KF5 if (d->dirtyFlagBibTeXEncoding) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("FileExporterBibTeX")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("BibTeXEncoding"), Preferences::defaultBibTeXEncoding); if (d->validateValueForBibTeXEncoding(valueFromConfig)) { d->cachedBibTeXEncoding = valueFromConfig; d->dirtyFlagBibTeXEncoding = false; } else { /// Configuration file setting for BibTeXEncoding has an invalid value, using default as fallback setBibTeXEncoding(Preferences::defaultBibTeXEncoding); } } return d->cachedBibTeXEncoding; #else // HAVE_KF5 return defaultBibTeXEncoding; #endif // HAVE_KF5 } bool Preferences::setBibTeXEncoding(const QString &newValue) { #ifdef HAVE_KF5 QString sanitizedNewValue = newValue; const QString lowerSanitizedNewValue = sanitizedNewValue.toLower(); for (const QString &knownBibTeXEncoding : availableBibTeXEncodings) if (knownBibTeXEncoding.toLower() == lowerSanitizedNewValue) { sanitizedNewValue = knownBibTeXEncoding; break; } if (!d->validateValueForBibTeXEncoding(sanitizedNewValue)) return false; d->dirtyFlagBibTeXEncoding = false; d->cachedBibTeXEncoding = sanitizedNewValue; static KConfigGroup configGroup(d->config, QStringLiteral("FileExporterBibTeX")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("BibTeXEncoding"), Preferences::defaultBibTeXEncoding); if (valueFromConfig == sanitizedNewValue) return false; configGroup.writeEntry(QStringLiteral("BibTeXEncoding"), sanitizedNewValue, KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QStringList Preferences::availableBibTeXStringDelimiters {QStringLiteral("{}"), QStringLiteral("\"\""), QStringLiteral("()")}; const QString Preferences::defaultBibTeXStringDelimiter = Preferences::availableBibTeXStringDelimiters.front(); const QString &Preferences::bibTeXStringDelimiter() { #ifdef HAVE_KF5 if (d->dirtyFlagBibTeXStringDelimiter) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("FileExporterBibTeX")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("BibTeXStringDelimiter"), Preferences::defaultBibTeXStringDelimiter); if (d->validateValueForBibTeXStringDelimiter(valueFromConfig)) { d->cachedBibTeXStringDelimiter = valueFromConfig; d->dirtyFlagBibTeXStringDelimiter = false; } else { /// Configuration file setting for BibTeXStringDelimiter has an invalid value, using default as fallback setBibTeXStringDelimiter(Preferences::defaultBibTeXStringDelimiter); } } return d->cachedBibTeXStringDelimiter; #else // HAVE_KF5 return defaultBibTeXStringDelimiter; #endif // HAVE_KF5 } bool Preferences::setBibTeXStringDelimiter(const QString &newValue) { #ifdef HAVE_KF5 QString sanitizedNewValue = newValue; const QString lowerSanitizedNewValue = sanitizedNewValue.toLower(); for (const QString &knownBibTeXStringDelimiter : availableBibTeXStringDelimiters) if (knownBibTeXStringDelimiter.toLower() == lowerSanitizedNewValue) { sanitizedNewValue = knownBibTeXStringDelimiter; break; } if (!d->validateValueForBibTeXStringDelimiter(sanitizedNewValue)) return false; d->dirtyFlagBibTeXStringDelimiter = false; d->cachedBibTeXStringDelimiter = sanitizedNewValue; static KConfigGroup configGroup(d->config, QStringLiteral("FileExporterBibTeX")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("BibTeXStringDelimiter"), Preferences::defaultBibTeXStringDelimiter); if (valueFromConfig == sanitizedNewValue) return false; configGroup.writeEntry(QStringLiteral("BibTeXStringDelimiter"), sanitizedNewValue, KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QVector> Preferences::availableBibTeXQuoteComments {{Preferences::qcNone, i18nc("Comment Quoting", "None")}, {Preferences::qcCommand, i18nc("Comment Quoting", "@comment{\342\200\246}")}, {Preferences::qcPercentSign, i18nc("Comment Quoting", "% \342\200\246")}}; const Preferences::QuoteComment Preferences::defaultBibTeXQuoteComment = Preferences::availableBibTeXQuoteComments.front().first; Preferences::QuoteComment Preferences::bibTeXQuoteComment() { #ifdef HAVE_KF5 if (d->dirtyFlagBibTeXQuoteComment) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("FileExporterBibTeX")); const Preferences::QuoteComment valueFromConfig = static_cast(configGroup.readEntry(QStringLiteral("BibTeXQuoteComment"), static_cast(Preferences::defaultBibTeXQuoteComment))); if (d->validateValueForBibTeXQuoteComment(valueFromConfig)) { d->cachedBibTeXQuoteComment = valueFromConfig; d->dirtyFlagBibTeXQuoteComment = false; } else { /// Configuration file setting for BibTeXQuoteComment has an invalid value, using default as fallback setBibTeXQuoteComment(Preferences::defaultBibTeXQuoteComment); } } return d->cachedBibTeXQuoteComment; #else // HAVE_KF5 return defaultBibTeXQuoteComment; #endif // HAVE_KF5 } bool Preferences::setBibTeXQuoteComment(const Preferences::QuoteComment newValue) { #ifdef HAVE_KF5 if (!d->validateValueForBibTeXQuoteComment(newValue)) return false; d->dirtyFlagBibTeXQuoteComment = false; d->cachedBibTeXQuoteComment = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("FileExporterBibTeX")); const Preferences::QuoteComment valueFromConfig = static_cast(configGroup.readEntry(QStringLiteral("BibTeXQuoteComment"), static_cast(Preferences::defaultBibTeXQuoteComment))); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("BibTeXQuoteComment"), static_cast(newValue), KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QVector> Preferences::availableBibTeXKeywordCasings {{KBibTeX::cLowerCase, i18nc("Casing of strings", "lowercase")}, {KBibTeX::cInitialCapital, i18nc("Casing of strings", "Initial capital")}, {KBibTeX::cUpperCamelCase, i18nc("Casing of strings", "UpperCamelCase")}, {KBibTeX::cLowerCamelCase, i18nc("Casing of strings", "lowerCamelCase")}, {KBibTeX::cUpperCase, i18nc("Casing of strings", "UPPERCASE")}}; const KBibTeX::Casing Preferences::defaultBibTeXKeywordCasing = Preferences::availableBibTeXKeywordCasings.front().first; KBibTeX::Casing Preferences::bibTeXKeywordCasing() { #ifdef HAVE_KF5 if (d->dirtyFlagBibTeXKeywordCasing) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("FileExporterBibTeX")); const KBibTeX::Casing valueFromConfig = static_cast(configGroup.readEntry(QStringLiteral("BibTeXKeywordCasing"), static_cast(Preferences::defaultBibTeXKeywordCasing))); if (d->validateValueForBibTeXKeywordCasing(valueFromConfig)) { d->cachedBibTeXKeywordCasing = valueFromConfig; d->dirtyFlagBibTeXKeywordCasing = false; } else { /// Configuration file setting for BibTeXKeywordCasing has an invalid value, using default as fallback setBibTeXKeywordCasing(Preferences::defaultBibTeXKeywordCasing); } } return d->cachedBibTeXKeywordCasing; #else // HAVE_KF5 return defaultBibTeXKeywordCasing; #endif // HAVE_KF5 } bool Preferences::setBibTeXKeywordCasing(const KBibTeX::Casing newValue) { #ifdef HAVE_KF5 if (!d->validateValueForBibTeXKeywordCasing(newValue)) return false; d->dirtyFlagBibTeXKeywordCasing = false; d->cachedBibTeXKeywordCasing = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("FileExporterBibTeX")); const KBibTeX::Casing valueFromConfig = static_cast(configGroup.readEntry(QStringLiteral("BibTeXKeywordCasing"), static_cast(Preferences::defaultBibTeXKeywordCasing))); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("BibTeXKeywordCasing"), static_cast(newValue), KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const bool Preferences::defaultBibTeXProtectCasing = true; bool Preferences::bibTeXProtectCasing() { #ifdef HAVE_KF5 if (d->dirtyFlagBibTeXProtectCasing) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("FileExporterBibTeX")); const bool valueFromConfig = configGroup.readEntry(QStringLiteral("BibTeXProtectCasing"), Preferences::defaultBibTeXProtectCasing); if (d->validateValueForBibTeXProtectCasing(valueFromConfig)) { d->cachedBibTeXProtectCasing = valueFromConfig; d->dirtyFlagBibTeXProtectCasing = false; } else { /// Configuration file setting for BibTeXProtectCasing has an invalid value, using default as fallback setBibTeXProtectCasing(Preferences::defaultBibTeXProtectCasing); } } return d->cachedBibTeXProtectCasing; #else // HAVE_KF5 return defaultBibTeXProtectCasing; #endif // HAVE_KF5 } bool Preferences::setBibTeXProtectCasing(const bool newValue) { #ifdef HAVE_KF5 if (!d->validateValueForBibTeXProtectCasing(newValue)) return false; d->dirtyFlagBibTeXProtectCasing = false; d->cachedBibTeXProtectCasing = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("FileExporterBibTeX")); const bool valueFromConfig = configGroup.readEntry(QStringLiteral("BibTeXProtectCasing"), Preferences::defaultBibTeXProtectCasing); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("BibTeXProtectCasing"), newValue, KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QStringList Preferences::availableBibTeXListSeparators {QStringLiteral("; "), QStringLiteral(", ")}; const QString Preferences::defaultBibTeXListSeparator = Preferences::availableBibTeXListSeparators.front(); const QString &Preferences::bibTeXListSeparator() { #ifdef HAVE_KF5 if (d->dirtyFlagBibTeXListSeparator) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("FileExporterBibTeX")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("BibTeXListSeparator"), Preferences::defaultBibTeXListSeparator); if (d->validateValueForBibTeXListSeparator(valueFromConfig)) { d->cachedBibTeXListSeparator = valueFromConfig; d->dirtyFlagBibTeXListSeparator = false; } else { /// Configuration file setting for BibTeXListSeparator has an invalid value, using default as fallback setBibTeXListSeparator(Preferences::defaultBibTeXListSeparator); } } return d->cachedBibTeXListSeparator; #else // HAVE_KF5 return defaultBibTeXListSeparator; #endif // HAVE_KF5 } bool Preferences::setBibTeXListSeparator(const QString &newValue) { #ifdef HAVE_KF5 QString sanitizedNewValue = newValue; const QString lowerSanitizedNewValue = sanitizedNewValue.toLower(); for (const QString &knownBibTeXListSeparator : availableBibTeXListSeparators) if (knownBibTeXListSeparator.toLower() == lowerSanitizedNewValue) { sanitizedNewValue = knownBibTeXListSeparator; break; } if (!d->validateValueForBibTeXListSeparator(sanitizedNewValue)) return false; d->dirtyFlagBibTeXListSeparator = false; d->cachedBibTeXListSeparator = sanitizedNewValue; static KConfigGroup configGroup(d->config, QStringLiteral("FileExporterBibTeX")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("BibTeXListSeparator"), Preferences::defaultBibTeXListSeparator); if (valueFromConfig == sanitizedNewValue) return false; configGroup.writeEntry(QStringLiteral("BibTeXListSeparator"), sanitizedNewValue, KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QString Preferences::defaultLaTeXBabelLanguage = QStringLiteral("english"); const QString &Preferences::laTeXBabelLanguage() { #ifdef HAVE_KF5 if (d->dirtyFlagLaTeXBabelLanguage) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("FileExporterLaTeXbased")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("LaTeXBabelLanguage"), Preferences::defaultLaTeXBabelLanguage); if (d->validateValueForLaTeXBabelLanguage(valueFromConfig)) { d->cachedLaTeXBabelLanguage = valueFromConfig; d->dirtyFlagLaTeXBabelLanguage = false; } else { /// Configuration file setting for LaTeXBabelLanguage has an invalid value, using default as fallback setLaTeXBabelLanguage(Preferences::defaultLaTeXBabelLanguage); } } return d->cachedLaTeXBabelLanguage; #else // HAVE_KF5 return defaultLaTeXBabelLanguage; #endif // HAVE_KF5 } bool Preferences::setLaTeXBabelLanguage(const QString &newValue) { #ifdef HAVE_KF5 if (!d->validateValueForLaTeXBabelLanguage(newValue)) return false; d->dirtyFlagLaTeXBabelLanguage = false; d->cachedLaTeXBabelLanguage = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("FileExporterLaTeXbased")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("LaTeXBabelLanguage"), Preferences::defaultLaTeXBabelLanguage); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("LaTeXBabelLanguage"), newValue, KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QString Preferences::defaultBibTeXBibliographyStyle = QStringLiteral("plain"); const QString &Preferences::bibTeXBibliographyStyle() { #ifdef HAVE_KF5 if (d->dirtyFlagBibTeXBibliographyStyle) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("FileExporterLaTeXbased")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("BibTeXBibliographyStyle"), Preferences::defaultBibTeXBibliographyStyle); if (d->validateValueForBibTeXBibliographyStyle(valueFromConfig)) { d->cachedBibTeXBibliographyStyle = valueFromConfig; d->dirtyFlagBibTeXBibliographyStyle = false; } else { /// Configuration file setting for BibTeXBibliographyStyle has an invalid value, using default as fallback setBibTeXBibliographyStyle(Preferences::defaultBibTeXBibliographyStyle); } } return d->cachedBibTeXBibliographyStyle; #else // HAVE_KF5 return defaultBibTeXBibliographyStyle; #endif // HAVE_KF5 } bool Preferences::setBibTeXBibliographyStyle(const QString &newValue) { #ifdef HAVE_KF5 if (!d->validateValueForBibTeXBibliographyStyle(newValue)) return false; d->dirtyFlagBibTeXBibliographyStyle = false; d->cachedBibTeXBibliographyStyle = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("FileExporterLaTeXbased")); const QString valueFromConfig = configGroup.readEntry(QStringLiteral("BibTeXBibliographyStyle"), Preferences::defaultBibTeXBibliographyStyle); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("BibTeXBibliographyStyle"), newValue, KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QVector> Preferences::availableFileViewDoubleClickActions {{Preferences::ActionOpenEditor, i18nc("What to do if double-clicking on a file view item", "Open Editor")}, {Preferences::ActionViewDocument, i18nc("What to do if double-clicking on a file view item", "View Document")}}; const Preferences::FileViewDoubleClickAction Preferences::defaultFileViewDoubleClickAction = Preferences::availableFileViewDoubleClickActions.front().first; Preferences::FileViewDoubleClickAction Preferences::fileViewDoubleClickAction() { #ifdef HAVE_KF5 if (d->dirtyFlagFileViewDoubleClickAction) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("User Interface")); const Preferences::FileViewDoubleClickAction valueFromConfig = static_cast(configGroup.readEntry(QStringLiteral("FileViewDoubleClickAction"), static_cast(Preferences::defaultFileViewDoubleClickAction))); if (d->validateValueForFileViewDoubleClickAction(valueFromConfig)) { d->cachedFileViewDoubleClickAction = valueFromConfig; d->dirtyFlagFileViewDoubleClickAction = false; } else { /// Configuration file setting for FileViewDoubleClickAction has an invalid value, using default as fallback setFileViewDoubleClickAction(Preferences::defaultFileViewDoubleClickAction); } } return d->cachedFileViewDoubleClickAction; #else // HAVE_KF5 return defaultFileViewDoubleClickAction; #endif // HAVE_KF5 } bool Preferences::setFileViewDoubleClickAction(const Preferences::FileViewDoubleClickAction newValue) { #ifdef HAVE_KF5 if (!d->validateValueForFileViewDoubleClickAction(newValue)) return false; d->dirtyFlagFileViewDoubleClickAction = false; d->cachedFileViewDoubleClickAction = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("User Interface")); const Preferences::FileViewDoubleClickAction valueFromConfig = static_cast(configGroup.readEntry(QStringLiteral("FileViewDoubleClickAction"), static_cast(Preferences::defaultFileViewDoubleClickAction))); if (valueFromConfig == newValue) return false; configGroup.writeEntry(QStringLiteral("FileViewDoubleClickAction"), static_cast(newValue), KConfig::Notify); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } const QVector> Preferences::defaultColorCodes {{QColor(0xcc, 0x33, 0x00), i18nc("Color Labels", "Important")}, {QColor(0x00, 0x33, 0xff), i18nc("Color Labels", "Unread")}, {QColor(0x00, 0x99, 0x66), i18nc("Color Labels", "Read")}, {QColor(0xf0, 0xd0, 0x00), i18nc("Color Labels", "Watch")}}; const QVector> &Preferences::colorCodes() { #ifdef HAVE_KF5 if (d->dirtyFlagColorCodes) { d->config->reparseConfiguration(); static const KConfigGroup configGroup(d->config, QStringLiteral("Color Labels")); const QVector> valueFromConfig = d->readEntryColorCodes(configGroup, QStringLiteral("ColorCodes")); if (d->validateValueForColorCodes(valueFromConfig)) { d->cachedColorCodes = valueFromConfig; d->dirtyFlagColorCodes = false; } else { /// Configuration file setting for ColorCodes has an invalid value, using default as fallback setColorCodes(Preferences::defaultColorCodes); } } return d->cachedColorCodes; #else // HAVE_KF5 return defaultColorCodes; #endif // HAVE_KF5 } bool Preferences::setColorCodes(const QVector> &newValue) { #ifdef HAVE_KF5 if (!d->validateValueForColorCodes(newValue)) return false; d->dirtyFlagColorCodes = false; d->cachedColorCodes = newValue; static KConfigGroup configGroup(d->config, QStringLiteral("Color Labels")); const QVector> valueFromConfig = d->readEntryColorCodes(configGroup, QStringLiteral("ColorCodes")); if (valueFromConfig == newValue) return false; d->writeEntryColorCodes(configGroup, QStringLiteral("ColorCodes"), newValue); d->config->sync(); return true; #else // HAVE_KF5 Q_UNUSED(newValue); return true; #endif // HAVE_KF5 } diff --git a/src/config/preferences.h b/src/config/preferences.h index 50f42f71..91a60c61 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -1,207 +1,207 @@ /*************************************************************************** * 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 . * ***************************************************************************/ /// This file has been automatically generated using the script 'preferences-generator.py' /// based on configuration data from file 'preferences.json'. If there are any problems or /// bugs, you need to fix those two files and re-generated both 'preferences.h' and /// 'preferences.cpp'. Manual changes in this file will be overwritten the next time the /// script will be run. You have been warned. #ifndef KBIBTEX_CONFIG_PREFERENCES_H #define KBIBTEX_CONFIG_PREFERENCES_H #include #include -#include "kbibtex.h" +#include #ifdef HAVE_KF5 #include "kbibtexconfig_export.h" #endif // HAVE_KF5 class KBIBTEXCONFIG_EXPORT Preferences { public: static Preferences &instance(); ~Preferences(); enum BackupScope { NoBackup, LocalOnly, BothLocalAndRemote }; enum BibliographySystem { BibTeX = 0, BibLaTeX = 1 }; enum FileViewDoubleClickAction { ActionOpenEditor = 0, ActionViewDocument = 1 }; enum QuoteComment { qcNone = 0, qcCommand = 1, qcPercentSign = 2 }; /// *** BibliographySystem of type BibliographySystem *** static const BibliographySystem defaultBibliographySystem; static const QVector> availableBibliographySystems; BibliographySystem bibliographySystem(); bool setBibliographySystem(const BibliographySystem bibliographySystem); /// *** PersonNameFormat of type QString *** static const QString personNameFormatLastFirst; static const QString personNameFormatFirstLast; static const QString defaultPersonNameFormat; const QString &personNameFormat(); bool setPersonNameFormat(const QString &personNameFormat); /// *** CopyReferenceCommand of type QString *** static const QString defaultCopyReferenceCommand; static const QStringList availableCopyReferenceCommands; const QString ©ReferenceCommand(); bool setCopyReferenceCommand(const QString ©ReferenceCommand); /// *** PageSize of type QPageSize::PageSizeId *** static const QPageSize::PageSizeId defaultPageSize; static const QVector> availablePageSizes; QPageSize::PageSizeId pageSize(); bool setPageSize(const QPageSize::PageSizeId pageSize); /// *** BackupScope of type BackupScope *** static const BackupScope defaultBackupScope; static const QVector> availableBackupScopes; BackupScope backupScope(); bool setBackupScope(const BackupScope backupScope); /// *** NumberOfBackups of type int *** static const int defaultNumberOfBackups; int numberOfBackups(); bool setNumberOfBackups(const int numberOfBackups); /// *** IdSuggestionFormatStrings of type QStringList *** static const QStringList defaultIdSuggestionFormatStrings; const QStringList &idSuggestionFormatStrings(); bool setIdSuggestionFormatStrings(const QStringList &idSuggestionFormatStrings); /// *** ActiveIdSuggestionFormatString of type QString *** static const QString defaultActiveIdSuggestionFormatString; const QString &activeIdSuggestionFormatString(); bool setActiveIdSuggestionFormatString(const QString &activeIdSuggestionFormatString); /// *** LyXUseAutomaticPipeDetection of type bool *** static const bool defaultLyXUseAutomaticPipeDetection; bool lyXUseAutomaticPipeDetection(); bool setLyXUseAutomaticPipeDetection(const bool lyXUseAutomaticPipeDetection); /// *** LyXPipePath of type QString *** static const QString defaultLyXPipePath; const QString &lyXPipePath(); bool setLyXPipePath(const QString &lyXPipePath); /// *** BibTeXEncoding of type QString *** static const QString defaultBibTeXEncoding; static const QStringList availableBibTeXEncodings; const QString &bibTeXEncoding(); bool setBibTeXEncoding(const QString &bibTeXEncoding); /// *** BibTeXStringDelimiter of type QString *** static const QString defaultBibTeXStringDelimiter; static const QStringList availableBibTeXStringDelimiters; const QString &bibTeXStringDelimiter(); bool setBibTeXStringDelimiter(const QString &bibTeXStringDelimiter); /// *** BibTeXQuoteComment of type QuoteComment *** static const QuoteComment defaultBibTeXQuoteComment; static const QVector> availableBibTeXQuoteComments; QuoteComment bibTeXQuoteComment(); bool setBibTeXQuoteComment(const QuoteComment bibTeXQuoteComment); /// *** BibTeXKeywordCasing of type KBibTeX::Casing *** static const KBibTeX::Casing defaultBibTeXKeywordCasing; static const QVector> availableBibTeXKeywordCasings; KBibTeX::Casing bibTeXKeywordCasing(); bool setBibTeXKeywordCasing(const KBibTeX::Casing bibTeXKeywordCasing); /// *** BibTeXProtectCasing of type bool *** static const bool defaultBibTeXProtectCasing; bool bibTeXProtectCasing(); bool setBibTeXProtectCasing(const bool bibTeXProtectCasing); /// *** BibTeXListSeparator of type QString *** static const QString defaultBibTeXListSeparator; static const QStringList availableBibTeXListSeparators; const QString &bibTeXListSeparator(); bool setBibTeXListSeparator(const QString &bibTeXListSeparator); /// *** LaTeXBabelLanguage of type QString *** static const QString defaultLaTeXBabelLanguage; const QString &laTeXBabelLanguage(); bool setLaTeXBabelLanguage(const QString &laTeXBabelLanguage); /// *** BibTeXBibliographyStyle of type QString *** static const QString defaultBibTeXBibliographyStyle; const QString &bibTeXBibliographyStyle(); bool setBibTeXBibliographyStyle(const QString &bibTeXBibliographyStyle); /// *** FileViewDoubleClickAction of type FileViewDoubleClickAction *** static const FileViewDoubleClickAction defaultFileViewDoubleClickAction; static const QVector> availableFileViewDoubleClickActions; FileViewDoubleClickAction fileViewDoubleClickAction(); bool setFileViewDoubleClickAction(const FileViewDoubleClickAction fileViewDoubleClickAction); /// *** ColorCodes of type QVector> *** static const QVector> defaultColorCodes; const QVector> &colorCodes(); bool setColorCodes(const QVector> &colorCodes); private: Q_DISABLE_COPY(Preferences) explicit Preferences(); class Private; Private *const d; }; #endif // KBIBTEX_CONFIG_PREFERENCES_H diff --git a/src/data/CMakeLists.txt b/src/data/CMakeLists.txt index 57d162ed..8e92f0f8 100644 --- a/src/data/CMakeLists.txt +++ b/src/data/CMakeLists.txt @@ -1,66 +1,60 @@ # KBibTeXData library set( kbibtexdata_LIB_SRCS comment.cpp element.cpp entry.cpp file.cpp macro.cpp preamble.cpp value.cpp models/filemodel.cpp - ${CMAKE_SOURCE_DIR}/src/config/preferences.cpp logging_data.cpp ) set( kbibtexdata_HDRS comment.h element.h entry.h file.h macro.h preamble.h value.h models/filemodel.h ) if(UNITY_BUILD) enable_unity_build(kbibtexdata kbibtexdata_LIB_SRCS) endif(UNITY_BUILD) -include_directories( - ${CMAKE_SOURCE_DIR}/src/config - ${CMAKE_BINARY_DIR}/src/config -) - add_library( kbibtexdata SHARED ${kbibtexdata_LIB_SRCS} ) target_link_libraries( kbibtexdata Qt5::Core Qt5::Widgets KF5::I18n KF5::XmlGui kbibtexconfig ) set_target_properties( kbibtexdata PROPERTIES EXPORT_NAME "kbibtexdata" VERSION ${KBIBTEX_RELEASE_VERSION} SOVERSION ${KBIBTEX_SOVERSION} ) install( TARGETS kbibtexdata ${INSTALL_TARGETS_DEFAULT_ARGS} ) generate_export_header( kbibtexdata ) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 13fe6b54..0e6cce7d 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1,137 +1,134 @@ # KBibTeX GUI library set( kbibtexgui_LIB_SRCS field/fieldinput.cpp field/fieldlineedit.cpp field/fieldlistedit.cpp field/colorlabelwidget.cpp file/fileview.cpp file/filedelegate.cpp file/partwidget.cpp file/findduplicatesui.cpp file/clipboard.cpp file/basicfileview.cpp file/sortfilterfilemodel.cpp element/elementeditor.cpp element/elementwidgets.cpp element/findpdfui.cpp element/associatedfilesui.cpp widgets/menulineedit.cpp widgets/filesettingswidget.cpp widgets/filterbar.cpp widgets/radiobuttontreeview.cpp widgets/hidingtabwidget.cpp widgets/starrating.cpp widgets/rangewidget.cpp config/entrylayout.cpp preferences/kbibtexpreferencesdialog.cpp preferences/settingsgeneralwidget.cpp preferences/settingsglobalkeywordswidget.cpp preferences/settingscolorlabelwidget.cpp preferences/settingsuserinterfacewidget.cpp preferences/settingsfileexporterpdfpswidget.cpp preferences/settingsfileexporterwidget.cpp preferences/settingsabstractwidget.cpp preferences/settingsidsuggestionswidget.cpp preferences/settingsidsuggestionseditor.cpp guihelper.cpp italictextitemmodel.cpp valuelistmodel.cpp delayedexecutiontimer.cpp - ${CMAKE_SOURCE_DIR}/src/config/preferences.cpp logging_gui.cpp ) set( kbibtexgui_HDRS field/fieldinput.h field/colorlabelwidget.h field/fieldlineedit.h widgets/filterbar.h preferences/settingsuserinterfacewidget.h preferences/kbibtexpreferencesdialog.h preferences/settingsglobalkeywordswidget.h preferences/settingsfileexporterwidget.h preferences/settingsgeneralwidget.h preferences/settingsabstractwidget.h preferences/settingscolorlabelwidget.h preferences/settingsfileexporterpdfpswidget.h preferences/settingsidsuggestionswidget.h preferences/settingsidsuggestionseditor.h guihelper.h valuelistmodel.h italictextitemmodel.h delayedexecutiontimer.h file/findduplicatesui.h file/basicfileview.h file/clipboard.h file/fileview.h file/filedelegate.h file/sortfilterfilemodel.h file/partwidget.h element/findpdfui.h element/elementeditor.h element/associatedfilesui.h ) if(UNITY_BUILD) enable_unity_build(kbibtexgui kbibtexgui_LIB_SRCS) endif(UNITY_BUILD) include_directories( - ${CMAKE_SOURCE_DIR}/src/config - ${CMAKE_BINARY_DIR}/src/config ${CMAKE_SOURCE_DIR}/src/data ${CMAKE_BINARY_DIR}/src/data ${CMAKE_SOURCE_DIR}/src/io ${CMAKE_BINARY_DIR}/src/io ${CMAKE_SOURCE_DIR}/src/io/config ${CMAKE_SOURCE_DIR}/src/networking ${CMAKE_BINARY_DIR}/src/networking ${CMAKE_SOURCE_DIR}/src/processing ${CMAKE_BINARY_DIR}/src/processing ${CMAKE_SOURCE_DIR}/src/gui ${CMAKE_BINARY_DIR}/src/gui ${CMAKE_SOURCE_DIR}/src/gui/file ${CMAKE_SOURCE_DIR}/src/gui/dialogs ${CMAKE_SOURCE_DIR}/src/gui/element ${CMAKE_SOURCE_DIR}/src/gui/field ${CMAKE_SOURCE_DIR}/src/gui/widgets ${CMAKE_SOURCE_DIR}/src/gui/config ) add_library( kbibtexgui SHARED ${kbibtexgui_LIB_SRCS} ) target_link_libraries( kbibtexgui Qt5::Core KF5::IconThemes KF5::ItemViews KF5::Completion KF5::TextEditor kbibtexconfig kbibtexdata kbibtexio kbibtexnetworking kbibtexproc ) set_target_properties( kbibtexgui PROPERTIES EXPORT_NAME "kbibtexgui" VERSION ${KBIBTEX_RELEASE_VERSION} SOVERSION ${KBIBTEX_SOVERSION} ) install( TARGETS kbibtexgui ${INSTALL_TARGETS_DEFAULT_ARGS} ) generate_export_header( kbibtexgui ) diff --git a/src/io/CMakeLists.txt b/src/io/CMakeLists.txt index a752b44c..998c4e13 100644 --- a/src/io/CMakeLists.txt +++ b/src/io/CMakeLists.txt @@ -1,105 +1,102 @@ # KBibTeXIO library set( kbibtexio_LIB_SRCS encoder.cpp encoderlatex.cpp encoderxml.cpp fileexporterbibtex2html.cpp fileexporterbibtex.cpp fileexporterbibutils.cpp fileexporterbibtexoutput.cpp fileexporter.cpp fileexporterpdf.cpp fileexporterps.cpp fileexporterris.cpp fileexporterrtf.cpp fileexportertoolchain.cpp fileexporterxml.cpp fileexporterxslt.cpp fileimporterbibtex.cpp fileimporterbibutils.cpp fileimporter.cpp fileimporterpdf.cpp fileimporterris.cpp fileinfo.cpp textencoder.cpp bibutils.cpp xsltransform.cpp - ${CMAKE_SOURCE_DIR}/src/config/preferences.cpp logging_io.cpp ) set( kbibtexio_HDRS encoder.h encoderlatex.h encoderxml.h fileexporterbibtex2html.h fileexporterbibtex.h fileexporterbibutils.h fileexporterbibtexoutput.h fileexporter.h fileexporterpdf.h fileexporterps.h fileexporterris.h fileexporterrtf.h fileexportertoolchain.h fileexporterxml.h fileexporterxslt.h fileimporterbibtex.h fileimporterbibutils.h fileimporter.h fileimporterpdf.h fileimporterris.h fileinfo.h textencoder.h bibutils.h xsltransform.h ) if(UNITY_BUILD) enable_unity_build(kbibtexio kbibtexio_LIB_SRCS) endif(UNITY_BUILD) include_directories( - ${CMAKE_SOURCE_DIR}/src/config - ${CMAKE_BINARY_DIR}/src/config ${CMAKE_SOURCE_DIR}/src/data ${CMAKE_BINARY_DIR}/src/data ) add_library( kbibtexio SHARED ${kbibtexio_LIB_SRCS} ) target_link_libraries( kbibtexio Qt5::Core Qt5::Widgets Qt5::XmlPatterns Qt5::Concurrent KF5::I18n KF5::XmlGui Poppler::Qt5 ${ICU_LIBRARIES} kbibtexconfig kbibtexdata ) set_target_properties( kbibtexio PROPERTIES EXPORT_NAME "kbibtexio" VERSION ${KBIBTEX_RELEASE_VERSION} SOVERSION ${KBIBTEX_SOVERSION} ) install( TARGETS kbibtexio ${INSTALL_TARGETS_DEFAULT_ARGS} ) generate_export_header( kbibtexio ) diff --git a/src/networking/CMakeLists.txt b/src/networking/CMakeLists.txt index 1ff87135..5ba120b6 100644 --- a/src/networking/CMakeLists.txt +++ b/src/networking/CMakeLists.txt @@ -1,136 +1,133 @@ # Network library set( kbibtexnetworking_LIB_SRCS onlinesearch/onlinesearchabstract.cpp onlinesearch/onlinesearchbibsonomy.cpp onlinesearch/onlinesearcharxiv.cpp onlinesearch/onlinesearchsciencedirect.cpp onlinesearch/onlinesearchgooglescholar.cpp onlinesearch/onlinesearchieeexplore.cpp onlinesearch/onlinesearchpubmed.cpp onlinesearch/onlinesearchacmportal.cpp onlinesearch/onlinesearchspringerlink.cpp onlinesearch/onlinesearchjstor.cpp onlinesearch/onlinesearchmathscinet.cpp onlinesearch/onlinesearchmrlookup.cpp onlinesearch/onlinesearchinspirehep.cpp onlinesearch/onlinesearchcernds.cpp onlinesearch/onlinesearchingentaconnect.cpp onlinesearch/onlinesearchsimplebibtexdownload.cpp onlinesearch/onlinesearchgeneral.cpp onlinesearch/onlinesearchsoanasaads.cpp # onlinesearch/onlinesearchisbndb.cpp # disabled as provider switched to a paid model on 2017-12-26 onlinesearch/onlinesearchideasrepec.cpp onlinesearch/onlinesearchdoi.cpp onlinesearch/onlinesearchbiorxiv.cpp onlinesearch/onlinesearchsemanticscholar.cpp zotero/api.cpp zotero/collectionmodel.cpp zotero/collection.cpp zotero/items.cpp zotero/groups.cpp zotero/oauthwizard.cpp zotero/tags.cpp zotero/tagmodel.cpp associatedfiles.cpp findpdf.cpp internalnetworkaccessmanager.cpp - ${CMAKE_SOURCE_DIR}/src/config/preferences.cpp logging_networking.cpp ) set( kbibtexnetworking_HDRS onlinesearch/onlinesearchgeneral.h onlinesearch/onlinesearchsciencedirect.h onlinesearch/onlinesearchabstract.h onlinesearch/onlinesearchacmportal.h onlinesearch/onlinesearchbibsonomy.h onlinesearch/onlinesearchgooglescholar.h onlinesearch/onlinesearchspringerlink.h onlinesearch/onlinesearchjstor.h onlinesearch/onlinesearchieeexplore.h onlinesearch/onlinesearcharxiv.h onlinesearch/onlinesearchpubmed.h onlinesearch/onlinesearchingentaconnect.h onlinesearch/onlinesearchsimplebibtexdownload.h onlinesearch/onlinesearchsoanasaads.h onlinesearch/onlinesearchmathscinet.h onlinesearch/onlinesearchmrlookup.h onlinesearch/onlinesearchinspirehep.h onlinesearch/onlinesearchcernds.h onlinesearch/onlinesearchisbndb.h onlinesearch/onlinesearchideasrepec.h onlinesearch/onlinesearchdoi.h onlinesearch/onlinesearchbiorxiv.h onlinesearch/onlinesearchsemanticscholar.h zotero/api.h zotero/collectionmodel.h zotero/collection.h zotero/items.h zotero/groups.h zotero/oauthwizard.h zotero/tags.h zotero/tagmodel.h associatedfiles.h findpdf.h internalnetworkaccessmanager.h ) if(UNITY_BUILD) enable_unity_build(kbibtexnetworking kbibtexnetworking_LIB_SRCS) endif(UNITY_BUILD) include_directories( - ${CMAKE_BINARY_DIR}/src/config - ${CMAKE_SOURCE_DIR}/src/config ${CMAKE_BINARY_DIR}/src/data ${CMAKE_SOURCE_DIR}/src/data ${CMAKE_BINARY_DIR}/src/io ${CMAKE_SOURCE_DIR}/src/io ${CMAKE_SOURCE_DIR}/src/networking/onlinesearch ${CMAKE_SOURCE_DIR}/src/networking ) add_library( kbibtexnetworking SHARED ${kbibtexnetworking_LIB_SRCS} ) target_link_libraries( kbibtexnetworking Qt5::Core Qt5::Widgets Qt5::Network Qt5::NetworkAuth KF5::I18n KF5::XmlGui KF5::Completion KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets KF5::KIONTLM KF5::Wallet kbibtexconfig kbibtexdata kbibtexio Poppler::Qt5 ) set_target_properties( kbibtexnetworking PROPERTIES EXPORT_NAME "kbibtexnetworking" VERSION ${KBIBTEX_RELEASE_VERSION} SOVERSION ${KBIBTEX_SOVERSION} ) install( TARGETS kbibtexnetworking ${INSTALL_TARGETS_DEFAULT_ARGS} ) generate_export_header( kbibtexnetworking ) diff --git a/src/parts/CMakeLists.txt b/src/parts/CMakeLists.txt index 469fb7e1..061c7646 100644 --- a/src/parts/CMakeLists.txt +++ b/src/parts/CMakeLists.txt @@ -1,87 +1,87 @@ # KBibTeX KPart set( kbibtexpart_SRCS part.cpp partfactory.cpp browserextension.cpp - ${CMAKE_SOURCE_DIR}/src/config/preferences.cpp logging_parts.cpp ) if(UNITY_BUILD) enable_unity_build(kbibtexpart kbibtexpart_SRCS) endif(UNITY_BUILD) include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/src/config ${CMAKE_SOURCE_DIR}/src/data ${CMAKE_BINARY_DIR}/src/io ${CMAKE_SOURCE_DIR}/src/io ${CMAKE_SOURCE_DIR}/src/gui ${CMAKE_SOURCE_DIR}/src/gui/config ${CMAKE_SOURCE_DIR}/src/gui/element ${CMAKE_SOURCE_DIR}/src/gui/preferences ${CMAKE_SOURCE_DIR}/src/gui/widgets ${CMAKE_SOURCE_DIR}/src/gui/file ${CMAKE_SOURCE_DIR}/src/processing ${CMAKE_SOURCE_DIR}/src/networking ) # Creates kbibtex-git-info.h containing information about the source code's Git revision # (if source directory is a Git clone) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_SOURCE_DIR} -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_SOURCE_DIR}/src/getgit.cmake ) set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h PROPERTIES GENERATED 1 HEADER_FILE_ONLY 1 SKIP_AUTOMOC ON SKIP_AUTOUIC ON SKIP_AUTOGEN ON ) add_library( kbibtexpart MODULE ${kbibtexpart_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h ) target_link_libraries( kbibtexpart KF5::Parts + KF5::CoreAddons + KF5::ItemViews kbibtexconfig kbibtexdata kbibtexio kbibtexgui kbibtexproc ) install( TARGETS kbibtexpart DESTINATION ${KDE_INSTALL_PLUGINDIR} ) kcoreaddons_desktop_to_json(kbibtexpart kbibtexpart.desktop SERVICE_TYPES kpart.desktop) install( FILES kbibtexpart.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) install( FILES kbibtexpartui.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/kbibtexpart ) diff --git a/src/processing/CMakeLists.txt b/src/processing/CMakeLists.txt index d87e90b7..7a8e7ab3 100644 --- a/src/processing/CMakeLists.txt +++ b/src/processing/CMakeLists.txt @@ -1,68 +1,65 @@ # KBibTeX Processing library set( kbibtexproc_LIB_SRCS findduplicates.cpp idsuggestions.cpp lyx.cpp checkbibtex.cpp bibliographyservice.cpp journalabbreviations.cpp - ${CMAKE_SOURCE_DIR}/src/config/preferences.cpp logging_processing.cpp ) set( kbibtexproc_HDRS findduplicates.h idsuggestions.h lyx.h checkbibtex.h bibliographyservice.h journalabbreviations.h ) if(UNITY_BUILD) enable_unity_build(kbibtexproc kbibtexproc_LIB_SRCS) endif(UNITY_BUILD) include_directories( - ${CMAKE_BINARY_DIR}/src/config - ${CMAKE_SOURCE_DIR}/src/config ${CMAKE_BINARY_DIR}/src/data ${CMAKE_SOURCE_DIR}/src/data ${CMAKE_BINARY_DIR}/src/io ${CMAKE_SOURCE_DIR}/src/io ${CMAKE_BINARY_DIR}/src/gui ${CMAKE_SOURCE_DIR}/src/gui ) add_library( kbibtexproc SHARED ${kbibtexproc_LIB_SRCS} ) target_link_libraries( kbibtexproc Qt5::Core KF5::Parts kbibtexconfig kbibtexdata kbibtexio ) set_target_properties( kbibtexproc PROPERTIES EXPORT_NAME "kbibtexproc" VERSION ${KBIBTEX_RELEASE_VERSION} SOVERSION ${KBIBTEX_SOVERSION} ) install( TARGETS kbibtexproc ${INSTALL_TARGETS_DEFAULT_ARGS} ) generate_export_header( kbibtexproc ) diff --git a/src/program/CMakeLists.txt b/src/program/CMakeLists.txt index 5792abf1..98d8db9c 100644 --- a/src/program/CMakeLists.txt +++ b/src/program/CMakeLists.txt @@ -1,155 +1,153 @@ # KBibTeX main program project( kbibtexprogram ) set( kbibtex_SRCS program.cpp mainwindow.cpp documentlist.cpp mdiwidget.cpp docklets/statistics.cpp docklets/referencepreview.cpp docklets/documentpreview.cpp docklets/valuelist.cpp docklets/searchform.cpp docklets/searchresults.cpp docklets/elementform.cpp docklets/filesettings.cpp docklets/zoterobrowser.cpp openfileinfo.cpp logging_program.cpp ) if(UNITY_BUILD AND NOT WIN32) # FIXME: Unity build of programs breaks on Windows enable_unity_build(kbibtex kbibtex_SRCS) endif(UNITY_BUILD AND NOT WIN32) include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/src/config - ${CMAKE_BINARY_DIR}/src/config ${CMAKE_SOURCE_DIR}/src/data ${CMAKE_BINARY_DIR}/src/data ${CMAKE_SOURCE_DIR}/src/processing ${CMAKE_BINARY_DIR}/src/processing ${CMAKE_SOURCE_DIR}/src/io ${CMAKE_BINARY_DIR}/src/io ${CMAKE_SOURCE_DIR}/src/io/config ${CMAKE_SOURCE_DIR}/src/networking ${CMAKE_BINARY_DIR}/src/networking ${CMAKE_SOURCE_DIR}/src/networking/onlinesearch ${CMAKE_SOURCE_DIR}/src/gui ${CMAKE_BINARY_DIR}/src/gui ${CMAKE_SOURCE_DIR}/src/gui/widgets ${CMAKE_SOURCE_DIR}/src/gui/file ${CMAKE_SOURCE_DIR}/src/gui/element ${CMAKE_SOURCE_DIR}/src/program/docklets ) ecm_add_app_icon( kbibtex_SRCS ICONS ${CMAKE_SOURCE_DIR}/icons/128-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/16-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/22-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/32-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/48-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/64-apps-kbibtex.png ) # Creates kbibtex-git-info.h containing information about the source code's Git revision # (if source directory is a Git clone) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_SOURCE_DIR} -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_SOURCE_DIR}/src/getgit.cmake ) set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h PROPERTIES GENERATED 1 HEADER_FILE_ONLY 1 SKIP_AUTOMOC ON SKIP_AUTOUIC ON SKIP_AUTOGEN ON ) add_executable( kbibtex ${kbibtex_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h ) target_link_libraries( kbibtex Qt5::Core Qt5::Widgets KF5::CoreAddons KF5::I18n KF5::ConfigCore KF5::Service KF5::Parts KF5::IconThemes KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets KF5::KIONTLM KF5::Crash kbibtexio kbibtexgui kbibtexnetworking ) if(Qt5WebEngineWidgets_FOUND) target_link_libraries( kbibtex Qt5::WebEngineWidgets ) else(Qt5WebEngineWidgets_FOUND) if(Qt5WebKitWidgets_FOUND) target_link_libraries( kbibtex Qt5::WebKitWidgets ) endif(Qt5WebKitWidgets_FOUND) endif(Qt5WebEngineWidgets_FOUND) install( TARGETS kbibtex ${INSTALL_TARGETS_DEFAULT_ARGS} ) install( PROGRAMS org.kde.kbibtex.desktop DESTINATION ${KDE_INSTALL_APPDIR} ) install( FILES kbibtexui.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/kbibtex ) install( FILES org.kde.kbibtex.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR} ) ecm_install_icons( ICONS ${CMAKE_SOURCE_DIR}/icons/128-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/16-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/22-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/32-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/48-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/64-apps-kbibtex.png DESTINATION ${KDE_INSTALL_ICONDIR} ) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 04eae882..9d8459eb 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -1,185 +1,183 @@ # KBibTeX test program project( test ) include( AddFileDependencies ) include( ECMMarkAsTest ) configure_file(test-config.h.in test-config.h @ONLY) include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/src/config ${CMAKE_SOURCE_DIR}/src/data ${CMAKE_SOURCE_DIR}/src/io ${CMAKE_SOURCE_DIR}/src/gui ${CMAKE_SOURCE_DIR}/src/gui/config ${CMAKE_SOURCE_DIR}/src/gui/bibtex ${CMAKE_SOURCE_DIR}/src/gui/element ${CMAKE_SOURCE_DIR}/src/gui/widgets ${CMAKE_SOURCE_DIR}/src/networking ${CMAKE_SOURCE_DIR}/src/networking/onlinesearch ${CMAKE_SOURCE_DIR}/src/processing ) set( kbibtextest_SRCS main.cpp kbibtextest.cpp logging_test.cpp ) set( kbibtexfilestest_SRCS kbibtexfilestest.cpp kbibtexfilestest-rawdata.h ) set( kbibtexnetworkingtest_SRCS kbibtexnetworkingtest.cpp ) set( kbibtexiotest_SRCS kbibtexiotest.cpp - ${CMAKE_SOURCE_DIR}/src/config/preferences.cpp ) set( kbibtexdatatest_SRCS kbibtexdatatest.cpp ) if(UNITY_BUILD AND NOT WIN32) # FIXME: Unity build of programs breaks on Windows enable_unity_build(kbibtextest kbibtextest_SRCS) enable_unity_build(kbibtexfilestest kbibtexfilestest_SRCS) enable_unity_build(kbibtexnetworkingtest kbibtexnetworkingtest_SRCS) enable_unity_build(kbibtexiotest kbibtexiotest_SRCS) enable_unity_build(kbibtexdatatest kbibtexdatatest_SRCS) endif(UNITY_BUILD AND NOT WIN32) # Creates kbibtex-git-info.h containing information about the source code's Git revision # (if source directory is a Git clone) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_SOURCE_DIR} -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_SOURCE_DIR}/src/getgit.cmake ) set_source_files_properties( ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h PROPERTIES GENERATED 1 HEADER_FILE_ONLY 1 SKIP_AUTOMOC ON SKIP_AUTOUIC ON SKIP_AUTOGEN ON ) add_executable( kbibtextest ${kbibtextest_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h ) add_executable( kbibtexfilestest ${kbibtexfilestest_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h ) add_executable( kbibtexnetworkingtest ${kbibtexnetworkingtest_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h ) add_executable( kbibtexiotest ${kbibtexiotest_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h ) add_executable( kbibtexdatatest ${kbibtexdatatest_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h ) target_link_libraries( kbibtextest Qt5::Core KF5::KIOCore kbibtexconfig kbibtexdata kbibtexio kbibtexproc kbibtexgui kbibtexnetworking ) target_link_libraries( kbibtexfilestest Qt5::Test kbibtexdata kbibtexio ) target_link_libraries( kbibtexnetworkingtest Qt5::Test kbibtexnetworking ) target_link_libraries( kbibtexiotest Qt5::Test kbibtexio ) target_link_libraries( kbibtexdatatest Qt5::Test kbibtexdata ) ecm_mark_as_test( kbibtexfilestest kbibtexnetworkingtest kbibtexiotest kbibtexdatatest ) add_test( NAME kbibtexfilestest COMMAND kbibtexfilestest ) add_test( NAME kbibtexnetworkingtest COMMAND kbibtexnetworkingtest ) add_test( NAME kbibtexiotest COMMAND kbibtexiotest ) add_test( NAME kbibtexdatatest COMMAND kbibtexdatatest )