diff --git a/src/controls/ListDelegate.qml b/src/controls/ListDelegate.qml index bdb7eb6..0a83c1b 100644 --- a/src/controls/ListDelegate.qml +++ b/src/controls/ListDelegate.qml @@ -1,114 +1,115 @@ /* * Copyright 2018 Camilo Higuita * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.9 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.2 import org.kde.kirigami 2.2 as Kirigami import org.kde.mauikit 1.0 as Maui ItemDelegate { id: control property bool isCurrentListItem : ListView.isCurrentItem property alias label: controlLabel.text - property alias iconName: controlIcon.iconName + property alias iconName: controlIcon.source property int radius : 0 signal rightClicked() width: parent.width height: rowHeight clip: true property string labelColor: ListView.isCurrentItem ? highlightedTextColor : textColor hoverEnabled: !isMobile MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton onClicked: { if(!isMobile && mouse.button === Qt.RightButton) rightClicked() } } background: Rectangle { anchors.fill: parent color: isCurrentListItem || hovered ? highlightColor : "transparent" radius: control.radius opacity: hovered ? 0.3 : 1 // index % 2 === 0 ? Qt.lighter(backgroundColor,1.2) : // backgroundColor } RowLayout { anchors.fill: parent Item { Layout.fillHeight: true visible: model.icon !== typeof("undefined") width: model.icon ? parent.height : 0 - Maui.ToolButton + Kirigami.Icon { id:controlIcon anchors.centerIn: parent - iconName: model.icon ? model.icon : "" -// isMask: !isMobile - iconColor: labelColor - enabled: false + source: model.icon ? model.icon : "" + isMask: true + color: labelColor + height: iconSizes.medium + width: height } } Item { Layout.fillHeight: true Layout.fillWidth: true Layout.alignment: Qt.AlignVCenter Label { id: controlLabel height: parent.height width: parent.width verticalAlignment: Qt.AlignVCenter horizontalAlignment: Qt.AlignLeft text: model.label font.bold: false elide: Text.ElideRight font.pointSize: isMobile ? fontSizes.big : fontSizes.default color: labelColor } } } } diff --git a/src/controls/Page.qml b/src/controls/Page.qml index 652da8f..01b0dd6 100644 --- a/src/controls/Page.qml +++ b/src/controls/Page.qml @@ -1,294 +1,294 @@ /* * Copyright 2018 Camilo Higuita * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.9 import QtQuick.Controls 2.2 as QQC2 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.2 as Kirigami import QtGraphicalEffects 1.0 import QtQuick.Window 2.0 import "private" QQC2.Page { id: control /* Controlc color scheming */ ColorScheme { id: colorScheme backgroundColor: viewBackgroundColor } property alias colorScheme : colorScheme /***************************/ property bool headBarExit : true property bool headBarTitleVisible: headBarTitle property string headBarExitIcon : "dialog-close" property string headBarTitle: "" property int margins: contentMargins * 1.5 property int topMargin: margins property int rightMargin: margins property int leftMargin: margins property int bottomMargin: margins property alias headBar: topToolBar property alias headBarItem: topToolBar.data property alias footBar: bottomToolBar property alias floatingBar: bottomToolBar.floating property alias flickable: flickable property int footBarAligment : Qt.AlignCenter property bool altToolBars : false property int footBarMargins : space.large property bool footBarOverlap: false property bool allowRiseContent: floatingBar && footBarOverlap && footBar.visible property bool contentIsRised: false signal exit(); default property alias content : mainContainer.data property alias backContain: backContainer.data clip: true leftPadding: 0 topPadding: leftPadding rightPadding: leftPadding bottomPadding: leftPadding background: Rectangle { color: colorScheme.backgroundColor } GridLayout { id: rootLayout anchors.fill: parent rows: 3 columns: 1 rowSpacing: 0 Maui.ToolBar { id: topToolBar Layout.fillWidth: !folded Layout.rightMargin: plegable ? space.big : (floating ? space.small : 0) Layout.leftMargin: plegable ? space.big : (floating ? space.small : 0) Layout.bottomMargin: plegable ? space.big : 0 Layout.topMargin: plegable && !altToolBars ? space.big : 0 - Layout.alignment: plegable ? Qt.AlignRight : undefined + Layout.alignment: plegable ? Qt.AlignRight : Qt.AlignCenter Layout.row: altToolBars ? 3 : 1 Layout.column: 1 colorScheme { backgroundColor: folded ? altColor : control.colorScheme.backgroundColor textColor : folded ? altColorText : control.colorScheme.textColor } position: altToolBars ? ToolBar.Footer : ToolBar.Header dropShadow: false drawBorder: !dropShadow && !plegable width: folded ? height : implicitWidth implicitWidth: width Layout.preferredHeight: implicitHeight implicitHeight: topToolBar.visible ? toolBarHeightAlt : 0 plegable: control.width < Kirigami.Units.gridUnit * 17 visible: count > 0 clip: false z: container.z +1 leftContent: Maui.ToolButton { id: exitBtn visible: headBarExit anim : true iconName : headBarExitIcon onClicked : exit() } middleContent: QQC2.Label { visible: headBarTitleVisible text : headBarTitle width: topToolBar.middleLayout.width elide : Text.ElideRight font.bold : false font.weight: Font.Bold color : colorScheme.textColor font.pointSize: fontSizes.big horizontalAlignment : Text.AlignHCenter verticalAlignment : Text.AlignVCenter } } Item { id: container Layout.fillWidth: true Layout.fillHeight: true Layout.topMargin: topMargin Layout.bottomMargin: bottomMargin Layout.rightMargin: rightMargin Layout.leftMargin: leftMargin Layout.row: altToolBars ? 1 : 2 Layout.column: 1 clip: false anchors.margins: floatingBar && footBarOverlap ? margins : 0 anchors.top: if(!floatingBar && !topToolBar.plegable) undefined else { if(!altToolBars && headBar.visible && !topToolBar.plegable) topToolBar.bottom else if(!altToolBars && headBar.visible && topToolBar.plegable) topToolBar.top else if(altToolBars && headBar.visible) rootLayout.top } anchors.bottom: if(!floatingBar && !topToolBar.plegable) undefined else { if(altToolBars && headBar.visible && (footBarOverlap && floatingBar && footBar.visible) && !topToolBar.plegable) topToolBar.top/*.bottom*/ else if(altToolBars && headBar.visible && (!footBarOverlap && floatingBar && footBar.visible) && !topToolBar.plegable) bottomToolBar.verticalCenter/*.bottom*/ else if(altToolBars && headBar.visible && (footBarOverlap && floatingBar && footBar.visible) && topToolBar.plegable) topToolBar.bottom else if(altToolBars && headBar.visible && !footBar.visible && topToolBar.plegable) topToolBar.verticalCenter else if(!footBarOverlap && !floatingBar && footBar.visible) bottomToolBar.top else if(!altToolBars && floatingBar && footBarOverlap && footBar.visible) rootLayout.bottom } z: 1 Flickable { id: flickable flickableDirection: Flickable.VerticalFlick height: parent.height width: parent.width z: container.z // boundsMovement: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds interactive: allowRiseContent contentWidth: parent.width contentHeight: allowRiseContent ? parent.height + footBar.height + footBarMargins + space.big : parent.height onContentYChanged: control.contentIsRised = contentY > 0 Item { id: mainContainer z: container.z width: container.width height: contentIsRised ? container.height - (footBar.height + footBarMargins + space.big) : container.height y: contentIsRised ? flickable.contentY : 0 Item { id: backContainer z: mainContainer.z - 1 width: container.width height: footBar.height + footBarMargins + space.big anchors { left: parent.left right: parent.right top: parent.bottom margins: space.big } } } } } Maui.ToolBar { id: bottomToolBar visible: count > 0 readonly property int _margins : footBarMargins Layout.leftMargin: footBarAligment === Qt.AlignLeft ? _margins : (floating ? space.small : 0) Layout.rightMargin: footBarAligment === Qt.AlignRight ? _margins : (floating ? space.small : 0) Layout.bottomMargin: floating ? _margins : 0 Layout.alignment: footBarAligment Layout.fillWidth: true Layout.preferredHeight: implicitHeight // Layout.minimumWidth: parent.width * (floatingBar ? 0.4 : 1) Layout.maximumWidth: floating ? middleLayout.implicitWidth + layout.implicitWidth : parent.width Layout.row: altToolBars ? 2 : 3 Layout.column: 1 z: container.z +1 position: ToolBar.Footer clip: false colorScheme { backgroundColor: control.colorScheme.backgroundColor textColor : control.colorScheme.textColor } drawBorder: !floating } } function riseContent() { if(allowRiseContent) flickable.flick(0, flickable.contentHeight* -2) } function dropContent() { if(allowRiseContent) flickable.flick(0, flickable.contentHeight* 2) } } diff --git a/src/controls/ToolButton.qml b/src/controls/ToolButton.qml index af2fd2d..f5ad87b 100644 --- a/src/controls/ToolButton.qml +++ b/src/controls/ToolButton.qml @@ -1,119 +1,119 @@ /* * Copyright 2018 Camilo Higuita * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.6 import QtQuick.Controls 2.2 import QtQuick.Controls.impl 2.3 import org.kde.kirigami 2.4 as Kirigami import "private" ToolButton { id: control focusPolicy: Qt.NoFocus /* Controlc color scheming */ ColorScheme { id: colorScheme backgroundColor: "transparent" borderColor: "transparent" } property alias colorScheme : colorScheme /***************************/ property bool isMask: true property string iconName: "" property string iconFallback: "" property int size: iconSize property color iconColor: colorScheme.textColor property bool anim: false property string tooltipText : "" hoverEnabled: !isMobile // implicitWidth: Math.max(background ? background.implicitWidth : 0, // contentItem.implicitWidth + leftPadding + rightPadding) // implicitHeight: Math.max(background ? background.implicitHeight : 0, // contentItem.implicitHeight + topPadding + bottomPadding) height: control.visible ? (control.display === ToolButton.IconOnly ? size + space.medium : implicitHeight) : 0 width: control.visible ? (control.display === ToolButton.IconOnly ? height : implicitWidth + space.small) : 0 icon.name: control.iconName icon.source: control.iconFallback icon.width: control.size icon.height: control.size icon.color: !control.isMask ? "transparent" : (down || pressed) ? colorScheme.highlightColor : iconColor Kirigami.Theme.inherit: false Kirigami.Theme.textColor: icon.color onClicked: if(anim) animIcon.running = true flat: true highlighted: !isMask font.pointSize: control.display === ToolButton.TextUnderIcon ? fontSizes.small : undefined - display: control.text.length > 0 ? (isWide ? ToolButton.TextBesideIcon : ToolButton.TextUnderIcon) : ToolButton.IconOnlyS + display: control.text.length > 0 ? (isWide ? ToolButton.TextBesideIcon : ToolButton.TextUnderIcon) : ToolButton.IconOnly spacing: space.tiny // background: Rectangle // { // implicitHeight: control.visible? iconSizes.medium : 0 // implicitWidth: control.visible? iconSizes.medium : 0 // // anchors.centerIn: control // color: /*(down || pressed || checked) */ checked && enabled ? // Qt.lighter(colorScheme.highlightColor, 1.2) : colorScheme.backgroundColor // radius: unit * 3 // opacity: (down || pressed || checked) && enabled ? 0.5 : 1 // border.color: colorScheme.borderColor // } // contentItem: IconLabel // { // spacing: control.display === ToolButton.TextUnderIcon ? space.tiny : control.spacing // mirrored: control.mirrored // display: control.display // icon: control.icon // text: control.text // font: control.font // color: control.iconColor // } SequentialAnimation { id: animIcon PropertyAnimation { target: control property: "icon.color" easing.type: Easing.InOutQuad from: colorScheme.highlightColor to: iconColor duration: 500 } } ToolTip.delay: 1000 ToolTip.timeout: 5000 ToolTip.visible: hovered && !isMobile && tooltipText.length > 0 ToolTip.text: tooltipText }