From: David Llewellyn-Jones Date: Mon, 16 Jul 2018 01:03:26 +0000 (+0100) Subject: Add images to buttons on main page X-Git-Url: https://www.flypig.org.uk/git/?p=harbour-pedalo.git;a=commitdiff_plain;h=d8058e5edcec89d8103ead111f87dc9040323685 Add images to buttons on main page --- diff --git a/generate.sh b/generate.sh index 170bbf4..7233e82 100755 --- a/generate.sh +++ b/generate.sh @@ -33,3 +33,6 @@ function generate { # Generate titles generate 303 86 "pedalo-title" +# Generate buttons +generate 246 200 "button-journey-add button-journey-start button-journey-finish button-list button-stats" + diff --git a/inputs/button-journey-add.svg b/inputs/button-journey-add.svg new file mode 100644 index 0000000..cc9ac9c --- /dev/null +++ b/inputs/button-journey-add.svg @@ -0,0 +1,135 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/inputs/button-journey-finish.svg b/inputs/button-journey-finish.svg new file mode 100644 index 0000000..7048fa6 --- /dev/null +++ b/inputs/button-journey-finish.svg @@ -0,0 +1,135 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/inputs/button-journey-start.svg b/inputs/button-journey-start.svg new file mode 100644 index 0000000..d27deba --- /dev/null +++ b/inputs/button-journey-start.svg @@ -0,0 +1,135 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/inputs/button-list.svg b/inputs/button-list.svg new file mode 100644 index 0000000..821c379 --- /dev/null +++ b/inputs/button-list.svg @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inputs/button-stats.svg b/inputs/button-stats.svg new file mode 100644 index 0000000..1865042 --- /dev/null +++ b/inputs/button-stats.svg @@ -0,0 +1,127 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/qml/components/BarButton.qml b/qml/components/BarButton.qml index 052f2e2..ddf2cf0 100644 --- a/qml/components/BarButton.qml +++ b/qml/components/BarButton.qml @@ -28,6 +28,7 @@ MouseArea { Label { id: label text: "" + color: Theme.highlightColor font.pixelSize: Theme.fontSizeLarge anchors.right: parent.right anchors.top: parent.top @@ -42,6 +43,7 @@ MouseArea { id: image source: "" anchors.left: parent.left + anchors.leftMargin: Theme.paddingLarge fillMode: Image.PreserveAspectFit width: parent.height height: parent.height @@ -50,7 +52,7 @@ MouseArea { OpacityRampEffect { id: verticalBackgroundEffect slope: 0.5 - offset: -1.0 + offset: -1.5 direction: OpacityRamp.TopToBottom sourceItem: verticalback } @@ -65,8 +67,8 @@ MouseArea { OpacityRampEffect { id: imageeffect - slope: 1.0 - offset: 0.0 + slope: 0.5 + offset: -0.8 direction: OpacityRamp.TopToBottom sourceItem: image } diff --git a/qml/pages/MainPage.qml b/qml/pages/MainPage.qml index 4e7293c..8190afc 100644 --- a/qml/pages/MainPage.qml +++ b/qml/pages/MainPage.qml @@ -33,7 +33,7 @@ Page { spacing: 0 BarButton { - source: "image://theme/icon-launcher-component-gallery" + source: (currentStatus.cycling ? "image://pedalo/button-journey-finish?" : "image://pedalo/button-journey-start?") + (pressed ? Theme.primaryColor : Theme.highlightColor) text: currentStatus.cycling ? qsTr("Finish your journey") : qsTr("Start a journey") onClicked: { if (currentStatus.cycling) { @@ -50,7 +50,7 @@ Page { } BarButton { - source: "image://theme/icon-launcher-component-gallery" + source: "image://pedalo/button-journey-add?" + (pressed ? Theme.primaryColor : Theme.highlightColor) text: "Add a journey" onClicked: pageStack.push(Qt.resolvedUrl("JourneyEdit.qml")) } @@ -66,13 +66,13 @@ Page { x: isPortrait ? 0 : page.width / 2.0 BarButton { - source: "image://theme/icon-launcher-component-gallery" + source: "image://pedalo/button-stats?" + (pressed ? Theme.primaryColor : Theme.highlightColor) text: "View latest stats" onClicked: pageStack.push(Qt.resolvedUrl("Stats.qml")) } BarButton { - source: "image://theme/icon-launcher-component-gallery" + source: "image://pedalo/button-list?" + (pressed ? Theme.primaryColor : Theme.highlightColor) text: "Previous journeys" onClicked: pageStack.push(Qt.resolvedUrl("JourneyList.qml")) } diff --git a/src/imageprovider.cpp b/src/imageprovider.cpp index 431fd23..452fa97 100644 --- a/src/imageprovider.cpp +++ b/src/imageprovider.cpp @@ -15,6 +15,7 @@ QPixmap ImageProvider::requestPixmap(const QString &id, QSize *size, const QSize QPixmap image; QStringList parts = id.split('?'); QPixmap sourcePixmap(imageDir + parts.at(0) + ".png"); + QPixmap alphaMask(sourcePixmap); if (size) { *size = sourcePixmap.size(); @@ -22,8 +23,11 @@ QPixmap ImageProvider::requestPixmap(const QString &id, QSize *size, const QSize if (parts.length() > 1) { if (QColor::isValidColor(parts.at(1))) { QPainter painter(&sourcePixmap); - painter.setCompositionMode(QPainter::CompositionMode_SourceIn); + painter.setCompositionMode(QPainter::CompositionMode_SoftLight); painter.fillRect(sourcePixmap.rect(), parts.at(1)); + + painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); + painter.drawPixmap(sourcePixmap.rect(), alphaMask); painter.end(); } }