diff --git a/CMakeLists.txt b/CMakeLists.txt index 18fb763..b023e98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,16 +32,13 @@ else() set(CAMERA_OUTPUT_DIR "C:/temp/luneos-camera") endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -Wall -std=c++0x") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -Wall -std=c++1z") add_definitions(-DCAMERA_OUTPUT_DIR="${CAMERA_OUTPUT_DIR}") # Standard install paths. Needs to be set before finding packages. include(GNUInstallDirs) -find_package(Qt5Qml) -find_package(Qt5Quick) -find_package(Qt5Multimedia) -find_package(Qt5Gui) +find_package(Qt6 REQUIRED COMPONENTS Qml Quick Multimedia Gui ShaderTools) set(APP_DATA appinfo.json icon.png icon-256x256.png) set(PLUGIN_DIR ${APP_DIR}/CameraApp) @@ -56,4 +53,9 @@ install(DIRECTORY qml DESTINATION ${APP_DIR}) file(GLOB_RECURSE NON_COMPILED_FILES *.qml *.js *.svg *.png *.json *.sci qmldir) add_custom_target(NON_COMPILED_TARGET ALL SOURCES ${NON_COMPILED_FILES}) +qt6_add_shaders(org.webosports.app.camera "camera_shaders" + FILES + "qml/components/cornershader.frag" +) + add_subdirectory(CameraApp) diff --git a/CameraApp/CMakeLists.txt b/CameraApp/CMakeLists.txt index a9382d3..1b6de23 100644 --- a/CameraApp/CMakeLists.txt +++ b/CameraApp/CMakeLists.txt @@ -25,9 +25,9 @@ add_library(camera-qml MODULE ${plugin_SRCS} ${plugin_HDRS}) file(COPY qmldir DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(camera-qml - ${Qt5Qml_LIBRARIES} - ${Qt5Quick_LIBRARIES} - ${Qt5Multimedia_LIBRARIES} + ${Qt6Qml_LIBRARIES} + ${Qt6Quick_LIBRARIES} + ${Qt6Multimedia_LIBRARIES} ) install(TARGETS camera-qml DESTINATION ${PLUGIN_DIR}) diff --git a/CameraApp/advancedcamerasettings.cpp b/CameraApp/advancedcamerasettings.cpp index f1b7a57..12698f9 100644 --- a/CameraApp/advancedcamerasettings.cpp +++ b/CameraApp/advancedcamerasettings.cpp @@ -20,212 +20,65 @@ #include "advancedcamerasettings.h" #include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include + #include +#define SUPPORT_HDR_LUNEOS 0 + +#if SUPPORT_HDR_LUNEOS // Definition of this enum value is duplicated in qtubuntu-camera -static const QCameraExposure::ExposureMode ExposureHdr = static_cast(QCameraExposure::ExposureModeVendor + 1); +static const QCamera::ExposureMode ExposureHdr = static_cast(QCamera::ExposureBarcode + 1); +#endif AdvancedCameraSettings::AdvancedCameraSettings(QObject *parent) : QObject(parent), - m_cameraObject(0), - m_camera(0), - m_deviceSelector(0), - m_viewFinderControl(0), - m_cameraFlashControl(0), - m_cameraExposureControl(0), - m_imageEncoderControl(0), - m_videoEncoderControl(0), - m_cameraInfoControl(0), + m_captureSession(nullptr), m_hdrEnabled(false) { } -QCamera* AdvancedCameraSettings::cameraFromCameraObject(QObject* cameraObject) const -{ - QVariant cameraVariant = cameraObject->property("mediaObject"); - if (!cameraVariant.isValid()) { - qWarning() << "No valid mediaObject"; - return 0; - } - - QCamera *camera = qvariant_cast(cameraVariant); - if (camera == 0) { - qWarning() << "No valid camera passed"; - return 0; - } - - return camera; -} - -QMediaControl* AdvancedCameraSettings::mediaControlFromCamera(QCamera *camera, const char* iid) const +QMediaCaptureSession* AdvancedCameraSettings::captureSession() const { - if (camera == 0) { - return 0; - } - - QMediaService *service = camera->service(); - if (service == 0) { - qWarning() << "Camera has no Mediaservice"; - return 0; - } - - QMediaControl *control = service->requestControl(iid); - if (control == 0) { - qWarning() << "No media control support for" << iid; - return 0; - } - - return control; + return m_captureSession.get(); } -QVideoDeviceSelectorControl* AdvancedCameraSettings::selectorFromCamera(QCamera *camera) const +void AdvancedCameraSettings::setCaptureSession(QMediaCaptureSession *captureSession) { - QMediaControl *control = mediaControlFromCamera(camera, QVideoDeviceSelectorControl_iid); - if (control == 0) { - return 0; - } - - QVideoDeviceSelectorControl *selector = qobject_cast(control); - if (selector == 0) { - qWarning() << "No video device selector support"; - return 0; - } + if (captureSession != m_captureSession.get()) { + m_captureSession.reset(captureSession); - return selector; -} - -QCameraViewfinderSettingsControl* AdvancedCameraSettings::viewfinderFromCamera(QCamera *camera) const -{ - QMediaControl *control = mediaControlFromCamera(camera, QCameraViewfinderSettingsControl_iid); - if (control == 0) { - return 0; - } - - QCameraViewfinderSettingsControl *selector = qobject_cast(control); - if (selector == 0) { - qWarning() << "No viewfinder settings support"; - return 0; - } - - return selector; -} - -QCameraControl *AdvancedCameraSettings::camcontrolFromCamera(QCamera *camera) const -{ - QMediaControl *control = mediaControlFromCamera(camera, QCameraControl_iid); - if (control == 0) { - return 0; - } - - QCameraControl *camControl = qobject_cast(control); - if (camControl == 0) { - qWarning() << "No camera control support"; - return 0; - } - - return camControl; -} - -QCameraFlashControl *AdvancedCameraSettings::flashControlFromCamera(QCamera *camera) const -{ - QMediaControl *control = mediaControlFromCamera(camera, QCameraFlashControl_iid); - QCameraFlashControl *flashControl = qobject_cast(control); - - if (flashControl == 0) { - qWarning() << "No flash control support"; - } - - return flashControl; -} - -QCameraExposureControl* AdvancedCameraSettings::exposureControlFromCamera(QCamera *camera) const -{ - QMediaControl *control = mediaControlFromCamera(camera, QCameraExposureControl_iid); - QCameraExposureControl *exposureControl = qobject_cast(control); - - if (exposureControl == 0) { - qWarning() << "No exposure control support"; - } - - return exposureControl; -} - -QImageEncoderControl* AdvancedCameraSettings::imageEncoderControlFromCamera(QCamera *camera) const -{ - QMediaControl *control = mediaControlFromCamera(camera, QImageEncoderControl_iid); - QImageEncoderControl *imageEncoderControl = qobject_cast(control); - - if (imageEncoderControl == 0) { - qWarning() << "No image encoder control support"; - } - - return imageEncoderControl; -} - -QVideoEncoderSettingsControl* AdvancedCameraSettings::videoEncoderControlFromCamera(QCamera *camera) const -{ - QMediaControl *control = mediaControlFromCamera(camera, QVideoEncoderSettingsControl_iid); - QVideoEncoderSettingsControl *videoEncoderControl = qobject_cast(control); + if (camera_()) { + selectedDeviceChanged(0); + cameraStateChanged(); + } - if (videoEncoderControl == 0) { - qWarning() << "No video encoder settings control support"; + Q_EMIT captureSessionChanged(); } - - return videoEncoderControl; } -QCameraInfoControl* AdvancedCameraSettings::cameraInfoControlFromCamera(QCamera *camera) const +inline QCamera* AdvancedCameraSettings::camera_() const { - QMediaControl *control = mediaControlFromCamera(camera, QCameraInfoControl_iid); - QCameraInfoControl *infoControl = qobject_cast(control); - - if (infoControl == 0) { - qWarning() << "No info control support"; - } - - return infoControl; + return m_captureSession ? m_captureSession->camera() : nullptr; } -QObject* AdvancedCameraSettings::camera() const +inline QImageCapture* AdvancedCameraSettings::imageCapture_() const { - return m_cameraObject; + return m_captureSession ? m_captureSession->imageCapture() : nullptr; } -void AdvancedCameraSettings::setCamera(QObject *cameraObject) +inline QMediaRecorder* AdvancedCameraSettings::mediaRecorder_() const { - if (cameraObject != m_cameraObject) { - m_cameraObject = cameraObject; - - if (m_camera != 0) { - this->disconnect(m_camera, SIGNAL(stateChanged(QCamera::State))); - } - QCamera* camera = cameraFromCameraObject(cameraObject); - m_camera = camera; - if (m_camera != 0) { - this->connect(m_camera, SIGNAL(stateChanged(QCamera::State)), - SLOT(onCameraStateChanged())); - onCameraStateChanged(); - - QVideoDeviceSelectorControl* selector = selectorFromCamera(m_camera); - m_deviceSelector = selector; - connect(m_deviceSelector, SIGNAL(selectedDeviceChanged(int)), - this, SLOT(onSelectedDeviceChanged(int))); - } - - Q_EMIT cameraChanged(); - } + return m_captureSession ? m_captureSession->recorder() : nullptr; } -void AdvancedCameraSettings::onSelectedDeviceChanged(int index) +void AdvancedCameraSettings::selectedDeviceChanged(int index) { Q_UNUSED(index); @@ -240,35 +93,24 @@ void AdvancedCameraSettings::onSelectedDeviceChanged(int index) void AdvancedCameraSettings::readCapabilities() { - m_viewFinderControl = viewfinderFromCamera(m_camera); - m_cameraControl = camcontrolFromCamera(m_camera); - if (m_cameraControl) { - QObject::connect(m_cameraControl, - SIGNAL(captureModeChanged(QCamera::CaptureModes)), - this, SIGNAL(resolutionChanged())); - QObject::connect(m_cameraControl, - SIGNAL(captureModeChanged(QCamera::CaptureModes)), - this, SIGNAL(maximumResolutionChanged())); - QObject::connect(m_cameraControl, - SIGNAL(captureModeChanged(QCamera::CaptureModes)), - this, SIGNAL(fittingResolutionChanged())); - } + QCamera *camera = camera_(); + if (camera) { + QObject::connect(camera, &QCamera::cameraFormatChanged, this, &AdvancedCameraSettings::resolutionChanged); + QObject::connect(camera, &QCamera::cameraFormatChanged, this, &AdvancedCameraSettings::maximumResolutionChanged); + QObject::connect(camera, &QCamera::cameraFormatChanged, this, &AdvancedCameraSettings::fittingResolutionChanged); + QObject::connect(camera, &QCamera::activeChanged, this, &AdvancedCameraSettings::cameraStateChanged); - m_cameraFlashControl = flashControlFromCamera(m_camera); - m_cameraExposureControl = exposureControlFromCamera(m_camera); + QObject::connect(camera, &QCamera::exposureModeChanged, this, &AdvancedCameraSettings::exposureValueChanged); + } - if (m_cameraExposureControl) { - QVariant exposureMode = m_hdrEnabled ? QVariant::fromValue(ExposureHdr) - : QVariant::fromValue(QCameraExposure::ExposureAuto); - m_cameraExposureControl->setValue(QCameraExposureControl::ExposureMode, exposureMode); - QObject::connect(m_cameraExposureControl, - SIGNAL(actualValueChanged(int)), - this, SLOT(onExposureValueChanged(int))); +#if SUPPORT_HDR_LUNEOS + if (m_camera) { + QCamera::ExposureMode exposureMode = m_hdrEnabled ? ExposureHdr : QCamera::ExposureAuto; + m_camera->setExposureMode(exposureMode); + QObject::connect(m_camera.get(), &QCamera::exposureModeChanged, this, &AdvancedCameraSettings::exposureValueChanged); } +#endif - m_imageEncoderControl = imageEncoderControlFromCamera(m_camera); - m_videoEncoderControl = videoEncoderControlFromCamera(m_camera); - m_cameraInfoControl = cameraInfoControlFromCamera(m_camera); m_videoSupportedResolutions.clear(); Q_EMIT resolutionChanged(); @@ -281,20 +123,19 @@ void AdvancedCameraSettings::readCapabilities() Q_EMIT videoSupportedResolutionsChanged(); } -void AdvancedCameraSettings::onCameraStateChanged() +void AdvancedCameraSettings::cameraStateChanged() { - if (m_camera->state() == QCamera::LoadedState || m_camera->state() == QCamera::ActiveState) { + QCamera *camera = camera_(); + if (camera && camera->isActive()) { readCapabilities(); } } QSize AdvancedCameraSettings::resolution() const { - if (m_viewFinderControl != 0) { - QVariant result = m_viewFinderControl->viewfinderParameter(QCameraViewfinderSettingsControl::Resolution); - if (result.isValid()) { - return result.toSize(); - } + QCamera *camera = camera_(); + if (camera) { + return camera->cameraFormat().resolution(); } return QSize(); @@ -302,8 +143,9 @@ QSize AdvancedCameraSettings::resolution() const QSize AdvancedCameraSettings::imageCaptureResolution() const { - if (m_imageEncoderControl != 0) { - return m_imageEncoderControl->imageSettings().resolution(); + QImageCapture* imageCapture = imageCapture_(); + if (imageCapture != 0) { + return imageCapture->resolution(); } return QSize(); @@ -311,8 +153,9 @@ QSize AdvancedCameraSettings::imageCaptureResolution() const QSize AdvancedCameraSettings::videoRecorderResolution() const { - if (m_videoEncoderControl != 0) { - return m_videoEncoderControl->videoSettings().resolution(); + QMediaRecorder* recorder = mediaRecorder_(); + if (recorder) { + return recorder->videoResolution(); } return QSize(); @@ -320,9 +163,9 @@ QSize AdvancedCameraSettings::videoRecorderResolution() const QSize AdvancedCameraSettings::maximumResolution() const { - if (m_imageEncoderControl) { - QList sizes = m_imageEncoderControl->supportedResolutions( - m_imageEncoderControl->imageSettings()); + QCamera *camera = camera_(); + if (camera) { + QList sizes = camera->cameraDevice().photoResolutions(); QSize maximumSize; long maximumPixels = 0; @@ -369,9 +212,9 @@ QSize AdvancedCameraSettings::fittingResolution() const } } - if (m_imageEncoderControl) { - QList sizes = m_imageEncoderControl->supportedResolutions( - m_imageEncoderControl->imageSettings()); + QCamera *camera = camera_(); + if (camera) { + QList sizes = camera->cameraDevice().photoResolutions(); QSize optimalSize; long optimalPixels = 0; @@ -413,18 +256,20 @@ QSize AdvancedCameraSettings::fittingResolution() const QStringList AdvancedCameraSettings::videoSupportedResolutions() { - if (m_videoEncoderControl) { + QCamera *camera = camera_(); + if (camera) { if (m_videoSupportedResolutions.isEmpty()) { - QString currentDeviceName = m_deviceSelector->deviceName(m_deviceSelector->selectedDevice()); - QCamera::Position cameraPosition = m_cameraInfoControl->cameraPosition(currentDeviceName); - QList sizes = m_videoEncoderControl->supportedResolutions( - m_videoEncoderControl->videoSettings()); - Q_FOREACH(QSize size, sizes) { + QList videoFormats = camera->cameraDevice().videoFormats(); + QCameraDevice::Position cameraPosition = camera->cameraDevice().position(); + + for (auto &format: videoFormats) { + QSize size = format.resolution(); + // Workaround for bug https://bugs.launchpad.net/ubuntu/+source/libhybris/+bug/1408650 // When using the front camera on krillin, using resolution 640x480 does // not work properly and results in stretched videos. Remove it from // the list of supported resolutions. - if (cameraPosition == QCamera::FrontFace && + if (cameraPosition == QCameraDevice::FrontFace && size.width() == 640 && size.height() == 480) { continue; } @@ -440,10 +285,11 @@ QStringList AdvancedCameraSettings::videoSupportedResolutions() bool AdvancedCameraSettings::hasFlash() const { - if (m_cameraFlashControl) { - return m_cameraFlashControl->isFlashModeSupported(QCameraExposure::FlashAuto) - && m_cameraFlashControl->isFlashModeSupported(QCameraExposure::FlashOff) - && m_cameraFlashControl->isFlashModeSupported(QCameraExposure::FlashOn); + QCamera *camera = camera_(); + if (camera) { + return camera->isFlashModeSupported(QCamera::FlashAuto) + && camera->isFlashModeSupported(QCamera::FlashOff) + && camera->isFlashModeSupported(QCamera::FlashOn); } else { return false; } @@ -451,13 +297,13 @@ bool AdvancedCameraSettings::hasFlash() const bool AdvancedCameraSettings::hasHdr() const { - if (m_cameraExposureControl) { - bool continuous; - if (m_cameraExposureControl->isParameterSupported(QCameraExposureControl::ExposureMode)) { - QVariantList range = m_cameraExposureControl->supportedParameterRange(QCameraExposureControl::ExposureMode, &continuous); - return range.contains(QVariant::fromValue(ExposureHdr)); +#if SUPPORT_HDR_LUNEOS + if (m_camera) { + if (m_camera->exposureMode() == ExposureHdr) { + return true; } } +#endif return false; } @@ -469,39 +315,43 @@ bool AdvancedCameraSettings::hdrEnabled() const void AdvancedCameraSettings::setHdrEnabled(bool enabled) { +#if SUPPORT_HDR_LUNEOS if (enabled != m_hdrEnabled) { m_hdrEnabled = enabled; - if (m_cameraExposureControl) { - QVariant exposureMode = enabled ? QVariant::fromValue(ExposureHdr) - : QVariant::fromValue(QCameraExposure::ExposureAuto); - m_cameraExposureControl->setValue(QCameraExposureControl::ExposureMode, exposureMode); + + if (m_camera) { + QCamera::ExposureMode exposureMode = m_hdrEnabled ? ExposureHdr : QCamera::ExposureAuto; + m_camera->setExposureMode(exposureMode); } else { Q_EMIT hdrEnabledChanged(); } } +#endif } -int AdvancedCameraSettings::encodingQuality() const +QImageCapture::Quality AdvancedCameraSettings::encodingQuality() const { - if (m_imageEncoderControl) { - return m_imageEncoderControl->imageSettings().quality(); + QImageCapture* imageCapture = imageCapture_(); + if (imageCapture) { + return imageCapture->quality(); } else { - return QMultimedia::NormalQuality; + return QImageCapture::NormalQuality; } } -void AdvancedCameraSettings::setEncodingQuality(int quality) +void AdvancedCameraSettings::setEncodingQuality(QImageCapture::Quality quality) { - if (m_imageEncoderControl) { - QImageEncoderSettings settings; - settings.setQuality((QMultimedia::EncodingQuality)quality); - m_imageEncoderControl->setImageSettings(settings); + QImageCapture* imageCapture = imageCapture_(); + if (imageCapture) { + imageCapture->setQuality(quality); } } -void AdvancedCameraSettings::onExposureValueChanged(int parameter) +void AdvancedCameraSettings::exposureValueChanged() { - if (parameter == QCameraExposureControl::ExposureMode) { +#if SUPPORT_HDR_LUNEOS + if (m_camera && m_camera->exposureMode() == ExposureHdr) { Q_EMIT hdrEnabledChanged(); } +#endif } diff --git a/CameraApp/advancedcamerasettings.h b/CameraApp/advancedcamerasettings.h index 85d07ad..c73c6ec 100644 --- a/CameraApp/advancedcamerasettings.h +++ b/CameraApp/advancedcamerasettings.h @@ -21,23 +21,15 @@ #define ADVANCEDCAMERASETTINGS_H #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class QCameraControl; -class QCameraFlashControl; +#include +#include +#include +#include class AdvancedCameraSettings : public QObject { Q_OBJECT - Q_PROPERTY (QObject* camera READ camera WRITE setCamera NOTIFY cameraChanged) + Q_PROPERTY (QMediaCaptureSession* captureSession READ captureSession WRITE setCaptureSession NOTIFY captureSessionChanged) Q_PROPERTY (QSize resolution READ resolution NOTIFY resolutionChanged) Q_PROPERTY (QSize imageCaptureResolution READ imageCaptureResolution) Q_PROPERTY (QSize videoRecorderResolution READ videoRecorderResolution) @@ -47,12 +39,12 @@ class AdvancedCameraSettings : public QObject Q_PROPERTY (bool hasFlash READ hasFlash NOTIFY hasFlashChanged) Q_PROPERTY (bool hdrEnabled READ hdrEnabled WRITE setHdrEnabled NOTIFY hdrEnabledChanged) Q_PROPERTY (bool hasHdr READ hasHdr NOTIFY hasHdrChanged) - Q_PROPERTY (int encodingQuality READ encodingQuality WRITE setEncodingQuality NOTIFY encodingQualityChanged) + Q_PROPERTY (QImageCapture::Quality encodingQuality READ encodingQuality WRITE setEncodingQuality NOTIFY encodingQualityChanged) public: explicit AdvancedCameraSettings(QObject *parent = 0); - QObject* camera() const; - void setCamera(QObject* camera); + QMediaCaptureSession* captureSession() const; + void setCaptureSession(QMediaCaptureSession* camera); QSize resolution() const; QSize imageCaptureResolution() const; QSize videoRecorderResolution() const; @@ -64,12 +56,12 @@ class AdvancedCameraSettings : public QObject bool hasHdr() const; bool hdrEnabled() const; void setHdrEnabled(bool enabled); - int encodingQuality() const; - void setEncodingQuality(int quality); + QImageCapture::Quality encodingQuality() const; + void setEncodingQuality(QImageCapture::Quality quality); void readCapabilities(); Q_SIGNALS: - void cameraChanged(); + void captureSessionChanged(); void resolutionChanged(); void maximumResolutionChanged(); void fittingResolutionChanged(); @@ -80,32 +72,16 @@ class AdvancedCameraSettings : public QObject void videoSupportedResolutionsChanged(); private Q_SLOTS: - void onCameraStateChanged(); - void onExposureValueChanged(int parameter); - void onSelectedDeviceChanged(int index); + void cameraStateChanged(); + void exposureValueChanged(); + void selectedDeviceChanged(int index); private: - QVideoDeviceSelectorControl* selectorFromCamera(QCamera *camera) const; - QCameraViewfinderSettingsControl* viewfinderFromCamera(QCamera *camera) const; - QCameraControl *camcontrolFromCamera(QCamera *camera) const; - QCameraFlashControl* flashControlFromCamera(QCamera* camera) const; - QCameraExposureControl* exposureControlFromCamera(QCamera *camera) const; - QCamera* cameraFromCameraObject(QObject* cameraObject) const; - QMediaControl* mediaControlFromCamera(QCamera *camera, const char* iid) const; - QImageEncoderControl* imageEncoderControlFromCamera(QCamera *camera) const; - QVideoEncoderSettingsControl* videoEncoderControlFromCamera(QCamera *camera) const; - QCameraInfoControl* cameraInfoControlFromCamera(QCamera *camera) const; + inline QCamera* camera_() const; + inline QImageCapture* imageCapture_() const; + inline QMediaRecorder* mediaRecorder_() const; - QObject* m_cameraObject; - QCamera* m_camera; - QVideoDeviceSelectorControl* m_deviceSelector; - QCameraViewfinderSettingsControl* m_viewFinderControl; - QCameraControl* m_cameraControl; - QCameraFlashControl* m_cameraFlashControl; - QCameraExposureControl* m_cameraExposureControl; - QImageEncoderControl* m_imageEncoderControl; - QVideoEncoderSettingsControl* m_videoEncoderControl; - QCameraInfoControl* m_cameraInfoControl; + QSharedPointer m_captureSession; bool m_hdrEnabled; QStringList m_videoSupportedResolutions; }; diff --git a/CameraApp/foldersmodel.cpp b/CameraApp/foldersmodel.cpp index f7604c4..8e5ddf4 100644 --- a/CameraApp/foldersmodel.cpp +++ b/CameraApp/foldersmodel.cpp @@ -114,7 +114,10 @@ void FoldersModel::updateFileInfoList() Q_EMIT countChanged(); m_updateFutureWatcher.cancel(); - QFuture > future = QtConcurrent::run(this, &FoldersModel::computeFileInfoList, m_folders); + QFuture > future = QtConcurrent::run([=]() -> QPair { + return this->computeFileInfoList(m_folders); + }); + m_updateFutureWatcher.setFuture(future); } @@ -136,7 +139,7 @@ QPair FoldersModel::computeFileInfoList(QStringList } } } - qSort(filteredFileInfoList.begin(), filteredFileInfoList.end(), newerThan); + std::sort(filteredFileInfoList.begin(), filteredFileInfoList.end(), newerThan); return QPair(filteredFileInfoList, filesToWatch); } @@ -160,7 +163,9 @@ void FoldersModel::setFileInfoList(QFileInfoList fileInfoList, const QStringList endResetModel(); // Start monitoring files for modifications in a separate thread as it is very time consuming - QtConcurrent::run(m_watcher, &QFileSystemWatcher::addPaths, filesToWatch); + QtConcurrent::run([=]() { + m_watcher->addPaths(filesToWatch); + }); m_loading = false; Q_EMIT loadingChanged(); diff --git a/CameraApp/foldersmodel.h b/CameraApp/foldersmodel.h index 46eef97..0fab6f7 100644 --- a/CameraApp/foldersmodel.h +++ b/CameraApp/foldersmodel.h @@ -28,6 +28,8 @@ class FoldersModel : public QAbstractListModel, public QQmlParserStatus { + Q_INTERFACES(QQmlParserStatus) + Q_OBJECT Q_PROPERTY (QStringList folders READ folders WRITE setFolders NOTIFY foldersChanged) Q_PROPERTY (QStringList typeFilters READ typeFilters WRITE setTypeFilters NOTIFY typeFiltersChanged) diff --git a/CameraApp/storagelocations.cpp b/CameraApp/storagelocations.cpp index 0667366..9951028 100644 --- a/CameraApp/storagelocations.cpp +++ b/CameraApp/storagelocations.cpp @@ -105,6 +105,10 @@ void StorageLocations::updateRemovableStorageInfo() { QString removableStorageLocation; QString mediaRoot("/media/" + qgetenv("USER")); + + QDir mediaRootDir(mediaRoot); + if (!mediaRootDir.exists()) return; // no need to get further, it's bound to fail... + // FIXME: calling QStorageInfo::mountedVolumes() is very slow (80ms on krillin) Q_FOREACH(QStorageInfo volume, QStorageInfo::mountedVolumes()) { if (volume.rootPath().startsWith(mediaRoot) && diff --git a/qml/CameraView.qml b/qml/CameraView.qml index 4c6df50..2ac7fbf 100644 --- a/qml/CameraView.qml +++ b/qml/CameraView.qml @@ -1,5 +1,5 @@ import QtQuick 2.6 -import QtMultimedia 5.5 +import QtMultimedia import LunaNext.Common 0.1 @@ -14,29 +14,77 @@ Item { signal galleryButtonClicked(); property PreferencesModel prefs; - property alias cameraItem: camera + property alias captureSessionItem: captureSession - Camera { - id: camera + MediaDevices { + id: mediaDevices + } - captureMode: prefs.captureMode - position: prefs.position + CaptureSession { + id: captureSession + camera: Camera { + id: camera + + cameraDevice: mediaDevices.defaultVideoInput + cameraFormat: cameraDevice.videoFormats[0] + + flashMode: camera.captureMode === PreferencesModel.CaptureStillImage ? prefs.flashMode : + camera.captureMode === PreferencesModel.CaptureVideo ? prefs.videoFlashMode : + Camera.FlashOff + + focusMode: Camera.FocusModeAuto + whiteBalanceMode: Camera.WhiteBalanceAuto + exposureMode: Camera.ExposureAuto + + property AdvancedCameraSettings advanced: AdvancedCameraSettings { + captureSession: captureSession + hdrEnabled: prefs.hdrEnabled + encodingQuality: prefs.encodingQuality + /* + onVideoSupportedResolutionsChanged: prefs.updateVideoResolutionOptions(camera.advanced.videoSupportedResolutions); + onFittingResolutionChanged: prefs.updatePhotoResolutionOptions(camera.advanced.maximumResolution, camera.advanced.fittingResolution); + onMaximumResolutionChanged: prefs.updatePhotoResolutionOptions(camera.advanced.maximumResolution, camera.advanced.fittingResolution); + */ + } - flash { - mode: camera.captureMode === Camera.CaptureStillImage ? prefs.flashMode : - camera.captureMode === Camera.CaptureVideo ? prefs.videoFlashMode : - CameraFlash.FlashOff - } + function updateResolutionOptions() { + prefs.updateVideoResolutionOptions(camera.advanced.videoSupportedResolutions); + prefs.updatePhotoResolutionOptions(camera.advanced.maximumResolution, camera.advanced.fittingResolution); + // FIXME: see workaround setting camera.viewfinder.resolution above + camera.cameraFormat.resolution = camera.advanced.resolution; + } - focus.focusMode: Camera.FocusContinuous - Component.onCompleted: { - updateResolutionOptions(); - } + Component.onCompleted: { + //updateResolutionOptions(); + + console.log("cameraDevice: " + JSON.stringify(camera.cameraDevice)); + console.log("camera format: " + JSON.stringify(camera.cameraFormat)); + start(); + } + + onErrorChanged: { + if(camera.error === Camera.CameraError) { + console.warn("Camera ERROR: " + camera.errorString); + } + } + /* + // TODO + captureMode: prefs.captureMode + position: prefs.position - imageCapture { - resolution: prefs.photoResolutionOptionsModel.getAsSize(prefs.photoResolutionIndex) + imageProcessing { + colorFilter: CameraImageProcessing.ColorFilterGrayscale + contrast: 0.66 + saturation: -0.5 + } + */ + } + imageCapture: ImageCapture { + id: imageCapture + + // resolution: prefs.photoResolutionOptionsModel.getAsSize(prefs.photoResolutionIndex) onResolutionChanged: { // FIXME: this is a necessary workaround because: @@ -50,67 +98,37 @@ Item { camera.viewfinder.resolution = camera.advanced.resolution; } - onImageCaptured: { - cameraViewRoot.imageCaptured(preview) + onImageCaptured: (requestId, previewImage) => { + cameraViewRoot.imageCaptured(previewImage) } - onImageSaved: { + onImageSaved: (requestId, path) => { cameraViewRoot.captureDone(path); } } - videoRecorder { + + recorder: MediaRecorder { + id: recorder + outputLocation: StorageLocations.videosLocation; + + /* TODO resolution: prefs.videoResolutionOptionsModel.getAsSize(prefs.videoResolutionIndex) onResolutionChanged: { // FIXME: see workaround setting camera.viewfinder.resolution above camera.viewfinder.resolution = camera.advanced.resolution; } + */ } - - imageProcessing { - colorFilter: CameraImageProcessing.ColorFilterGrayscale - whiteBalanceMode: CameraImageProcessing.WhiteBalanceTungsten - contrast: 0.66 - saturation: -0.5 - } - - property AdvancedCameraSettings advanced: AdvancedCameraSettings { - camera: cameraViewRoot.cameraItem - hdrEnabled: prefs.hdrEnabled - encodingQuality: prefs.encodingQuality - - onVideoSupportedResolutionsChanged: prefs.updateVideoResolutionOptions(camera.advanced.videoSupportedResolutions); - onFittingResolutionChanged: prefs.updatePhotoResolutionOptions(camera.advanced.maximumResolution, camera.advanced.fittingResolution); - onMaximumResolutionChanged: prefs.updatePhotoResolutionOptions(camera.advanced.maximumResolution, camera.advanced.fittingResolution); - } - - function updateResolutionOptions() { - prefs.updateVideoResolutionOptions(camera.advanced.videoSupportedResolutions); - prefs.updatePhotoResolutionOptions(camera.advanced.maximumResolution, camera.advanced.fittingResolution); - // FIXME: see workaround setting camera.viewfinder.resolution above - camera.viewfinder.resolution = camera.advanced.resolution; - } - - onDeviceIdChanged: { - updateResolutionOptions(); - } - - onCaptureModeChanged: { - // FIXME: see workaround setting camera.viewfinder.resolution above - camera.viewfinder.resolution = camera.advanced.resolution; - } - - onError: console.warn("Camera ERROR " + errorCode + ": " + errorString); + videoOutput: videoOutputView } VideoOutput { id: videoOutputView - source: camera anchors.fill: parent - focus: visible fillMode: VideoOutput.PreserveAspectCrop - orientation: camera.position === Camera.BackFace ? -camera.orientation : camera.orientation + //orientation: camera.position === Camera.BackFace ? -camera.orientation : camera.orientation } GridLines { anchors.fill: parent diff --git a/qml/CaptureOverlay.qml b/qml/CaptureOverlay.qml index db701cd..9f34f1d 100644 --- a/qml/CaptureOverlay.qml +++ b/qml/CaptureOverlay.qml @@ -1,5 +1,5 @@ import QtQuick 2.6 -import QtMultimedia 5.5 +import QtMultimedia import LunaNext.Common 0.1 @@ -7,19 +7,18 @@ import CameraApp 0.1 import "components" Item { - property Camera camera + property CaptureSession captureSession property QtObject prefs; property int captureTimeout: prefs.selfTimerDelay signal galleryButtonClicked(); + function setLastCapturedImage(preview) { lastCaptureImage.source = preview } function startCapture() { - camera.searchAndLock(); - var outputPath = StorageLocations.picturesLocation; var dateAsString = new Date().toLocaleString(Qt.locale(), "yyyy-MM-dd-hh-mm-ss"); outputPath += "/" + dateAsString; @@ -28,8 +27,7 @@ Item { // start he capture !capture the image! timeOutTimer.startTimeout(captureTimeout, function() { - camera.imageCapture.captureToLocation(outputPath); - camera.unlock(); + captureSession.imageCapture.captureToFile(outputPath); } ); } @@ -47,7 +45,7 @@ Item { ExclusiveGroup { id: exclusiveGroupPhotoVideo - readonly property var prefsMapping: [ Camera.CaptureStillImage, Camera.CaptureVideo ] + readonly property var prefsMapping: [ PreferencesModel.CaptureStillImage, PreferencesModel.CaptureVideo ] currentIndexInGroup: prefsMapping.indexOf(prefs.captureMode); onCurrentIndexInGroupChanged: prefs.captureMode = prefsMapping[currentIndexInGroup] } @@ -109,7 +107,7 @@ Item { ExclusiveGroup { id: exclusiveGroupSide - readonly property var prefsMapping: [ Camera.FrontFace, Camera.BackFace ] + readonly property var prefsMapping: [ CameraDevice.FrontFace, CameraDevice.BackFace ] currentIndexInGroup: prefsMapping.indexOf(prefs.position); onCurrentIndexInGroupChanged: prefs.position = prefsMapping[currentIndexInGroup] } diff --git a/qml/PreferencesModel.qml b/qml/PreferencesModel.qml index 1a70694..3cb0ade 100644 --- a/qml/PreferencesModel.qml +++ b/qml/PreferencesModel.qml @@ -1,5 +1,5 @@ import QtQuick 2.6 -import QtMultimedia 5.5 +import QtMultimedia import "components" @@ -8,8 +8,13 @@ import "components" QtObject { id: settings - property int position: Camera.BackFace - property int captureMode: Camera.CaptureStillImage + enum CaptureMode { + CaptureStillImage, + CaptureVideo + } + + property int position: CameraDevice.BackFace + property int captureMode: PreferencesModel.CaptureStillImage property int flashMode: Camera.FlashAuto property int videoFlashMode: Camera.FlashOff property bool gpsEnabled: false diff --git a/qml/PreferencesOverlay.qml b/qml/PreferencesOverlay.qml index 107171e..2eb673f 100644 --- a/qml/PreferencesOverlay.qml +++ b/qml/PreferencesOverlay.qml @@ -58,7 +58,7 @@ Item { property real lastPressedY: 0 anchors.fill: parent drag.target: parent - onPressed: { + onPressed: (mouse) => { lastPressedX = mouse.x; lastPressedY = mouse.y; } diff --git a/qml/PreferencesView.qml b/qml/PreferencesView.qml index 0c0ffde..914ece3 100644 --- a/qml/PreferencesView.qml +++ b/qml/PreferencesView.qml @@ -1,7 +1,6 @@ import QtQuick 2.0 -import QtMultimedia 5.5 import QtQml.Models 2.2 -import QtGraphicalEffects 1.0 +import QtMultimedia import LunaNext.Common 0.1 @@ -12,19 +11,13 @@ import "components" Item { id: root - // useful shortcuts - readonly property real menuInnerRadius: ringMenuProperties.menuAreaWidth/2 - ringMenuProperties.ringWidth - readonly property real menuXOffset: ringMenuProperties.menuXOffset - - property real arcScroll: 0 - property PreferencesModel prefs; property var prefsMapping: ({ "flashMode": [ Camera.FlashAuto, Camera.FlashOff, Camera.FlashOn ], "selfTimerDelay": [ 0, 3, 10, 15 ], "position": [ Camera.FrontFace, Camera.BackFace ], "gridEnabled": [ false, true ], - "captureMode": [ Camera.CaptureStillImage, Camera.CaptureVideo ], + "captureMode": [ PreferencesModel.CaptureStillImage, PreferencesModel.CaptureVideo ], "photoResolutionIndex": [], // will be filled dynamically "videoResolutionIndex": [], // will be filled dynamically "effectMode": [ 0, 1, 2, 3 ] @@ -98,8 +91,8 @@ Item { } Connections { - target: prefs.captureMode === Camera.CaptureStillImage ? prefs.photoResolutionOptionsModel : null - onModelChanged: { + target: prefs.captureMode === PreferencesModel.CaptureMode.CaptureStillImage ? prefs.photoResolutionOptionsModel : null + function onModelChanged() { var subMenuModel = [] var nbPhotoResolutions = prefs.photoResolutionOptionsModel.count; var prefsMappingQuality = []; @@ -113,8 +106,8 @@ Item { } } Connections { - target: prefs.captureMode === Camera.CaptureVideo ? prefs.videoResolutionOptionsModel : null - onModelChanged: { + target: prefs.captureMode === PreferencesModel.CaptureMode.CaptureVideo ? prefs.videoResolutionOptionsModel : null + function onModelChanged() { var subMenuModel = [] var nbVideoResolutions = prefs.videoResolutionOptionsModel.count; var prefsMappingQuality = []; @@ -128,195 +121,6 @@ Item { } } - QtObject { - id: ringMenuProperties - readonly property real menuAreaHeight: root.height*0.8 - readonly property real menuAreaWidth: menuAreaHeight - readonly property real ringWidth: root.height*1.1 / 6.5 - readonly property real arcLength: Math.PI/6 - readonly property real menuXOffset: -(menuAreaWidth/2)*1.3 - } - QtObject { - id: ringSubMenuProperties - readonly property real menuAreaHeight: ringMenuProperties.menuAreaHeight + 2*root.height/6.5 - readonly property real menuAreaWidth: menuAreaHeight - readonly property real ringWidth: ringMenuProperties.ringWidth * 0.8 - readonly property real arcLength: Math.PI/16 - readonly property real menuXOffset: -(ringMenuProperties.menuAreaWidth/2)*1.3 - root.height/6.5 - } - - // Pre-generate canvas images for the buttons - DropShadow { - id: mainMenuRadialBg; - height: ringMenuProperties.menuAreaHeight - width: ringMenuProperties.menuAreaWidth - opacity: 0 - - horizontalOffset: 0 - verticalOffset: 0 - radius: Units.gu(0.5) - samples: 6 - color: "#333" - - source: MenuPieSlice { - height: ringMenuProperties.menuAreaHeight - width: ringMenuProperties.menuAreaWidth - innerRadius: root.menuInnerRadius - arcLength: ringMenuProperties.arcLength*180/Math.PI - shadowRadius: Units.gu(0.5) - color: Qt.rgba(0.93, 0.93, 0.93, 0.67) - } - } - DropShadow { - id: mainMenuRadialSelectedBg; - height: ringMenuProperties.menuAreaHeight - width: ringMenuProperties.menuAreaWidth - opacity: 0 - - horizontalOffset: 0 - verticalOffset: 0 - radius: Units.gu(0.5) - samples: 6 - color: "#333" - source: MenuPieSlice { - height: ringMenuProperties.menuAreaHeight - width: ringMenuProperties.menuAreaWidth - innerRadius: root.menuInnerRadius - arcLength: ringMenuProperties.arcLength*180/Math.PI - shadowRadius: Units.gu(0.5) - color: Qt.rgba(0.42, 0.63, 0.76, 1.0) - } - } - DropShadow { - id: subMenuRadialBg; - height: ringSubMenuProperties.menuAreaHeight - width: ringSubMenuProperties.menuAreaWidth - opacity: 0 - - horizontalOffset: 0 - verticalOffset: 0 - radius: Units.gu(0.5) - samples: 6 - color: "#333" - source: MenuPieSlice { - height: ringSubMenuProperties.menuAreaHeight - width: ringSubMenuProperties.menuAreaWidth - innerRadius: root.menuInnerRadius + ringMenuProperties.ringWidth - arcLength: ringSubMenuProperties.arcLength*180/Math.PI - shadowRadius: Units.gu(0.5) - color: Qt.rgba(0.93, 0.93, 0.93, 0.67) - } - } - DropShadow { - id: subMenuRadialSelectedBg; - height: ringSubMenuProperties.menuAreaHeight - width: ringSubMenuProperties.menuAreaWidth - opacity: 0 - - horizontalOffset: 0 - verticalOffset: 0 - radius: Units.gu(0.5) - samples: 6 - color: "#333" - source: MenuPieSlice { - height: ringSubMenuProperties.menuAreaHeight - width: ringSubMenuProperties.menuAreaWidth - innerRadius: root.menuInnerRadius + ringMenuProperties.ringWidth - arcLength: ringSubMenuProperties.arcLength*180/Math.PI - shadowRadius: Units.gu(0.5) - color: Qt.rgba(0.42, 0.63, 0.76, 1.0) - } - } - - Item { - id: mainMenuItems - anchors.fill: parent - - ExclusiveGroup { - id: exclusiveMainMenu - currentIndexInGroup: -1 - } - Repeater { - anchors.verticalCenter: parent.verticalCenter - x: 0 - - model: prefsMenuModel - delegate: MenuItemRingArc { - height: ringMenuProperties.menuAreaHeight - width: ringMenuProperties.menuAreaWidth - x: ringMenuProperties.menuXOffset - y: (root.height-height)/2 - - z: 2 - - backgroundImage: isSelected ? mainMenuRadialSelectedBg : mainMenuRadialBg - - innerRadius: root.menuInnerRadius - - arcLength: ringMenuProperties.arcLength - arcOffset: (index - prefsMenuModel.count/2)*arcLength - arcScroll - - text: model.text - menuImageUrl: model.imageUrl !== "" ? Qt.resolvedUrl(model.imageUrl) : "" - - group: exclusiveMainMenu - indexInGroup: index - interactive: !!model.prefsKey - - onSelected: { - exclusiveSubMenu.prefsKey = model.prefsKey; - subMenuRepeater.model = model.subMenuModel; - } - } - } - } - - Item { - id: subMenuItems - - visible: !!subMenuRepeater.model - - anchors.fill: parent - ExclusiveGroup { - id: exclusiveSubMenu - property string prefsKey: "" - onPrefsKeyChanged: currentIndexInGroup = root.prefsMapping[prefsKey].indexOf(prefs[prefsKey]); - currentIndexInGroup: -1 - } - Repeater { - id: subMenuRepeater - anchors.verticalCenter: parent.verticalCenter - x: 0 - - delegate: MenuItemRingArc { - height: ringSubMenuProperties.menuAreaHeight - width: ringSubMenuProperties.menuAreaWidth - x: -(root.height*0.8/2)*1.3 - root.height/6.5 - y: (root.height-height)/2 - - z: 2 - - backgroundImage: isSelected ? subMenuRadialSelectedBg : subMenuRadialBg - - innerRadius: root.menuInnerRadius + ringMenuProperties.ringWidth; - - arcLength: ringSubMenuProperties.arcLength - arcOffset: -arcLength*subMenuRepeater.count/2 + index*arcLength - - text: model.text - menuImageUrl: model.imageUrl !== "" ? Qt.resolvedUrl(model.imageUrl) : "" - - group: exclusiveSubMenu - indexInGroup: index - - onClicked: { - root.prefs[exclusiveSubMenu.prefsKey] = root.prefsMapping[exclusiveSubMenu.prefsKey][exclusiveSubMenu.currentIndexInGroup] - } - } - } - } - -/* ListView { id: subMenuListView visible: false @@ -341,8 +145,8 @@ Item { text: model.text } } -*/ - /* + + Column { width: parent.width spacing: Units.gu(0.5) @@ -356,7 +160,7 @@ Item { ExclusiveGroup { id: exclusiveGroupSide - readonly property var prefsMapping: [ Camera.FrontFace, Camera.BackFace ] + readonly property var prefsMapping: [ CameraDevice.FrontFace, CameraDevice.BackFace ] currentIndexInGroup: prefsMapping.indexOf(prefs.position); onCurrentIndexInGroupChanged: prefs.position = prefsMapping[currentIndexInGroup] } @@ -424,7 +228,7 @@ Item { ExclusiveGroup { id: exclusiveGroupPhotoVideo - readonly property var prefsMapping: [ Camera.CaptureStillImage, Camera.CaptureVideo ] + readonly property var prefsMapping: [ PreferencesModel.CaptureMode.CaptureStillImage, PreferencesModel.CaptureMode.CaptureVideo ] currentIndexInGroup: prefsMapping.indexOf(prefs.captureMode); onCurrentIndexInGroupChanged: prefs.captureMode = prefsMapping[currentIndexInGroup] } @@ -471,7 +275,7 @@ Item { anchors.horizontalCenter: parent.horizontalCenter height: Units.gu(6) - visible: prefs.captureMode === Camera.CaptureVideo + visible: prefs.captureMode === PreferencesModel.CaptureMode.CaptureVideo ExclusiveGroup { id: exclusiveGroupFlashVideo @@ -499,7 +303,7 @@ Item { anchors.horizontalCenter: parent.horizontalCenter height: Units.gu(6) - visible: prefs.captureMode === Camera.CaptureStillImage && prefs.photoResolutionOptionsModel.count>0 + visible: prefs.captureMode === PreferencesModel.CaptureMode.CaptureStillImage && prefs.photoResolutionOptionsModel.count>0 function sizeToMegapixels(size) { var megapixels = (size.width * size.height) / 1000000; @@ -569,5 +373,4 @@ Item { } } } - */ } diff --git a/qml/components/CornerShader.qml b/qml/components/CornerShader.qml index 77b3fd1..1309034 100644 --- a/qml/components/CornerShader.qml +++ b/qml/components/CornerShader.qml @@ -32,6 +32,7 @@ ShaderEffect { property size start: Qt.size(0.5 - radius/width, 0.5 - radius/height) property real delta: 0.05 property real active: 1 + /* vertexShader: " uniform highp mat4 qt_Matrix; attribute highp vec4 qt_Vertex; @@ -41,17 +42,8 @@ ShaderEffect { textureCoords = qt_MultiTexCoord0; gl_Position = qt_Matrix * qt_Vertex; }" - fragmentShader: " - varying highp vec2 textureCoords; - uniform sampler2D source; - uniform lowp float qt_Opacity; - uniform highp vec2 start; - uniform highp vec2 center; - uniform highp float delta; - uniform highp float active; - void main() { - highp vec2 Coord = max((abs(textureCoords - center) - start) / (center - start), vec2(0.0)); - lowp float Alpha = smoothstep(1.0, 1.0 - delta, length(Coord)); - gl_FragColor = vec4(texture2D(source, textureCoords).rgb * Alpha * active, Alpha) * qt_Opacity; - }" + */ + /* + fragmentShader: "cornershader.vert.qsb" + */ } diff --git a/qml/components/MenuItemRingArc.qml b/qml/components/MenuItemRingArc.qml index fe76887..fc2c685 100644 --- a/qml/components/MenuItemRingArc.qml +++ b/qml/components/MenuItemRingArc.qml @@ -1,5 +1,5 @@ import QtQuick 2.9 -import QtGraphicalEffects 1.0 +import Qt5Compat.GraphicalEffects import LunaNext.Common 0.1 diff --git a/qml/components/cornershader.vert b/qml/components/cornershader.vert new file mode 100644 index 0000000..1d8a7a1 --- /dev/null +++ b/qml/components/cornershader.vert @@ -0,0 +1,14 @@ +varying highp vec2 textureCoords; +uniform sampler2D source; +uniform lowp float qt_Opacity; +uniform highp vec2 start; +uniform highp vec2 center; +uniform highp float delta; +uniform highp float active; + +void main() { + highp vec2 Coord = max((abs(textureCoords - center) - start) / (center - start), vec2(0.0)); + lowp float Alpha = smoothstep(1.0, 1.0 - delta, length(Coord)); + gl_FragColor = vec4(texture2D(source, textureCoords).rgb * Alpha * active, Alpha) * qt_Opacity; +} + diff --git a/qml/main.qml b/qml/main.qml index ca595ed..c270aee 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -1,11 +1,10 @@ -import QtQuick 2.9 -import QtQuick.Window 2.2 - -import LunaNext.Common 0.1 +import QtQuick +import QtQuick.Controls +import Eos.Window 0.1 import "components" -Window { +WebOSWindow { visible: true width: 600 @@ -33,28 +32,34 @@ Window { prefs: preferences - onImageCaptured: captureOverlayItem.setLastCapturedImage(preview); - onCaptureDone: capturedFilesModel.addFileToGallery(filepath); + //onImageCaptured: (preview) => { captureOverlayItem.setLastCapturedImage(preview); } + onCaptureDone: (filepath) => { + captureOverlayItem.setLastCapturedImage(filepath); + capturedFilesModel.addFileToGallery(filepath); + } } - CaptureOverlay { - id: captureOverlayItem + SwipeView { + id: switcherListView + + currentIndex: 0 width: parent.width height: parent.height - camera: cameraViewItem.cameraItem - prefs: preferences + CaptureOverlay { + id: captureOverlayItem - onGalleryButtonClicked: switcherListView.currentIndex = 2 - } + captureSession: cameraViewItem.captureSessionItem + prefs: preferences - PreferencesOverlay { - id: preferencesOverlay + // onGalleryButtonClicked: switcherListView.currentIndex = 2 + } - width: parent.width - height: parent.height + PreferencesView { + id: preferencesOverlay - prefs: preferences + prefs: preferences + } } }