diff --git a/CMakeLists.txt b/CMakeLists.txt index a86b173..e28e246 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,29 +1,56 @@ project(plasma-camera) cmake_minimum_required(VERSION 2.8.12) +set(KF5_MIN_VERSION "5.18.0") +set(QT_MIN_VERSION "5.5.0") +################# Disallow in-source build ################# + +if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + message(FATAL_ERROR "This application requires an out of source build. Please create a separate build directory.") +endif() + + +# Make CPack available to easy generate binary packages include(CPack) include(FeatureSummary) -find_package(PkgConfig) ################# set KDE specific information ################# find_package(ECM 0.0.8 REQUIRED NO_MODULE) # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) +include(ECMSetupVersion) +include(ECMGenerateHeaders) include(KDEInstallDirs) include(KDECMakeSettings) -include(KDECompilerSettings) +include(ECMPoQmTools) +include(KDECompilerSettings NO_POLICY_SCOPE) + +set(KF5_VERSION "5.22.0") + +find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Svg QuickControls2) + +find_package(KF5Kirigami2 ${KF5_DEP_VERSION} "5.22.0") + +################# Enable C++11 features for clang and gcc ################# + +if(UNIX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++0x") +endif() + +################# now find all used packages ################# + +set (QT_MIN_VERSION "5.6.0") + +find_package(PkgConfig) +######################################################################### -# find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui) +add_subdirectory(src) -set (QT_MIN_VERSION "5.9.0") -find_package(KF5Kirigami2 REQUIRED) -find_package(KF5 REQUIRED COMPONENTS - Package) +install(PROGRAMS org.kde.phone.camera.desktop DESTINATION ${KDE_INSTALL_APPDIR}) -kpackage_install_package(package org.kde.phone.camera genericqml) -install(FILES package/metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.phone.camera.desktop) +feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/org.kde.phone.camera.desktop b/org.kde.phone.camera.desktop new file mode 100644 index 0000000..ca64a7c --- /dev/null +++ b/org.kde.phone.camera.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Comment= +Encoding=UTF-8 +Keywords= +Name=Camera +Type=Application +Icon=camera-photo +Exec=plasma-camera +X-KDE-PluginInfo-Author=Marco Martin +X-KDE-PluginInfo-Category=Miscellaneous +X-KDE-PluginInfo-Email=mart@kde.org +X-KDE-PluginInfo-License=GPL diff --git a/package/metadata.desktop b/package/metadata.desktop deleted file mode 100644 index 409fa8e..0000000 --- a/package/metadata.desktop +++ /dev/null @@ -1,20 +0,0 @@ -[Desktop Entry] -Comment= -Encoding=UTF-8 -Keywords= -Name=Camera -Type=Application -Icon=camera-photo -Exec=kpackagelauncherqml -a org.kde.phone.camera -X-KDE-ParentApp= -X-KDE-PluginInfo-Author=Marco Martin -X-KDE-PluginInfo-Category=Miscellaneous -X-KDE-PluginInfo-Email=mart@kde.org -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-Name=org.kde.phone.camera -X-KDE-PluginInfo-Version= -X-KDE-PluginInfo-Website= -X-KDE-ServiceTypes=KPackage/GenericQML - -X-Plasma-MainScript=ui/main.qml -X-Plasma-RemoteLocation= diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..e383ca0 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,8 @@ +set(plasma-camera_SRCS + main.cpp + ) + +qt5_add_resources(RESOURCES resources.qrc) +add_executable(plasma-camera ${plasma-camera_SRCS} ${RESOURCES}) +target_link_libraries(plasma-camera Qt5::Core Qt5::Qml Qt5::Quick Qt5::Svg) +install(TARGETS plasma-camera ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/package/contents/ui/AboutDialog.qml b/src/contents/ui/AboutDialog.qml similarity index 100% rename from package/contents/ui/AboutDialog.qml rename to src/contents/ui/AboutDialog.qml diff --git a/package/contents/ui/CameraPage.qml b/src/contents/ui/CameraPage.qml similarity index 100% rename from package/contents/ui/CameraPage.qml rename to src/contents/ui/CameraPage.qml diff --git a/package/contents/ui/GlobalDrawer.qml b/src/contents/ui/GlobalDrawer.qml similarity index 94% rename from package/contents/ui/GlobalDrawer.qml rename to src/contents/ui/GlobalDrawer.qml index 4624885..8281a37 100644 --- a/package/contents/ui/GlobalDrawer.qml +++ b/src/contents/ui/GlobalDrawer.qml @@ -1,151 +1,151 @@ /**************************************************************************** ** ** Copyright (C) 2018 Jonah BrĂ¼chert ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names ** of its contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ import org.kde.kirigami 2.0 as Kirigami import QtQuick 2.7 import QtMultimedia 5.8 Kirigami.GlobalDrawer { Component { id: devicesSubAction Kirigami.Action { property string value onTriggered: { settings.cameraDeviceId = value } } } Component { id: resolutionSubAction Kirigami.Action { property size value onTriggered: { settings.resolution = value } } } actions: [ Kirigami.Action { id: devicesAction text: qsTr("Camera") iconName: "camera-photo" Component.onCompleted: { var cameras = QtMultimedia.availableCameras var childrenList = [] for (var i in cameras) { childrenList[i] = devicesSubAction.createObject(devicesAction, { value: cameras[i].deviceId, text: "%1".arg(cameras[i].displayName) }) devicesAction.children = childrenList } } }, Kirigami.Action { id: resolutionAction text: qsTr("Resolution") iconName: "ratiocrop" Component.onCompleted: { var resolutions = camera.imageCapture.supportedResolutions var childrenList = [] for (var i in resolutions) { var pixels = resolutions[i].width * resolutions[i].height var megapixels = Math.round(pixels / 10000) / 100 childrenList[i] = resolutionSubAction.createObject(resolutionAction, { value: resolutions[i], text: "%1 x %2 (%3 MP)".arg(resolutions[i].width).arg(resolutions[i].height).arg(megapixels) }) resolutionAction.children = childrenList } } }, Kirigami.Action { id: wbaction text: qsTr("White balance") iconName: "whitebalance" Kirigami.Action { - iconName: "images/camera_auto_mode.png" + iconName: "camera_auto_mode" onTriggered: settings.whiteBalanceMode = CameraImageProcessing.WhiteBalanceAuto text: qsTr("Auto") } Kirigami.Action { - iconName: "images/camera_white_balance_sunny.png" + iconName: "camera_white_balance_sunny" onTriggered: settings.whiteBalanceMode = CameraImageProcessing.WhiteBalanceSunlight text: qsTr("Sunlight") } Kirigami.Action { - iconName: "images/camera_white_balance_cloudy.png" + iconName: "camera_white_balance_cloudy" onTriggered: settings.whiteBalanceMode = CameraImageProcessing.WhiteBalanceCloudy text: qsTr("Cloudy") } Kirigami.Action { - iconName: "images/camera_white_balance_incandescent.png" + iconName: "camera_white_balance_incandescent" onTriggered: settings.whiteBalanceMode = CameraImageProcessing.WhiteBalanceTungsten text: qsTr("Tungsten") } Kirigami.Action { - iconName: "images/camera_white_balance_flourescent.png" + iconName: "camera_white_balance_flourescent" onTriggered: settings.whiteBalanceMode = CameraImageProcessing.WhiteBalanceFluorescent text: qsTr("Fluorescent") } }, Kirigami.Action { text: qsTr("About") iconName: "help-about" onTriggered: { aboutDialog.open(); } } ] Camera { id: camera deviceId: settings.cameraDeviceId } } diff --git a/package/contents/ui/ZoomControl.qml b/src/contents/ui/ZoomControl.qml similarity index 100% rename from package/contents/ui/ZoomControl.qml rename to src/contents/ui/ZoomControl.qml diff --git a/package/contents/ui/declarative-camera.qmlproject b/src/contents/ui/declarative-camera.qmlproject similarity index 100% rename from package/contents/ui/declarative-camera.qmlproject rename to src/contents/ui/declarative-camera.qmlproject diff --git a/package/contents/ui/images/.directory b/src/contents/ui/images/.directory similarity index 100% rename from package/contents/ui/images/.directory rename to src/contents/ui/images/.directory diff --git a/package/contents/ui/images/camera_auto_mode.png b/src/contents/ui/images/camera_auto_mode.png similarity index 100% rename from package/contents/ui/images/camera_auto_mode.png rename to src/contents/ui/images/camera_auto_mode.png diff --git a/package/contents/ui/images/camera_camera_setting.png b/src/contents/ui/images/camera_camera_setting.png similarity index 100% rename from package/contents/ui/images/camera_camera_setting.png rename to src/contents/ui/images/camera_camera_setting.png diff --git a/package/contents/ui/images/camera_flash_auto.png b/src/contents/ui/images/camera_flash_auto.png similarity index 100% rename from package/contents/ui/images/camera_flash_auto.png rename to src/contents/ui/images/camera_flash_auto.png diff --git a/package/contents/ui/images/camera_flash_fill.png b/src/contents/ui/images/camera_flash_fill.png similarity index 100% rename from package/contents/ui/images/camera_flash_fill.png rename to src/contents/ui/images/camera_flash_fill.png diff --git a/package/contents/ui/images/camera_flash_off.png b/src/contents/ui/images/camera_flash_off.png similarity index 100% rename from package/contents/ui/images/camera_flash_off.png rename to src/contents/ui/images/camera_flash_off.png diff --git a/package/contents/ui/images/camera_flash_redeye.png b/src/contents/ui/images/camera_flash_redeye.png similarity index 100% rename from package/contents/ui/images/camera_flash_redeye.png rename to src/contents/ui/images/camera_flash_redeye.png diff --git a/package/contents/ui/images/camera_white_balance_cloudy.png b/src/contents/ui/images/camera_white_balance_cloudy.png similarity index 100% rename from package/contents/ui/images/camera_white_balance_cloudy.png rename to src/contents/ui/images/camera_white_balance_cloudy.png diff --git a/package/contents/ui/images/camera_white_balance_flourescent.png b/src/contents/ui/images/camera_white_balance_flourescent.png similarity index 100% rename from package/contents/ui/images/camera_white_balance_flourescent.png rename to src/contents/ui/images/camera_white_balance_flourescent.png diff --git a/package/contents/ui/images/camera_white_balance_incandescent.png b/src/contents/ui/images/camera_white_balance_incandescent.png similarity index 100% rename from package/contents/ui/images/camera_white_balance_incandescent.png rename to src/contents/ui/images/camera_white_balance_incandescent.png diff --git a/package/contents/ui/images/camera_white_balance_sunny.png b/src/contents/ui/images/camera_white_balance_sunny.png similarity index 100% rename from package/contents/ui/images/camera_white_balance_sunny.png rename to src/contents/ui/images/camera_white_balance_sunny.png diff --git a/package/contents/ui/main.qml b/src/contents/ui/main.qml similarity index 100% rename from package/contents/ui/main.qml rename to src/contents/ui/main.qml diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..142a474 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +Q_DECL_EXPORT int main(int argc, char *argv[]) +{ + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication app(argc, argv); + QCoreApplication::setOrganizationName("KDE"); + QCoreApplication::setOrganizationDomain("kde.org"); + QCoreApplication::setApplicationName("phone.camera"); + + QQmlApplicationEngine engine; + + engine.load(QUrl(QStringLiteral("qrc:///main.qml"))); + + if (engine.rootObjects().isEmpty()) { + return -1; + } + int ret = app.exec(); + return ret; +} diff --git a/src/resources.qrc b/src/resources.qrc new file mode 100644 index 0000000..eb6993a --- /dev/null +++ b/src/resources.qrc @@ -0,0 +1,20 @@ + + + contents/ui/main.qml + contents/ui/GlobalDrawer.qml + contents/ui/CameraPage.qml + contents/ui/AboutDialog.qml + contents/ui/ZoomControl.qml + + contents/ui/images/camera_flash_off.png + contents/ui/images/camera_camera_setting.png + contents/ui/images/camera_auto_mode.png + contents/ui/images/camera_white_balance_sunny.png + contents/ui/images/camera_white_balance_incandescent.png + contents/ui/images/camera_flash_auto.png + contents/ui/images/camera_flash_redeye.png + contents/ui/images/camera_white_balance_cloudy.png + contents/ui/images/camera_white_balance_flourescent.png + contents/ui/images/camera_flash_fill.png + +