This is just the UI. Changing the device leads to a crash.
width: parent.width
}
+ SectionHeader {
+ text: qsTr("Camera")
+ width: parent.width
+ }
+
+ CameraButtonRow {
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ CameraButton {
+ text: qsTr("Back (Primary)");
+ checkable: true
+ checked: settings.device == 0
+ onClicked: settings.device = 0
+ }
+
+ CameraButton {
+ text: qsTr("Front (Secondary)");
+ checkable: true
+ checked: settings.device == 1
+ onClicked: settings.device = 1
+ }
+ }
+
TextSwitch {
text: qsTr("Show grid lines")
Component.onCompleted: {
platformSettings.init()
- // TODO: hardcoding device id
- root.resetCamera(0, settings.mode)
+ root.resetCamera(settings.device, settings.mode)
}
PlatformSettings {
Settings {
id: settings
+ onDeviceChanged: root.resetCamera(settings.device, settings.mode)
}
PipelineManager {
#define DEFAULT_GRID_ENABLED false
#define DEFAULT_FACE_DETECTION_ENABLED true
#define DEFAULT_ZOOM_AS_SHUTTER false
+#define DEFAULT_DEVICE 0
Settings::Settings(QObject *parent) :
QObject(parent),
emit zoomAsShutterChanged();
}
}
+
+int Settings::device() const {
+ return m_settings->value("camera/device", DEFAULT_DEVICE).toInt();
+}
+
+void Settings::setDevice(int device) {
+ if (device != Settings::device()) {
+ m_settings->setValue("camera/device", device);
+ emit deviceChanged();
+ }
+}
Q_PROPERTY(bool faceDetectionEnabled READ isFaceDetectionEnabled WRITE setFaceDetectionEnabled NOTIFY faceDetectionEnabledChanged);
Q_PROPERTY(bool zoomAsShutter READ isZoomAsShutterEnabled WRITE setZoomAsShutterEnabled NOTIFY zoomAsShutterChanged);
+ Q_PROPERTY(int device READ device WRITE setDevice NOTIFY deviceChanged);
public:
Settings(QObject *parent = 0);
bool isZoomAsShutterEnabled();
void setZoomAsShutterEnabled(bool enabled);
+ int device() const;
+ void setDevice(int device);
+
signals:
void modeChanged();
void creatorNameChanged();
void gridEnabledChanged();
void faceDetectionEnabledChanged();
void zoomAsShutterChanged();
+ void deviceChanged();
private:
QSettings *m_settings;