Commit c567df17 authored by Camilo Higuita's avatar Camilo Higuita

more work towards ui scaling on plasma mobile

parent fcd971f9
......@@ -11,6 +11,7 @@
#include "services/local/linking.h"
#ifdef Q_OS_ANDROID
#include "./3rdparty/kirigami/src/kirigamiplugin.h"
#include <QtWebView/QtWebView>
#else
#include <QtWebEngine>
......@@ -84,6 +85,7 @@ int main(int argc, char *argv[])
);
#ifdef Q_OS_ANDROID
KirigamiPlugin::getInstance().registerTypes();
QtWebView::initialize();
#else
// if(QQuickStyle::availableStyles().contains("nomad"))
......
......@@ -92,8 +92,8 @@ Kirigami.ApplicationWindow {
property int miniArtSize: iconSizes.large
property int columnWidth: Kirigami.Units.gridUnit * 17
property int coverSize: isMobile ? Math.sqrt(
root.width * root.height) * 0.4 : columnWidth * 0.6
property int coverSize: isAndroid ? Math.sqrt(root.width * root.height) * 0.4 :
columnWidth * (isMobile ? 0.5 : 0.6)
/***************************************************/
......@@ -146,11 +146,21 @@ Kirigami.ApplicationWindow {
readonly property int defaultFontSize: Kirigami.Theme.defaultFont.pointSize
readonly property var fontSizes: ({
tiny: defaultFontSize * 0.4,
small: defaultFontSize * 0.6,
medium: defaultFontSize * 0.8,
default: defaultFontSize,
big: defaultFontSize * 1.2,
large: defaultFontSize * 1.4
small: (isMobile ? defaultFontSize * 0.4 :
defaultFontSize * 0.6),
medium: (isMobile ? defaultFontSize * 0.6 :
defaultFontSize * 0.8),
default: (isMobile ? defaultFontSize * 0.8 :
defaultFontSize),
big: (isMobile ? defaultFontSize :
defaultFontSize * 1.2),
large: (isMobile ? defaultFontSize * 1.2 :
defaultFontSize * 1.4)
})
readonly property var space : ({
......@@ -232,7 +242,7 @@ Kirigami.ApplicationWindow {
pageStack.separatorVisible: pageStack.wideMode
overlay.modal: Rectangle {
color: isMobile ? darkColor : "transparent"
color: isAndroid ? darkColor : "transparent"
opacity: 0.5
height: root.height - playbackControls.height - toolbar.height
y: toolbar.height
......@@ -374,7 +384,7 @@ Kirigami.ApplicationWindow {
Slider {
id: progressBar
height: 10
height: iconSizes.small
width: parent.width
anchors.left: parent.left
anchors.right: parent.right
......@@ -392,14 +402,14 @@ Kirigami.ApplicationWindow {
x: progressBar.leftPadding
y: progressBar.y
implicitWidth: 200
implicitHeight: 10
implicitHeight: iconSizes.tiny*0.1
width: progressBar.availableWidth
height: implicitHeight
color: "transparent"
Rectangle {
width: progressBar.visualPosition * parent.width
height: 4
height: iconSizes.tiny*0.1
color: babeColor
}
}
......@@ -408,9 +418,9 @@ Kirigami.ApplicationWindow {
x: progressBar.leftPadding + progressBar.visualPosition
* (progressBar.availableWidth - width)
y: progressBar.y - (height / 2)
implicitWidth: progressBar.pressed ? 16 : 0
implicitHeight: progressBar.pressed ? 16 : 0
radius: progressBar.pressed ? 16 : 0
implicitWidth: progressBar.pressed ? iconSizes.medium : 0
implicitHeight: progressBar.pressed ? iconSizes.medium : 0
radius: progressBar.pressed ? iconSizes.medium : 0
color: babeColor
}
}
......@@ -441,8 +451,8 @@ Kirigami.ApplicationWindow {
Rectangle {
visible: miniArtwork.visible
anchors.centerIn: parent
height: miniArtSize + 4
width: miniArtSize + 4
height: miniArtSize + miniArtSize*0.05
width: miniArtSize + miniArtSize*0.05
color: darktextColor
opacity: opacityLevel
......
......@@ -52,7 +52,7 @@ BabeDialog
text:qsTr("Linking allows to connect two devices on the same network. Just provide the device IP address to which you want to connect")
verticalAlignment: Qt.AlignVCenter
elide: Text.ElideRight
font.pointSize: fontSizes.medium
font.pointSize: fontSizes.default
wrapMode: Text.Wrap
Layout.fillWidth: true
}
......@@ -69,7 +69,7 @@ BabeDialog
text: qsTr("IP Address")
verticalAlignment: Qt.AlignVCenter
elide: Text.ElideRight
font.pointSize: fontSizes.medium
font.pointSize: fontSizes.default
Layout.fillWidth: true
}
......
......@@ -63,7 +63,7 @@ ColumnLayout
{
id: linkingFilter
headerBarExitIcon: "arrow-left"
headerBarExitIcon: "go-previous"
model : ListModel {}
delegate: BabeDelegate
......@@ -99,7 +99,7 @@ ColumnLayout
trackDuration: false
allowMenu: false
headerBarVisible: true
headerBarExitIcon: "arrow-left"
headerBarExitIcon: "go-previous"
headerBarExit: !linkingPage.wideMode
headerBarTitle: linkingPage.wideMode ? "" : linkingModel.model.get(linkingModel.currentIndex).playlist
onExit: if(!linkingPage.wideMode)
......
......@@ -5,44 +5,49 @@
#include <QByteArray>
#include <QObject>
#if defined(Q_OS_ANDROID)
#include <./3rdparty/taglib/tag.h>
#include <./3rdparty/taglib/fileref.h>
#else
#include <taglib/tag.h>
#include <taglib/fileref.h>
#endif
namespace TagLib
{
class FileRef;
class FileRef;
}
class TagInfo : public QObject
{
Q_OBJECT
public:
TagInfo(QObject *parent = nullptr);
~TagInfo();
bool feed(const QString &url);
QString getAlbum() const;
QString getTitle() const;
QString getArtist() const;
int getTrack() const;
QString getGenre() const;
QString fileName() const;
QString getComment() const;
QByteArray getCover() const;
int getDuration() const;
uint getYear() const;
void setAlbum(const QString &album) ;
void setTitle(const QString &title);
void setTrack(const int &track);
void setArtist(const QString &artist);
void setGenre(const QString &genre);
void setComment(const QString &comment);
void setCover(const QByteArray &array);
private:
TagLib::FileRef file;
QString path;
Q_OBJECT
public:
TagInfo(QObject *parent = nullptr);
~TagInfo();
bool feed(const QString &url);
QString getAlbum() const;
QString getTitle() const;
QString getArtist() const;
int getTrack() const;
QString getGenre() const;
QString fileName() const;
QString getComment() const;
QByteArray getCover() const;
int getDuration() const;
uint getYear() const;
void setAlbum(const QString &album) ;
void setTitle(const QString &title);
void setTrack(const int &track);
void setArtist(const QString &artist);
void setGenre(const QString &genre);
void setComment(const QString &comment);
void setCover(const QByteArray &array);
private:
TagLib::FileRef file;
QString path;
};
#endif // TAGINFO_H
......@@ -87,7 +87,7 @@ Page
Loader
{
id: youtubePlayer
source: isMobile ? "qrc:/services/web/YoutubePlayer_A.qml" : "qrc:/services/web/YoutubePlayer.qml"
source: isAndroid ? "qrc:/services/web/YoutubePlayer_A.qml" : "qrc:/services/web/YoutubePlayer.qml"
}
BabePopup
......@@ -117,7 +117,7 @@ Page
text: qsTr("Custom API Key")
verticalAlignment: Qt.AlignVCenter
elide: Text.ElideRight
font.pointSize: fontSizes.medium
font.pointSize: fontSizes.default
Layout.column: 1
Layout.row: 2
Layout.fillWidth: true
......@@ -136,7 +136,7 @@ Page
text: qsTr("Search results")
verticalAlignment: Qt.AlignVCenter
elide: Text.ElideRight
font.pointSize: fontSizes.medium
font.pointSize: fontSizes.default
Layout.column: 1
Layout.row: 4
Layout.fillWidth: true
......@@ -283,23 +283,12 @@ Page
{
id: searchBox
Layout.fillWidth: true
// width: parent.width
// height: toolBarHeight
position: ToolBar.Footer
Rectangle
{
anchors.fill: parent
z: -999
color: backgroundColor
}
position: ToolBar.Footer
RowLayout
{
anchors.fill: parent
TextInput
{
id: searchInput
......
......@@ -18,27 +18,12 @@ Page
spacing: 0
Rectangle
ToolBar
{
id: headerRoot
width: parent.width
height: visible ? toolBarHeight : 0
width: parent.width
Layout.fillWidth: true
focus: true
color: darkDarkColor
Kirigami.Separator
{
visible: !isMobile
width: parent.width
height: 1
anchors
{
left: parent.left
right: parent.right
bottom: parent.bottom
}
}
RowLayout
{
......@@ -50,8 +35,7 @@ Page
Layout.alignment : Qt.AlignLeft
Layout.leftMargin: contentMargins
width: rowHeight
iconName : "arrow-left"
iconColor: darktextColor
iconName : "go-previous"
onClicked: stackView.pop(youtubeList)
}
......@@ -64,7 +48,6 @@ Page
elide : Text.ElideRight
font.bold : false
color : darktextColor
font.pointSize: fontSizes.big
horizontalAlignment : Text.AlignHCenter
verticalAlignment : Text.AlignVCenter
......@@ -75,7 +58,6 @@ Page
Layout.alignment : Qt.AlignLeft
width: rowHeight
iconName : "link"
iconColor: darktextColor
onClicked: webView.url = currentYt.url.replace("embed/", "watch?v=")
}
......@@ -84,7 +66,6 @@ Page
Layout.alignment : Qt.AlignLeft
width: rowHeight
iconName : "download"
iconColor: darktextColor
onClicked: bae.getYoutubeTrack(JSON.stringify(currentYt))
}
......@@ -95,7 +76,6 @@ Page
Layout.rightMargin: contentMargins
width: rowHeight
iconName : "overflow-menu"
iconColor: darktextColor
}
}
}
......@@ -106,7 +86,7 @@ Page
clip: true
Layout.fillHeight: true
Layout.fillWidth: true
source: isMobile ? "qrc:/services/web/WebView_A.qml" : "qrc:/services/web/WebView.qml"
source: isAndroid ? "qrc:/services/web/WebView_A.qml" : "qrc:/services/web/WebView.qml"
onVisibleChanged:
{
if(!visible) webView.url = "about:blank"
......
......@@ -1699,7 +1699,7 @@ var Babe = {
"media-playlist-repeat": "\uf49E",
"babe" : Icon.heart,
"arrow-left": Icon.arrowLeft,
"go-previous": Icon.arrowLeft,
"overflow-menu": Icon.dotsVertical,
"player-time": "\uf40C",
......
......@@ -44,7 +44,7 @@ ItemDelegate
text: labelTxt.text
elide: Text.ElideRight
color: labelColor
font.pointSize: fontSizes.medium
font.pointSize: fontSizes.default
font.bold: boldLabel
font.weight : boldLabel ? Font.Bold : Font.Normal
......
......@@ -4,25 +4,30 @@ import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
ColumnLayout
ItemDelegate
{
id: babeAlbumRoot
signal albumClicked(int index)
signal albumPressed(int index)
property int albumSize : 150
property int borderRadius : 2
property int albumSize : iconSizes.huge
property int borderRadius : albumSize*0.05
property int albumRadius : 0
property bool albumCard : true
property string fillColor: backgroundColor
property string labelColor: textColor
property bool hide : false
property color labelColor : GridView.isCurrentItem || hovered ? highlightColor : textColor
// height: typeof album === 'undefined' ? parseInt(albumSize+(albumSize*0.3)) : parseInt(albumSize+(albumSize*0.4))
visible: !hide
spacing: 0
hoverEnabled: !isMobile
// spacing: 0
background: Rectangle
{
color: "transparent"
}
DropShadow
{
......@@ -40,88 +45,125 @@ ColumnLayout
{
id: card
visible: albumCard
anchors.fill: parent
width: albumSize
height:albumSize
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
color: fillColor
radius: borderRadius
}
Item
{
height: albumSize
width: albumSize
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
ColumnLayout
{
anchors.fill: parent
anchors.centerIn: parent
Image
Item
{
id: img
width: albumSize
height: albumSize
Layout.fillHeight: true
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
Layout.maximumHeight: albumSize
Layout.minimumHeight: albumSize
sourceSize.width: albumSize
sourceSize.height: albumSize
Image
{
id: img
width: albumSize
height: albumSize
fillMode: Image.PreserveAspectFit
cache: true
antialiasing: true
anchors.centerIn: parent
source:
{
if(artwork)
(artwork.length > 0 && artwork !== "NONE")? "file://"+encodeURIComponent(artwork) : "qrc:/assets/cover.png"
else "qrc:/assets/cover.png"
}
layer.enabled: albumRadius > 0
layer.effect: OpacityMask
{
maskSource: Item
sourceSize.width: albumSize
sourceSize.height: albumSize
fillMode: Image.PreserveAspectFit
cache: true
// antialiasing: true
source:
{
width: img.width
height: img.height
Rectangle
if(artwork)
(artwork.length > 0 && artwork !== "NONE")? "file://"+encodeURIComponent(artwork) : "qrc:/assets/cover.png"
else "qrc:/assets/cover.png"
}
layer.enabled: albumRadius > 0
layer.effect: OpacityMask
{
maskSource: Item
{
anchors.centerIn: parent
width: img.adapt ? img.width : Math.min(img.width, img.height)
height: img.adapt ? img.height : width
radius: albumRadius
// radius: Math.min(width, height)
width: img.width
height: img.height
Rectangle
{
anchors.centerIn: parent
width: img.adapt ? img.width : Math.min(img.width, img.height)
height: img.adapt ? img.height : width
radius: albumRadius
// radius: Math.min(width, height)
}
}
}
}
}
}
Column
{
id: albumInfoRow
Layout.maximumHeight: rowHeight
Layout.fillWidth: true
Layout.fillHeight: true
Layout.margins: contentMargins
spacing: 5
Label
Item
{
width: parent.width
text: typeof album === 'undefined' ? artist : album
visible: true
horizontalAlignment: Qt.AlignHCenter
elide: Text.ElideRight
font.pointSize: fontSizes.medium
font.bold: true
color: labelColor
}
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter
Layout.margins: 0
ColumnLayout
{
anchors.fill: parent
spacing: space.tiny
Item
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
// Layout.margins: space.medium
Label
{
width: parent.width * 0.8
anchors.centerIn: parent
text: typeof album === 'undefined' ? artist : album
visible: true
horizontalAlignment: Qt.AlignHCenter
elide: Text.ElideRight
font.pointSize: fontSizes.default
font.bold: true
font.weight: Font.Bold
color: labelColor
}
}
Item
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
// Layout.margins: space.medium
Label
{
width: parent.width*0.8
anchors.centerIn: parent
text: typeof album === 'undefined' ? "" : artist
visible: typeof album === 'undefined'? false : true
horizontalAlignment: Qt.AlignHCenter
elide: Text.ElideRight
font.pointSize: fontSizes.medium
color: labelColor
}
}
}
Label
{
width: parent.width
text: typeof album === 'undefined' ? "" : artist
visible: typeof album === 'undefined'? false : true
horizontalAlignment: Qt.AlignHCenter
elide: Text.ElideRight
font.pointSize: fontSizes.small
color: labelColor
}
}
......@@ -129,7 +171,6 @@ ColumnLayout
{
anchors.fill: parent
onClicked: albumClicked(index)
onPressAndHold: albumPressed(index)
}
......
......@@ -2,34 +2,22 @@ import QtQuick.Controls 2.2
import QtQuick 2.9
import ".."
Page
Pane
{
id: gridPage
padding: 20
// readonly property int screenSize : bae.screenGeometry("width")*bae.screenGeometry("height");
// readonly property int screenSize : bae.screenGeometry("width")*bae.screenGeometry("height");
property int hintSize : Math.sqrt(root.width*root.height)*0.3
property int albumCoverSize: hintSize > 150 ? 150 : hintSize
// property int albumSize:
// {
// if(!isMobile)
// {
// Math.sqrt(screenSize)*0.15 > 150 ? 150 : Math.sqrt(screenSize)*0.15
// }else
// {
// if(hintSize > 150)
// 150
// else
// hintSize
// }
// }
readonly property int albumSpacing: contentMargins*2
property int albumCoverRadius : 0
property int albumCoverSize: isMobile ? iconSizes.huge : iconSizes.enormous
readonly property int albumSpacing: albumCoverSize*0.5 + space.big
property int albumCoverRadius : albumCoverSize*0.05
property bool albumCardVisible : true
property alias gridModel: gridModel
property alias grid: grid
signal albumCoverClicked(string album, string artist)
signal albumCoverPressed(string album, string artist)
signal bgClicked()
......@@ -59,7 +47,7 @@ Page
GridView
{
id: grid
clip: true
MouseArea
{
anchors.fill: parent
......@@ -67,15 +55,11 @@ Page
z: -999
}
width: Math.min(model.count, Math.floor(parent.width/cellWidth))*cellWidth
width: parent.width
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter
cellWidth: albumCoverSize + albumSpacing
cellHeight: albumCoverSize+rowHeight+albumSpacing
highlightFollowsCurrentItem: false
cellHeight: albumCoverSize + albumSpacing
focus: true
boundsBehavior: Flickable.StopAtBounds
......@@ -87,30 +71,6 @@ Page
// maximumFlickVelocity: albumSize*8
model: gridModel
// highlight: Rectangle
// {
// id: highlight
// width: albumSize
// height: albumSize
// color: myPalette.highlight
// radius: 4
// }
// onWidthChanged:
// {
// var amount = parseInt(grid.width/(albumSize+albumSpacing),10)
// var leftSpace = parseInt(grid.width-(amount*albumSize), 10)
// var size = parseInt(albumSize+(parseInt(leftSpace/amount, 10)), 10)
// size = size > albumSize+albumSpacing ? size : albumSize+albumSpacing
// grid.cellWidth = size
// // grid.cellHeight = size
// }
delegate: BabeAlbum
{
id: albumDelegate
......@@ -119,6 +79,9 @@ Page
albumRadius: albumCoverRadius
albumCard: albumCardVisible
height: grid.cellHeight
width: grid.cellWidth
Connections
{
target: albumDelegate
......@@ -140,6 +103,18 @@ Page
}
ScrollBar.vertical:BabeScrollBar { visible: true }
onWidthChanged:
{
var amount = parseInt(width/(albumCoverSize + albumSpacing),10)
var leftSpace = parseInt(width-(amount*(albumCoverSize + albumSpacing)), 10)
var size = parseInt((albumCoverSize + albumSpacing)+(parseInt(leftSpace/amount, 10)), 10)
size = size > albumCoverSize + albumSpacing? size : albumCoverSize + albumSpacing
cellWidth = size
// grid.cellHeight = size
}
}
}
......@@ -33,8 +33,8 @@ Item
id: imageHolder
anchors.centerIn: parent
width: 40