Warning, /libraries/kirigami-addons/tests/FloatingButtons.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *  SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 import QtQuick 2.15
0008 import QtQuick.Layouts 1.15
0009 import QtQuick.Controls 2.15 as QQC2
0010 import org.kde.kirigami 2.20 as Kirigami
0011 import org.kde.kirigamiaddons.components 1.0 as KirigamiComponents
0012 
0013 Kirigami.ScrollablePage {
0014     id: root
0015 
0016     width: cellSize * columns
0017     height: cellSize * 4
0018     padding: 0
0019 
0020     property real cellSize: Kirigami.Units.gridUnit * 12
0021     property int columns: 4
0022 
0023     component Cell : Item {
0024         implicitWidth: root.cellSize
0025         implicitHeight: root.cellSize
0026         Rectangle {
0027             anchors.fill: parent
0028             z: -1
0029             color: "transparent"
0030             border.color: Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.backgroundColor, Kirigami.Theme.textColor, Kirigami.Theme.frameContrast)
0031             border.width: 1
0032             opacity: 0.3
0033         }
0034     }
0035 
0036     component CenterSet : Cell {
0037         id: cell
0038 
0039         // These are the default values of FloatingButton
0040         property real radius: Kirigami.Units.largeSpacing
0041         property real margins: 0
0042 
0043         property alias title: label.text
0044 
0045         QQC2.Label {
0046             id: label
0047             anchors.centerIn: parent
0048             horizontalAlignment: Text.AlignHCenter
0049             z: 1
0050         }
0051         KirigamiComponents.FloatingButton {
0052             anchors {
0053                 top: parent.top
0054                 horizontalCenter: parent.horizontalCenter
0055             }
0056             icon.name: "arrow-up-symbolic"
0057             radius: cell.radius
0058             margins: cell.margins
0059         }
0060         KirigamiComponents.FloatingButton {
0061             anchors {
0062                 left: parent.left
0063                 verticalCenter: parent.verticalCenter
0064             }
0065             icon.name: "arrow-left-symbolic"
0066             radius: cell.radius
0067             margins: cell.margins
0068         }
0069         KirigamiComponents.FloatingButton {
0070             anchors {
0071                 right: parent.right
0072                 verticalCenter: parent.verticalCenter
0073             }
0074             icon.name: "arrow-right-symbolic"
0075             radius: cell.radius
0076             margins: cell.margins
0077         }
0078         KirigamiComponents.FloatingButton {
0079             anchors {
0080                 bottom: parent.bottom
0081                 horizontalCenter: parent.horizontalCenter
0082             }
0083             icon.name: "arrow-down-symbolic"
0084             radius: cell.radius
0085             margins: cell.margins
0086         }
0087     }
0088 
0089     component CornerSet : Cell {
0090         id: cell
0091 
0092         // These are the default values of FloatingButton
0093         property real radius: Kirigami.Units.largeSpacing
0094         property real margins: 0
0095         property real iconSize: 0
0096         property int focusPolicy: Qt.StrongFocus
0097 
0098         property alias title: label.text
0099 
0100         QQC2.Label {
0101             id: label
0102             anchors.centerIn: parent
0103             horizontalAlignment: Text.AlignHCenter
0104             z: 1
0105         }
0106         KirigamiComponents.FloatingButton {
0107             anchors {
0108                 top: parent.top
0109                 left: parent.left
0110             }
0111             icon.name: "go-top-symbolic"
0112             icon.width: cell.iconSize
0113             icon.height: cell.iconSize
0114             radius: cell.radius
0115             margins: cell.margins
0116             focusPolicy: cell.focusPolicy
0117         }
0118         KirigamiComponents.FloatingButton {
0119             anchors {
0120                 left: parent.left
0121                 bottom: parent.bottom
0122             }
0123             icon.name: "go-bottom-symbolic"
0124             icon.width: cell.iconSize
0125             icon.height: cell.iconSize
0126             radius: cell.radius
0127             margins: cell.margins
0128             focusPolicy: cell.focusPolicy
0129         }
0130         KirigamiComponents.FloatingButton {
0131             anchors {
0132                 right: parent.right
0133                 top: parent.top
0134             }
0135             icon.name: "search-symbolic"
0136             icon.width: cell.iconSize
0137             icon.height: cell.iconSize
0138             radius: cell.radius
0139             margins: cell.margins
0140             focusPolicy: cell.focusPolicy
0141         }
0142         KirigamiComponents.FloatingButton {
0143             anchors {
0144                 right: parent.right
0145                 bottom: parent.bottom
0146             }
0147             icon.name: "list-add-symbolic"
0148             icon.width: cell.iconSize
0149             icon.height: cell.iconSize
0150             radius: cell.radius
0151             margins: cell.margins
0152             focusPolicy: cell.focusPolicy
0153         }
0154     }
0155 
0156     GridLayout {
0157         columns: root.columns
0158         rowSpacing: 0
0159         columnSpacing: 0
0160 
0161         CenterSet {
0162             title: "Default"
0163         }
0164         CenterSet {
0165             title: "Round"
0166             radius: Infinity
0167         }
0168         CenterSet {
0169             title: "Default\nDisabled"
0170             enabled: false
0171         }
0172         CenterSet {
0173             title: "Round\nDisabled"
0174             radius: Infinity
0175             enabled: false
0176         }
0177 
0178         CornerSet {
0179             title: "Default"
0180         }
0181         CornerSet {
0182             title: "Round"
0183             radius: Infinity
0184         }
0185         CornerSet {
0186             title: "Default\nDisabled"
0187             enabled: false
0188         }
0189         CornerSet {
0190             title: "Round\nDisabled"
0191             radius: Infinity
0192             enabled: false
0193         }
0194 
0195         CornerSet {
0196             title: "Default\nMargins"
0197             margins: Kirigami.Units.gridUnit
0198         }
0199         CornerSet {
0200             title: "Round\nMargins"
0201             margins: Kirigami.Units.gridUnit
0202             radius: Infinity
0203         }
0204         CornerSet {
0205             title: "Default\nBig"
0206             iconSize: Kirigami.Units.iconSizes.large
0207         }
0208         CornerSet {
0209             title: "Round\nBig"
0210             iconSize: Kirigami.Units.iconSizes.large
0211             radius: Infinity
0212         }
0213 
0214         CornerSet {
0215             title: "Default\nNo Focus"
0216             focusPolicy: Qt.NoFocus
0217         }
0218         CornerSet {
0219             title: "Round\nNo Focus"
0220             radius: Infinity
0221             focusPolicy: Qt.NoFocus
0222         }
0223         CornerSet {
0224             title: "Default\nMargins\nNo Focus"
0225             margins: Kirigami.Units.gridUnit
0226             focusPolicy: Qt.NoFocus
0227         }
0228         CornerSet {
0229             title: "Default\nMargins\nNo Focus"
0230             radius: Infinity
0231             margins: Kirigami.Units.gridUnit
0232             focusPolicy: Qt.NoFocus
0233         }
0234     }
0235 }