Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update requires added nfc indicator and update volume control #104

Merged
merged 5 commits into from Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions rpm/lipstick-glacier-home-qt5.spec
Expand Up @@ -15,6 +15,7 @@ Requires: nemo-qml-plugin-statusnotifier
Requires: qt5-qtfeedback
Requires: qt5-qtdeclarative-import-window2
Requires: qt5-qtdeclarative-import-sensors
Requires: qt5-qtmultimedia-plugin-mediaservice-gstmediaplayer
Requires: qt5-qtquickcontrols >= 5.3.1
Requires: qt5-qtquickcontrols-nemo >= 5.1.1
Requires: nemo-qml-plugin-contextkit-qt5
Expand Down
4 changes: 2 additions & 2 deletions src/qml/AppSwitcher.qml
Expand Up @@ -92,8 +92,8 @@ Item {
}

delegate: Item {
width: (desktop.width - (gridview.spacing * gridview.columns)) / gridview.columns
height: (desktop.height - (gridview.spacing * gridview.columns)) / gridview.columns
width: (desktop.width - (gridview.spacing * (gridview.columns + 1))) / gridview.columns
height: (desktop.height - (gridview.spacing * (gridview.columns + 1))) / gridview.columns

// The outer Item is necessary because of animations in SwitcherItem changing
// its size, which would break the Grid.
Expand Down
12 changes: 12 additions & 0 deletions src/qml/MainScreen.qml
Expand Up @@ -46,6 +46,7 @@ import org.nemomobile.systemsettings 1.0
import "scripts/desktop.js" as Desktop
import "mainscreen"
import "dialogs"
import "volumecontrol"

Page {
id: desktop
Expand Down Expand Up @@ -203,6 +204,10 @@ Page {
z: 200
}

AudioWarningDialog{
id: audioWarnigDialog
}

Connections{
target: feeds
onXChanged: {
Expand All @@ -224,4 +229,11 @@ Page {
statusbar.opacityStart = opacityCalc
}
}

Connections {
target: volumeControl
onShowAudioWarning: {
audioWarnigDialog.open();
}
}
}
4 changes: 1 addition & 3 deletions src/qml/Statusbar.qml
Expand Up @@ -226,10 +226,8 @@ Item {
id: bluetoothIndicator
}

StatusbarItem {
NfcIndicator {
id: nfcIndicator
iconSize: statusbar.height
source: "/usr/share/lipstick-glacier-home-qt5/qml/theme/icon_nfc.png"
}

StatusbarItem {
Expand Down
38 changes: 38 additions & 0 deletions src/qml/statusbar/NfcIndicator.qml
@@ -0,0 +1,38 @@
import QtQuick 2.6
import Nemo.DBus 2.0

StatusbarItem {
id: nfcIndicator
iconSize: parent.height * 0.671875
iconSizeHeight: parent.height
source: "/usr/share/lipstick-glacier-home-qt5/qml/theme/icon_nfc.png"
visible: nfcIndicator.enabled

property bool enabled

property QtObject nfcSettingsDbus: DBusInterface {
bus: DBus.SystemBus
service: 'org.sailfishos.nfc.settings'
path: '/'
iface: 'org.sailfishos.nfc.Settings'
signalsEnabled: true

function enabledChanged(enabled) {
nfcIndicator.enabled = enabled
}

function getEnabled() {
call("GetEnabled", undefined, function (enabled) {
// Success state
nfcIndicator.enabled = enabled
}, function() {
// Failure state
nfcIndicator.enabled = false
})
}
}

Component.onCompleted: {
nfcSettingsDbus.getEnabled()
}
}
58 changes: 58 additions & 0 deletions src/qml/volumecontrol/AudioWarningDialog.qml
@@ -0,0 +1,58 @@
/****************************************************************************************
**
** Copyright (C) 2020 Chupligin Sergey <neochapay@gmail.com>
** All rights reserved.
**
** You may use this file under the terms of BSD license as follows:
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** * Neither the name of the author nor the
** names of its contributors may be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
****************************************************************************************/

import QtQuick 2.6
import QtQuick.Controls 1.0
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0

import Nemo.Dialogs 1.0

import org.nemomobile.lipstick 0.1

QueryDialog {
id: audioWarningDialog
visible: false
inline: true

cancelText: qsTr("Cancel")
acceptText: qsTr("Ok")
headingText: qsTr("Dangerous volume level!")
subLabelText: qsTr("Do you want to continue?")

onAccepted: {
volumeControl.setWarningAcknowledged(true)
}

onSelected: {
audioWarningDialog.close()
}
}
37 changes: 28 additions & 9 deletions src/qml/volumecontrol/VolumeControl.qml
Expand Up @@ -52,11 +52,34 @@ Rectangle{

visible: volumeControl.windowVisible

Image{
id: soundIcon
height: Theme.itemHeightMedium
width: height

anchors{
left: parent.left
leftMargin: (parent.height-soundIcon.height)/2
verticalCenter: parent.verticalCenter
}
source: if(volumeControl.volume == volumeControl.maximumVolume) {
"image://theme/volume-up"
} else if(volumeControl.volume == 0) {
"image://theme/volume-off"
} else {
"image://theme/volume-down"
}
}

Slider {
id: volumeSlider
width: parent.width*0.8
width: parent.width-parent.height*1.2

anchors.centerIn: parent
anchors{
left: soundIcon.right
leftMargin: parent.height*0.2
verticalCenter: parent.verticalCenter
}

minimumValue: 0
value: volumeControl.volume
Expand Down Expand Up @@ -132,14 +155,10 @@ Rectangle{
{
if(volumeControlWindow.pressedKey == Qt.Key_VolumeUp) {
//up volume
if(volumeControl.volume < volumeSlider.maximumValue) {
volumeControl.volume = volumeControl.volume+1
}
volumeControl.volume = volumeControl.volume+1

} else if(volumeControlWindow.pressedKey == Qt.Key_VolumeDown) {
//down volume
if(volumeControl.volume > 0) {
volumeControl.volume = volumeControl.volume-1
}
volumeControl.volume = volumeControl.volume-1
}
}
}