Skip to content

Commit

Permalink
Merge pull request #3 from fridlmue/update
Browse files Browse the repository at this point in the history
Update to Version 1.0
  • Loading branch information
fridlmue authored Oct 27, 2022
2 parents eac5bc4 + 7c4de54 commit a34019e
Show file tree
Hide file tree
Showing 15 changed files with 253 additions and 52 deletions.
Binary file added btvol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 113 additions & 0 deletions btvol.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion harbour-btvol.pro
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ CONFIG += sailfishapp
SOURCES += src/harbour-btvol.cpp

DISTFILES += qml/harbour-btvol.qml \
btvol.svg \
qml/cover/CoverPage.qml \
qml/pages/FirstPage.qml \
rpm/harbour-btvol.changes.in \
rpm/harbour-btvol.changes.run.in \
rpm/harbour-btvol.spec \
rpm/harbour-btvol.yaml \
translations/*.ts \
harbour-btvol.desktop
harbour-btvol.desktop \
translations/harbour-btvol-sv.ts

SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172

Expand All @@ -37,3 +39,6 @@ CONFIG += sailfishapp_i18n
# following TRANSLATIONS line. And also do not forget to
# modify the localized app name in the the .desktop file.
TRANSLATIONS += translations/harbour-btvol-de.ts

RESOURCES += \
res.qrc
Binary file modified icons/108x108/harbour-btvol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/128x128/harbour-btvol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/172x172/harbour-btvol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/86x86/harbour-btvol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 34 additions & 2 deletions qml/cover/CoverPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,45 @@ import QtQuick 2.0
import Sailfish.Silica 1.0

CoverBackground {
id: coverPage
transparent: true

Label {
id: label
anchors.centerIn: parent
text: qsTr("BT Volume Control")
text: coverExchange.initialized ? coverExchange.bt_dev : qsTr("BT Volume Control")
}

CoverActionList {
id: coverAction
enabled: coverExchange.initialized
CoverAction {
iconSource: "image://theme/icon-m-remove"
onTriggered: {
dbusbluez.volumeDown();
}
}
CoverAction {
iconSource: "image://theme/icon-m-add"
onTriggered: {
dbusbluez.volumeUp();
}
}
}
Image {
id: bgImg
asynchronous: true
fillMode: Image.PreserveAspectFit
opacity: 0.30
source: "qrc:///btvol.png"
anchors {
bottom: parent.bottom
right: parent.right
bottomMargin: Theme.paddingMedium
rightMargin: Theme.paddingMedium
}
sourceSize {
width: coverPage.width
height: coverPage.height
}
}
}
40 changes: 40 additions & 0 deletions qml/harbour-btvol.qml
Original file line number Diff line number Diff line change
@@ -1,9 +1,49 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import Nemo.DBus 2.0
import "pages"

ApplicationWindow {
initialPage: Component { FirstPage { } }
cover: Qt.resolvedUrl("cover/CoverPage.qml")
allowedOrientations: defaultAllowedOrientations

Item {
id: coverExchange
property bool initialized: false
property string bt_dev: ""
}

Item {
DBusInterface {
property string _deviceAddress
id: dbusbluez
bus: DBus.SystemBus
service: 'org.bluez'
iface: 'org.bluez.MediaControl1'
//path: '/org/bluez/hci0/dev_00_00_00_00_00_00' //_deviceAddress
path: _deviceAddress

function volumeUp() {
call('VolumeUp',
undefined,
function(result) {
// console.log('call completed with:', result)
},
function(error, message) {
// console.log('call failed', error, 'message:', message)
})
}
function volumeDown() {
call('VolumeDown',
undefined,
function(result) {
// console.log('call completed with:', result)
},
function(error, message) {
// console.log('call failed', error, 'message:', message)
})
}
}
}
}
46 changes: 7 additions & 39 deletions qml/pages/FirstPage.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import Nemo.DBus 2.0
import QtQml.Models 2.2
import org.kde.bluezqt 1.0 as BluezQt

Expand All @@ -26,7 +25,7 @@ Page {
}

function getBattPercent(model) {
if (model.battery !== "undefined") {
if (typeof model.battery !== "undefined") {
return " - " + qsTr("Battery: ") + model.battery
}
return ""
Expand All @@ -39,7 +38,6 @@ Page {
}
}


SilicaListView {
id: listView
anchors.fill: parent
Expand All @@ -51,30 +49,27 @@ Page {
onClicked: volumeUp = !volumeUp
}
}

delegate: ListItem {
id: listItem
onClicked: {
_deviceAddress = "/org/bluez/hci0/dev_" + model.Address.split(":").join("_");
console.log(_deviceAddress);
dbusbluez._deviceAddress = "/org/bluez/hci0/dev_" + model.Address.split(":").join("_");
coverExchange.bt_dev = model.FriendlyName
coverExchange.initialized = true
if (volumeUp) {
dbusbluez.volumeUp();
} else {
dbusbluez.volumeDown()();
dbusbluez.volumeDown();
}

}


hidden: !model.Connected
Item {
anchors {
left: parent.left
right: parent.right
margins: Theme.horizontalPageMargin
verticalCenter: parent.verticalCenter
}
height: nameLabel.height + addressLabel.height + Theme.paddingSmall
visible: model.Connected

Label {
id: nameLabel
Expand All @@ -83,7 +78,6 @@ Page {
color: listItem.pressed ? Theme.highlightColor : Theme.primaryColor
}


Label {
id: addressLabel
anchors {
Expand All @@ -94,10 +88,10 @@ Page {
text: model.Address + getBattPercent(model)
color: listItem.pressed ? Theme.secondaryHighlightColor : Theme.secondaryColor
}
height: addressLabel.height + nameLabel.height

}
}

header: Column {
height: header.height + Theme.paddingLarge
width: parent.width
Expand All @@ -106,42 +100,16 @@ Page {
id: header
title: qsTr("Device List")
description: volumeUp ? qsTr("Tap on Device to increase internal Volume") : qsTr("Tap on Device to decrease internal Volume")

}
}

VerticalScrollDecorator { flickable: listView }
}


BluezQt.DevicesModel {
id: devicesModel
filters: BluezQt.DevicesModelPrivate.AllDevices
}


Item {
DBusInterface {
id: dbusbluez
bus: DBus.SystemBus
service: 'org.bluez'
iface: 'org.bluez.MediaControl1'
//path: '/org/bluez/hci0/dev_F8_4E_17_B5_66_89' //_deviceAddress
path: _deviceAddress

function volumeUp() {
call('VolumeUp',
undefined,
function(result) { console.log('call completed with:', result) },
function(error, message) { console.log('call failed', error, 'message:', message) })
}
function volumeDown() {
call('VolumeDown',
undefined,
function(result) { console.log('call completed with:', result) },
function(error, message) { console.log('call failed', error, 'message:', message) })
}
}
}

}
5 changes: 5 additions & 0 deletions res.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>btvol.png</file>
</qresource>
</RCC>
4 changes: 2 additions & 2 deletions rpm/harbour-btvol.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Name: harbour-btvol
# << macros

Summary: BT device Volume Control
Version: 0.1
Version: 1.0
Release: 1
Group: Qt/Qt
License: GPL3
Expand All @@ -26,7 +26,7 @@ BuildRequires: qt5-qttools-linguist
BuildRequires: desktop-file-utils

%description
Short description of my Sailfish OS Application
App to change internal volume of some BT devices


%prep
Expand Down
Loading

0 comments on commit a34019e

Please sign in to comment.