Commit f40d82c1 authored by Ismael Asensio's avatar Ismael Asensio

[cuttlefish] Refactor icon montage

Extract the common code shared between `Preview`, `ResponsivePreview`
and `DualMontage` into a common component (`IconMontage`)`.
parent 33e6e04d
......@@ -34,10 +34,11 @@ Item {
nameFilters: [ "PNG screenshot files (*.png)" ]
}
Column {
Rectangle {
IconMontage {
height: 256
width: 512
color: Kirigami.Theme.backgroundColor
showWatermark: true
Kirigami.Theme.inherit: false
Kirigami.Theme.textColor: "#232629"
Kirigami.Theme.backgroundColor: "#eff0f1"
......@@ -46,50 +47,12 @@ Item {
Kirigami.Theme.positiveTextColor: "#27ae60"
Kirigami.Theme.neutralTextColor: "#f67400"
Kirigami.Theme.negativeTextColor: "#da4453"
RowLayout {
id: previewGrid
anchors.centerIn: parent
Repeater {
model: cuttlefish.iconSizes
delegate: ColumnLayout {
Layout.alignment: Qt.AlignBottom
Kirigami.Icon {
source: preview.iconName
implicitWidth: modelData
implicitHeight: implicitWidth
}
QQC2.Label {
Layout.alignment: Qt.AlignHCenter
text: modelData
Behavior on color {
ColorAnimation {
duration: Kirigami.Units.longDuration
}
}
}
}
}
}
Row {
anchors.top: parent.top
anchors.left: parent.left
anchors.margins: Kirigami.Units.smallSpacing
Kirigami.Icon {
height: 32
width: 32
source: "cuttlefish"
}
QQC2.Label {
anchors.verticalCenter: parent.verticalCenter
text: "Montage made with Cuttlefish"
}
}
}
Rectangle {
IconMontage {
height: 256
width: 512
color: Kirigami.Theme.backgroundColor
showWatermark: false
Kirigami.Theme.inherit: false
Kirigami.Theme.textColor: "#eff0f1"
Kirigami.Theme.backgroundColor: "#31363b"
......@@ -98,30 +61,6 @@ Item {
Kirigami.Theme.positiveTextColor: "#27ae60"
Kirigami.Theme.neutralTextColor: "#f67400"
Kirigami.Theme.negativeTextColor: "#da4453"
RowLayout {
anchors.centerIn: parent
Repeater {
model: cuttlefish.iconSizes
delegate: ColumnLayout {
Layout.alignment: Qt.AlignBottom
Kirigami.Icon {
source: preview.iconName
implicitWidth: modelData
implicitHeight: implicitWidth
}
QQC2.Label {
Layout.alignment: Qt.AlignHCenter
text: modelData
Behavior on color {
ColorAnimation {
duration: Kirigami.Units.longDuration
}
}
}
}
}
}
}
}
}
/*
SPDX-FileCopyrightText: 2014-2017 Sebastian Kügler <sebas@kde.org>
SPDX-FileCopyrightText: 2019 Carson Black <uhhadd@gmail.com>
SPDX-FileCopyrightText: 2020 David Redondo <kde@david-redondo.de>
SPDX-FileCopyrightText: 2020 Ismael Asensio <isma.af@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick 2.2
import QtQuick.Controls 2.5 as QQC2
import QtQuick.Layouts 1.0
import org.kde.kirigami 2.8 as Kirigami
Rectangle {
property int columns: cuttlefish.iconSizes.length
property bool showWatermark: false
color: Kirigami.Theme.backgroundColor
implicitWidth: previewGridLayout.implicitWidth
implicitHeight: previewGridLayout.implicitHeight
GridLayout {
id: previewGridLayout
anchors.centerIn: parent
Repeater {
model: cuttlefish.iconSizes
delegate: ColumnLayout {
readonly property bool isLastItem: (index == columns)
Layout.alignment: Qt.AlignBottom | Qt.AlignHCenter
Layout.row: isLastItem ? 1 : 0
Layout.column: isLastItem ? 0 : index
Layout.columnSpan: isLastItem ? columns : 1
Kirigami.Icon {
source: preview.iconName
implicitWidth: modelData
implicitHeight: implicitWidth
}
QQC2.Label {
Layout.alignment: Qt.AlignHCenter
text: modelData
Behavior on color {
ColorAnimation {
duration: Kirigami.Units.longDuration
}
}
}
}
}
}
Row {
opacity: showWatermark ? 1 : 0
anchors.top: parent.top
anchors.left: parent.left
anchors.margins: Kirigami.Units.smallSpacing
Kirigami.Icon {
height: 32
width: 32
source: "cuttlefish"
}
QQC2.Label {
anchors.verticalCenter: parent.verticalCenter
text: "Montage made with Cuttlefish"
}
Behavior on opacity {
OpacityAnimator {
duration: Kirigami.Units.longDuration
}
}
}
}
......@@ -79,12 +79,13 @@ Rectangle {
font.capitalization: Font.Capitalize
}
}
Rectangle {
IconMontage {
id: iconPreview
property bool screenshotting: false
color: Kirigami.Theme.backgroundColor
columns: cuttlefish.iconSizes.length - 1
showWatermark: iconPreview.screenshotting
Behavior on color {
ColorAnimation {
......@@ -98,65 +99,11 @@ Rectangle {
}
Layout.fillWidth: true
Layout.preferredHeight: screenshotting ? previewGrid.height + (Kirigami.Units.gridUnit * 4) : previewGrid.height
Layout.preferredHeight: implicitHeight + (screenshotting ? (Kirigami.Units.gridUnit * 4) : 0)
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.bottomMargin: Kirigami.Units.largeSpacing * 4
ColumnLayout {
id: previewGrid
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
GridLayout {
id: previewGridLayout
Layout.alignment: Qt.AlignHCenter
columns: cuttlefish.iconSizes.length - 1
Repeater {
model: cuttlefish.iconSizes
delegate: ColumnLayout {
readonly property bool isLastItem: (index == previewGridLayout.columns)
Layout.alignment: Qt.AlignBottom | Qt.AlignHCenter
Layout.row: isLastItem ? 1 : 0
Layout.column: isLastItem ? 0 : index
Layout.columnSpan: isLastItem ? previewGridLayout.columns : 1
Kirigami.Icon {
source: preview.iconName
implicitWidth: modelData
implicitHeight: implicitWidth
}
QQC2.Label {
Layout.alignment: Qt.AlignHCenter
text: modelData
Behavior on color {
ColorAnimation {
duration: Kirigami.Units.longDuration
}
}
}
}
}
}
}
Row {
opacity: iconPreview.screenshotting ? 1 : 0
anchors.top: parent.top
anchors.left: parent.left
anchors.margins: Kirigami.Units.smallSpacing
Kirigami.Icon {
height: 32
width: 32
source: "cuttlefish"
}
QQC2.Label {
anchors.verticalCenter: parent.verticalCenter
text: "Montage made with Cuttlefish"
}
Behavior on opacity {
OpacityAnimator {
duration: Kirigami.Units.longDuration
}
}
}
function shot(type) {
iconPreview.screenshotting = true
if (type == "normal") {
......
......@@ -49,29 +49,9 @@ Kirigami.GlobalDrawer {
font.capitalization: Font.Capitalize
}
}
GridLayout {
IconMontage {
id: grid
columns: 2
columns: cuttlefish.iconSizes.length - 1
Layout.alignment: Qt.AlignHCenter
Repeater {
model: cuttlefish.iconSizes.slice(0, cuttlefish.iconSizes.length - 1)
delegate: ColumnLayout {
Layout.alignment: Qt.AlignBottom
Kirigami.Icon {
source: preview.iconName
implicitWidth: modelData
implicitHeight: implicitWidth
}
QQC2.Label {
Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
text: modelData
Behavior on color {
ColorAnimation {
duration: Kirigami.Units.longDuration
}
}
}
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment