diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt index f8eba3b3..edb8c18f 100644 --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -1,53 +1,53 @@ # KBibTeXConfig library set( kbibtexconfig_LIB_SRCS notificationhub.cpp bibtexentries.cpp bibtexfields.cpp - ${CMAKE_SOURCE_DIR}/src/global/preferences.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) include_directories( ${CMAKE_SOURCE_DIR}/src/global ) add_library( kbibtexconfig SHARED ${kbibtexconfig_LIB_SRCS} ) target_link_libraries( kbibtexconfig Qt5::Core KF5::I18n KF5::XmlGui ) set_target_properties( kbibtexconfig PROPERTIES EXPORT_NAME "kbibtexconfig" VERSION ${KBIBTEX_RELEASE_VERSION} SOVERSION ${KBIBTEX_SOVERSION} ) install( TARGETS kbibtexconfig ${INSTALL_TARGETS_DEFAULT_ARGS} ) generate_export_header( kbibtexconfig ) diff --git a/src/global/preferences-generator.py b/src/config/preferences-generator.py similarity index 95% rename from src/global/preferences-generator.py rename to src/config/preferences-generator.py index 29124e5b..df7fd9cc 100644 --- a/src/global/preferences-generator.py +++ b/src/config/preferences-generator.py @@ -1,484 +1,498 @@ ########################################################################### # Copyright (C) 2019 by Thomas Fischer # # # # This script 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 script 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 script; if not, see . # ########################################################################### import sys import json import datetime def print_copyright_header(outputdevice=sys.stdout): """Print the default copyright statement to the output device.""" print("""/*************************************************************************** * Copyright (C) 2004-{year} 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 . * ***************************************************************************/""" .format(year=datetime.date.today().year), file=outputdevice) print(file=outputdevice) print("""/// 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.""", file=outputdevice) print(file=outputdevice) def needsReference(type): """Check if given Qt/C++ data type should be passed by reference rather than by value.""" return type in ["QString", "QStringList"] \ or type.startswith(('QPair<', 'QVector<', 'QSet<', 'QList<', 'QLinkedList<', 'QMap<', 'QVector<', 'QHash<')) def print_header(headerincludes, implementationincludes, enums, settings, outputdevice=sys.stdout): """Print the header file for the Preferences ('preferences.h').""" print_copyright_header(outputdevice) # Include guard definition - print("#ifndef KBIBTEX_GLOBAL_PREFERENCES_H", file=outputdevice) - print("#define KBIBTEX_GLOBAL_PREFERENCES_H", file=outputdevice) + print("#ifndef KBIBTEX_CONFIG_PREFERENCES_H", file=outputdevice) + print("#define KBIBTEX_CONFIG_PREFERENCES_H", file=outputdevice) print(file=outputdevice) # Include other headers as necessary for includeline in headerincludes: - print("#include", includeline, file=outputdevice) + if len(includeline) == 0: + print(file=outputdevice) + elif includeline[0] == '#': + print(includeline, file=outputdevice) + else: + print("#include", includeline, file=outputdevice) if headerincludes: print(file=outputdevice) + print('#ifdef HAVE_KF5', file=outputdevice) + print('#include "kbibtexconfig_export.h"', file=outputdevice) + print('#endif // HAVE_KF5', file=outputdevice) + print(file=outputdevice) - print("class Preferences {", file=outputdevice) + print("class KBIBTEXCONFIG_EXPORT Preferences {", file=outputdevice) print("public:", file=outputdevice) print(" static Preferences &instance();", file=outputdevice) print(" ~Preferences();", file=outputdevice) print(file=outputdevice) for enum in sorted(enums): print(" enum " + enum + " {", end="", file=outputdevice) first = True for enumvaluepair in enums[enum]: if not first: print(",", end="", file=outputdevice) print(" ", end="", file=outputdevice) if isinstance(enumvaluepair, list): print(enumvaluepair[0], end="", file=outputdevice) if len(enumvaluepair) >= 2 and enumvaluepair[1] != None: print( " = " + str(enumvaluepair[1]), end="", file=outputdevice) elif isinstance(enumvaluepair, str): print(enumvaluepair, end="", file=outputdevice) first = False print(" };", file=outputdevice) if enums: print(file=outputdevice) for setting in settings: stem = setting['stem'] type = setting['type'] lowercasestart = stem[0].lower() + stem[1:] print(file=outputdevice) print(" /// ***", stem, "of type", type, "***", file=outputdevice) print(file=outputdevice) if 'predefined' in setting: for predefined in setting['predefined']: print(" static const " + type + " " + lowercasestart + predefined[0] + ";", file=outputdevice) print(" static const " + type + " default" + stem + ";", file=outputdevice) if 'availabletype' in setting: print(" static const " + setting['availabletype'] + " available" + stem + "s;", file=outputdevice) print((" const " if needsReference(type) else " ") + type + (" &" if needsReference(type) else " ") + lowercasestart + "();", file=outputdevice) print(" bool set" + stem + "(const " + type + (" &" if needsReference(type) else " ") + lowercasestart + ");", file=outputdevice) print("", file=outputdevice) print("private:", file=outputdevice) print(" Q_DISABLE_COPY(Preferences)", file=outputdevice) print(file=outputdevice) print(" explicit Preferences();", file=outputdevice) print(file=outputdevice) print(" class Private;", file=outputdevice) print(" Private *const d;", file=outputdevice) print("};", file=outputdevice) print(file=outputdevice) - print("#endif // KBIBTEX_GLOBAL_PREFERENCES_H", file=outputdevice) + print("#endif // KBIBTEX_CONFIG_PREFERENCES_H", file=outputdevice) def print_implementation(headerincludes, implementationincludes, enums, settings, outputdevice=sys.stdout): """Print the implementatiom file for the Preferences ('preferences.cpp').""" print_copyright_header(outputdevice) # Include headers that will always be necessary - print('#include "preferences.h"', file=outputdevice) + print('#include ', file=outputdevice) print(file=outputdevice) print('#include ', file=outputdevice) print('#ifdef HAVE_KF5', file=outputdevice) print('#include ', file=outputdevice) print('#include ', file=outputdevice) print('#include ', file=outputdevice) print('#include ', file=outputdevice) print('#else // HAVE_KF5', file=outputdevice) print('#define i18n(text) QStringLiteral(text)', file=outputdevice) print('#define i18nc(comment,text) QStringLiteral(text)', file=outputdevice) print('#endif // HAVE_KF5', file=outputdevice) print(file=outputdevice) print('#ifdef HAVE_KF5', file=outputdevice) - print('#include "notificationhub.h"', file=outputdevice) + print('#include ', file=outputdevice) print('#endif // HAVE_KF5', file=outputdevice) print(file=outputdevice) # Include other headers as necessary for includeline in implementationincludes: - print("#include", includeline, file=outputdevice) + if len(includeline) == 0: + print(file=outputdevice) + elif includeline[0] == '#': + print(includeline, file=outputdevice) + else: + print("#include", includeline, file=outputdevice) if implementationincludes: print(file=outputdevice) print('class Preferences::Private', file=outputdevice) print('{', file=outputdevice) print('public:', file=outputdevice) print('#ifdef HAVE_KF5', file=outputdevice) print(' KSharedConfigPtr config;', file=outputdevice) print(' KConfigWatcher::Ptr watcher;', file=outputdevice) print(file=outputdevice) for setting in settings: stem = setting['stem'] type = setting['type'] if type in enums: type = "Preferences::" + type print(' bool dirtyFlag' + stem + ';', file=outputdevice) print(' ' + type + ' cached' + stem + ';', file=outputdevice) print('#endif // HAVE_KF5', file=outputdevice) # Constructor for Preferences::Private print(file=outputdevice) print(' Private(Preferences *)', file=outputdevice) print(' {', file=outputdevice) print('#ifdef HAVE_KF5', file=outputdevice) print(' config = KSharedConfig::openConfig(QStringLiteral("kbibtexrc"));', file=outputdevice) print(' watcher = KConfigWatcher::create(config);', file=outputdevice) for setting in settings: stem = setting['stem'] print(' dirtyFlag' + stem + ' = true;', file=outputdevice) print(' cached' + stem + ' = Preferences::default' + stem + ';', file=outputdevice) print('#endif // HAVE_KF5', file=outputdevice) print(' }', file=outputdevice) print(file=outputdevice) print('#ifdef HAVE_KF5', file=outputdevice) first = True for setting in settings: stem = setting['stem'] type = setting['type'] if type in enums: type = "Preferences::" + type if first: first = False else: print(file=outputdevice) print(' inline bool validateValueFor' + stem + '(const ' + type + (" &" if needsReference(type) else " ") + "valueToBeChecked) {", file=outputdevice) if 'validationcode' in setting: if isinstance(setting['validationcode'], list): for line in setting['validationcode']: print(' ' + line, file=outputdevice) if not setting['validationcode'][-1].startswith("return "): print(' return false;', file=outputdevice) elif isinstance(setting['validationcode'], str): print(' ' + setting['validationcode'], file=outputdevice) elif 'availabletype' in setting and setting['availabletype'].startswith('QVectorfirst == valueToBeChecked) return true;', file=outputdevice) print(' return false;', file=outputdevice) elif 'availabletype' in setting and setting['availabletype'] == "QStringList": print(' return Preferences::available' + stem + 's.contains(valueToBeChecked);', file=outputdevice) else: print(' Q_UNUSED(valueToBeChecked)', file=outputdevice) print(' return true;', file=outputdevice) print(' }', file=outputdevice) if 'readEntry' in setting: print(file=outputdevice) print(' ' + type + ' readEntry' + stem + '(const KConfigGroup &configGroup, const QString &key) const', file=outputdevice) print(' {', file=outputdevice) if isinstance(setting['readEntry'], list): for line in setting['readEntry']: print(' ' + line, file=outputdevice) elif isinstance(setting['readEntry'], str): print(' ' + setting['readEntry'], file=outputdevice) print(' }', file=outputdevice) if 'writeEntry' in setting: print(file=outputdevice) print(' void writeEntry' + stem + '(KConfigGroup &configGroup, const QString &key, const ' + type + (" &" if needsReference(type) else " ") + 'valueToBeWritten)', file=outputdevice) print(' {', file=outputdevice) if isinstance(setting['writeEntry'], list): for line in setting['writeEntry']: print(' ' + line, file=outputdevice) elif isinstance(setting['writeEntry'], str): print(' ' + setting['writeEntry'], file=outputdevice) print(' }', file=outputdevice) print('#endif // HAVE_KF5', file=outputdevice) print('};', file=outputdevice) # Singleton function Preferences::instance() print(file=outputdevice) print('Preferences &Preferences::instance()', file=outputdevice) print('{', file=outputdevice) print(' static Preferences singleton;', file=outputdevice) print(' return singleton;', file=outputdevice) print('}', file=outputdevice) print(file=outputdevice) # Constructor for class Preferences print('Preferences::Preferences()', file=outputdevice) print(' : d(new Preferences::Private(this))', file=outputdevice) print('{', file=outputdevice) print('#ifdef HAVE_KF5', file=outputdevice) print( ' QObject::connect(d->watcher.data(), &KConfigWatcher::configChanged, QCoreApplication::instance(), [this](const KConfigGroup &group, const QByteArrayList &names) {', file=outputdevice) print(' QSet eventsToPublish;', file=outputdevice) for setting in settings: stem = setting['stem'] configgroup = setting['configgroup'] if 'configgroup' in setting else 'General' print(' if (group.name() == QStringLiteral("' + configgroup + '") && names.contains("' + stem + '")) {', file=outputdevice) print(' /// Configuration setting ' + stem + ' got changed by another Preferences instance";', file=outputdevice) print(' d->dirtyFlag' + stem + ' = true;', file=outputdevice) if 'notificationevent' in setting: print(' eventsToPublish.insert(' + setting['notificationevent'] + ');', file=outputdevice) print(' }', file=outputdevice) print(file=outputdevice) print(' for (const int eventId : eventsToPublish)', file=outputdevice) print(' NotificationHub::publishEvent(eventId);', file=outputdevice) print(' });', file=outputdevice) print('#endif // HAVE_KF5', file=outputdevice) print('}', file=outputdevice) print(file=outputdevice) # Destructor for Preferences print('Preferences::~Preferences()', file=outputdevice) print('{', file=outputdevice) print(' delete d;', file=outputdevice) print('}', file=outputdevice) for setting in settings: stem = setting['stem'] configgroup = setting['configgroup'] if 'configgroup' in setting else 'General' type = type = setting['type'] typeInConfig = "int" if type in enums.keys() else type if 'podtype' in setting: typeInConfig = setting['podtype'] if type in enums: type = "Preferences::" + type lowercasestart = stem[0].lower() + stem[1:] print(file=outputdevice) if 'predefined' in setting: for predefined in setting['predefined']: print('const ' + type + ' Preferences::' + lowercasestart + predefined[0] + " = " + predefined[1] + ";", file=outputdevice) if 'available' in setting: available = setting['available'] print('const ' + setting['availabletype'] + ' Preferences::available' + stem + ('s ' if available.startswith("{") else "s = ") + available + ";", file=outputdevice) default = "nullptr" if 'default' in setting: default = setting['default'] if 'predefined' in setting and default in [pair[0] for pair in setting['predefined']]: default = "Preferences::" + lowercasestart + default elif 'availabletype' in setting: if setting['availabletype'].startswith("QVectordirtyFlag' + stem + ') {', file=outputdevice) print(' d->config->reparseConfiguration();', file=outputdevice) print(' static const KConfigGroup configGroup(d->config, QStringLiteral("' + configgroup + '"));', file=outputdevice) print(' const ' + type + ' valueFromConfig = ', end="", file=outputdevice) if 'readEntry' in setting: print('d->readEntry' + stem + '(configGroup, QStringLiteral("' + stem + '"));', file=outputdevice) else: if typeInConfig != type: print('static_cast<' + type + '>(', end="", file=outputdevice) print('configGroup.readEntry(QStringLiteral("' + stem + '"), ', end="", file=outputdevice) if typeInConfig != type: print('static_cast<' + typeInConfig + '>(', end="", file=outputdevice) print('Preferences::default' + stem, end="", file=outputdevice) if typeInConfig != type: print(')', end="", file=outputdevice) print(')', end="", file=outputdevice) if typeInConfig != type: print(')', end="", file=outputdevice) print(';', file=outputdevice) print(' if (d->validateValueFor' + stem + '(valueFromConfig)) {', file=outputdevice) print(' d->cached' + stem + ' = valueFromConfig;', file=outputdevice) print(' d->dirtyFlag' + stem + ' = false;', file=outputdevice) print(' } else {', file=outputdevice) print(' /// Configuration file setting for ' + stem + ' has an invalid value, using default as fallback', file=outputdevice) print(' set' + stem + '(Preferences::default' + stem + ');', file=outputdevice) print(' }', file=outputdevice) print(' }', file=outputdevice) print(' return d->cached' + stem + ";", file=outputdevice) print('#else // HAVE_KF5', file=outputdevice) print(' return default' + stem + ";", file=outputdevice) print('#endif // HAVE_KF5', file=outputdevice) print("}", file=outputdevice) print(file=outputdevice) print("bool Preferences::set" + stem + '(const ' + type + (" &" if needsReference(type) else " ") + 'newValue)', file=outputdevice) print("{", file=outputdevice) print('#ifdef HAVE_KF5', file=outputdevice) if 'sanitizecode' in setting: newValueVariable = 'sanitizedNewValue' if isinstance(setting['sanitizecode'], str): print(' ' + setting['sanitizecode'], file=outputdevice) elif isinstance(setting['sanitizecode'], list): for line in setting['sanitizecode']: print(' ' + line, file=outputdevice) else: newValueVariable = 'newValue' elif 'availabletype' in setting and setting['availabletype'] == 'QStringList': newValueVariable = 'sanitizedNewValue' print(' ' + type + ' sanitizedNewValue = newValue;', file=outputdevice) print(' const ' + type + ' lowerSanitizedNewValue = sanitizedNewValue.toLower();', file=outputdevice) print(' for (const QString &known' + stem + ' : available' + stem + 's)', file=outputdevice) print(' if (known' + stem + '.toLower() == lowerSanitizedNewValue) {', file=outputdevice) print(' sanitizedNewValue = known' + stem + ';', file=outputdevice) print(' break;', file=outputdevice) print(' }', file=outputdevice) else: newValueVariable = 'newValue' print(' if (!d->validateValueFor' + stem + '(' + newValueVariable + ')) return false;', file=outputdevice) print(' d->dirtyFlag' + stem + ' = false;', file=outputdevice) print(' d->cached' + stem + ' = ' + newValueVariable + ';', file=outputdevice) print(' static KConfigGroup configGroup(d->config, QStringLiteral("' + configgroup + '"));', file=outputdevice) print(' const ' + type + ' valueFromConfig = ', end="", file=outputdevice) if 'readEntry' in setting: print('d->readEntry' + stem + '(configGroup, QStringLiteral("' + stem + '"));', file=outputdevice) else: if typeInConfig != type: print('static_cast<' + type + '>(', end="", file=outputdevice) print('configGroup.readEntry(QStringLiteral("' + stem + '"), ', end="", file=outputdevice) if typeInConfig != type: print('static_cast<' + typeInConfig + '>(', end="", file=outputdevice) print('Preferences::default' + stem, end="", file=outputdevice) if typeInConfig != type: print(')', end="", file=outputdevice) print(')', end="", file=outputdevice) if typeInConfig != type: print(')', end="", file=outputdevice) print(';', file=outputdevice) print(' if (valueFromConfig == ' + newValueVariable + ') return false;', file=outputdevice) if 'writeEntry' in setting: print(' d->writeEntry' + stem + '(configGroup, QStringLiteral("' + stem + '"), ' + newValueVariable + ');', file=outputdevice) else: print(' configGroup.writeEntry(QStringLiteral("' + stem + '"), ', end="", file=outputdevice) if typeInConfig != type: print('static_cast<' + typeInConfig + '>(', end="", file=outputdevice) print(newValueVariable, end="", file=outputdevice) if typeInConfig != type: print(')', end="", file=outputdevice) print(', KConfig::Notify);', file=outputdevice) print(' d->config->sync();', file=outputdevice) # NotificationHub::publishEvent(notificationEventId); print(' return true;', file=outputdevice) print('#else // HAVE_KF5', file=outputdevice) print(' Q_UNUSED(newValue);', file=outputdevice) print(' return true;', file=outputdevice) print('#endif // HAVE_KF5', file=outputdevice) print("}", file=outputdevice) jsondata = {} with open("preferences.json") as jsonfile: jsondata = json.load(jsonfile) headerincludes = jsondata['headerincludes'] \ if 'headerincludes' in jsondata else {} implementationincludes = jsondata['implementationincludes'] \ if 'implementationincludes' in jsondata else {} enums = jsondata['enums'] \ if 'enums' in jsondata else {} settings = jsondata['settings'] \ if 'settings' in jsondata else {} with open("/tmp/preferences.h", "w") as headerfile: print_header(headerincludes, implementationincludes, enums, settings, outputdevice=headerfile) with open("/tmp/preferences.cpp", "w") as implementationfile: print_implementation(headerincludes, implementationincludes, enums, settings, outputdevice=implementationfile) diff --git a/src/global/preferences.cpp b/src/config/preferences.cpp similarity index 100% rename from src/global/preferences.cpp rename to src/config/preferences.cpp diff --git a/src/global/preferences.h b/src/config/preferences.h similarity index 97% rename from src/global/preferences.h rename to src/config/preferences.h index f5b6d4b4..50f42f71 100644 --- a/src/global/preferences.h +++ b/src/config/preferences.h @@ -1,202 +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_GLOBAL_PREFERENCES_H -#define KBIBTEX_GLOBAL_PREFERENCES_H +#ifndef KBIBTEX_CONFIG_PREFERENCES_H +#define KBIBTEX_CONFIG_PREFERENCES_H #include #include + #include "kbibtex.h" -class Preferences { +#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_GLOBAL_PREFERENCES_H +#endif // KBIBTEX_CONFIG_PREFERENCES_H diff --git a/src/global/preferences.json b/src/config/preferences.json similarity index 99% rename from src/global/preferences.json rename to src/config/preferences.json index 3e66f0d4..1751052f 100644 --- a/src/global/preferences.json +++ b/src/config/preferences.json @@ -1,204 +1,205 @@ { "headerincludes": [ "", "", - "\"kbibtex.h\"" + "", + "" ], "implementationincludes": [ "", "" ], "enums": { "BibliographySystem": [ ["BibTeX", 0], ["BibLaTeX", 1] ], "BackupScope": [ "NoBackup", "LocalOnly", "BothLocalAndRemote" ], "QuoteComment": [ ["qcNone", 0], ["qcCommand", 1], ["qcPercentSign", 2] ], "FileViewDoubleClickAction": [ ["ActionOpenEditor", 0], ["ActionViewDocument", 1] ] }, "settings": [ { "stem": "BibliographySystem", "type": "BibliographySystem", "availabletype": "QVector>", "available": "{{Preferences::BibTeX, i18n(\"BibTeX\")}, {Preferences::BibLaTeX, i18n(\"BibLaTeX\")}}", "notificationevent": "NotificationHub::EventBibliographySystemChanged" }, { "stem": "PersonNameFormat", "type": "QString", "default": "LastFirst", "predefined": [ ["LastFirst", "QStringLiteral(\"<%l><, %s><, %f>\")"], ["FirstLast", "QStringLiteral(\"<%f ><%l>< %s>\")"] ], "validationcode": "return valueToBeChecked.contains(QStringLiteral(\"%f\")) && valueToBeChecked.contains(QStringLiteral(\"%l\")) && valueToBeChecked.contains(QStringLiteral(\"%s\"));", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "CopyReferenceCommand", "type": "QString", "configgroup": "LaTeX", "availabletype": "QStringList", "available": "{QStringLiteral(\"cite\"), QStringLiteral(\"citealt\"), QStringLiteral(\"citeauthor\"), QStringLiteral(\"citeauthor*\"), QStringLiteral(\"citeyear\"), QStringLiteral(\"citeyearpar\"), QStringLiteral(\"shortcite\"), QStringLiteral(\"citet\"), QStringLiteral(\"citet*\"), QStringLiteral(\"citep\"), QStringLiteral(\"citep*\")}", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "PageSize", "type": "QPageSize::PageSizeId", "podtype": "int", "availabletype": "QVector>", "available": "{{QPageSize::A4, QStringLiteral(\"a4paper\")}, {QPageSize::Letter, QStringLiteral(\"letter\")}, {QPageSize::Legal, QStringLiteral(\"legal\")}}", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "BackupScope", "type": "BackupScope", "configgroup": "InputOutput", "availabletype": "QVector>", "available": "{{Preferences::NoBackup, i18n(\"No backups\")}, {Preferences::LocalOnly, i18n(\"Local files only\")}, {Preferences::BothLocalAndRemote, i18n(\"Both local and remote files\")}}", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "NumberOfBackups", "type": "int", "configgroup": "InputOutput", "default": "5", "validationcode": "return valueToBeChecked >= 0;", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "IdSuggestionFormatStrings", "type": "QStringList", "configgroup": "IdSuggestions", "default": "{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\")}", "validationcode": "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')));", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "ActiveIdSuggestionFormatString", "type": "QString", "configgroup": "IdSuggestions", "default": "{}", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "LyXUseAutomaticPipeDetection", "type": "bool", "configgroup": "LyX", "default": "true", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "LyXPipePath", "type": "QString", "configgroup": "LyX", "default": "QDir::homePath() + QStringLiteral(\"/.lyxpipe.in\")", "validationcode": "return valueToBeChecked.startsWith(QLatin1Char('/'));", "sanitizecode": [ "QString sanitizedNewValue = newValue;", "if (sanitizedNewValue.endsWith(QStringLiteral(\".out\")))", " sanitizedNewValue = sanitizedNewValue.left(sanitizedNewValue.length() - 4);", "if (!sanitizedNewValue.endsWith(QStringLiteral(\".in\")))", " sanitizedNewValue = sanitizedNewValue.append(QStringLiteral(\".in\"));" ], "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "BibTeXEncoding", "type": "QString", "configgroup": "FileExporterBibTeX", "default": "QStringLiteral(\"UTF-8\")", "availabletype": "QStringList", "available": "{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\")}", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "BibTeXStringDelimiter", "type": "QString", "configgroup": "FileExporterBibTeX", "availabletype": "QStringList", "available": "{QStringLiteral(\"{}\"), QStringLiteral(\"\\\"\\\"\"), QStringLiteral(\"()\")}", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "BibTeXQuoteComment", "type": "QuoteComment", "configgroup": "FileExporterBibTeX", "availabletype": "QVector>", "available": "{{Preferences::qcNone, i18nc(\"Comment Quoting\", \"None\")}, {Preferences::qcCommand, i18nc(\"Comment Quoting\", \"@comment{\\342\\200\\246}\")}, {Preferences::qcPercentSign, i18nc(\"Comment Quoting\", \"% \\342\\200\\246\")}}", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "BibTeXKeywordCasing", "type": "KBibTeX::Casing", "podtype": "int", "configgroup": "FileExporterBibTeX", "availabletype": "QVector>", "available": "{{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\")}}", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "BibTeXProtectCasing", "type": "bool", "default": "true", "configgroup": "FileExporterBibTeX", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "BibTeXListSeparator", "type": "QString", "configgroup": "FileExporterBibTeX", "availabletype": "QStringList", "available": "{QStringLiteral(\"; \"), QStringLiteral(\", \")}", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "LaTeXBabelLanguage", "type": "QString", "configgroup": "FileExporterLaTeXbased", "default": "QStringLiteral(\"english\")", "validationcode": "return !valueToBeChecked.isEmpty();", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "BibTeXBibliographyStyle", "type": "QString", "configgroup": "FileExporterLaTeXbased", "default": "QStringLiteral(\"plain\")", "validationcode": "return !valueToBeChecked.isEmpty();", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "FileViewDoubleClickAction", "type": "FileViewDoubleClickAction", "podtype": "int", "configgroup": "User Interface", "availabletype": "QVector>", "available": "{{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\")}}", "notificationevent": "NotificationHub::EventConfigurationChanged" }, { "stem": "ColorCodes", "type": "QVector>", "configgroup": "Color Labels", "default": "{{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\")}}", "validationcode": ["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;"], "notificationevent": "NotificationHub::EventConfigurationChanged", "readEntry": ["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;"], "writeEntry": ["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);"] } ] } diff --git a/src/data/CMakeLists.txt b/src/data/CMakeLists.txt index 6309a7f0..e4bbd7ec 100644 --- a/src/data/CMakeLists.txt +++ b/src/data/CMakeLists.txt @@ -1,68 +1,68 @@ # 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/global/kbibtex.cpp - ${CMAKE_SOURCE_DIR}/src/global/preferences.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 ${CMAKE_SOURCE_DIR}/src/global ) 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 26d7a9d4..b2246ae1 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1,139 +1,139 @@ # 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/global/kbibtex.cpp - ${CMAKE_SOURCE_DIR}/src/global/preferences.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 ${CMAKE_SOURCE_DIR}/src/global ) 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 4b961891..fdc9f1c0 100644 --- a/src/io/CMakeLists.txt +++ b/src/io/CMakeLists.txt @@ -1,107 +1,107 @@ # 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/global/kbibtex.cpp - ${CMAKE_SOURCE_DIR}/src/global/preferences.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 ${CMAKE_SOURCE_DIR}/src/global ) 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 3bb09f7c..c3ac57bf 100644 --- a/src/networking/CMakeLists.txt +++ b/src/networking/CMakeLists.txt @@ -1,138 +1,138 @@ # 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/global/kbibtex.cpp - ${CMAKE_SOURCE_DIR}/src/global/preferences.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 ${CMAKE_SOURCE_DIR}/src/global ) 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 ee7ab579..e498b56b 100644 --- a/src/parts/CMakeLists.txt +++ b/src/parts/CMakeLists.txt @@ -1,88 +1,88 @@ # KBibTeX KPart set( kbibtexpart_SRCS part.cpp partfactory.cpp browserextension.cpp - ${CMAKE_SOURCE_DIR}/src/global/preferences.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 ${CMAKE_SOURCE_DIR}/src/global ) # 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 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 00485717..6637f725 100644 --- a/src/processing/CMakeLists.txt +++ b/src/processing/CMakeLists.txt @@ -1,69 +1,69 @@ # KBibTeX Processing library set( kbibtexproc_LIB_SRCS findduplicates.cpp idsuggestions.cpp lyx.cpp checkbibtex.cpp bibliographyservice.cpp journalabbreviations.cpp - ${CMAKE_SOURCE_DIR}/src/global/preferences.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_SOURCE_DIR}/src/global ${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/test/CMakeLists.txt b/src/test/CMakeLists.txt index e2738677..857e8c16 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -1,187 +1,187 @@ # 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/global ${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/global/kbibtex.cpp - ${CMAKE_SOURCE_DIR}/src/global/preferences.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 )