Skip to content

Commit 64e05a9

Browse files
committed
Camera App ubports#53 : added vibrate on picture shot
- Changed the OptionButton and OptionValueButton logic to suport icon source path as well as icon name.
1 parent 6f41704 commit 64e05a9

File tree

4 files changed

+37
-10
lines changed

4 files changed

+37
-10
lines changed

OptionButton.qml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ CircleButton {
2626
iconName: (!model.get(model.selectedIndex) || !model.get(model.selectedIndex).icon) ?
2727
(model.icon ? model.icon : "") :
2828
model.get(model.selectedIndex).icon
29-
iconSource: (model && model.iconSource) ? model.iconSource : ""
29+
iconSource: (!model.get(model.selectedIndex) || !model.get(model.selectedIndex).iconSource) ?
30+
((model && model.iconSource) ? model.iconSource : "") :
31+
model.get(model.selectedIndex).iconSource
32+
3033
on: model.isToggle ? model.get(model.selectedIndex).value : true
3134
enabled: model.visible && model.available
3235
label: model.label

OptionValueButton.qml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ AbstractButton {
2424

2525
property alias label: label.text
2626
property alias iconName: icon.name
27+
property alias iconSource: icon.source
2728
property bool selected
2829
property bool isLast
2930
property int columnWidth
@@ -32,14 +33,14 @@ AbstractButton {
3233
width: marginSize + iconLabelGroup.width + marginSize
3334

3435
Item {
36+
property bool showIcon: iconName !== "" || (iconName == "" && iconSource.toString().match(/^file:\/\//))
3537
id: iconLabelGroup
36-
width: childrenRect.width
38+
width: (icon.width * showIcon) + label.width
3739
height: icon.height
3840

3941
anchors {
40-
left: (iconName) ? undefined : parent.left
41-
leftMargin: (iconName) ? undefined : marginSize
42-
horizontalCenter: (iconName) ? parent.horizontalCenter : undefined
42+
left: parent.left
43+
leftMargin: marginSize
4344
verticalCenter: parent.verticalCenter
4445
topMargin: marginSize
4546
bottomMargin: marginSize
@@ -54,14 +55,14 @@ AbstractButton {
5455
width: optionValueButton.height - optionValueButton.marginSize * 2
5556
color: "white"
5657
opacity: optionValueButton.selected ? 1.0 : 0.5
57-
visible: name !== ""
58+
visible: iconLabelGroup.showIcon
5859
asynchronous: true
5960
}
6061

6162
Label {
6263
id: label
6364
anchors {
64-
left: icon.name != "" ? icon.right : parent.left
65+
left: iconLabelGroup.showIcon ? icon.right : parent.left
6566
verticalCenter: parent.verticalCenter
6667
}
6768

OptionsOverlay.qml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,14 @@ Item {
143143
columnWidth: optionValueSelector.width
144144

145145
label: (model && model.label) ? i18n.tr(model.label) : ""
146+
146147
iconName: (model && model.icon) ? model.icon : ""
147148
selected: optionValueSelector.model.selectedIndex == index
149+
Component.onCompleted: {
150+
if (model && model.iconSource) {
151+
iconSource = model.iconSource
152+
}
153+
}
148154

149155
isLast: index === optionValueSelector.count - 1
150156
onClicked: {
@@ -155,6 +161,7 @@ Item {
155161
}
156162
}
157163
}
164+
158165
footerPositioning: ListView.OverlayFooter
159166
footer: Icon {
160167
anchors.horizontalCenter: parent.horizontalCenter

ViewFinderOverlay.qml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Item {
5454
property bool preferRemovableStorage: false
5555
property string videoResolution: "1920x1080"
5656
property bool playShutterSound: true
57+
property bool shutterVibration: true
5758
property var photoResolutions
5859
property bool dateStampImages: false
5960
property string dateStampFormat: Qt.locale().dateFormat(Locale.ShortFormat)
@@ -118,6 +119,11 @@ Item {
118119
// value
119120
camera.viewfinder.resolution = camera.advanced.resolution;
120121
}
122+
onImageCaptured: {
123+
if(settings.shutterVibration) {
124+
Haptics.play({intensity:0.25,duration:UbuntuAnimation.SnapDuration/3});
125+
}
126+
}
121127
}
122128

123129
Connections {
@@ -564,24 +570,34 @@ Item {
564570
ListModel {
565571
id: shutterSoundOptionsModel
566572

573+
function setSettingProperty(value) {
574+
settings.shutterVibration = value & 0x1;
575+
settings.playShutterSound = value & 0x2;
576+
}
577+
567578
property string settingsProperty: "playShutterSound"
568579
property string icon: ""
569580
property string label: ""
570581
property bool isToggle: true
571-
property int selectedIndex: bottomEdge.indexForValue(shutterSoundOptionsModel, settings.playShutterSound)
582+
property int selectedIndex: bottomEdge.indexForValue(shutterSoundOptionsModel, 2 * settings.playShutterSound + settings.shutterVibration)
572583
property bool available: true
573584
property bool visible: camera.captureMode === Camera.CaptureStillImage
574585
property bool showInIndicators: false
575586

576587
ListElement {
577588
icon: "audio-volume-high"
578589
label: QT_TR_NOOP("On")
579-
value: true
590+
value: 2
591+
}
592+
ListElement {
593+
iconSource: "assets/vibrate.png"
594+
label: QT_TR_NOOP("Vibrate")
595+
value: 1
580596
}
581597
ListElement {
582598
icon: "audio-volume-muted"
583599
label: QT_TR_NOOP("Off")
584-
value: false
600+
value: 0
585601
}
586602
},
587603
ListModel {

0 commit comments

Comments
 (0)