Skip to content

Commit

Permalink
Make amount of tiles on mainpage even by adding About tile (thanks Fu…
Browse files Browse the repository at this point in the history
…chsmich)
  • Loading branch information
a-dekker committed Aug 24, 2020
1 parent 603e0ec commit 903c75e
Show file tree
Hide file tree
Showing 11 changed files with 335 additions and 272 deletions.
1 change: 1 addition & 0 deletions harbour-smpc.pro
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ HEADERS += \
DISTFILES += \
harbour-smpc.desktop \
qml/components/ConsumeSwitch.qml \
qml/components/MainMenuItem.qml \
qml/components/SingleSwitch.qml \
rpm/harbour-smpc.changes \
rpm/harbour-smpc.spec \
Expand Down
36 changes: 36 additions & 0 deletions qml/components/MainMenuItem.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import QtQuick 2.0
import Sailfish.Silica 1.0

BackgroundItem {
id: gridItem
property alias text: itemLabel.text
property alias iconSource: itemIcon.source
width: Theme.itemSizeHuge
height: width
Rectangle {
anchors.fill: parent
anchors.margins: Theme.paddingSmall
color: Theme.rgba(
Theme.highlightBackgroundColor,
Theme.highlightBackgroundOpacity)
}
Column {
anchors.centerIn: parent
Image {
id: itemIcon
//source: icon
anchors.horizontalCenter: parent.horizontalCenter
}
Label {
id: itemLabel
anchors {
horizontalCenter: parent.horizontalCenter
}
font.pixelSize: Theme.fontSizeMedium
width: gridItem.width - (2 * Theme.paddingSmall)
horizontalAlignment: "AlignHCenter"
scale: paintedWidth > width ? (width / paintedWidth) : 1
//text: name
}
}
}
282 changes: 115 additions & 167 deletions qml/pages/MainPage.qml
Original file line number Diff line number Diff line change
@@ -1,149 +1,137 @@
import QtQuick 2.2
import Sailfish.Silica 1.0
import "../components"
import QtQml.Models 2.2

Page {
id: mainPage
PageHeader {
id: mainHeader
title: "SMPC"
anchors {
top: parent.top
right: parent.right
left: parent.left
}
}
property list<Component> mainMenuBtn: [
Component {
MainMenuItem {
text: qsTr("Saved playlists")
iconSource: "image://theme/icon-m-document"
onClicked: {

Label {
id: connectedLabel
anchors {
top: mainHeader.bottom
right: parent.right
left: parent.left
}
horizontalAlignment: Text.AlignHCenter
color: Theme.highlightColor
text: connected ? qsTr("Connected to: %1").arg(profilename) : qsTr(
"Disconnected")
}
}
}
},
Component {
MainMenuItem {
text: qsTr("Shuffle all")
iconSource: "image://theme/icon-m-shuffle"
onClicked: {

SilicaFlickable {
anchors {
top: connectedLabel.bottom
bottom: parent.bottom
right: parent.right
left: parent.left
}
}
}
contentHeight: mainGrid.height
clip: true
Item {
height: mainGrid.height
width: parent.width
Grid {
id: mainGrid
]

columns: Screen.sizeCategory
>= Screen.Large ? 3 : (orientation === Orientation.Landscape
|| orientation
=== Orientation.LandscapeInverted) ? 4 : 2
SilicaGridView {
id: gridView
property int columns:
Screen.sizeCategory >= Screen.Large ?
3 : (orientation === Orientation.Landscape || orientation === Orientation.LandscapeInverted) ?
4 : 2
anchors.top: mainPage.top
anchors.bottom: mainPage.bottom
anchors.horizontalCenter: parent.horizontalCenter
width: columns*cellWidth

header: Item {
width: GridView.view.width
height: headerCol.height
Column {
id: headerCol
width: mainPage.width
anchors.horizontalCenter: parent.horizontalCenter
Repeater {
model: mainMenuModel
delegate: Component {
BackgroundItem {
id: gridItem
width: Theme.itemSizeHuge
height: Theme.itemSizeHuge
Rectangle {
anchors.fill: parent
anchors.margins: Theme.paddingSmall
color: Theme.rgba(
Theme.highlightBackgroundColor,
Theme.highlightBackgroundOpacity)
}
Column {
anchors.centerIn: parent
Image {
id: itemIcon
source: icon
anchors.horizontalCenter: parent.horizontalCenter
}
Label {
id: itemLabel
anchors {
horizontalCenter: parent.horizontalCenter
}
font.pixelSize: Theme.fontSizeMedium
width: gridItem.width - (2 * Theme.paddingSmall)
horizontalAlignment: "AlignHCenter"
scale: paintedWidth > width ? (width / paintedWidth) : 1
PageHeader {
title: "SMPC"
}
Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
text: connected ? qsTr("Connected to: %1").arg(profilename) : qsTr(
"Disconnected")
color: Theme.highlightColor
}
}
}


/* transform: [
Scale {
id: scale
xScale: yScale
yScale: itemLabel.width > (gridItem.width - (2 * Theme.paddingSmall)) ? (gridItem.width - (2 * Theme.paddingSmall)) / itemLabel.width : 1
},
Translate {
x: scale.xScale != 1 ? ((gridItem.width - (2 * Theme.paddingSmall))-itemLabel.width*scale.xScale)/2 : 0 ;
y: scale.yScale != 1 ? ((gridItem.height - (2 * Theme.paddingSmall))-itemLabel.height*scale.yScale)/2 : 0;}
]
*/
text: name
}
}
cellHeight: Theme.itemSizeHuge
cellWidth: cellHeight

onClicked: {
parseClickedMainMenu(ident)
}
}
model: ObjectModel {
MainMenuItem {
text: qsTr("Playlist")
iconSource: "image://theme/icon-m-document"
onClicked: if (connected)
pageStack.push(Qt.resolvedUrl("database/CurrentPlaylistPage.qml"))
}
MainMenuItem {
text: qsTr("Artists")
iconSource: "image://theme/icon-m-mic"
enabled: connected
onClicked:{
if (connected) {
requestArtists()
pageStack.push(Qt.resolvedUrl("database/ArtistListPage.qml"))
}
}
}
}
}

Component.onCompleted: {
mainMenuModel.append({
"name": qsTr("Playlist"),
"ident": "playlist",
"icon": "image://theme/icon-m-document"
})
mainMenuModel.append({
"name": qsTr("Artists"),
"ident": "artists",
"icon": "image://theme/icon-m-mic"
})
mainMenuModel.append({
"name": qsTr("Albums"),
"ident": "albums",
"icon": "image://theme/icon-m-music"
})
mainMenuModel.append({
"name": qsTr("Files"),
"ident": "files",
"icon": "image://theme/icon-m-folder"
})
mainMenuModel.append({
"name": qsTr("Search"),
"ident": "search",
"icon": "image://theme/icon-m-search"
})
mainMenuModel.append({
"name": qsTr("Connect"),
"ident": "connectto",
"icon": "image://theme/icon-m-computer"
})
mainMenuModel.append({
"name": qsTr("Settings"),
"ident": "settings",
"icon": "image://theme/icon-m-developer-mode"
})
}
MainMenuItem {
text: qsTr("Albums")
iconSource: "image://theme/icon-m-music"
onClicked: {
artistname = ""
if (connected) {
requestAlbums()
pageStack.push(Qt.resolvedUrl("database/AlbumListPage.qml"), {
"artistname": artistname
})
}
}
}

ListModel {
id: mainMenuModel
MainMenuItem {
text: qsTr("Files")
iconSource: "image://theme/icon-m-folder"
onClicked: if (connected) filesClicked("/")
}

MainMenuItem {
text: qsTr("Search")
iconSource: "image://theme/icon-m-search"
onClicked: if (connected) pageStack.push(Qt.resolvedUrl("database/SearchPage.qml"))
}

MainMenuItem {
text: qsTr("Connect")
iconSource: "image://theme/icon-m-computer"
onClicked: pageStack.push(Qt.resolvedUrl("settings/ConnectServerPage.qml"))
}
MainMenuItem {
text: qsTr("Settings")
iconSource: "image://theme/icon-m-developer-mode"
onClicked: pageStack.push(Qt.resolvedUrl("settings/SettingsPage.qml"))
}
MainMenuItem {
text: qsTr("About")
iconSource: "image://theme/icon-m-about"
onClicked: pageStack.push(Qt.resolvedUrl("settings/AboutPage.qml"))
}
Loader {
active: gridView.columns === 3
sourceComponent: Component {
MainMenuItem {
text: qsTr("Playback")
iconSource: "image://theme/icon-m-music"
onClicked: pageStack.push(Qt.resolvedUrl("settings/PlaybackSettings.qml"))
}
}
}
}
}

Timer {
Expand All @@ -157,46 +145,6 @@ Page {
}
}

function parseClickedMainMenu(ident) {
if (ident === "playlist") {
if (connected) {
//pageStack.navigateForward(PageStackAction.Animated)
pageStack.push(Qt.resolvedUrl(
"database/CurrentPlaylistPage.qml"))
}
} else if (ident === "settings") {
pageStack.push(Qt.resolvedUrl("settings/SettingsPage.qml"))
} else if (ident === "currentsong") {
if (connected)
pageStack.push(currentsongpage)
} else if (ident === "albums") {
artistname = ""
if (connected) {
requestAlbums()
pageStack.push(Qt.resolvedUrl("database/AlbumListPage.qml"), {
"artistname": artistname
})
}
} else if (ident === "artists") {
if (connected) {
requestArtists()
pageStack.push(Qt.resolvedUrl("database/ArtistListPage.qml"))
}
} else if (ident === "files") {
if (connected)
filesClicked("/")
} else if (ident === "connectto") {
pageStack.push(Qt.resolvedUrl("settings/ConnectServerPage.qml"))
} else if (ident === "about") {
aboutdialog.visible = true
aboutdialog.open()
} else if (ident === "updatedb") {
updateDB()
} else if (ident === "search") {
pageStack.push(Qt.resolvedUrl("database/SearchPage.qml"))
}
}

onStatusChanged: {
if (status === PageStatus.Active) {
if (mPlaylistPage == undefined) {
Expand Down
10 changes: 5 additions & 5 deletions qml/pages/settings/SettingsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ Page {
"ident": "updatedb",
"img": "icon-m-refresh"
})
settingsMenuModel.append({
"name": qsTr("About"),
"ident": "about",
"img": "icon-m-about"
})
// settingsMenuModel.append({
// "name": qsTr("About"),
// "ident": "about",
// "img": "icon-m-about"
// })
// Debug-only
if (mDebugEnabled) {
settingsMenuModel.append({
Expand Down
7 changes: 5 additions & 2 deletions rpm/harbour-smpc.changes
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
# * date Author's Name <author's email> version-release
# - Summary of changes

* Thu Aug 20 2020 Arno Dekker <jack.tar@example.com> 1.3.19-1
- Add option to enable volume rocker to control MPD volume
* Mon Aug 24 2020 Arno Dekker <jack.tar@example.com> 1.3.20-1
- Make amount of tiles on mainpage even by adding About tile (thanks Fuchsmich)
- Highlight currently connected machine on connect page
* Sat Aug 22 2020 Arno Dekker <jack.tar@example.com> 1.3.19-1
- Added icons to server and settings pages
* Thu Aug 20 2020 Arno Dekker <jack.tar@example.com> 1.3.18-1
- Add option to enable volume rocker to control MPD volume
* Fri Aug 07 2020 Arno Dekker <jack.tar@example.com> 1.3.17-1
Expand Down
2 changes: 1 addition & 1 deletion rpm/harbour-smpc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Name: harbour-smpc
# << macros

Summary: SailfishOS Port of qmobilempd client
Version: 1.3.19
Version: 1.3.20
Release: 1
Group: Qt/Qt
License: GPLv3
Expand Down
Loading

1 comment on commit 903c75e

@fuchsmich
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you.
ATM I've got very little spare time for this project, sorry. But I'll be back. 🤖

Please sign in to comment.