commit 04ca6caa819d46964dd955ea5dee3b0cfb728827 Author: tanius Date: Tue Jun 2 02:46:15 2020 +0200 initial commit Empty application template using the standard KDE CMake system. Builds on desktop Linux; should build on Android but untested. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9eaf29 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Ignore Qt Creator user settings. +# (As they can be burdensome to create, an example is provided in CMakeLists.txt.user.template.) +/CMakeLists.txt.user + +# Ignore build output, as configured in CMakeLists.txt.user.template. +/build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..02b063d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,58 @@ +cmake_minimum_required(VERSION 3.0) + +set(KF5_VERSION "5.47.0") # handled by release scripts +set(KF5_DEP_VERSION "5.47.0") # handled by release scripts + +project(foodrescue-app VERSION ${KF5_VERSION}) + +set(REQUIRED_QT_VERSION 5.8.0) + +SET(CMAKE_CXX_STANDARD 11) + +################# Disallow in-source build ################# + +if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + message(FATAL_ERROR "foodrescue-app requires an out of source build. Please create a separate build directory and run 'cmake path_to_kirigami [options]' there.") +endif() + +# Make CPack available to easy generate binary packages +include(CPack) +include(FeatureSummary) + +find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Gui Svg QuickControls2) + +set(CMAKE_AUTOMOC ON) +set(AUTOMOC_MOC_OPTIONS -Muri=org.kde.kirigami) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +################# set KDE specific information ################# + +find_package(ECM 5.47.0 NO_MODULE) +set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") + +# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH}) + +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings NO_POLICY_SCOPE) +include(ECMPoQmTools) +include(ECMQMLModules) + +if(CMAKE_SYSTEM_NAME STREQUAL "Android") + find_package(Qt5AndroidExtras ${REQUIRED_QT_VERSION} REQUIRED) +endif() + + +ecm_find_qmlmodule(QtGraphicalEffects 1.0) + +add_definitions(-DQT_NO_URL_CAST_FROM_STRING) + +add_subdirectory(src) + +if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") + ecm_install_po_files_as_qm(po) +endif() + +feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) + diff --git a/CMakeLists.txt.user.template b/CMakeLists.txt.user.template new file mode 100644 index 0000000..a477e01 --- /dev/null +++ b/CMakeLists.txt.user.template @@ -0,0 +1,282 @@ + + + + + + EnvironmentId + {260b20d3-159d-4ccf-aece-265ee3167f2f} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + true + true + true + true + + 0 + true + + true + Builtin.Questionable + + true + Builtin.DefaultTidyAndClazy + 2 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop (KDE kit, system Qt) + Desktop (KDE kit, system Qt) + {e4b5adc8-36e6-4796-9cab-958c3876147a} + 1 + 0 + 0 + + + CMAKE_BUILD_TYPE:STRING=Debug + CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++ + CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + 2 + /home/matthias/Projects/Fairdirect.Food_Rescue_App/Repo.foodrescue-app/build/Desktop.KDE_kit+system_Qt.Debug + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=Release + CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} + CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} + QT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + + 2 + /home/matthias/Projects/Fairdirect.Food_Rescue_App/Repo.foodrescue-app/build/Desktop.KDE_kit+system_Qt.Release + + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + CMakeProjectManager.CMakeBuildConfiguration + + 2 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + foodrescue + CMakeProjectManager.CMakeRunConfiguration.foodrescue + foodrescue + + false + + false + true + true + false + false + true + + /home/matthias/Projects/Fairdirect.Food_Rescue_App/Repo.foodrescue-app/build/Desktop.KDE_kit+system_Qt.Release/bin + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/metadata.desktop b/metadata.desktop new file mode 100644 index 0000000..e3559b4 --- /dev/null +++ b/metadata.desktop @@ -0,0 +1,24 @@ +[Desktop Entry] +Name=Food Rescue +Name[de]=LebensmittelRetter +GenericName=Food Rescue Information Browser +GenericName[de]=Lebensmittel-Haltbarkeits-Informierer +Comment=Helps to assess if food is still edible. +Comment[de]=Hilft zu entscheiden, ob Lebensmittel noch essbar sind. + +Type=Application +Exec=foodrescue +Icon=preferences-desktop-theme +Categories=Qt;KDE; + +X-KDE-ParentApp= +X-KDE-PluginInfo-Author=Matthias Ansorg +X-KDE-PluginInfo-Email=matthias@ansorgs.de +X-KDE-PluginInfo-Name=org.fairdirect.foodrescue +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website= +X-KDE-PluginInfo-Category= +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License= +X-KDE-PluginInfo-EnabledByDefault=false +X-Plasma-MainScript= diff --git a/org.fairdirect.foodrescue.appdata.xml b/org.fairdirect.foodrescue.appdata.xml new file mode 100644 index 0000000..6cc4e78 --- /dev/null +++ b/org.fairdirect.foodrescue.appdata.xml @@ -0,0 +1,45 @@ + + + org.fairdirect.foodrescue + FSFAP + MIT + + Food Rescue + Lebensmittel-Rettung + + Helps to assess if food is still edible. + Hilft zu entscheiden, ob Lebensmittel noch essbar sind. + + +

See https://fairdirect.org/food-rescue-app

+

Siehe https://fairdirect.org/realmhd-app

+
+ + https://fairdirect.org/food-rescue-app + https://github.com/fairdirect/foodrescue-app/issues + + + Matthias Ansorg <matthias@ansorgs.de> + + preferences-desktop-theme + + org.fairirect.foodrescue.desktop + + + + + + + + + + + foodrescue + + + KDE +
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..1095268 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,86 @@ +# ------------------------- BEGIN: lists to maintain manually ------------------------- + +# Define the application source files to be compiled. +set(foodrescue_SRCS + main.cpp +) + +# Define Qt Resource Collection (.qrc) files, to include the resource files listed there. +qt5_add_resources(RESOURCES + resources.qrc +) + +# Define libraries to link statically with the application. +# (Needed on Android only, as desktop systems should supply these system-wide.) +if (CMAKE_SYSTEM_NAME STREQUAL "Android") + find_package(KF5Kirigami2 ${KF5_DEP_VERSION}) + set(foodrescue_EXTRA_LIBS Qt5::AndroidExtras + KF5::Kirigami2 + # FIXME: Linking with QQC2 should not be needed. But if we don't, the lib will not be + # included into the Android APK package. + Qt5::QuickControls2 + ) +endif() + +# Include in-use icons with the Android APK package. +if (CMAKE_SYSTEM_NAME STREQUAL "Android") + find_package(KF5Kirigami2 REQUIRED) + kirigami_package_breeze_icons(ICONS + applications-graphics + configure + ) +endif() + +# ------------------------- END: lists to maintain manually ------------------------- + + +# Generate KDE AppStream meta information about the application, to integrate it with KDE. +# (This is not an essential build step though. Disable when not working.) +find_program(kpackagetool_cmd kpackagetool5) +if (kpackagetool_cmd) + set(component org.fairdirect.foodrescue) + set(APPDATAFILE "${CMAKE_CURRENT_BINARY_DIR}/${component}.appdata.xml") + + message(STATUS "${kpackagetool_cmd} --appstream-metainfo ${CMAKE_CURRENT_SOURCE_DIR}/data --appstream-metainfo-output ${APPDATAFILE}") + execute_process( + COMMAND ${kpackagetool_cmd} --appstream-metainfo ${CMAKE_CURRENT_SOURCE_DIR} --appstream-metainfo-output ${APPDATAFILE} + ERROR_VARIABLE appstreamerror + RESULT_VARIABLE result + ) + + if (NOT result EQUAL 0) + message(WARNING "couldn't generate metainfo for ${component}: ${appstreamerror}") + else() + if(appstreamerror) + message(WARNING "warnings during generation of metainfo for ${component}: ${appstreamerror}") + endif() + + install( + FILES ${APPDATAFILE} + DESTINATION ${KDE_INSTALL_METAINFODIR} + OPTIONAL # Because "NoDisplay" .desktop files will render no XML. + ) + endif() +else() + message(WARNING "Could not find command kpackagetool5. Appstream information won't be generated for ${component}.") +endif() + +# Define the name of the executable. +add_executable(foodrescue ${foodrescue_SRCS} ${RESOURCES}) + +# Link all required libraries with the executable. +target_link_libraries(foodrescue + Qt5::Core + Qt5::Qml + Qt5::Quick + Qt5::Svg + ${foodrescue_EXTRA_LIBS} +) + +# What files to install during deploys (the executable and KDE's .desktop file). +install(TARGETS foodrescue ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) +install( + FILES metadata.desktop + DESTINATION ${XDG_APPS_INSTALL_DIR} + RENAME org.fairdirect.foodrescue.desktop +) diff --git a/src/android/AndroidManifest.xml b/src/android/AndroidManifest.xml new file mode 100644 index 0000000..5649945 --- /dev/null +++ b/src/android/AndroidManifest.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..569f693 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,41 @@ +#ifdef Q_OS_ANDROID + #include + #include +#else + #include +#endif + +#include + + +int main(int argc, char *argv[]) { + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + + #ifdef Q_OS_ANDROID + QGuiApplication app(argc, argv); + #else + // Our QuickControls2 style for desktops requires a QApplication. + QApplication app(argc, argv); + #endif + + QQmlApplicationEngine engine; + + // Use different main files on desktop vs. mobile platform. + // FIXME: Switch to the "qrc:/something" URLs if possible. So far not working. + const QUrl desktopQML(QStringLiteral("qrc:///qml/BaseApp.qml")); + const QUrl mobileQML(QStringLiteral("qrc:///qml/MobileApp.qml")); + const bool QQC_MOBILE_SET(qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_MOBILE")); + const QString QQC_MOBILE(QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_MOBILE"))); + if (QQC_MOBILE_SET && (QQC_MOBILE == QStringLiteral("1") || QQC_MOBILE == QStringLiteral("true"))) { + engine.load(mobileQML); + } else { + engine.load(desktopQML); + } + + if (engine.rootObjects().isEmpty()) { + QCoreApplication::exit(-1); + } + + return app.exec(); +} diff --git a/src/metadata.desktop b/src/metadata.desktop new file mode 100644 index 0000000..e3559b4 --- /dev/null +++ b/src/metadata.desktop @@ -0,0 +1,24 @@ +[Desktop Entry] +Name=Food Rescue +Name[de]=LebensmittelRetter +GenericName=Food Rescue Information Browser +GenericName[de]=Lebensmittel-Haltbarkeits-Informierer +Comment=Helps to assess if food is still edible. +Comment[de]=Hilft zu entscheiden, ob Lebensmittel noch essbar sind. + +Type=Application +Exec=foodrescue +Icon=preferences-desktop-theme +Categories=Qt;KDE; + +X-KDE-ParentApp= +X-KDE-PluginInfo-Author=Matthias Ansorg +X-KDE-PluginInfo-Email=matthias@ansorgs.de +X-KDE-PluginInfo-Name=org.fairdirect.foodrescue +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website= +X-KDE-PluginInfo-Category= +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License= +X-KDE-PluginInfo-EnabledByDefault=false +X-Plasma-MainScript= diff --git a/src/qml/BaseApp.qml b/src/qml/BaseApp.qml new file mode 100644 index 0000000..c992635 --- /dev/null +++ b/src/qml/BaseApp.qml @@ -0,0 +1,33 @@ +import QtQuick 2.1 +import QtQuick.Controls 2.0 as Controls +import QtQuick.Layouts 1.2 +import org.kde.kirigami 2.4 as Kirigami + +// Content of the main application window. +// (Used as-is on desktop. For mobile, wrapped via MobileApp.qml.) +Kirigami.ApplicationWindow { + id: root + + // Main content area. + pageStack.initialPage: mainAreaComponent + Component { + id: mainAreaComponent + MainArea {} // See MainArea.qml. + } + + // Left sidebar drawer with the menu. + globalDrawer: Kirigami.GlobalDrawer { + title: "Global Drawer" + titleIcon: "applications-graphics" + + actions: [ + Kirigami.Action { + text: "Menu Entry" + icon { + name: "configure" + color: Kirigami.Theme.activeTextColor + } + } + ] + } +} diff --git a/src/qml/MainArea.qml b/src/qml/MainArea.qml new file mode 100644 index 0000000..fac9170 --- /dev/null +++ b/src/qml/MainArea.qml @@ -0,0 +1,41 @@ +import QtQuick 2.1 +import QtQuick.Controls 2.0 as QQC2 +import QtQuick.Layouts 1.2 +import org.kde.kirigami 2.4 as Kirigami + +Kirigami.ScrollablePage { + id: pageRoot + + title: qsTr("Empty App") + + background: Rectangle { + color: Kirigami.Theme.backgroundColor + } + implicitWidth: Kirigami.Units.gridUnit * 12 // Subdivides available for sizing things. + + ListView { + id: mainAreaList + + currentIndex: -1 // Don't show any list item as "selected". + focus: true + + model: ListModel { + ListElement { + text: qsTr("List Item 1") + } + ListElement { + text: qsTr("List Item 2") + } + ListElement { + text: qsTr("List Item 3") + } + } + + delegate: Kirigami.BasicListItem { + id: listItem + label: model.text + highlighted: focus && ListView.isCurrentItem + checked: mainAreaList.openPageIndex === index + } + } +} diff --git a/src/qml/MobileApp.qml b/src/qml/MobileApp.qml new file mode 100644 index 0000000..1d221ee --- /dev/null +++ b/src/qml/MobileApp.qml @@ -0,0 +1,14 @@ +import QtQuick 2.1 +import QtQuick.Controls 2.0 as Controls +import QtQuick.Layouts 1.2 +import org.kde.kirigami 2.4 as Kirigami + +// Content of the main application window for the mobile version. +// (Same for the desktop version in BaseApp.qml, plus an added contextDrawer.) +BaseApp { + id: root + + contextDrawer: Kirigami.ContextDrawer { + id: contextDrawer + } +} diff --git a/src/qtquickcontrols2.conf b/src/qtquickcontrols2.conf new file mode 100644 index 0000000..ae54427 --- /dev/null +++ b/src/qtquickcontrols2.conf @@ -0,0 +1,14 @@ +[Universal] +Primary=#7f6bf3 +Accent=#7f6bf3 +Theme=System + +[Material] +Primary=#7f6bf3 +Accent=#7f6bf3 +Theme=System + +[Default] +Primary=#7f6bf3 +Accent=#7f6bf3 +Theme=System diff --git a/src/resources.qrc b/src/resources.qrc new file mode 100644 index 0000000..7dbeb65 --- /dev/null +++ b/src/resources.qrc @@ -0,0 +1,9 @@ + + + qml/MainArea.qml + qml/BaseApp.qml + qml/MobileApp.qml + qtquickcontrols2.conf + metadata.desktop + +