Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Unverified Commit a07f2ac3 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

Restructure project based on hellokirigami template

parent aeb72590
project(plasma-camera) project(plasma-camera)
cmake_minimum_required(VERSION 2.8.12) 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(CPack)
include(FeatureSummary) include(FeatureSummary)
find_package(PkgConfig)
################# set KDE specific information ################# ################# set KDE specific information #################
...@@ -13,17 +22,35 @@ find_package(ECM 0.0.8 REQUIRED NO_MODULE) ...@@ -13,17 +22,35 @@ find_package(ECM 0.0.8 REQUIRED NO_MODULE)
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked # 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}) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
include(ECMSetupVersion)
include(ECMGenerateHeaders)
include(KDEInstallDirs) include(KDEInstallDirs)
include(KDECMakeSettings) 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 Multimedia)
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") install(PROGRAMS org.kde.plasma-camera.desktop DESTINATION ${KDE_INSTALL_APPDIR})
find_package(KF5Kirigami2 REQUIRED)
find_package(KF5 REQUIRED COMPONENTS
Package)
kpackage_install_package(package org.kde.phone.camera genericqml) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
install(FILES package/metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.phone.camera.desktop)
[Desktop Entry]
Name=Camera
Comment=Take photos and record videos
Version=1.0
Exec=plasma-camera
Icon=camera-photo
Type=Application
Terminal=false
Categories=Qt;KDE;
[Dolphin]
Timestamp=2015,7,15,15,36,31
Version=3
[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=
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})
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2018 Jonah Brüchert ** Copyright (C) 2018 Jonah Brüchert
...@@ -36,7 +37,6 @@ ...@@ -36,7 +37,6 @@
** $QT_END_LICENSE$ ** $QT_END_LICENSE$
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.7 import QtQuick 2.7
import QtMultimedia 5.8 import QtMultimedia 5.8
import org.kde.kirigami 2.0 as Kirigami import org.kde.kirigami 2.0 as Kirigami
...@@ -75,20 +75,18 @@ Kirigami.Page { ...@@ -75,20 +75,18 @@ Kirigami.Page {
if (camera.captureMode == Camera.CaptureStillImage) { if (camera.captureMode == Camera.CaptureStillImage) {
camera.imageCapture.capture() camera.imageCapture.capture()
showPassiveNotification(qsTr("Took a photo")) showPassiveNotification(qsTr("Took a photo"))
} } else if (camera.videoRecorder.recorderStatus == CameraRecorder.RecordingStatus) {
else if (camera.videoRecorder.recorderStatus == CameraRecorder.RecordingStatus) {
camera.videoRecorder.stop() camera.videoRecorder.stop()
recordingFeedback.visible = false recordingFeedback.visible = false
showPassiveNotification(qsTr("Stopped recording")) showPassiveNotification(qsTr("Stopped recording"))
} } else if (camera.captureMode == Camera.CaptureVideo) {
else if (camera.captureMode == Camera.CaptureVideo) {
camera.videoRecorder.record() camera.videoRecorder.record()
recordingFeedback.visible = true recordingFeedback.visible = true
showPassiveNotification(qsTr("Started recording")) showPassiveNotification(qsTr("Started recording"))
} }
} }
} }
leftAction: Kirigami.Action { leftAction: Kirigami.Action {
id: switchAction id: switchAction
text: qsTr("Switch mode") text: qsTr("Switch mode")
...@@ -98,7 +96,7 @@ Kirigami.Page { ...@@ -98,7 +96,7 @@ Kirigami.Page {
camera.captureMode = Camera.CaptureVideo camera.captureMode = Camera.CaptureVideo
else else
camera.captureMode = Camera.CaptureStillImage camera.captureMode = Camera.CaptureStillImage
console.log("Capture Mode switched") console.log("Capture Mode switched")
} }
} }
...@@ -132,7 +130,6 @@ Kirigami.Page { ...@@ -132,7 +130,6 @@ Kirigami.Page {
camera.start() camera.start()
} }
} }
} }
] ]
...@@ -155,8 +152,9 @@ Kirigami.Page { ...@@ -155,8 +152,9 @@ Kirigami.Page {
VideoOutput { VideoOutput {
id: viewfinder id: viewfinder
visible: cameraUI.state == "PhotoCapture" || cameraUI.state == "VideoCapture" visible: cameraUI.state == "PhotoCapture"
|| cameraUI.state == "VideoCapture"
// Workaround // Workaround
orientation: Kirigami.Settings.isMobile ? -90 : 0 orientation: Kirigami.Settings.isMobile ? -90 : 0
...@@ -169,11 +167,13 @@ Kirigami.Page { ...@@ -169,11 +167,13 @@ Kirigami.Page {
anchors.fill: parent anchors.fill: parent
property real initialZoom property real initialZoom
onPinchStarted: { onPinchStarted: {
initialZoom = camera.digitalZoom; initialZoom = camera.digitalZoom
} }
onPinchUpdated: { onPinchUpdated: {
var scale = camera.maximumDigitalZoom / 8 * pinch.scale - camera.maximumDigitalZoom / 8; var scale = camera.maximumDigitalZoom / 8 * pinch.scale
camera.setDigitalZoom(Math.min(camera.maximumDigitalZoom, camera.digitalZoom + scale)) - camera.maximumDigitalZoom / 8
camera.setDigitalZoom(Math.min(camera.maximumDigitalZoom,
camera.digitalZoom + scale))
} }
} }
...@@ -182,11 +182,10 @@ Kirigami.Page { ...@@ -182,11 +182,10 @@ Kirigami.Page {
onClicked: { onClicked: {
if (camera.lockStatus == Camera.Unlocked) { if (camera.lockStatus == Camera.Unlocked) {
camera.searchAndLock(); camera.searchAndLock()
console.log("searching focus...") console.log("searching focus...")
} } else {
else { camera.unlock()
camera.unlock();
console.log("unlocking focus...") console.log("unlocking focus...")
} }
} }
......
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2018 Jonah Brüchert ** Copyright (C) 2018 Jonah Brüchert
...@@ -36,10 +37,9 @@ ...@@ -36,10 +37,9 @@
** $QT_END_LICENSE$ ** $QT_END_LICENSE$
** **
****************************************************************************/ ****************************************************************************/
import org.kde.kirigami 2.0 as Kirigami import org.kde.kirigami 2.0 as Kirigami
import QtQuick 2.7 import QtQuick 2.7
import QtQml.Models 2.2 import QtQml 2.2
import QtMultimedia 5.8 import QtMultimedia 5.8
Kirigami.GlobalDrawer { Kirigami.GlobalDrawer {
...@@ -47,42 +47,43 @@ Kirigami.GlobalDrawer { ...@@ -47,42 +47,43 @@ Kirigami.GlobalDrawer {
Kirigami.Action { Kirigami.Action {
text: qsTr("Camera") text: qsTr("Camera")
iconName: "camera-photo" iconName: "camera-photo"
DelegateModel { Instantiator {
model: QtMultimedia.availableCameras model: QtMultimedia.availableCameras
onObjectAdded: console.log("object added: " + object.text)
delegate: Kirigami.Action { delegate: Kirigami.Action {
text: model.displayName text: modelData.displayName
onTriggered: settings.cameraDeviceId = model.deviceId onTriggered: settings.cameraDeviceId = modelData.deviceId
} }
} }
}, },
Kirigami.Action { Kirigami.Action {
text: qsTr("Video resolution") text: qsTr("Photo resolution")
iconName: "ratiocrop" iconName: "ratiocrop"
DelegateModel { Instantiator {
model: CameraRecorder.supportedResolutions model: CameraCapture.supportedResolutions
delegate: Kirigami.Action { delegate: Kirigami.Action {
text: model text: modelData
onTriggered: settings.videoResolution = text; onTriggered: settings.photoResolution = text
} }
} }
}, },
Kirigami.Action { Kirigami.Action {
text: qsTr("Photo resolution") text: qsTr("Video resolution")
iconName: "ratiocrop" iconName: "ratiocrop"
DelegateModel { Instantiator {
model: CameraCapture.supportedResolutions model: CameraCapture.supportedResolutions
delegate: Kirigami.Action { delegate: Kirigami.Action {
text: model text: modelData
onTriggered: settings.photoResolution = text; onTriggered: settings.videoResolution = text
} }
} }
}, },
Kirigami.Action { Kirigami.Action {
id: wbaction
text: qsTr("White balance") text: qsTr("White balance")
iconName: "whitebalance" iconName: "whitebalance"
Kirigami.Action { Kirigami.Action {
iconName: "images/camera_auto_mode.png" iconName: "images/camera_auto_mode.png"
onTriggered: settings.whiteBalanceMode = CameraImageProcessing.WhiteBalanceAuto onTriggered: settings.whiteBalanceMode = CameraImageProcessing.WhiteBalanceAuto
text: qsTr("Auto") text: qsTr("Auto")
} }
...@@ -103,7 +104,8 @@ Kirigami.GlobalDrawer { ...@@ -103,7 +104,8 @@ Kirigami.GlobalDrawer {
} }
Kirigami.Action { Kirigami.Action {
iconName: "images/camera_white_balance_flourescent.png" iconName: "images/camera_white_balance_flourescent.png"
onTriggered: settings.whiteBalanceMode = CameraImageProcessing.WhiteBalanceFluorescent onTriggered: settings.whiteBalanceMode
= CameraImageProcessing.WhiteBalanceFluorescent
text: qsTr("Fluorescent") text: qsTr("Fluorescent")
} }
} }
......
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2018 Jonah Brüchert ** Copyright (C) 2018 Jonah Brüchert
...@@ -36,7 +37,6 @@ ...@@ -36,7 +37,6 @@
** $QT_END_LICENSE$ ** $QT_END_LICENSE$
** **
****************************************************************************/ ****************************************************************************/
import QtQuick 2.7 import QtQuick 2.7
import org.kde.kirigami 2.2 as Kirigami import org.kde.kirigami 2.2 as Kirigami
import Qt.labs.settings 1.0 import Qt.labs.settings 1.0
...@@ -45,7 +45,7 @@ import QtMultimedia 5.8 ...@@ -45,7 +45,7 @@ import QtMultimedia 5.8
Kirigami.ApplicationWindow { Kirigami.ApplicationWindow {
Settings { Settings {
id: settings id: settings
// Default settings // Default settings
property size videoResolution: Qt.size(640, 480) property size videoResolution: Qt.size(640, 480)
property size photoResolution property size photoResolution
...@@ -53,11 +53,16 @@ Kirigami.ApplicationWindow { ...@@ -53,11 +53,16 @@ Kirigami.ApplicationWindow {
property int whiteBalanceMode: CameraImageProcessing.WhiteBalanceAuto property int whiteBalanceMode: CameraImageProcessing.WhiteBalanceAuto
} }
Component {id: cameraPage; CameraPage {}} Component {
id: cameraPage
CameraPage {
}
}
id: root id: root
title: qsTr("Camera") title: qsTr("Camera")
globalDrawer: GlobalDrawer {} globalDrawer: GlobalDrawer {
}
pageStack.initialPage: cameraPage pageStack.initialPage: cameraPage
} }
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QtQml>
#include <QUrl>
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("Plasma Camera");
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty()) {
return -1;
}
int ret = app.exec();
return ret;
}
<RCC>
<qresource prefix="/">
<file alias="main.qml">contents/ui/main.qml</file>
<file alias="CameraPage.qml">contents/ui/CameraPage.qml</file>
<file alias="GlobalDrawer.qml">contents/ui/GlobalDrawer.qml</file>
<file alias="images/camera_auto_mode.png">contents/ui/images/camera_auto_mode.png</file>
<file alias="images/camera_camera_setting.png">contents/ui/images/camera_camera_setting.png</file>
<file alias="images/camera_flash_auto.png">contents/ui/images/camera_flash_auto.png</file>
<file alias="images/camera_white_balance_cloudy.png">contents/ui/images/camera_white_balance_cloudy.png</file>
<file alias="images/camera_white_balance_flourescent.png">contents/ui/images/camera_white_balance_flourescent.png</file>
<file alias="images/camera_white_balance_incandescent.png">contents/ui/images/camera_white_balance_incandescent.png</file>
<file alias="images/camera_flash_fill.png">contents/ui/images/camera_flash_fill.png</file>
<file alias="images/camera_flash_off.png">contents/ui/images/camera_flash_off.png</file>
<file alias="images/camera_flash_redeye.png">contents/ui/images/camera_flash_redeye.png</file>
<file alias="images/camera_white_balance_sunny.png">contents/ui/images/camera_white_balance_sunny.png</file>
</qresource>
</RCC>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment