diff --git a/CMakeLists.txt b/CMakeLists.txt index b77d01c676..af54d0e9ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,659 +1,660 @@ project(krita) message(STATUS "Using CMake version: ${CMAKE_VERSION}") cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) set(MIN_QT_VERSION 5.6.0) option(OVERRIDE_QT_VERSION "Use this to make it possible to build with Qt < 5.6.0. There will be bugs." OFF) if (OVERRIDE_QT_VERSION) set(MIN_QT_VERSION 5.4.0) endif() set(MIN_FRAMEWORKS_VERSION 5.7.0) if (POLICY CMP0002) cmake_policy(SET CMP0002 OLD) endif() if (POLICY CMP0017) cmake_policy(SET CMP0017 NEW) endif () if (POLICY CMP0022) cmake_policy(SET CMP0022 OLD) endif () if (POLICY CMP0026) cmake_policy(SET CMP0026 OLD) endif() if (POLICY CMP0042) cmake_policy(SET CMP0042 NEW) endif() if (POLICY CMP0046) cmake_policy(SET CMP0046 OLD) endif () if (POLICY CMP0059) cmake_policy(SET CMP0059 OLD) endif() if (POLICY CMP0063) cmake_policy(SET CMP0063 OLD) endif() if (POLICY CMP0054) cmake_policy(SET CMP0054 OLD) endif() if (POLICY CMP0064) cmake_policy(SET CMP0064 OLD) endif() if (APPLE) set(APPLE_SUPPRESS_X11_WARNING TRUE) set(KDE_SKIP_RPATH_SETTINGS TRUE) set(CMAKE_MACOSX_RPATH 1) set(BUILD_WITH_INSTALL_RPATH 1) add_definitions(-mmacosx-version-min=10.9 -Wno-macro-redefined -Wno-deprecated-register) endif() ###################### ####################### ## Constants defines ## ####################### ###################### # define common versions of Krita applications, used to generate kritaversion.h # update these version for every release: set(KRITA_VERSION_STRING "4.0.0-pre-alpha") set(KRITA_STABLE_VERSION_MAJOR 4) # 3 for 3.x, 4 for 4.x, etc. set(KRITA_STABLE_VERSION_MINOR 0) # 0 for 3.0, 1 for 3.1, etc. set(KRITA_VERSION_RELEASE 0) # 88 for pre-alpha, 89 for Alpha, increase for next test releases, set 0 for first Stable, etc. set(KRITA_ALPHA 1) # uncomment only for Alpha #set(KRITA_BETA 1) # uncomment only for Beta #set(KRITA_RC 1) # uncomment only for RC set(KRITA_YEAR 2017) # update every year if(NOT DEFINED KRITA_ALPHA AND NOT DEFINED KRITA_BETA AND NOT DEFINED KRITA_RC) set(KRITA_STABLE 1) # do not edit endif() message(STATUS "Krita version: ${KRITA_VERSION_STRING}") # Define the generic version of the Krita libraries here # This makes it easy to advance it when the next Krita release comes. # 14 was the last GENERIC_KRITA_LIB_VERSION_MAJOR of the previous Krita series # (2.x) so we're starting with 15 in 3.x series, 16 in 4.x series if(KRITA_STABLE_VERSION_MAJOR EQUAL 4) math(EXPR GENERIC_KRITA_LIB_VERSION_MAJOR "${KRITA_STABLE_VERSION_MINOR} + 16") else() # let's make sure we won't forget to update the "16" message(FATAL_ERROR "Reminder: please update offset == 16 used to compute GENERIC_KRITA_LIB_VERSION_MAJOR to something bigger") endif() set(GENERIC_KRITA_LIB_VERSION "${GENERIC_KRITA_LIB_VERSION_MAJOR}.0.0") set(GENERIC_KRITA_LIB_SOVERSION "${GENERIC_KRITA_LIB_VERSION_MAJOR}") LIST (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") LIST (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/kde_macro") # fetch git revision for the current build set(KRITA_GIT_SHA1_STRING "") set(KRITA_GIT_BRANCH_STRING "") include(GetGitRevisionDescription) get_git_head_revision(GIT_REFSPEC GIT_SHA1) get_git_branch(GIT_BRANCH) if(GIT_SHA1 AND GIT_BRANCH) string(SUBSTRING ${GIT_SHA1} 0 7 GIT_SHA1) set(KRITA_GIT_SHA1_STRING ${GIT_SHA1}) set(KRITA_GIT_BRANCH_STRING ${GIT_BRANCH}) endif() if(NOT DEFINED RELEASE_BUILD) # estimate mode by CMAKE_BUILD_TYPE content if not set on cmdline string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_TOLOWER) set(RELEASE_BUILD_TYPES "release" "relwithdebinfo" "minsizerel") list(FIND RELEASE_BUILD_TYPES "${CMAKE_BUILD_TYPE_TOLOWER}" INDEX) if (INDEX EQUAL -1) set(RELEASE_BUILD FALSE) else() set(RELEASE_BUILD TRUE) endif() endif() message(STATUS "Release build: ${RELEASE_BUILD}") # create test make targets enable_testing() # collect list of broken tests, empty here to start fresh with each cmake run set(KRITA_BROKEN_TESTS "" CACHE INTERNAL "KRITA_BROKEN_TESTS") ############ ############# ## Options ## ############# ############ include(FeatureSummary) if (WIN32) option(USE_DRMINGW "Support the Dr. Mingw crash handler (only on windows)" ON) add_feature_info("Dr. Mingw" USE_DRMINGW "Enable the Dr. Mingw crash handler") if (MINGW) option(USE_MINGW_HARDENING_LINKER "Enable DEP (NX), ASLR and high-entropy ASLR linker flags (mingw-w64)" ON) add_feature_info("Linker Security Flags" USE_MINGW_HARDENING_LINKER "Enable DEP (NX), ASLR and high-entropy ASLR linker flags") if (USE_MINGW_HARDENING_LINKER) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat -Wl,--disable-auto-image-base") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat -Wl,--disable-auto-image-base") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--dynamicbase -Wl,--nxcompat -Wl,--disable-auto-image-base") if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") # Enable high-entropy ASLR for 64-bit # The image base has to be >4GB for HEASLR to be enabled. # The values used here are kind of arbitrary. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--high-entropy-va -Wl,--image-base,0x140000000") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--high-entropy-va -Wl,--image-base,0x180000000") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--high-entropy-va -Wl,--image-base,0x180000000") endif ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") else (USE_MINGW_HARDENING_LINKER) message(WARNING "Linker Security Flags not enabled!") endif (USE_MINGW_HARDENING_LINKER) endif (MINGW) endif () option(HIDE_SAFE_ASSERTS "Don't show message box for \"safe\" asserts, just ignore them automatically and dump a message to the terminal." ON) configure_file(config-hide-safe-asserts.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-hide-safe-asserts.h) add_feature_info("Safe Asserts" HIDE_SAFE_ASSERTS "Don't show message box for \"safe\" asserts, just ignore them automatically and dump a message to the terminal.") option(FOUNDATION_BUILD "A Foundation build is a binary release build that can package some extra things like color themes. Linux distributions that build and install Krita into a default system location should not define this option to true." OFF) add_feature_info("Foundation Build" FOUNDATION_BUILD "A Foundation build is a binary release build that can package some extra things like color themes. Linux distributions that build and install Krita into a default system location should not define this option to true.") option(KRITA_ENABLE_BROKEN_TESTS "Enable tests that are marked as broken" OFF) add_feature_info("Enable Broken Tests" KRITA_ENABLE_BROKEN_TESTS "Runs broken test when \"make test\" is invoked (use -DKRITA_ENABLE_BROKEN_TESTS=ON to enable).") include(MacroJPEG) ########################################################### ## Look for Python3. It is also searched by KF5, ## ## so we should request the correct version in advance ## ########################################################### find_package(PythonInterp 3.0) find_package(PythonLibrary 3.0) ######################## ######################### ## Look for KDE and Qt ## ######################### ######################## find_package(ECM 1.7.0 REQUIRED NOMODULE) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) include(ECMOptionalAddSubdirectory) include(ECMAddAppIcon) include(ECMSetupVersion) include(ECMMarkNonGuiExecutable) include(ECMGenerateHeaders) include(GenerateExportHeader) include(ECMMarkAsTest) include(ECMInstallIcons) include(CMakePackageConfigHelpers) include(WriteBasicConfigVersionFile) include(CheckFunctionExists) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings) # do not reorder to be alphabetical: this is the order in which the frameworks # depend on each other. find_package(KF5 ${MIN_FRAMEWORKS_VERSION} REQUIRED COMPONENTS Archive Config WidgetsAddons Completion CoreAddons GuiAddons I18n ItemModels ItemViews WindowSystem ) # KConfig deprecated authorizeKAction. In order to be warning free, # compile with the updated function when the dependency is new enough. # Remove this (and the uses of the define) when the minimum KF5 # version is >= 5.24.0. if (${KF5Config_VERSION} VERSION_LESS "5.24.0" ) message("Old KConfig (< 5.24.0) found.") add_definitions(-DKCONFIG_BEFORE_5_24) endif() find_package(Qt5 ${MIN_QT_VERSION} REQUIRED COMPONENTS Core Gui Widgets Xml Network PrintSupport Svg Test Concurrent ) include (MacroAddFileDependencies) include (MacroBoolTo01) include (MacroEnsureOutOfSourceBuild) macro_ensure_out_of_source_build("Compiling Krita inside the source directory is not possible. Please refer to the build instruction https://community.kde.org/Krita#Build_Instructions") # Note: OPTIONAL_COMPONENTS does not seem to be reliable # (as of ECM 5.15.0, CMake 3.2) find_package(Qt5Multimedia ${MIN_QT_VERSION}) set_package_properties(Qt5Multimedia PROPERTIES DESCRIPTION "Qt multimedia integration" URL "http://www.qt.io/" TYPE OPTIONAL PURPOSE "Optionally used to provide sound support for animations") macro_bool_to_01(Qt5Multimedia_FOUND HAVE_QT_MULTIMEDIA) configure_file(config-qtmultimedia.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-qtmultimedia.h ) if (NOT WIN32 AND NOT APPLE) find_package(Qt5 ${MIN_QT_VERSION} REQUIRED X11Extras) find_package(Qt5DBus ${MIN_QT_VERSION}) set(HAVE_DBUS ${Qt5DBus_FOUND}) set_package_properties(Qt5DBus PROPERTIES DESCRIPTION "Qt DBUS integration" URL "http://www.qt.io/" TYPE OPTIONAL PURPOSE "Optionally used to provide a dbus api on Linux") find_package(KF5KIO ${MIN_FRAMEWORKS_VERSION}) macro_bool_to_01(KF5KIO_FOUND HAVE_KIO) set_package_properties(KF5KIO PROPERTIES DESCRIPTION "KDE's KIO Framework" URL "http://api.kde.org/frameworks-api/frameworks5-apidocs/kio/html/index.html" TYPE OPTIONAL PURPOSE "Optionally used for recent document handling") find_package(KF5Crash ${MIN_FRAMEWORKS_VERSION}) macro_bool_to_01(KF5Crash_FOUND HAVE_KCRASH) set_package_properties(KF5Crash PROPERTIES DESCRIPTION "KDE's Crash Handler" URL "http://api.kde.org/frameworks-api/frameworks5-apidocs/kcrash/html/index.html" TYPE OPTIONAL PURPOSE "Optionally used to provide crash reporting on Linux") find_package(X11 REQUIRED COMPONENTS Xinput) set(HAVE_X11 TRUE) add_definitions(-DHAVE_X11) find_package(XCB COMPONENTS XCB ATOM) set(HAVE_XCB ${XCB_FOUND}) + find_package (UserFeedback) else() set(HAVE_DBUS FALSE) set(HAVE_X11 FALSE) set(HAVE_XCB FALSE) endif() add_definitions( -DQT_USE_QSTRINGBUILDER -DQT_STRICT_ITERATORS -DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DQT_NO_URL_CAST_FROM_STRING -DQT_DISABLE_DEPRECATED_BEFORE=0 ) add_definitions(-DTRANSLATION_DOMAIN=\"krita\") # # The reason for this mode is that the Debug mode disable inlining # if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS_KRITADEVS "-O3 -g" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals") endif() if(UNIX) set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};m") endif() if(WIN32) if(MSVC) # C4522: 'class' : multiple assignment operators specified set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd4522") endif() endif() # enable exceptions globally kde_enable_exceptions() # only with this definition will all the FOO_TEST_EXPORT macro do something # TODO: check if this can be moved to only those places which make use of it, # to reduce global compiler definitions that would trigger a recompile of # everything on a change (like adding/removing tests to/from the build) if(BUILD_TESTING) add_definitions(-DCOMPILING_TESTS) endif() set(KRITA_DEFAULT_TEST_DATA_DIR ${CMAKE_SOURCE_DIR}/sdk/tests/data/) macro(macro_add_unittest_definitions) add_definitions(-DFILES_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data/") add_definitions(-DFILES_OUTPUT_DIR="${CMAKE_CURRENT_BINARY_DIR}") add_definitions(-DFILES_DEFAULT_DATA_DIR="${KRITA_DEFAULT_TEST_DATA_DIR}") add_definitions(-DSYSTEM_RESOURCES_DATA_DIR="${CMAKE_SOURCE_DIR}/krita/data/") endmacro() # overcome some platform incompatibilities if(WIN32) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/winquirks) add_definitions(-D_USE_MATH_DEFINES) add_definitions(-DNOMINMAX) set(WIN32_PLATFORM_NET_LIBS ws2_32.lib netapi32.lib) endif() # set custom krita plugin installdir set(KRITA_PLUGIN_INSTALL_DIR ${LIB_INSTALL_DIR}/kritaplugins) ########################### ############################ ## Required dependencies ## ############################ ########################### find_package(PNG REQUIRED) if (APPLE) # this is not added correctly on OSX -- see http://forum.kde.org/viewtopic.php?f=139&t=101867&p=221242#p221242 include_directories(SYSTEM ${PNG_INCLUDE_DIR}) endif() add_definitions(-DBOOST_ALL_NO_LIB) find_package(Boost REQUIRED COMPONENTS system) # for pigment and stage include_directories(${Boost_INCLUDE_DIRS}) ## ## Test for GNU Scientific Library ## find_package(GSL) set_package_properties(GSL PROPERTIES URL "http://www.gnu.org/software/gsl" TYPE RECOMMENDED PURPOSE "Required by Krita's Transform tool.") macro_bool_to_01(GSL_FOUND HAVE_GSL) configure_file(config-gsl.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-gsl.h ) ########################### ############################ ## Optional dependencies ## ############################ ########################### ## ## Check for OpenEXR ## find_package(ZLIB) set_package_properties(ZLIB PROPERTIES DESCRIPTION "Compression library" URL "http://www.zlib.net/" TYPE OPTIONAL PURPOSE "Optionally used by the G'Mic and the PSD plugins") macro_bool_to_01(ZLIB_FOUND HAVE_ZLIB) find_package(OpenEXR) set_package_properties(OpenEXR PROPERTIES DESCRIPTION "High dynamic-range (HDR) image file format" URL "http://www.openexr.com" TYPE OPTIONAL PURPOSE "Required by the Krita OpenEXR filter") macro_bool_to_01(OPENEXR_FOUND HAVE_OPENEXR) set(LINK_OPENEXR_LIB) if(OPENEXR_FOUND) include_directories(SYSTEM ${OPENEXR_INCLUDE_DIR}) set(LINK_OPENEXR_LIB ${OPENEXR_LIBRARIES}) add_definitions(${OPENEXR_DEFINITIONS}) endif() find_package(TIFF) set_package_properties(TIFF PROPERTIES DESCRIPTION "TIFF Library and Utilities" URL "http://www.remotesensing.org/libtiff" TYPE OPTIONAL PURPOSE "Required by the Krita TIFF filter") find_package(JPEG) set_package_properties(JPEG PROPERTIES DESCRIPTION "Free library for JPEG image compression. Note: libjpeg8 is NOT supported." URL "http://www.libjpeg-turbo.org" TYPE OPTIONAL PURPOSE "Required by the Krita JPEG filter") set(LIBRAW_MIN_VERSION "0.16") find_package(LibRaw ${LIBRAW_MIN_VERSION}) set_package_properties(LibRaw PROPERTIES DESCRIPTION "Library to decode RAW images" URL "http://www.libraw.org" TYPE OPTIONAL PURPOSE "Required to build the raw import plugin") find_package(FFTW3) set_package_properties(FFTW3 PROPERTIES DESCRIPTION "A fast, free C FFT library" URL "http://www.fftw.org/" TYPE OPTIONAL PURPOSE "Required by the Krita for fast convolution operators and some G'Mic features") macro_bool_to_01(FFTW3_FOUND HAVE_FFTW3) find_package(OCIO) set_package_properties(OCIO PROPERTIES DESCRIPTION "The OpenColorIO Library" URL "http://www.opencolorio.org" TYPE OPTIONAL PURPOSE "Required by the Krita LUT docker") macro_bool_to_01(OCIO_FOUND HAVE_OCIO) ## ## Look for OpenGL ## # TODO: see if there is a better check for QtGui being built with opengl support (and thus the QOpenGL* classes) if(Qt5Gui_OPENGL_IMPLEMENTATION) message(STATUS "Found QtGui OpenGL support") else() message(FATAL_ERROR "Did NOT find QtGui OpenGL support. Check your Qt configuration. You cannot build Krita without Qt OpenGL support.") endif() ## ## Test for eigen3 ## find_package(Eigen3 REQUIRED "3.0") set_package_properties(Eigen3 PROPERTIES DESCRIPTION "C++ template library for linear algebra" URL "http://eigen.tuxfamily.org" TYPE REQUIRED) ## ## Test for exiv2 ## set(EXIV2_MIN_VERSION "0.16") find_package(Exiv2 REQUIRED) set_package_properties(Exiv2 PROPERTIES DESCRIPTION "Image metadata library and tools" URL "http://www.exiv2.org" PURPOSE "Required by Krita") ## ## Test for lcms ## find_package(LCMS2 REQUIRED "2.4") set_package_properties(LCMS2 PROPERTIES DESCRIPTION "LittleCMS Color management engine" URL "http://www.littlecms.com" TYPE REQUIRED PURPOSE "Will be used for color management and is necessary for Krita") if(LCMS2_FOUND) if(NOT ${LCMS2_VERSION} VERSION_LESS 2040 ) set(HAVE_LCMS24 TRUE) endif() set(HAVE_REQUIRED_LCMS_VERSION TRUE) set(HAVE_LCMS2 TRUE) endif() ## ## Test for Vc ## set(OLD_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ) set(HAVE_VC FALSE) if( NOT MSVC) find_package(Vc 1.1.0) set_package_properties(Vc PROPERTIES DESCRIPTION "Portable, zero-overhead SIMD library for C++" URL "https://github.com/VcDevel/Vc" TYPE OPTIONAL PURPOSE "Required by the Krita for vectorization") macro_bool_to_01(Vc_FOUND HAVE_VC) endif() configure_file(config-vc.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-vc.h ) if(HAVE_VC) message(STATUS "Vc found!") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/vc") include (VcMacros) if(Vc_COMPILER_IS_CLANG) set(ADDITIONAL_VC_FLAGS "-Wabi -ffp-contract=fast -fPIC") elseif (NOT MSVC) set(ADDITIONAL_VC_FLAGS "-Wabi -fabi-version=0 -ffp-contract=fast -fPIC") endif() #Handle Vc master if(Vc_COMPILER_IS_GCC OR Vc_COMPILER_IS_CLANG) AddCompilerFlag("-std=c++11" _ok) if(NOT _ok) AddCompilerFlag("-std=c++0x" _ok) endif() endif() macro(ko_compile_for_all_implementations_no_scalar _objs _src) vc_compile_for_all_implementations(${_objs} ${_src} FLAGS ${ADDITIONAL_VC_FLAGS} ONLY SSE2 SSSE3 SSE4_1 AVX AVX2+FMA+BMI2) endmacro() macro(ko_compile_for_all_implementations _objs _src) vc_compile_for_all_implementations(${_objs} ${_src} FLAGS ${ADDITIONAL_VC_FLAGS} ONLY Scalar SSE2 SSSE3 SSE4_1 AVX AVX2+FMA+BMI2) endmacro() endif() set(CMAKE_MODULE_PATH ${OLD_CMAKE_MODULE_PATH} ) add_definitions(${QT_DEFINITIONS} ${QT_QTDBUS_DEFINITIONS}) if(WIN32) set(LIB_INSTALL_DIR ${LIB_INSTALL_DIR} RUNTIME DESTINATION ${BIN_INSTALL_DIR} LIBRARY ${INSTALL_TARGETS_DEFAULT_ARGS} ARCHIVE ${INSTALL_TARGETS_DEFAULT_ARGS} ) endif() ## ## Test endianess ## include (TestBigEndian) test_big_endian(CMAKE_WORDS_BIGENDIAN) ## ## Test for qt-poppler ## find_package(Poppler) set_package_properties(Poppler PROPERTIES DESCRIPTION "A PDF rendering library" URL "http://poppler.freedesktop.org" TYPE OPTIONAL PURPOSE "Required by the Krita PDF filter.") ## ## Test for pthreads (for G'Mic) ## find_package(Threads) set_package_properties(Threads PROPERTIES DESCRIPTION "PThreads - A low-level threading library" TYPE OPTIONAL PURPOSE "Optionally used by the G'Mic plugin") ## ## Test for OpenMP (for G'Mic) ## find_package(OpenMP) set_package_properties(OpenMP PROPERTIES DESCRIPTION "A low-level parallel execution library" URL "http://openmp.org/wp/" TYPE OPTIONAL PURPOSE "Optionally used by the G'Mic plugin") ## ## Test for Curl (for G'Mic) ## find_package(CURL) set_package_properties(CURL PROPERTIES DESCRIPTION "A tool to fetch remote data" URL "http://curl.haxx.se/" TYPE OPTIONAL PURPOSE "Optionally used by the G'Mic plugin") ############################ ############################# ## Add Krita helper macros ## ############################# ############################ include(MacroKritaAddBenchmark) #################### ##################### ## Define includes ## ##################### #################### # for config.h and includes (if any?) include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/interfaces ) add_subdirectory(libs) add_subdirectory(plugins) add_subdirectory(benchmarks) add_subdirectory(krita) configure_file(KoConfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/KoConfig.h ) configure_file(config_convolution.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config_convolution.h) configure_file(config-ocio.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ocio.h ) check_function_exists(powf HAVE_POWF) configure_file(config-powf.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-powf.h) message("\nBroken tests:") foreach(tst ${KRITA_BROKEN_TESTS}) message(" * ${tst}") endforeach() feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/libs/kuserfeedback/CMakeLists.txt b/libs/kuserfeedback/CMakeLists.txt deleted file mode 100644 index daeae8c160..0000000000 --- a/libs/kuserfeedback/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory( provider ) diff --git a/libs/kuserfeedback/provider/Doxyfile b/libs/kuserfeedback/provider/Doxyfile deleted file mode 100644 index ca65bd894a..0000000000 --- a/libs/kuserfeedback/provider/Doxyfile +++ /dev/null @@ -1,42 +0,0 @@ -PROJECT_NAME = "User Feedback Framework" -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -QT_AUTOBRIEF = YES -INHERIT_DOCS = YES -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = YES -HIDE_IN_BODY_DOCS = YES -CASE_SENSE_NAMES = YES -SORT_MEMBERS_CTORS_1ST = YES -SORT_BRIEF_DOCS = YES -SHOW_USED_FILES = NO -SHOW_FILES = NO -WARN_NO_PARAMDOC = YES - -INPUT = . -FILE_PATTERNS = *.h *.dox -EXCLUDE_PATTERNS = *_p.h -RECURSIVE = YES - -GENERATE_HTML = YES -SOURCE_BROWSER = NO -SEARCHENGINE = NO -SERVER_BASED_SEARCH = NO -GENERATE_LATEX = NO -GENERATE_RTF = NO -ALPHABETICAL_INDEX = NO - -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES - -CLASS_DIAGRAMS = YES -HAVE_DOT = YES -CLASS_GRAPH = YES -COLLABORATION_GRAPH = NO -GROUP_GRAPHS = NO -INCLUDE_GRAPH = NO -INCLUDED_BY_GRAPH = NO -DIRECTORY_GRAPH = NO diff --git a/libs/kuserfeedback/provider/Mainpage.dox b/libs/kuserfeedback/provider/Mainpage.dox deleted file mode 100644 index 98504a4d51..0000000000 --- a/libs/kuserfeedback/provider/Mainpage.dox +++ /dev/null @@ -1,36 +0,0 @@ -/*! - * @mainpage User Feedback Framework - * @section User Feedback - * Framework for collecting feedback from application users. This currently consists of two aspects: - * - Telemetry - * - Surveys - * - * @section Telemetry - * - Extensible set of data sources for telemetry. - * - Full control for the user on what data to contribute. - * - * @section Surveys - * - Distribute surveys and offer users to participate in them. - * - Allow the user to configure how often they want to participate in surveys. - * - * @section Integration - * To use this framework in your application, on a high level you have to do - * the following steps inside your program: - * - Create an instance of UserFeedback::Provider for the entire lifetime of your - * application, and configure it as described in its documetation. - * - Add one or more data sources to the provider, choosing from the standard - * built-in ones, or by adding custom ones deriving from UserFeedback::AbstractDataSource. - * - Add a way to notify your users about surveys, and to encourage them to contriubute - * in the first place, by hooking a suitable user interface up with the corresponding - * signals in UserFeedback::Provider. UserFeedback::NotificationPopup provides a - * reference widget for this purpose. - * - Add a way for your users to configure what data to contribute, and how often - * to be bothered by surveys. UserFeedback::FeedbackConfigDialog provides a - * reference implementation of a configuration dialog for this. - */ - -/*! - * @namespace UserFeedback - * Classes for integrating telemetry collection, survey targeting, - * and contribution encouragenemt and configuration into applications. - */ diff --git a/libs/kuserfeedback/provider/Messages.sh b/libs/kuserfeedback/provider/Messages.sh deleted file mode 100755 index 384c8290e9..0000000000 --- a/libs/kuserfeedback/provider/Messages.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -$EXTRACT_TR_STRINGS `find . -name \*.cpp -o -name \*.h -o -name \*.ui -o -name \*.qml` -o $podir/userfeedbackprovider5_qt.pot - diff --git a/libs/kuserfeedback/provider/core/ApplicationVersionSource b/libs/kuserfeedback/provider/core/ApplicationVersionSource deleted file mode 100644 index 489ec29d64..0000000000 --- a/libs/kuserfeedback/provider/core/ApplicationVersionSource +++ /dev/null @@ -1 +0,0 @@ -#include "applicationversionsource.h" diff --git a/libs/kuserfeedback/provider/core/CMakeLists.txt b/libs/kuserfeedback/provider/core/CMakeLists.txt deleted file mode 100644 index 745530d6aa..0000000000 --- a/libs/kuserfeedback/provider/core/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ - - -set(userfeedback_core_srcs - abstractdatasource.cpp - applicationversionsource.cpp - compilerinfosource.cpp - cpuinfosource.cpp - localeinfosource.cpp - openglinfosource.cpp - platforminfosource.cpp - propertyratiosource.cpp - provider.cpp - qtversionsource.cpp - screeninfosource.cpp - selectionratiosource.cpp - startcountsource.cpp - surveyinfo.cpp - usagetimesource.cpp -) -if(Qt5Core_FOUND) - list(APPEND userfeedback_core_srcs ${userfeedback_core_QM_LOADER}) -endif() - -add_library(UserFeedbackCore SHARED ${userfeedback_core_srcs}) -set_target_properties(UserFeedbackCore PROPERTIES - SOVERSION ${USERFEEDBACK_VERSION} - VERSION ${USERFEEDBACK_VERSION} -) -generate_export_header(UserFeedbackCore) - -if(Qt5Core_FOUND) - target_link_libraries(UserFeedbackCore PUBLIC Qt5::Core PRIVATE Qt5::Gui Qt5::Network) - target_compile_definitions(UserFeedbackCore PRIVATE QT_DISABLE_DEPRECATED_BEFORE=0x040800) -else() - target_link_libraries(UserFeedbackCore PUBLIC ${QT_QTCORE_LIBRARIES} PRIVATE ${QT_QTGUI_LIBRARIES} ${QT_QTNETWORK_LIBRARIES}) -endif() -target_link_libraries(UserFeedbackCore PRIVATE UserFeedbackCommon) -target_include_directories(UserFeedbackCore PUBLIC "$") -target_include_directories(UserFeedbackCore INTERFACE "$") - -install(TARGETS UserFeedbackCore EXPORT UserFeedbackTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) -install(FILES - ${UserFeedbackCore_HEADERS} - ${CMAKE_CURRENT_BINARY_DIR}/userfeedbackcore_export.h - DESTINATION ${KDE_INSTALL_INCLUDEDIR}/UserFeedback -) - - - diff --git a/libs/kuserfeedback/provider/core/abstractdatasource.cpp b/libs/kuserfeedback/provider/core/abstractdatasource.cpp deleted file mode 100644 index f59475f587..0000000000 --- a/libs/kuserfeedback/provider/core/abstractdatasource.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "abstractdatasource.h" -#include "abstractdatasource_p.h" - -using namespace UserFeedback; - -AbstractDataSourcePrivate::AbstractDataSourcePrivate() - : mode(Provider::DetailedUsageStatistics) -{ -} - -AbstractDataSourcePrivate::~AbstractDataSourcePrivate() -{ -} - -AbstractDataSource::AbstractDataSource(const QString &name, AbstractDataSourcePrivate* dd) : - d_ptr(dd ? dd : new AbstractDataSourcePrivate) -{ - Q_ASSERT(!name.isEmpty()); - d_ptr->name = name; -} - -AbstractDataSource::~AbstractDataSource() -{ - delete d_ptr; -} - -QString AbstractDataSource::name() const -{ - return d_ptr->name; -} - -void AbstractDataSource::load(QSettings *settings) -{ - Q_UNUSED(settings); -} - -void AbstractDataSource::store(QSettings *settings) -{ - Q_UNUSED(settings); -} - -void AbstractDataSource::reset(QSettings *settings) -{ - Q_UNUSED(settings); -} - -Provider::StatisticsCollectionMode AbstractDataSource::collectionMode() const -{ - Q_D(const AbstractDataSource); - - Q_ASSERT(d->mode != Provider::NoStatistics); - if (d->mode == Provider::NoStatistics) - return Provider::DetailedUsageStatistics; - return d->mode; -} - -void AbstractDataSource::setCollectionMode(Provider::StatisticsCollectionMode mode) -{ - Q_D(AbstractDataSource); - Q_ASSERT(mode != Provider::NoStatistics); - d->mode = mode; -} diff --git a/libs/kuserfeedback/provider/core/abstractdatasource.h b/libs/kuserfeedback/provider/core/abstractdatasource.h deleted file mode 100644 index 40bff7fc22..0000000000 --- a/libs/kuserfeedback/provider/core/abstractdatasource.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_ABSTRACTDATASOURCE_H -#define USERFEEDBACK_ABSTRACTDATASOURCE_H - -#include "userfeedbackcore_export.h" -#include "provider.h" - -#include - -QT_BEGIN_NAMESPACE -class QSettings; -QT_END_NAMESPACE - -namespace UserFeedback { - -class AbstractDataSourcePrivate; - -/*! Base class for data sources for statistical data. */ -class USERFEEDBACKCORE_EXPORT AbstractDataSource -{ -public: - virtual ~AbstractDataSource(); - - /*! Returns the name of this data source. - * This is used as identifier towards the server and should - * not be shown to the user. - * @see description() - * @returns The data source identifier configured on the feedback server. - */ - QString name() const; - - /*! Returns a human-readable, translated description of what - * this source provides. - * @see name() - * @returns A translated, human-readable string. - */ - virtual QString description() const = 0; - - /*! - * Returns the data gathered by this source. - * - * Implement this to return the data provided by this source. - * One of the three following formats are expected: - * - scalar entries: QAssiciativeIterable - * - list entries: QSequentialIterable containing QAssociativeIterable - * - map entries: QAssiciativeIterable containing QAssociativeIterable - * - * The innermost QAssiciativeIterable must only contain one of the following - * base types (which has to match the corresponding schema entry element): - * - QString - * - int - * - double - * - bool - * All keys must be strings. - * - * @returns A variant complying with the above requirements. - */ - virtual QVariant data() = 0; - - /*! Load persistent state for this data source. - * @param settings A QSettings object opened in a dedicated group for loading - * persistent data. - */ - virtual void load(QSettings *settings); - - /*! Store persistent state for this data source. - * @param settings A QSettings object opened in a dedicated group for storing - * persistent data. - */ - virtual void store(QSettings *settings); - - /*! Reset the persistent state of this data source. - * This is called after a successful submission of data, and can be used - * by sources that track differential rather than absolute data to reset - * their counters. - * @param settings A QSettings object opened in the dedicated group of this - * data source. - */ - virtual void reset(QSettings *settings); - - /*! Returns which colleciton mode this data source belongs to. - * @return The statistics collection category this source belongs to. - */ - Provider::StatisticsCollectionMode collectionMode() const; - - /*! Sets which colleciton mode this data source belongs to. - * @param mode The data collection mode of this source. - */ - void setCollectionMode(Provider::StatisticsCollectionMode mode); - -protected: - /*! Create a new data source named @p name. - * The name of the data source must match the corresponding - * product schema entry. - * @param name Must not be empty. - */ - explicit AbstractDataSource(const QString &name, AbstractDataSourcePrivate *dd = nullptr); - - ///@cond internal - class AbstractDataSourcePrivate* const d_ptr; - ///@endcond - -private: - Q_DECLARE_PRIVATE(AbstractDataSource) - Q_DISABLE_COPY(AbstractDataSource) -}; -} - -#endif // USERFEEDBACK_ABSTRACTDATASOURCE_H diff --git a/libs/kuserfeedback/provider/core/abstractdatasource_p.h b/libs/kuserfeedback/provider/core/abstractdatasource_p.h deleted file mode 100644 index 52cfb6896b..0000000000 --- a/libs/kuserfeedback/provider/core/abstractdatasource_p.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 ABSTRACTDATASOURCEPRIVATE_H -#define ABSTRACTDATASOURCEPRIVATE_H - -#include "provider.h" - -namespace UserFeedback { - -class AbstractDataSourcePrivate -{ -public: - AbstractDataSourcePrivate(); - virtual ~AbstractDataSourcePrivate(); - - QString name; - Provider::StatisticsCollectionMode mode; -}; - -} - -#endif // ABSTRACTDATASOURCEPRIVATE_H diff --git a/libs/kuserfeedback/provider/core/applicationversionsource.cpp b/libs/kuserfeedback/provider/core/applicationversionsource.cpp deleted file mode 100644 index 937348724e..0000000000 --- a/libs/kuserfeedback/provider/core/applicationversionsource.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "applicationversionsource.h" - -#include -#include - -using namespace UserFeedback; - -ApplicationVersionSource::ApplicationVersionSource() : - AbstractDataSource(QStringLiteral("applicationVersion")) -{ -} - -QString ApplicationVersionSource::description() const -{ - return tr("The version of the application."); -} - -QVariant ApplicationVersionSource::data() -{ - if (QCoreApplication::applicationVersion().isEmpty()) - return QVariant(); - - QVariantMap m; - m.insert(QStringLiteral("value"), QCoreApplication::applicationVersion()); - return m; -} diff --git a/libs/kuserfeedback/provider/core/applicationversionsource.h b/libs/kuserfeedback/provider/core/applicationversionsource.h deleted file mode 100644 index 12b46a64a7..0000000000 --- a/libs/kuserfeedback/provider/core/applicationversionsource.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_APPLICATIONVERSIONSOURCE_H -#define USERFEEDBACK_APPLICATIONVERSIONSOURCE_H - -#include "userfeedbackcore_export.h" -#include "abstractdatasource.h" - -namespace UserFeedback { - -/*! Data source for the application version. - * The application version is retrieved via QCoreApplication::applicationVersion. - */ -class USERFEEDBACKCORE_EXPORT ApplicationVersionSource : public AbstractDataSource -{ - Q_DECLARE_TR_FUNCTIONS(UserFeedback::ApplicationVersionSource) -public: - /*! Create a new application version source. */ - ApplicationVersionSource(); - QString description() const override; - QVariant data() override; -}; - -} - -#endif // USERFEEDBACK_APPLICATIONVERSIONSOURCE_H diff --git a/libs/kuserfeedback/provider/core/compilerinfosource.cpp b/libs/kuserfeedback/provider/core/compilerinfosource.cpp deleted file mode 100644 index 236033cbe0..0000000000 --- a/libs/kuserfeedback/provider/core/compilerinfosource.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "compilerinfosource.h" - -#include - -using namespace UserFeedback; - -CompilerInfoSource::CompilerInfoSource() - : AbstractDataSource(QStringLiteral("compiler")) -{ -} - -QString CompilerInfoSource::description() const -{ - return tr("The compiler used to build this application."); -} - -#define STRINGIFY(x) #x -#define INT2STR(x) STRINGIFY(x) - -QVariant CompilerInfoSource::data() -{ - QVariantMap m; - -#ifdef Q_CC_GNU - m.insert(QStringLiteral("type"), QStringLiteral("GCC")); - m.insert(QStringLiteral("version"), QString::fromLatin1( "" INT2STR(__GNUC__) "." INT2STR(__GNUC_MINOR__))); -#endif - -#ifdef Q_CC_CLANG - m.insert(QStringLiteral("type"), QStringLiteral("Clang")); - m.insert(QStringLiteral("version"), QString::fromLatin1( "" INT2STR(__clang_major__) "." INT2STR(__clang_minor__))); -#endif - -#ifdef Q_CC_MSVC - m.insert(QStringLiteral("type"), QStringLiteral("MSVC")); - m.insert(QStringLiteral("version"), QString::fromLatin1( "" INT2STR(_MSC_VER))); -#endif - - if (m.isEmpty()) - m.insert(QStringLiteral("type"), QStringLiteral("unknown")); - - return m; -} - -#undef STRINGIFY -#undef INT2STR diff --git a/libs/kuserfeedback/provider/core/compilerinfosource.h b/libs/kuserfeedback/provider/core/compilerinfosource.h deleted file mode 100644 index 1d9f9e25f5..0000000000 --- a/libs/kuserfeedback/provider/core/compilerinfosource.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_COMPILERINFOSOURCE_H -#define USERFEEDBACK_COMPILERINFOSOURCE_H - -#include "abstractdatasource.h" - -namespace UserFeedback { - -/*! Data source reporting which compiler was used to build this code. - * @note This will report which compiler was used to build the feedback - * library, which technically does not need to be the same as used for - * the application code. This is particularly true for compilers that - * don't break ABI regularly (such as Clang and GCC), so this information - * is most reliable when this is not the case, e.g. with MSVC. - */ -class USERFEEDBACKCORE_EXPORT CompilerInfoSource : public AbstractDataSource -{ -public: - Q_DECLARE_TR_FUNCTIONS(UserFeedback::CompilerInfoSource) -public: - CompilerInfoSource(); - QString description() const override; - QVariant data() override; -}; - -} - -#endif // USERFEEDBACK_COMPILERINFOSOURCE_H diff --git a/libs/kuserfeedback/provider/core/cpuinfosource.cpp b/libs/kuserfeedback/provider/core/cpuinfosource.cpp deleted file mode 100644 index 1d65637d33..0000000000 --- a/libs/kuserfeedback/provider/core/cpuinfosource.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "cpuinfosource.h" - -#include -#include -#include - -using namespace UserFeedback; - -CpuInfoSource::CpuInfoSource() - : AbstractDataSource(QStringLiteral("cpu")) -{ -} - -QString CpuInfoSource::description() const -{ - return tr("The amount and type of CPUs in the system."); -} - -QVariant CpuInfoSource::data() -{ - QVariantMap m; -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) - m.insert(QStringLiteral("architecture"), QSysInfo::currentCpuArchitecture()); -#else - m.insert(QStringLiteral("architecture"), QStringLiteral("unknown")); -#endif - m.insert(QStringLiteral("count"), QThread::idealThreadCount()); - return m; -} diff --git a/libs/kuserfeedback/provider/core/cpuinfosource.h b/libs/kuserfeedback/provider/core/cpuinfosource.h deleted file mode 100644 index 85c92bc172..0000000000 --- a/libs/kuserfeedback/provider/core/cpuinfosource.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_CPUINFOSOURCE_H -#define USERFEEDBACK_CPUINFOSOURCE_H - -#include "userfeedbackcore_export.h" -#include "abstractdatasource.h" - -namespace UserFeedback { - -/*! Data source reporting the type and amount of CPUs. */ -class USERFEEDBACKCORE_EXPORT CpuInfoSource : public AbstractDataSource -{ - Q_DECLARE_TR_FUNCTIONS(UserFeedback::CpuInfoSource) -public: - CpuInfoSource(); - QString description() const override; - QVariant data() override; -}; - -} - -#endif // USERFEEDBACK_CPUINFOSOURCE_H diff --git a/libs/kuserfeedback/provider/core/localeinfosource.cpp b/libs/kuserfeedback/provider/core/localeinfosource.cpp deleted file mode 100644 index 4f02400600..0000000000 --- a/libs/kuserfeedback/provider/core/localeinfosource.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "localeinfosource.h" - -#include -#include - -using namespace UserFeedback; - -LocaleInfoSource::LocaleInfoSource() - : AbstractDataSource(QStringLiteral("locale")) -{ -} - -QString LocaleInfoSource::description() const -{ - return tr("The current region and language settings."); -} - -QVariant LocaleInfoSource::data() -{ - QLocale l; - QVariantMap m; - m.insert(QStringLiteral("region"), QLocale::countryToString(l.country())); - m.insert(QStringLiteral("language"), QLocale::languageToString(l.language())); - return m; -} diff --git a/libs/kuserfeedback/provider/core/localeinfosource.h b/libs/kuserfeedback/provider/core/localeinfosource.h deleted file mode 100644 index 56d472991b..0000000000 --- a/libs/kuserfeedback/provider/core/localeinfosource.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_LOCALEINFOSOURCE_H -#define USERFEEDBACK_LOCALEINFOSOURCE_H - -#include "userfeedbackcore_export.h" -#include "abstractdatasource.h" - -namespace UserFeedback { - -/*! Data source reporting the region and language settings. */ -class USERFEEDBACKCORE_EXPORT LocaleInfoSource : public AbstractDataSource -{ - Q_DECLARE_TR_FUNCTIONS(UserFeedback::LocaleInfoSource) -public: - LocaleInfoSource(); - QString description() const override; - QVariant data() override; -}; - -} - -#endif // USERFEEDBACK_LOCALEINFOSOURCE_H diff --git a/libs/kuserfeedback/provider/core/logging_p.h b/libs/kuserfeedback/provider/core/logging_p.h deleted file mode 100644 index a94a5184ea..0000000000 --- a/libs/kuserfeedback/provider/core/logging_p.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_CORE_LOGGING_H -#define USERFEEDBACK_CORE_LOGGING_H - -#include - -#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) -#include - -namespace UserFeedback { -Q_DECLARE_LOGGING_CATEGORY(Log) -} -#endif - -#endif diff --git a/libs/kuserfeedback/provider/core/openglinfosource.cpp b/libs/kuserfeedback/provider/core/openglinfosource.cpp deleted file mode 100644 index 848ebfd5f1..0000000000 --- a/libs/kuserfeedback/provider/core/openglinfosource.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "openglinfosource.h" - -#include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -#include -#include -#include -#include -#endif - -using namespace UserFeedback; - -OpenGLInfoSource::OpenGLInfoSource() - : AbstractDataSource(QStringLiteral("opengl")) -{ -} - -QString OpenGLInfoSource::description() const -{ - return tr("Information about type, version and vendor of the OpenGL stack."); -} - -QVariant OpenGLInfoSource::data() -{ - QVariantMap m; - -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - QOpenGLContext context; - if (context.create()) { - switch (context.openGLModuleType()) { - case QOpenGLContext::LibGL: - m.insert(QStringLiteral("type"), QStringLiteral("GL")); - break; - case QOpenGLContext::LibGLES: - m.insert(QStringLiteral("type"), QStringLiteral("GLES")); - break; - } - - QWindow window; - window.setSurfaceType(QSurface::OpenGLSurface); - window.create(); - context.makeCurrent(&window); - QOpenGLFunctions functions(&context); - m.insert(QStringLiteral("vendor"), QString::fromLocal8Bit(reinterpret_cast(functions.glGetString(GL_VENDOR)))); - m.insert(QStringLiteral("renderer"), QString::fromLocal8Bit(reinterpret_cast(functions.glGetString(GL_RENDERER)))); - m.insert(QStringLiteral("version"), QString::fromLocal8Bit(reinterpret_cast(functions.glGetString(GL_VERSION)))); - m.insert(QStringLiteral("glslVersion"), QString::fromLocal8Bit(reinterpret_cast(functions.glGetString(GL_SHADING_LANGUAGE_VERSION)))); - - switch (context.format().profile()) { - case QSurfaceFormat::NoProfile: - break; - case QSurfaceFormat::CoreProfile: - m.insert(QStringLiteral("profile"), QStringLiteral("core")); - break; - case QSurfaceFormat::CompatibilityProfile: - m.insert(QStringLiteral("profile"), QStringLiteral("compat")); - break; - } - - return m; - } -#endif - - m.insert(QStringLiteral("type"), QStringLiteral("none")); - return m; -} diff --git a/libs/kuserfeedback/provider/core/openglinfosource.h b/libs/kuserfeedback/provider/core/openglinfosource.h deleted file mode 100644 index 0d3856b422..0000000000 --- a/libs/kuserfeedback/provider/core/openglinfosource.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_OPENGLINFOSOURCE_H -#define USERFEEDBACK_OPENGLINFOSOURCE_H - -#include "abstractdatasource.h" - -namespace UserFeedback { - -/*! Data source reporting type, version and vendor of the OpenGL stack. */ -class USERFEEDBACKCORE_EXPORT OpenGLInfoSource : public AbstractDataSource -{ -public: - Q_DECLARE_TR_FUNCTIONS(UserFeedback::OpenGLInfoSource) -public: - OpenGLInfoSource(); - QString description() const override; - QVariant data() override; -}; - -} - -#endif // USERFEEDBACK_OPENGLINFOSOURCE_H diff --git a/libs/kuserfeedback/provider/core/platforminfosource.cpp b/libs/kuserfeedback/provider/core/platforminfosource.cpp deleted file mode 100644 index f4b6d71703..0000000000 --- a/libs/kuserfeedback/provider/core/platforminfosource.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "platforminfosource.h" - -#include -#include - -using namespace UserFeedback; - -PlatformInfoSource::PlatformInfoSource() : - AbstractDataSource(QStringLiteral("platform")) -{ -} - -QString PlatformInfoSource::description() const -{ - return tr("Type and version of the operating system."); -} - -QVariant PlatformInfoSource::data() -{ - QVariantMap m; -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) -#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) - // on Linux productType() is the distro name - m.insert(QStringLiteral("os"), QStringLiteral("linux")); - - // openSUSE Tumbleweed has the current date as version number, that is a bit too precise for us - if (QSysInfo::productType() == QLatin1String("opensuse") && QSysInfo::productVersion().startsWith(QLatin1String("20"))) - m.insert(QStringLiteral("version"), QString(QSysInfo::productType() + QLatin1String("-tumbleweed"))); - else - m.insert(QStringLiteral("version"), QString(QSysInfo::productType() + QLatin1Char('-') + QSysInfo::productVersion())); -#else - m.insert(QStringLiteral("os"), QSysInfo::productType()); - m.insert(QStringLiteral("version"), QSysInfo::productVersion()); -#endif -#else - - // Qt4 and Qt5 < 5.4 -#ifdef Q_OS_LINUX - m.insert(QStringLiteral("os"), QStringLiteral("linux")); - m.insert(QStringLiteral("version"), QStringLiteral("unknown")); // TODO could be done by reading /etc/os-release -#elif defined(Q_OS_WIN32) - m.insert(QStringLiteral("os"), QStringLiteral("windows")); - switch (QSysInfo::windowsVersion()) { - case QSysInfo::WV_NT: m.insert(QStringLiteral("version"), QStringLiteral("4.0")); break; - case QSysInfo::WV_2000: m.insert(QStringLiteral("version"), QStringLiteral("5.0")); break; - case QSysInfo::WV_XP: m.insert(QStringLiteral("version"), QStringLiteral("5.1")); break; - case QSysInfo::WV_2003: m.insert(QStringLiteral("version"), QStringLiteral("5.2")); break; - case QSysInfo::WV_VISTA: m.insert(QStringLiteral("version"), QStringLiteral("6.0")); break; - case QSysInfo::WV_WINDOWS7: m.insert(QStringLiteral("version"), QStringLiteral("6.1")); break; - case QSysInfo::WV_WINDOWS8: m.insert(QStringLiteral("version"), QStringLiteral("6.2")); break; -#if QT_VERSION > QT_VERSION_CHECK(4, 8, 5) - case QSysInfo::WV_WINDOWS8_1: m.insert(QStringLiteral("version"), QStringLiteral("6.3")); break; -#endif - default: m.insert(QStringLiteral("version"), QStringLiteral("unknown")); - } -#elif defined(Q_OS_MAC) - m.insert(QStringLiteral("os"), QStringLiteral("mac")); - switch (QSysInfo::MacintoshVersion) { - case QSysInfo::MV_10_3: m.insert(QStringLiteral("version"), QStringLiteral("10.3")); break; - case QSysInfo::MV_10_4: m.insert(QStringLiteral("version"), QStringLiteral("10.4")); break; - case QSysInfo::MV_10_5: m.insert(QStringLiteral("version"), QStringLiteral("10.5")); break; - case QSysInfo::MV_10_6: m.insert(QStringLiteral("version"), QStringLiteral("10.6")); break; - case QSysInfo::MV_10_7: m.insert(QStringLiteral("version"), QStringLiteral("10.7")); break; - case QSysInfo::MV_10_8: m.insert(QStringLiteral("version"), QStringLiteral("10.8")); break; - case QSysInfo::MV_10_9: m.insert(QStringLiteral("version"), QStringLiteral("10.9")); break; - default: m.insert(QStringLiteral("version"), QStringLiteral("unknown")); - } -#else - m.insert(QStringLiteral("os"), QStringLiteral("unusual")); -#endif - -#endif - return m; -} diff --git a/libs/kuserfeedback/provider/core/platforminfosource.h b/libs/kuserfeedback/provider/core/platforminfosource.h deleted file mode 100644 index b1c34f303f..0000000000 --- a/libs/kuserfeedback/provider/core/platforminfosource.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_PLATFORMINFOSOURCE_H -#define USERFEEDBACK_PLATFORMINFOSOURCE_H - -#include "abstractdatasource.h" - -namespace UserFeedback { - -/*! Reports information about the platform the application is running on. - * This includes two string data fields: - * - platform.os: the operating system name - * - platform.version: the operating system or distribution version. - */ -class USERFEEDBACKCORE_EXPORT PlatformInfoSource : public AbstractDataSource -{ - Q_DECLARE_TR_FUNCTIONS(UserFeedback::PlatformInfoSource) -public: - /*! Create a new platform information source. */ - PlatformInfoSource(); - QString description() const override; - QVariant data() override; -}; - -} - -#endif // USERFEEDBACK_PLATFORMINFOSOURCE_H diff --git a/libs/kuserfeedback/provider/core/propertyratiosource.cpp b/libs/kuserfeedback/provider/core/propertyratiosource.cpp deleted file mode 100644 index 82a1e491ef..0000000000 --- a/libs/kuserfeedback/provider/core/propertyratiosource.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "propertyratiosource.h" -#include "abstractdatasource_p.h" -#include "logging_p.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace UserFeedback; - -namespace UserFeedback { -class PropertyRatioSourcePrivate : public AbstractDataSourcePrivate -{ -public: - PropertyRatioSourcePrivate(); - ~PropertyRatioSourcePrivate(); - - void propertyChanged(); - QString valueToString(const QVariant &value) const; - - QString description; - QObject *obj; // TODO make this a QPointer? - QObject *signalMonitor; - QMetaProperty property; - QString previousValue; - QTime lastChangeTime; - QHash ratioSet; // data we are currently tracking - QHash baseRatioSet; // data loaded from storage -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - QMap valueMap; -#else - struct ValueMapEntry { QVariant v; QString n; }; - QVector valueMap; -#endif -}; - -// inefficient workaround for not being able to connect QMetaMethod to a function directly -class SignalMonitor : public QObject -{ - Q_OBJECT -public: - explicit SignalMonitor(PropertyRatioSourcePrivate *r) : m_receiver(r) {} -public Q_SLOTS: - void propertyChanged() - { - m_receiver->propertyChanged(); - } -private: - PropertyRatioSourcePrivate *m_receiver; -}; - -} - -PropertyRatioSourcePrivate::PropertyRatioSourcePrivate() - : obj(nullptr) - , signalMonitor(nullptr) -{ -} - -PropertyRatioSourcePrivate::~PropertyRatioSourcePrivate() -{ - delete signalMonitor; -} - -void PropertyRatioSourcePrivate::propertyChanged() -{ - if (!previousValue.isEmpty() && lastChangeTime.elapsed() > 1000) { - ratioSet[previousValue] += lastChangeTime.elapsed() / 1000; - } - - lastChangeTime.start(); - previousValue = valueToString(property.read(obj)); -} - -QString PropertyRatioSourcePrivate::valueToString(const QVariant &value) const -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - const auto it = valueMap.constFind(value); - if (it != valueMap.constEnd() && it.key() == value) { - return it.value(); - } -#else - foreach (const auto &e, valueMap) { - if (e.v == value) - return e.n; - } -#endif - return value.toString(); -} - -PropertyRatioSource::PropertyRatioSource(QObject *obj, const char *propertyName, const QString &sampleName) : - AbstractDataSource(sampleName, new PropertyRatioSourcePrivate) -{ - Q_D(PropertyRatioSource); - - d->obj = obj; - Q_ASSERT(obj); - - auto idx = obj->metaObject()->indexOfProperty(propertyName); - Q_ASSERT(idx >= 0); - if (idx < 0) { - qCWarning(Log) << "Property" << propertyName << "not found in" << obj << "!"; - return; - } - - d->property = obj->metaObject()->property(idx); - if (!d->property.hasNotifySignal()) { - qCWarning(Log) << "Property" << propertyName << "has no notification signal!"; - return; - } - - d->signalMonitor = new SignalMonitor(d); - idx = d->signalMonitor->metaObject()->indexOfMethod("propertyChanged()"); - Q_ASSERT(idx >= 0); - const auto propertyChangedMethod = d->signalMonitor->metaObject()->method(idx); - QObject::connect(obj, d->property.notifySignal(), d->signalMonitor, propertyChangedMethod); - - d->lastChangeTime.start(); - propertyChangedMethod.invoke(d->signalMonitor, Qt::QueuedConnection); -} - -void PropertyRatioSource::addValueMapping(const QVariant &value, const QString &str) -{ - Q_D(PropertyRatioSource); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - d->valueMap.insert(value, str); -#else - PropertyRatioSourcePrivate::ValueMapEntry e; - e.v = value; - e.n = str; - d->valueMap.push_back(e); -#endif -} - -QString PropertyRatioSource::description() const -{ - Q_D(const PropertyRatioSource); - return d->description; -} - -void PropertyRatioSource::setDescription(const QString& desc) -{ - Q_D(PropertyRatioSource); - d->description = desc; -} - -QVariant PropertyRatioSource::data() -{ - Q_D(PropertyRatioSource); - d->propertyChanged(); - - QVariantMap m; - int total = 0; - for (auto it = d->ratioSet.constBegin(); it != d->ratioSet.constEnd(); ++it) - total += it.value() + d->baseRatioSet.value(it.key()); - - for (auto it = d->ratioSet.constBegin(); it != d->ratioSet.constEnd(); ++it) { - double currentValue = it.value() + d->baseRatioSet.value(it.key()); - QVariantMap v; - v.insert(QStringLiteral("property"), currentValue / (double)(total)); - m.insert(it.key(), v); - } - - return m; -} - -void PropertyRatioSource::load(QSettings *settings) -{ - Q_D(PropertyRatioSource); - foreach (const auto &value, settings->childKeys()) { - const auto amount = std::max(settings->value(value, 0).toInt(), 0); - d->baseRatioSet.insert(value, amount); - if (!d->ratioSet.contains(value)) - d->ratioSet.insert(value, 0); - } -} - -void PropertyRatioSource::store(QSettings *settings) -{ - Q_D(PropertyRatioSource); - d->propertyChanged(); - - // note that a second process can have updated the data meanwhile! - for (auto it = d->ratioSet.begin(); it != d->ratioSet.end(); ++it) { - if (it.value() == 0) - continue; - const auto oldValue = std::max(settings->value(it.key(), 0).toInt(), 0); - const auto newValue = oldValue + it.value(); - settings->setValue(it.key(), newValue); - *it = 0; - d->baseRatioSet.insert(it.key(), newValue); - } -} - -void PropertyRatioSource::reset(QSettings* settings) -{ - Q_D(PropertyRatioSource); - d->baseRatioSet.clear(); - d->ratioSet.clear(); - settings->remove(QString()); -} - -#include "propertyratiosource.moc" diff --git a/libs/kuserfeedback/provider/core/propertyratiosource.h b/libs/kuserfeedback/provider/core/propertyratiosource.h deleted file mode 100644 index 8c9b7e0ad7..0000000000 --- a/libs/kuserfeedback/provider/core/propertyratiosource.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_PROPERTYRATIOSOURCE_H -#define USERFEEDBACK_PROPERTYRATIOSOURCE_H - -#include "userfeedbackcore_export.h" -#include "abstractdatasource.h" - -namespace UserFeedback { - -class PropertyRatioSourcePrivate; - -/*! Records the time ratio a given QObject property has a specific value. - * - * An example use-case would be the usage ratio of a applications - * views/modes selected by a QTabWidget or QRadioButton. - */ -class USERFEEDBACKCORE_EXPORT PropertyRatioSource : public AbstractDataSource -{ -public: - /*! Create a new property ratio data source. - * @param obj the QObject of which a property should be monitored. - * @param propertyName The name of the property to monitor. - * This property must have a change notification signal. The value must have - * comparison operators registerd. - * @param sampleName This is the name of the database field this data source is - * associated with. - */ - explicit PropertyRatioSource(QObject *obj, const char* propertyName, const QString &sampleName); - - /*! Map property value @p value to @p str for sending to the server. - * This is useful to map internal identifiers to portable and persistable values, - * such as turning pointers or indexes into meaningful descriptions. - * @param value The property value to map. - * @param str The string the property value @p value should be mapped to. - */ - void addValueMapping(const QVariant &value, const QString &str); - - QString description() const override; - - /*! Set human-readable and translated description of the data provided by this source. - * @note This must be set before adding this source, sources without description are - * discarded. - * @param desc The description. - */ - void setDescription(const QString &desc); - - QVariant data() override; - void load(QSettings *settings) override; - void store(QSettings *settings) override; - void reset(QSettings *settings) override; - -private: - Q_DECLARE_PRIVATE(PropertyRatioSource) -}; - -} - -#endif // USERFEEDBACK_PROPERTYRATIOSOURCE_H diff --git a/libs/kuserfeedback/provider/core/provider.cpp b/libs/kuserfeedback/provider/core/provider.cpp deleted file mode 100644 index fd3d7114f3..0000000000 --- a/libs/kuserfeedback/provider/core/provider.cpp +++ /dev/null @@ -1,575 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include - -#include "logging_p.h" -#include "provider.h" -#include "provider_p.h" -#include "abstractdatasource.h" -#include "startcountsource.h" -#include "surveyinfo.h" -#include "usagetimesource.h" - -#include -#include - -#include -#include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -#include -#include -#include -#endif -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace UserFeedback { -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) -Q_LOGGING_CATEGORY(Log, "org.kde.UserFeedback", QtInfoMsg) -#elif QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) -Q_LOGGING_CATEGORY(Log, "org.kde.UserFeedback") -#endif -} - -using namespace UserFeedback; - -ProviderPrivate::ProviderPrivate(Provider *qq) - : q(qq) - , networkAccessManager(nullptr) - , redirectCount(0) - , submissionInterval(-1) - , statisticsMode(Provider::NoStatistics) - , surveyInterval(-1) - , startCount(0) - , usageTime(0) - , encouragementStarts(-1) - , encouragementTime(-1) - , encouragementDelay(300) - , encouragementInterval(-1) -{ - auto domain = QCoreApplication::organizationDomain().split(QLatin1Char('.')); - std::reverse(domain.begin(), domain.end()); - productId = domain.join(QLatin1String(".")); - if (!productId.isEmpty()) - productId += QLatin1Char('.'); - productId += QCoreApplication::applicationName(); - - submissionTimer.setSingleShot(true); - QObject::connect(&submissionTimer, SIGNAL(timeout()), q, SLOT(submit())); - - startTime.start(); - - encouragementTimer.setSingleShot(true); - QObject::connect(&encouragementTimer, SIGNAL(timeout()), q, SLOT(emitShowEncouragementMessage())); -} - -ProviderPrivate::~ProviderPrivate() -{ - qDeleteAll(dataSources); -} - -int ProviderPrivate::currentApplicationTime() const -{ - return usageTime + (startTime.elapsed() / 1000); -} - -static QMetaEnum statisticsCollectionModeEnum() -{ - const auto idx = Provider::staticMetaObject.indexOfEnumerator("StatisticsCollectionMode"); - Q_ASSERT(idx >= 0); - return Provider::staticMetaObject.enumerator(idx); -} - -std::unique_ptr ProviderPrivate::makeSettings() const -{ - // attempt to put our settings next to the application ones, - // so replicate how QSettings handles this - auto org = -#ifdef Q_OS_MAC - QCoreApplication::organizationDomain().isEmpty() ? QCoreApplication::organizationName() : QCoreApplication::organizationDomain(); -#else - QCoreApplication::organizationName().isEmpty() ? QCoreApplication::organizationDomain() : QCoreApplication::organizationName(); -#endif - if (org.isEmpty()) - org = QLatin1String("Unknown Organization"); - - std::unique_ptr s(new QSettings(org, QStringLiteral("UserFeedback.") + productId)); - return s; -} - -void ProviderPrivate::load() -{ - auto s = makeSettings(); - s->beginGroup(QStringLiteral("UserFeedback")); - lastSubmitTime = s->value(QStringLiteral("LastSubmission")).toDateTime(); - - const auto modeStr = s->value(QStringLiteral("StatisticsCollectionMode")).toByteArray(); - statisticsMode = static_cast(std::max(statisticsCollectionModeEnum().keyToValue(modeStr.constData()), 0)); - - surveyInterval = s->value(QStringLiteral("SurveyInterval"), -1).toInt(); - lastSurveyTime = s->value(QStringLiteral("LastSurvey")).toDateTime(); - completedSurveys = s->value(QStringLiteral("CompletedSurveys"), QStringList()).toStringList(); - - startCount = std::max(s->value(QStringLiteral("ApplicationStartCount"), 0).toInt(), 0); - usageTime = std::max(s->value(QStringLiteral("ApplicationTime"), 0).toInt(), 0); - - lastEncouragementTime = s->value(QStringLiteral("LastEncouragement")).toDateTime(); - - s->endGroup(); - - foreach (auto source, dataSources) { - s->beginGroup(QStringLiteral("Source-") + source->name()); - source->load(s.get()); - s->endGroup(); - } -} - -void ProviderPrivate::store() -{ - auto s = makeSettings(); - s->beginGroup(QStringLiteral("UserFeedback")); - - // another process might have changed this, so read the base value first before writing - usageTime = std::max(s->value(QStringLiteral("ApplicationTime"), 0).toInt(), usageTime); - s->setValue(QStringLiteral("ApplicationTime"), currentApplicationTime()); - usageTime = currentApplicationTime(); - startTime.restart(); - - s->endGroup(); - - foreach (auto source, dataSources) { - s->beginGroup(QStringLiteral("Source-") + source->name()); - source->store(s.get()); - s->endGroup(); - } -} - -void ProviderPrivate::storeOne(const QString &key, const QVariant &value) -{ - auto s = makeSettings(); - s->beginGroup(QStringLiteral("UserFeedback")); - s->setValue(key, value); -} - -void ProviderPrivate::aboutToQuit() -{ - store(); -} - -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -QByteArray variantMapToJson(const QVariantMap &m) -{ - QByteArray b = "{"; - for (auto it = m.begin(); it != m.end(); ++it) { - b += " \"" + it.key().toUtf8() + "\": "; - switch (it.value().type()) { - case QVariant::String: - b += '"' + it.value().toString().toUtf8() + '"'; - break; - case QVariant::Int: - b += QByteArray::number(it.value().toInt()); - break; - case QVariant::Double: - b += QByteArray::number(it.value().toDouble()); - break; - case QVariant::Map: - b += variantMapToJson(it.value().toMap()); - break; - default: - break; - } - if (std::distance(it, m.end()) != 1) - b += ",\n"; - } - b += " }"; - return b; -} -#endif - -QByteArray ProviderPrivate::jsonData(Provider::StatisticsCollectionMode mode) const -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - QJsonObject obj; - if (mode != Provider::NoStatistics) { - foreach (auto source, dataSources) { - if (mode < source->collectionMode()) - continue; - const auto data = source->data(); - if (data.canConvert()) - obj.insert(source->name(), QJsonObject::fromVariantMap(data.toMap())); - else if (data.canConvert()) - obj.insert(source->name(), QJsonArray::fromVariantList(data.value())); - } - } - - QJsonDocument doc(obj); - return doc.toJson(); -#else - QByteArray b = "{"; - if (mode != Provider::NoStatistics) { - for (auto it = dataSources.begin(); it != dataSources.end(); ++it) { - if (mode < (*it)->collectionMode()) - continue; - const auto data = (*it)->data(); - if (data.canConvert()) { - const auto l = data.value(); - b += " \"" + (*it)->name().toUtf8() + "\": [ "; - for (auto it2 = l.begin(); it2 != l.end(); ++it2) { - b += variantMapToJson((*it2).toMap()); - if (std::distance(it2, l.end()) != 1) - b += ", "; - } - b += " ]"; - } else { - b += " \"" + (*it)->name().toUtf8() + "\": " + variantMapToJson(data.toMap()); - } - if (std::distance(it, dataSources.end()) != 1) - b += ",\n"; - } - } - b += '}'; - return b; -#endif -} - -void ProviderPrivate::scheduleNextSubmission() -{ - submissionTimer.stop(); - if (submissionInterval <= 0 || (statisticsMode == Provider::NoStatistics && surveyInterval < 0)) - return; - - Q_ASSERT(submissionInterval > 0); - - const auto nextSubmission = lastSubmitTime.addDays(submissionInterval); - const auto now = QDateTime::currentDateTime(); - submissionTimer.start(std::max(0ll, now.msecsTo(nextSubmission))); -} - -void ProviderPrivate::submitFinished() -{ - auto reply = qobject_cast(q->sender()); - Q_ASSERT(reply); - - if (reply->error() != QNetworkReply::NoError) { - qCWarning(Log) << "failed to submit user feedback:" << reply->errorString() << reply->readAll(); - return; - } - - const auto redirectTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); - if (redirectTarget.isValid()) { - if (++redirectCount >= 20) { - qCWarning(Log) << "Redirect loop on" << reply->url().resolved(redirectTarget); - return; - } - submit(reply->url().resolved(redirectTarget)); - return; - } - - lastSubmitTime = QDateTime::currentDateTime(); - - auto s = makeSettings(); - s->beginGroup(QStringLiteral("UserFeedback")); - s->setValue(QStringLiteral("LastSubmission"), lastSubmitTime); - s->endGroup(); - - // reset source counters - foreach (auto source, dataSources) { - s->beginGroup(QStringLiteral("Source-") + source->name()); - source->reset(s.get()); - s->endGroup(); - } - -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - const auto obj = QJsonDocument::fromJson(reply->readAll()).object(); - const auto it = obj.find(QLatin1String("surveys")); - if (it != obj.end() && surveyInterval >= 0) { - const auto a = it.value().toArray(); - foreach(const auto &s, a) { - const auto survey = SurveyInfo::fromJson(s.toObject()); - if (selectSurvey(survey)) - break; - } - } -#endif - - scheduleNextSubmission(); -} - -QVariant ProviderPrivate::sourceData(const QString& sourceName) const -{ - foreach (auto src, dataSources) { - if (src->name() == sourceName) - return src->data(); - } - return QVariant(); -} - -bool ProviderPrivate::selectSurvey(const SurveyInfo &survey) const -{ - qCDebug(Log) << "got survey:" << survey.url() << survey.target(); - if (!survey.isValid() || completedSurveys.contains(survey.uuid().toString())) - return false; - - if (lastSurveyTime.addDays(surveyInterval) > QDateTime::currentDateTime()) - return false; - - if (!survey.target().isEmpty()) { - SurveyTargetExpressionParser parser; - if (!parser.parse(survey.target())) { - qCDebug(Log) << "failed to parse target expression"; - return false; - } - - SurveyTargetExpressionEvaluator eval; - eval.setDataProvider(this); - if (!eval.evaluate(parser.expression())) - return false; - } - - emit q->surveyAvailable(survey); - return true; -} - -Provider::StatisticsCollectionMode ProviderPrivate::highestStatisticsCollectionMode() const -{ - auto mode = Provider::NoStatistics; - foreach (auto src, dataSources) - mode = std::max(mode, src->collectionMode()); - return mode; -} - -void ProviderPrivate::scheduleEncouragement() -{ - encouragementTimer.stop(); - - // already done, not repetition - if (lastEncouragementTime.isValid() && encouragementInterval <= 0) - return; - - if (encouragementStarts < 0 && encouragementTime < 0) // encouragement disabled - return; - - if (encouragementStarts > startCount) // we need more starts - return; - - if (statisticsMode >= highestStatisticsCollectionMode() && surveyInterval == 0) // already everything enabled - return; - // no repetition if some feedback is enabled - if (lastEncouragementTime.isValid() && (statisticsMode > Provider::NoStatistics || surveyInterval >= 0)) - return; - - Q_ASSERT(encouragementDelay >= 0); - int timeToEncouragement = encouragementDelay; - if (encouragementTime > 0) - timeToEncouragement = std::max(timeToEncouragement, encouragementTime - currentApplicationTime()); - if (lastEncouragementTime.isValid()) { - Q_ASSERT(encouragementInterval > 0); - const auto targetTime = lastEncouragementTime.addDays(encouragementDelay); - timeToEncouragement = std::max(timeToEncouragement, (int)QDateTime::currentDateTime().secsTo(targetTime)); - } - encouragementTimer.start(timeToEncouragement * 1000); -} - -void ProviderPrivate::emitShowEncouragementMessage() -{ - lastEncouragementTime = QDateTime::currentDateTime(); // TODO make this explicit, in case the host application decides to delay? - storeOne(QStringLiteral("LastEncouragement"), lastEncouragementTime); - emit q->showEncouragementMessage(); -} - - -Provider::Provider(QObject *parent) : - QObject(parent), - d(new ProviderPrivate(this)) -{ - qCDebug(Log); - - connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); - - d->load(); - d->startCount++; - d->storeOne(QStringLiteral("ApplicationStartCount"), d->startCount); -} - -Provider::~Provider() -{ - delete d; -} - -void Provider::setProductIdentifier(const QString &productId) -{ - Q_ASSERT(!productId.isEmpty()); - d->productId = productId; -} - -void Provider::setFeedbackServer(const QUrl &url) -{ - d->serverUrl = url; -} - -void Provider::setSubmissionInterval(int days) -{ - d->submissionInterval = days; - d->scheduleNextSubmission(); -} - -Provider::StatisticsCollectionMode Provider::statisticsCollectionMode() const -{ - return d->statisticsMode; -} - -void Provider::setStatisticsCollectionMode(StatisticsCollectionMode mode) -{ - if (d->statisticsMode == mode) - return; - - d->statisticsMode = mode; - d->storeOne(QStringLiteral("StatisticsCollectionMode"), QString::fromLatin1(statisticsCollectionModeEnum().valueToKey(d->statisticsMode))); - d->scheduleNextSubmission(); - d->scheduleEncouragement(); - emit statisticsCollectionModeChanged(); -} - -void Provider::addDataSource(AbstractDataSource *source, StatisticsCollectionMode mode) -{ - // sanity-check sources - if (mode == NoStatistics) { - qCritical() << "Source" << source->name() << "attempts to report data unconditionally, ignoring!"; - delete source; - return; - } - if (source->description().isEmpty()) { - qCritical() << "Source" << source->name() << "has no description, ignoring!"; - delete source; - return; - } - - Q_ASSERT(mode != NoStatistics); - Q_ASSERT(!source->description().isEmpty()); - source->setCollectionMode(mode); - - // special cases for sources where we track the data here, as it's needed even if we don't report it - if (auto countSrc = dynamic_cast(source)) - countSrc->setProvider(d); - if (auto timeSrc = dynamic_cast(source)) - timeSrc->setProvider(d); - - d->dataSources.push_back(source); - - auto s = d->makeSettings(); - s->beginGroup(QStringLiteral("Source-") + source->name()); - source->load(s.get()); -} - -QVector Provider::dataSources() const -{ - return d->dataSources; -} - -int Provider::surveyInterval() const -{ - return d->surveyInterval; -} - -void Provider::setSurveyInterval(int days) -{ - if (d->surveyInterval == days) - return; - - d->surveyInterval = days; - d->storeOne(QStringLiteral("SurveyInterval"), d->surveyInterval); - - d->scheduleNextSubmission(); - d->scheduleEncouragement(); - emit surveyIntervalChanged(); -} - -void Provider::setApplicationStartsUntilEncouragement(int starts) -{ - d->encouragementStarts = starts; - d->scheduleEncouragement(); -} - -void Provider::setApplicationUsageTimeUntilEncouragement(int secs) -{ - d->encouragementTime = secs; - d->scheduleEncouragement(); -} - -void Provider::setEncouragementDelay(int secs) -{ - d->encouragementDelay = std::max(0, secs); - d->scheduleEncouragement(); -} - -void Provider::setEncouragementInterval(int days) -{ - d->encouragementInterval = days; - d->scheduleEncouragement(); -} - -void Provider::setSurveyCompleted(const SurveyInfo &info) -{ - d->completedSurveys.push_back(info.uuid().toString()); - d->lastSurveyTime = QDateTime::currentDateTime(); - - auto s = d->makeSettings(); - s->beginGroup(QStringLiteral("UserFeedback")); - s->setValue(QStringLiteral("LastSurvey"), d->lastSurveyTime); - s->setValue(QStringLiteral("CompletedSurveys"), d->completedSurveys); -} - -void Provider::submit() -{ - if (d->productId.isEmpty()) { - qCWarning(Log) << "No productId specified!"; - return; - } - if (!d->serverUrl.isValid()) { - qCWarning(Log) << "No feedback server URL specified!"; - return; - } - - if (!d->networkAccessManager) - d->networkAccessManager = new QNetworkAccessManager(this); - - auto url = d->serverUrl; - url.setPath(url.path() + QStringLiteral("/receiver/submit/") + d->productId); - d->submit(url); -} - -void ProviderPrivate::submit(const QUrl &url) -{ - QNetworkRequest request(url); - request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/json")); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - request.setHeader(QNetworkRequest::UserAgentHeader, QString(QStringLiteral("UserFeedback/") + QStringLiteral(USERFEEDBACK_VERSION))); -#endif - auto reply = networkAccessManager->post(request, jsonData(statisticsMode)); - QObject::connect(reply, SIGNAL(finished()), q, SLOT(submitFinished())); -} - -#include "moc_provider.cpp" diff --git a/libs/kuserfeedback/provider/core/provider.h b/libs/kuserfeedback/provider/core/provider.h deleted file mode 100644 index e3e1d17602..0000000000 --- a/libs/kuserfeedback/provider/core/provider.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_PROVIDER_H -#define USERFEEDBACK_PROVIDER_H - -#include "userfeedbackcore_export.h" - -#include -#include -#include - -namespace UserFeedback { - -class AbstractDataSource; -class ProviderPrivate; -class SurveyInfo; - -/*! The central object managing data sources and transmitting feedback to the server. - * - * The defaults for this class are very defensive, so in order to make it actually - * operational and submit data, there is a number of settings you need to set in - * code, namely submission intervals, encouragement settings and adding data sources. - * The settings about what data to submit (statisticsCollectionMode) and how often - * to bother the user with surveys (surveyInterval) should not be set to hardcoded - * values in code, but left as choices to the user. - */ -class USERFEEDBACKCORE_EXPORT Provider : public QObject -{ - Q_OBJECT - /*! The interval in which the user accepts surveys. - * @c -1 indicates surveys are disabled. - * @see surveyInterval(), setSurveyInterval() - */ - Q_PROPERTY(int surveyInterval READ surveyInterval WRITE setSurveyInterval NOTIFY surveyIntervalChanged) - /*! The telemetry mode the user has configured. - * @see statisticsCollectionMode(), setStatisticsCollectionMode() - */ - Q_PROPERTY(StatisticsCollectionMode statisticsCollectionMode READ statisticsCollectionMode WRITE setStatisticsCollectionMode NOTIFY statisticsCollectionModeChanged) -public: - /*! Telemetry collection modes. - * Colleciton modes are inclusive, ie. higher modes always imply data from - * lower modes too. - */ - enum StatisticsCollectionMode { - NoStatistics, ///< Transmit no data at all. - BasicSystemInformation = 0x10, ///< Transmit basic information about the system. - BasicUsageStatistics = 0x20, ///< Transmit basic usage statistics. - DetailedSystemInformation = 0x30, ///< Transmit detailed system information. - DetailedUsageStatistics = 0x40, ///< Transmit detailed usage statistics. - }; - Q_ENUMS(StatisticsCollectionMode) - - /*! Create a new feedback provider. - * @param parent The parent object. - */ - explicit Provider(QObject *parent = nullptr); - ~Provider(); - - /*! Set the product identifier. - * This is used to distinguish independent products on the same server. - * If this is not specified, the product identifier is dervied from the application name - * organisation domain specified in QCoreApplication. - * @param productId Unique product identifier, as configured on the feedback server. - */ - void setProductIdentifier(const QString &productId); - - /*! Set the feedback server URL. - * This must be called with an appropriate URL for this class to be operational. - * @param url The URL of the feedback server. - */ - void setFeedbackServer(const QUrl &url); - - /*! Set the automatic submission interval. - * This must be called with a positive number for this class to be operational, - * as the default is -1 (no submission ever). - */ - void setSubmissionInterval(int days); - - /*! Returns the current statistics collection mode. - * The default is NoStatistics. - */ - StatisticsCollectionMode statisticsCollectionMode() const; - - /*! Set which statistics should be submitted. */ - void setStatisticsCollectionMode(StatisticsCollectionMode mode); - - /*! Adds a data source for statistical data collection. - * @param source The data source to add. The Provider takes ownership of @p source. - * @param mode The statistics collection mode this source belongs to. Data is only - * send to the server for this source is a sufficiently high collection mode is configured - * by the user. @c NoStatistics is not allowed. - */ - void addDataSource(AbstractDataSource *source, StatisticsCollectionMode mode); - - /*! Returns all data sources that have been added to this provider. - * @see addDataSource - */ - QVector dataSources() const; - - /*! Returns the minimum time between two surveys in days. - * The default is -1 (no surveys enabled). - */ - int surveyInterval() const; - - /*! Sets the minimum time in days between two surveys. - * @c -1 indicates no surveys should be requested. - */ - void setSurveyInterval(int days); - - /*! Marks the given survey as completed. This avoids getting further notification - * about the same survey. - */ - void setSurveyCompleted(const SurveyInfo &info); - - /*! Set the amount of application starts until the encouragement message should be shown. - * The default is -1, ie. no encouragement based on application starts. - * @param starts The amount of application starts after which an encouragement - * message should be displayed. - */ - void setApplicationStartsUntilEncouragement(int starts); - - /*! Set the amount of usage time until the encouragement message should be shown. - * The default is -1, ie. no encouragement based on application usage time. - * @param secs Amount of seconds until the encouragement should be shown. - */ - void setApplicationUsageTimeUntilEncouragement(int secs); - - /*! Set the delay after application start for the earliest display of the encouragement message. - * The default is 300, ie. 5 minutes after the application start. - * @note This only adds an additional contraint on usage time and startup count based - * encouragement messages, it does not actually trigger encouragement messages itself. - * - * @param secs Amount of seconds after the application start for the earliest display - * of an encouragement message. - * - * @see setApplicationStartsUntilEncouragement, setApplicationUsageTimeUntilEncouragement - */ - void setEncouragementDelay(int secs); - - /*! Sets the interval after the encouragement should be repeated. - * Encouragement messages are only repeated if no feedback options have been enabled. - * The default is -1, that is no repeated encouragement at all. - * @param days Days between encouragement messages, 0 disables repeated encouragements. - */ - void setEncouragementInterval(int days); - -public Q_SLOTS: - /*! Manually submit currently recorded data. */ - void submit(); - -Q_SIGNALS: - /*! Emitted whenever there is a new survey available that can be presented - * to the user. - */ - void surveyAvailable(const UserFeedback::SurveyInfo &survey); - - /*! Indicate that the encouragement notice should be shown. */ - void showEncouragementMessage(); - - /*! Emitted when the survey interval changed. */ - void surveyIntervalChanged(); - - /*! Emitted when the statistics collection mode has changed. */ - void statisticsCollectionModeChanged(); - -private: - friend class ProviderPrivate; - ProviderPrivate * const d; - Q_PRIVATE_SLOT(d, void aboutToQuit()) - Q_PRIVATE_SLOT(d, void submitFinished()) - Q_PRIVATE_SLOT(d, void emitShowEncouragementMessage()) - // for UI - Q_PRIVATE_SLOT(d, QByteArray jsonData(UserFeedback::Provider::StatisticsCollectionMode)) - // for testing - Q_PRIVATE_SLOT(d, void load()) - Q_PRIVATE_SLOT(d, void store()) -}; - -} - -Q_DECLARE_METATYPE(UserFeedback::Provider::StatisticsCollectionMode) - -#endif // USERFEEDBACK_PROVIDER_H diff --git a/libs/kuserfeedback/provider/core/provider_p.h b/libs/kuserfeedback/provider/core/provider_p.h deleted file mode 100644 index 86eaf691d4..0000000000 --- a/libs/kuserfeedback/provider/core/provider_p.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_PROVIDER_P_H -#define USERFEEDBACK_PROVIDER_P_H - -#include "provider.h" - -#include - -#include -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE -class QNetworkAccessManager; -class QSettings; -QT_END_NAMESPACE - -namespace UserFeedback { -class ProviderPrivate : public SurveyTargetExpressionDataProvider -{ -public: - ProviderPrivate(Provider *qq); - ~ProviderPrivate(); - - int currentApplicationTime() const; - - std::unique_ptr makeSettings() const; - void load(); - void store(); - void storeOne(const QString &key, const QVariant &value); - - void aboutToQuit(); - - QByteArray jsonData(Provider::StatisticsCollectionMode mode) const; - void scheduleNextSubmission(); - void submit(const QUrl &url); - void submitFinished(); - - bool selectSurvey(const SurveyInfo &survey) const; - - Provider::StatisticsCollectionMode highestStatisticsCollectionMode() const; - void scheduleEncouragement(); - void emitShowEncouragementMessage(); - - QVariant sourceData(const QString &sourceName) const override; - - Provider *q; - - QString productId; - - QTimer submissionTimer; - QNetworkAccessManager *networkAccessManager; - QUrl serverUrl; - QDateTime lastSubmitTime; - int redirectCount; - int submissionInterval; - Provider::StatisticsCollectionMode statisticsMode; - - int surveyInterval; - QDateTime lastSurveyTime; - QStringList completedSurveys; - - QTime startTime; - int startCount; - int usageTime; - - QTimer encouragementTimer; - QDateTime lastEncouragementTime; - int encouragementStarts; - int encouragementTime; - int encouragementDelay; - int encouragementInterval; - - QVector dataSources; -}; -} - -#endif diff --git a/libs/kuserfeedback/provider/core/qtversionsource.cpp b/libs/kuserfeedback/provider/core/qtversionsource.cpp deleted file mode 100644 index 08922b8185..0000000000 --- a/libs/kuserfeedback/provider/core/qtversionsource.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "qtversionsource.h" - -#include - -using namespace UserFeedback; - -QtVersionSource::QtVersionSource() : - AbstractDataSource(QStringLiteral("qtVersion")) -{ -} - -QString QtVersionSource::description() const -{ - return tr("The Qt version used by this application."); -} - -QVariant QtVersionSource::data() -{ - QVariantMap m; - m.insert(QStringLiteral("value"), QString::fromLatin1(qVersion())); - return m; -} diff --git a/libs/kuserfeedback/provider/core/qtversionsource.h b/libs/kuserfeedback/provider/core/qtversionsource.h deleted file mode 100644 index 90d8aab7a6..0000000000 --- a/libs/kuserfeedback/provider/core/qtversionsource.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_QTVERSIONSOURCE_H -#define USERFEEDBACK_QTVERSIONSOURCE_H - -#include "userfeedbackcore_export.h" -#include "abstractdatasource.h" - -namespace UserFeedback { - -/*! Data source reporting the Qt version used at runtime. */ -class USERFEEDBACKCORE_EXPORT QtVersionSource : public AbstractDataSource -{ - Q_DECLARE_TR_FUNCTIONS(UserFeedback::QtVersionSource) -public: - QtVersionSource(); - QString description() const override; - QVariant data() override; -}; -} - -#endif // USERFEEDBACK_QTVERSIONSOURCE_H diff --git a/libs/kuserfeedback/provider/core/screeninfosource.cpp b/libs/kuserfeedback/provider/core/screeninfosource.cpp deleted file mode 100644 index 173fc4a837..0000000000 --- a/libs/kuserfeedback/provider/core/screeninfosource.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "screeninfosource.h" - -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -#include -#else -#include -#include -#endif -#include -#include - -using namespace UserFeedback; - -ScreenInfoSource::ScreenInfoSource() : - AbstractDataSource(QStringLiteral("screens")) -{ -} - -QString ScreenInfoSource::description() const -{ - return tr("Size and resolution of all connected screens."); -} - -QVariant ScreenInfoSource::data() -{ - QVariantList l; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - foreach (auto screen, QGuiApplication::screens()) { - QVariantMap m; - m.insert(QStringLiteral("width"), screen->size().width()); - m.insert(QStringLiteral("height"), screen->size().height()); - m.insert(QStringLiteral("dpi"), qRound(screen->physicalDotsPerInch())); - l.push_back(m); - } -#else - auto desktop = QApplication::desktop(); - for (int i = 0; i < desktop->screenCount(); ++i) { - QVariantMap m; - m.insert(QStringLiteral("width"), desktop->screenGeometry(i).width()); - m.insert(QStringLiteral("height"), desktop->screenGeometry(i).height()); - l.push_back(m); - } -#endif - return l; -} diff --git a/libs/kuserfeedback/provider/core/screeninfosource.h b/libs/kuserfeedback/provider/core/screeninfosource.h deleted file mode 100644 index 65186f800c..0000000000 --- a/libs/kuserfeedback/provider/core/screeninfosource.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_SCREENINFOSOURCE_H -#define USERFEEDBACK_SCREENINFOSOURCE_H - -#include "userfeedbackcore_export.h" -#include "abstractdatasource.h" - -namespace UserFeedback { - -/*! Data source for information about connected displays. - * This provides as array of maps containing the following properties: - * - height: Height of the corresponding screen in pixel. - * - width: Width of the corresponding screen in pixel. - * - dpi: Dots per inch of the corresponding screen. - */ -class USERFEEDBACKCORE_EXPORT ScreenInfoSource : public AbstractDataSource -{ - Q_DECLARE_TR_FUNCTIONS(UserFeedback::ScreenInfoSource) -public: - /*! Create a new screen information source. */ - ScreenInfoSource(); - QString description() const override; - QVariant data() override; -}; - -} - -#endif // USERFEEDBACK_SCREENINFOSOURCE_H diff --git a/libs/kuserfeedback/provider/core/selectionratiosource.cpp b/libs/kuserfeedback/provider/core/selectionratiosource.cpp deleted file mode 100644 index 4d6742549d..0000000000 --- a/libs/kuserfeedback/provider/core/selectionratiosource.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "selectionratiosource.h" -#include "abstractdatasource_p.h" -#include "logging_p.h" - -#include -#include -#include -#include -#include -#include - -#include - -using namespace UserFeedback; - -namespace UserFeedback { -class SelectionRatioSourcePrivate : public AbstractDataSourcePrivate -{ -public: - SelectionRatioSourcePrivate(); - - void selectionChanged(); - QString selectedValue() const; - - QItemSelectionModel *model; - std::unique_ptr monitor; - QString description; - QString previousValue; - QTime lastChangeTime; - QHash ratioSet; // data we are currently tracking - QHash baseRatioSet; // data loaded from storage - int role; -}; - -class SelectionMonitor : public QObject -{ - Q_OBJECT -public: - explicit SelectionMonitor(SelectionRatioSourcePrivate *d) : m_receiver(d) {} -public Q_SLOTS: - void selectionChanged() - { - m_receiver->selectionChanged(); - } -private: - SelectionRatioSourcePrivate *m_receiver; -}; - -} - -SelectionRatioSourcePrivate::SelectionRatioSourcePrivate() - : model(nullptr) - , role(Qt::DisplayRole) -{ -} - -void SelectionRatioSourcePrivate::selectionChanged() -{ - if (!previousValue.isEmpty() && lastChangeTime.elapsed() > 1000) { - ratioSet[previousValue] += lastChangeTime.elapsed() / 1000; - } - - lastChangeTime.start(); - previousValue = selectedValue(); -} - -QString SelectionRatioSourcePrivate::selectedValue() const -{ - if (!model->hasSelection()) - return QString(); - const auto idxs = model->selectedIndexes(); - Q_ASSERT(!idxs.isEmpty()); - const auto idx = idxs.at(0); - return idx.data(role).toString(); -} - -SelectionRatioSource::SelectionRatioSource(QItemSelectionModel* selectionModel, const QString& sampleName) - : AbstractDataSource(sampleName, new SelectionRatioSourcePrivate) -{ - Q_D(SelectionRatioSource); - - d->model = selectionModel; - Q_ASSERT(selectionModel); - - d->monitor.reset(new SelectionMonitor(d)); - QObject::connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), d->monitor.get(), SLOT(selectionChanged())); - d->lastChangeTime.start(); - d->selectionChanged(); -} - -void SelectionRatioSource::setRole(int role) -{ - Q_D(SelectionRatioSource); - d->role = role; -} - -QString SelectionRatioSource::description() const -{ - Q_D(const SelectionRatioSource); - return d->description; -} - -void SelectionRatioSource::setDescription(const QString& desc) -{ - Q_D(SelectionRatioSource); - d->description = desc; -} - -QVariant SelectionRatioSource::data() -{ - Q_D(SelectionRatioSource); - d->selectionChanged(); - - QVariantMap m; - int total = 0; - for (auto it = d->ratioSet.constBegin(); it != d->ratioSet.constEnd(); ++it) - total += it.value() + d->baseRatioSet.value(it.key()); - - for (auto it = d->ratioSet.constBegin(); it != d->ratioSet.constEnd(); ++it) { - double currentValue = it.value() + d->baseRatioSet.value(it.key()); - QVariantMap v; - v.insert(QStringLiteral("property"), currentValue / (double)(total)); - m.insert(it.key(), v); - } - return m; -} - -void SelectionRatioSource::load(QSettings *settings) -{ - Q_D(SelectionRatioSource); - foreach (const auto &value, settings->childKeys()) { - const auto amount = std::max(settings->value(value, 0).toInt(), 0); - d->baseRatioSet.insert(value, amount); - if (!d->ratioSet.contains(value)) - d->ratioSet.insert(value, 0); - } -} - -void SelectionRatioSource::store(QSettings *settings) -{ - Q_D(SelectionRatioSource); - d->selectionChanged(); - - // note that a second process can have updated the data meanwhile! - for (auto it = d->ratioSet.begin(); it != d->ratioSet.end(); ++it) { - if (it.value() == 0) - continue; - const auto oldValue = std::max(settings->value(it.key(), 0).toInt(), 0); - const auto newValue = oldValue + it.value(); - settings->setValue(it.key(), newValue); - *it = 0; - d->baseRatioSet.insert(it.key(), newValue); - } -} - -void SelectionRatioSource::reset(QSettings* settings) -{ - Q_D(SelectionRatioSource); - d->baseRatioSet.clear(); - d->ratioSet.clear(); - settings->remove(QString()); -} - -#include "selectionratiosource.moc" diff --git a/libs/kuserfeedback/provider/core/selectionratiosource.h b/libs/kuserfeedback/provider/core/selectionratiosource.h deleted file mode 100644 index 922bb8b27d..0000000000 --- a/libs/kuserfeedback/provider/core/selectionratiosource.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_SELECTIONRATIOSOURCE_H -#define USERFEEDBACK_SELECTIONRATIOSOURCE_H - -#include "userfeedbackcore_export.h" -#include "abstractdatasource.h" - -QT_BEGIN_NAMESPACE -class QItemSelectionModel; -QT_END_NAMESPACE - -namespace UserFeedback { - -class SelectionRatioSourcePrivate; - -/*! Records the time ratio a given entry is selected via a QItemSelectionModel. - * - * An example use-case would be the usage ratio of a applications - * views/modes selected using a model-based view sidebar (such as - * used in e.g. Kontact). - */ -class USERFEEDBACKCORE_EXPORT SelectionRatioSource : public AbstractDataSource -{ -public: - /*! Create a new selection ratio data source. - * @param selectionModel The selection to monitor. - * @param sampleName This is the name of the database field this data source is - * associated with. - */ - explicit SelectionRatioSource(QItemSelectionModel *selectionModel, const QString &sampleName); - - /*! Determine which role to consider for the reported value. - * By default this is Qt::DisplayRole. - */ - void setRole(int role); - - QString description() const override; - /*! Set human-readable and translated description of the data provided by this source. - * @note This must be set before adding this source, sources without description are - * discarded. - * @param desc The description. - */ - void setDescription(const QString &desc); - - QVariant data() override; - void load(QSettings *settings) override; - void store(QSettings *settings) override; - void reset(QSettings *settings) override; - -private: - Q_DECLARE_PRIVATE(SelectionRatioSource) -}; - -} - -#endif // USERFEEDBACK_SELECTIONRATIOSOURCE_H diff --git a/libs/kuserfeedback/provider/core/startcountsource.cpp b/libs/kuserfeedback/provider/core/startcountsource.cpp deleted file mode 100644 index 4577c703a6..0000000000 --- a/libs/kuserfeedback/provider/core/startcountsource.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "startcountsource.h" -#include "abstractdatasource_p.h" -#include "provider_p.h" - -#include - -using namespace UserFeedback; - -namespace UserFeedback { -class StartCountSourcePrivate : public AbstractDataSourcePrivate -{ -public: - StartCountSourcePrivate() : provider(nullptr) {} - ProviderPrivate *provider; -}; -} - -StartCountSource::StartCountSource() : - AbstractDataSource(QStringLiteral("startCount"), new StartCountSourcePrivate) -{ -} - -QString StartCountSource::description() const -{ - return tr("How often the application has been started."); -} - -QVariant StartCountSource::data() -{ - Q_D(StartCountSource); - Q_ASSERT(d->provider); - - QVariantMap m; - m.insert(QStringLiteral("value"), d->provider->startCount); - return m; -} - -void StartCountSource::setProvider(ProviderPrivate *p) -{ - Q_D(StartCountSource); - d->provider = p; -} diff --git a/libs/kuserfeedback/provider/core/startcountsource.h b/libs/kuserfeedback/provider/core/startcountsource.h deleted file mode 100644 index d39a64a57e..0000000000 --- a/libs/kuserfeedback/provider/core/startcountsource.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_STARTCOUNTSOURCE_H -#define USERFEEDBACK_STARTCOUNTSOURCE_H - -#include "userfeedbackcore_export.h" -#include "abstractdatasource.h" - -namespace UserFeedback { - -class Provider; -class ProviderPrivate; -class StartCountSourcePrivate; - -/*! Data source reporting the total amount of applications starts. */ -class USERFEEDBACKCORE_EXPORT StartCountSource : public AbstractDataSource -{ - Q_DECLARE_TR_FUNCTIONS(UserFeedback::StartCountSource) -public: - /*! Create a new start count data source. */ - StartCountSource(); - QString description() const override; - QVariant data() override; - -private: - Q_DECLARE_PRIVATE(StartCountSource) - friend class Provider; - void setProvider(ProviderPrivate *p); -}; - -} - -#endif // USERFEEDBACK_STARTCOUNTSOURCE_H diff --git a/libs/kuserfeedback/provider/core/surveyinfo.cpp b/libs/kuserfeedback/provider/core/surveyinfo.cpp deleted file mode 100644 index a05ff6ce33..0000000000 --- a/libs/kuserfeedback/provider/core/surveyinfo.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "surveyinfo.h" - -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -#include -#endif -#include -#include -#include - -using namespace UserFeedback; - -class UserFeedback::SurveyInfoData : public QSharedData -{ -public: - QUuid uuid; - QUrl url; - QString target; -}; - - -SurveyInfo::SurveyInfo() : d (new SurveyInfoData) -{ -} - -SurveyInfo::SurveyInfo(const SurveyInfo &other) : - d(other.d) -{ -} - -SurveyInfo::~SurveyInfo() -{ -} - -SurveyInfo& SurveyInfo::operator=(const SurveyInfo &other) -{ - d = other.d; - return *this; -} - -bool SurveyInfo::isValid() const -{ - return !d->uuid.isNull() && d->url.isValid(); -} - -QUuid SurveyInfo::uuid() const -{ - return d->uuid; -} - -void SurveyInfo::setUuid(const QUuid &id) -{ - d->uuid = id; -} - -QUrl SurveyInfo::url() const -{ - return d->url; -} - -void SurveyInfo::setUrl(const QUrl& url) -{ - d->url = url; -} - -QString SurveyInfo::target() const -{ - return d->target; -} - -void SurveyInfo::setTarget(const QString &target) -{ - d->target = target; -} - -SurveyInfo SurveyInfo::fromJson(const QJsonObject& obj) -{ - SurveyInfo s; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - s.setUuid(obj.value(QLatin1String("uuid")).toString()); - s.setUrl(QUrl(obj.value(QLatin1String("url")).toString())); - s.setTarget(obj.value(QLatin1String("target")).toString()); -#endif - return s; -} diff --git a/libs/kuserfeedback/provider/core/surveyinfo.h b/libs/kuserfeedback/provider/core/surveyinfo.h deleted file mode 100644 index def58c7858..0000000000 --- a/libs/kuserfeedback/provider/core/surveyinfo.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - Copyright (C) 2016 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_SURVEYINFO_H -#define USERFEEDBACK_SURVEYINFO_H - -#include "userfeedbackcore_export.h" - -#include - -QT_BEGIN_NAMESPACE -class QJsonObject; -class QUrl; -class QUuid; -QT_END_NAMESPACE - -namespace UserFeedback { - -class SurveyInfoData; - -/*! Information about a survey request. - * This class is implicitly shared. - */ -class USERFEEDBACKCORE_EXPORT SurveyInfo -{ -public: - /*! Create an empty, invalid survey request. */ - SurveyInfo(); - /*! Copy constructor. */ - SurveyInfo(const SurveyInfo&); - ~SurveyInfo(); - /*! Assignment operator. */ - SurveyInfo& operator=(const SurveyInfo&); - - /*! Returns @c true if this survey has all necessary information to actually execute it. */ - bool isValid() const; - - /*! Internal global unique id of the survey. - * Used to locally check if a user has completed the survey already. - */ - QUuid uuid() const; - - /*! The URL to the survey website. */ - QUrl url() const; - - /*! The survey targeting expression. */ - QString target() const; - - ///@cond internal - void setUuid(const QUuid &id); - void setUrl(const QUrl &url); - void setTarget(const QString &target); - static SurveyInfo fromJson(const QJsonObject &obj); - ///@endcond -private: - QSharedDataPointer d; -}; - -} - -#endif // USERFEEDBACK_SURVEYINFO_H diff --git a/libs/kuserfeedback/provider/core/usagetimesource.cpp b/libs/kuserfeedback/provider/core/usagetimesource.cpp deleted file mode 100644 index 1521808999..0000000000 --- a/libs/kuserfeedback/provider/core/usagetimesource.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library General Public - License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "usagetimesource.h" -#include "abstractdatasource_p.h" -#include "provider_p.h" - -#include - -using namespace UserFeedback; - -namespace UserFeedback { -class UsageTimeSourcePrivate : public AbstractDataSourcePrivate -{ -public: - UsageTimeSourcePrivate() : provider(nullptr) {} - ProviderPrivate *provider; -}; -} - -UsageTimeSource::UsageTimeSource() : - AbstractDataSource(QStringLiteral("usageTime"), new UsageTimeSourcePrivate) -{ -} - -QString UsageTimeSource::description() const -{ - return tr("The total amount of time the application has been used."); -} - -QVariant UsageTimeSource::data() -{ - Q_D(UsageTimeSource); - Q_ASSERT(d->provider); - - QVariantMap m; - m.insert(QStringLiteral("value"), d->provider->currentApplicationTime()); - return m; -} - -void UsageTimeSource::setProvider(ProviderPrivate* p) -{ - Q_D(UsageTimeSource); - d->provider = p; -} diff --git a/libs/kuserfeedback/provider/core/usagetimesource.h b/libs/kuserfeedback/provider/core/usagetimesource.h deleted file mode 100644 index 4faff74981..0000000000 --- a/libs/kuserfeedback/provider/core/usagetimesource.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright (C) 2017 Volker Krause - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library 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 Library 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 USERFEEDBACK_USAGETIMESOURCE_H -#define USERFEEDBACK_USAGETIMESOURCE_H - -#include "userfeedbackcore_export.h" -#include "abstractdatasource.h" - -namespace UserFeedback { - -class Provider; -class ProviderPrivate; -class UsageTimeSourcePrivate; - -/*! Data source reporting the total usage time of the application. */ -class USERFEEDBACKCORE_EXPORT UsageTimeSource : public AbstractDataSource -{ -public: - Q_DECLARE_TR_FUNCTIONS(UserFeedback::UsageTimeSource) -public: - /*! Create a new usage time data source. */ - UsageTimeSource(); - QString description() const override; - QVariant data() override; - -private: - Q_DECLARE_PRIVATE(UsageTimeSource) - friend class Provider; - void setProvider(ProviderPrivate *p); -}; - -} - -#endif // USERFEEDBACK_USAGETIMESOURCE_H