Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Volume control UI
  • Loading branch information
Vesa Halttunen committed Dec 21, 2012
1 parent 8d985e1 commit c18a610
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
61 changes: 61 additions & 0 deletions src/qml/VolumeControl.qml
@@ -0,0 +1,61 @@
import QtQuick 1.1
import org.nemomobile.lipstick 0.1
import com.jolla.components 1.0

This comment has been minimized.

Copy link
@faenil

faenil Dec 24, 2012

Member

is this needed?
this means it won't be available in Nemo until Jolla components are released

This comment has been minimized.

Copy link
@Venemo

Venemo Dec 24, 2012

Contributor

Where is the source code of com.jolla.components?

This comment has been minimized.

Copy link
@faenil

faenil Dec 24, 2012

Member

we don't have it...that is why I added the comment

This comment has been minimized.

Copy link
@Venemo

Venemo Dec 24, 2012

Contributor

Yup, the question wasn't directed towards you. :P

This comment has been minimized.

Copy link
@veskuh

veskuh Dec 27, 2012

Code itself doesn't seem to use anything from jollacomponents so in anycase this is unneeded import.

This comment has been minimized.

Copy link
@Venemo

Venemo Dec 27, 2012

Contributor

Ok, let's remove it then.

This comment has been minimized.

Copy link
@Vesuri

Vesuri Dec 27, 2012

It was needed for image://theme/ to work - in other words to find the specified icon ID from the theme. What should it be instead?

This comment has been minimized.

Copy link
@special

special Dec 27, 2012

Contributor

import com.nokia.meego 1.0

The theme resource API is identical.

This comment has been minimized.

Copy link
@Vesuri

Vesuri Dec 28, 2012

Fixed. Thanks!


Item {
property bool isPortrait: true
id: volumeWindow
width: initialSize.width
height: initialSize.height

Rectangle {
property bool shouldBeVisible
id: volumeBar
width: volumeWindow.isPortrait ? volumeWindow.height : volumeWindow.width
height: volumeWindow.isPortrait ? volumeWindow.width : volumeWindow.height
transform: Rotation {
origin.x: volumeWindow.isPortrait ? volumeWindow.height / 2 : 0;
origin.y: volumeWindow.isPortrait ? volumeWindow.height / 2 : 0;
angle: volumeWindow.isPortrait ? -90 : 0
}
color: "black"
opacity: volumeBar.shouldBeVisible ? 0.85 : 0

This comment has been minimized.

Copy link
@Venemo

Venemo Dec 27, 2012

Contributor

Wouldn't it be better to do it like this?

visible: shouldBeVisible
opacity: 0.85

This comment has been minimized.

Copy link
@Vesuri

Vesuri Dec 28, 2012

No, because you can't animate the visible property. There's a behavior on opacity which makes the opacity smoothly fade between 0 and 0.85 when changed.

This comment has been minimized.

Copy link
@Venemo

Venemo Dec 28, 2012

Contributor

That's true. Sorry!


Rectangle {
y: parent.height - height
width: parent.width
height: parent.height * volumeControl.volume / volumeControl.maximumVolume
color: "red"
opacity: 0.5
Behavior on height { NumberAnimation { duration: 250 } }
}

Timer {
id: volumeTimer
interval: 1500
onTriggered: volumeBar.shouldBeVisible = false
}

Connections {
target: volumeControl
onWindowVisibleChanged: if (volumeControl.windowVisible) { volumeTimer.restart(); volumeBar.shouldBeVisible = true }
onVolumeChanged: if (volumeControl.windowVisible) volumeTimer.restart()
}

Behavior on opacity {
NumberAnimation {
duration: 250
onRunningChanged: if (!running && volumeBar.opacity == 0) volumeControl.windowVisible = false
}
}

Image {
anchors {
horizontalCenter: parent.horizontalCenter
bottom: parent.bottom
bottomMargin: 50
}
source: volumeControl.volume > 0 ? "image://theme/icon-m-toolbar-volume" : "image://theme/icon-m-common-volume-off"
}
}
}
1 change: 1 addition & 0 deletions src/resources-qml.qrc
Expand Up @@ -13,5 +13,6 @@
<file>qml/pages/Cloud.qml</file>
<file>qml/pages/Favorites.qml</file>
<file>qml/NotificationPreview.qml</file>
<file>qml/VolumeControl.qml</file>
</qresource>
</RCC>
3 changes: 2 additions & 1 deletion src/src.pro
Expand Up @@ -35,4 +35,5 @@ OTHER_FILES += \
qml/pages/Search.qml \
qml/pages/Cloud.qml \
qml/pages/Favorites.qml \
qml/NotificationPreview.qml
qml/NotificationPreview.qml \
qml/VolumeControl.qml

0 comments on commit c18a610

Please sign in to comment.