mirror of https://github.com/nextcloud/desktop
Make activity action button an actual button, clean up contents
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
This commit is contained in:
parent
5dfd605049
commit
db861e1ade
|
@ -28,7 +28,9 @@
|
||||||
<file>src/gui/tray/UnifiedSearchResultNothingFound.qml</file>
|
<file>src/gui/tray/UnifiedSearchResultNothingFound.qml</file>
|
||||||
<file>src/gui/tray/UnifiedSearchResultSectionItem.qml</file>
|
<file>src/gui/tray/UnifiedSearchResultSectionItem.qml</file>
|
||||||
<file>src/gui/tray/CustomButton.qml</file>
|
<file>src/gui/tray/CustomButton.qml</file>
|
||||||
<file>src/gui/tray/CustomTextButton.qml</file>
|
<file>src/gui/tray/NCButtonContents.qml</file>
|
||||||
|
<file>src/gui/tray/NCButtonBackground.qml</file>
|
||||||
|
<file>src/gui/tray/TextButtonContents.qml</file>
|
||||||
<file>src/gui/tray/ActivityItemContextMenu.qml</file>
|
<file>src/gui/tray/ActivityItemContextMenu.qml</file>
|
||||||
<file>src/gui/tray/ActivityItemActions.qml</file>
|
<file>src/gui/tray/ActivityItemActions.qml</file>
|
||||||
<file>src/gui/tray/ActivityItemContent.qml</file>
|
<file>src/gui/tray/ActivityItemContent.qml</file>
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.3
|
||||||
import QtQuick.Layouts 1.15
|
|
||||||
import Style 1.0
|
import Style 1.0
|
||||||
import com.nextcloud.desktopclient 1.0
|
import com.nextcloud.desktopclient 1.0
|
||||||
|
|
||||||
Item {
|
AbstractButton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property string text: ""
|
|
||||||
property string toolTipText: ""
|
property string toolTipText: ""
|
||||||
|
|
||||||
property bool primaryButton: false
|
property bool primaryButton: false
|
||||||
|
@ -15,52 +13,65 @@ Item {
|
||||||
property string imageSource: ""
|
property string imageSource: ""
|
||||||
property string imageSourceHover: ""
|
property string imageSourceHover: ""
|
||||||
|
|
||||||
property color textColor: Style.ncTextColor
|
property color adjustedHeaderColor: Style.ncBlue
|
||||||
property color textColorHovered: Style.ncSecondaryTextColor
|
property color textColor: primaryButton ? adjustedHeaderColor : Style.ncTextColor
|
||||||
|
property color textColorHovered: primaryButton ? UserModel.currentUser.headerTextColor : Style.ncTextColor
|
||||||
|
|
||||||
signal clicked()
|
property string verb: ""
|
||||||
|
property bool isTalkReplyButton: false
|
||||||
|
|
||||||
Loader {
|
|
||||||
active: !root.primaryButton
|
|
||||||
|
|
||||||
anchors.fill: parent
|
background: NCButtonBackground {
|
||||||
|
color: UserModel.currentUser.headerColor
|
||||||
|
hovered: root.hovered
|
||||||
|
visible: root.primaryButton
|
||||||
|
}
|
||||||
|
|
||||||
sourceComponent: CustomTextButton {
|
contentItem: Loader {
|
||||||
anchors.fill: parent
|
id: contentItemLoader
|
||||||
text: root.text
|
active: true
|
||||||
toolTipText: root.toolTipText
|
sourceComponent: root.primaryButton ? primaryButtonContent : textButtonContent
|
||||||
|
}
|
||||||
|
|
||||||
textColor: root.textColor
|
ToolTip {
|
||||||
textColorHovered: root.textColorHovered
|
id: customTextButtonTooltip
|
||||||
|
text: root.toolTipText
|
||||||
onClicked: root.clicked()
|
delay: Qt.styleHints.mousePressAndHoldInterval
|
||||||
|
visible: root.toolTipText !== "" && root.hovered
|
||||||
|
contentItem: Label {
|
||||||
|
text: customTextButtonTooltip.text
|
||||||
|
color: Style.ncTextColor
|
||||||
|
}
|
||||||
|
background: Rectangle {
|
||||||
|
border.color: Style.menuBorder
|
||||||
|
color: Style.backgroundColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Component {
|
||||||
active: root.primaryButton
|
id: textButtonContent
|
||||||
|
TextButtonContents {
|
||||||
anchors.fill: parent
|
|
||||||
|
|
||||||
sourceComponent: CustomButton {
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.topMargin: Style.roundedButtonBackgroundVerticalMargins
|
hovered: root.hovered
|
||||||
anchors.bottomMargin: Style.roundedButtonBackgroundVerticalMargins
|
|
||||||
|
|
||||||
text: root.text
|
text: root.text
|
||||||
toolTipText: root.toolTipText
|
|
||||||
|
|
||||||
textColor: root.textColor
|
textColor: root.textColor
|
||||||
textColorHovered: root.textColorHovered
|
textColorHovered: root.textColorHovered
|
||||||
|
|
||||||
bold: root.primaryButton
|
bold: root.primaryButton
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
imageSource: root.imageSource
|
Component {
|
||||||
|
id: primaryButtonContent
|
||||||
|
NCButtonContents {
|
||||||
|
anchors.fill: parent
|
||||||
|
hovered: root.hovered
|
||||||
imageSourceHover: root.imageSourceHover
|
imageSourceHover: root.imageSourceHover
|
||||||
|
imageSource: root.imageSource
|
||||||
bgColor: UserModel.currentUser.headerColor
|
text: root.text
|
||||||
|
textColor: root.textColor
|
||||||
onClicked: root.clicked()
|
textColorHovered: root.textColorHovered
|
||||||
|
bold: root.primaryButton
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,25 +33,22 @@ RowLayout {
|
||||||
ActivityActionButton {
|
ActivityActionButton {
|
||||||
id: activityActionButton
|
id: activityActionButton
|
||||||
|
|
||||||
readonly property string verb: model.modelData.verb
|
Layout.minimumWidth: primaryButton ? Style.activityItemActionPrimaryButtonMinWidth : Style.activityItemActionSecondaryButtonMinWidth
|
||||||
readonly property bool primary: (model.index === 0 && verb !== "DELETE") || model.modelData.primary
|
Layout.preferredHeight: parent.height
|
||||||
readonly property bool isTalkReplyButton: verb === "REPLY"
|
Layout.preferredWidth: primaryButton ? -1 : parent.height
|
||||||
|
|
||||||
Layout.minimumWidth: primary ? Style.activityItemActionPrimaryButtonMinWidth : Style.activityItemActionSecondaryButtonMinWidth
|
verb: model.modelData.verb
|
||||||
Layout.preferredHeight: primary ? parent.height : parent.height * 0.3
|
primaryButton: (model.index === 0 && verb !== "DELETE") || model.modelData.primary
|
||||||
Layout.preferredWidth: primary ? -1 : parent.height
|
isTalkReplyButton: verb === "REPLY"
|
||||||
|
|
||||||
text: model.modelData.label
|
text: model.modelData.label
|
||||||
|
|
||||||
|
adjustedHeaderColor: root.adjustedHeaderColor
|
||||||
|
|
||||||
imageSource: model.modelData.imageSource ? model.modelData.imageSource + root.adjustedHeaderColor : ""
|
imageSource: model.modelData.imageSource ? model.modelData.imageSource + root.adjustedHeaderColor : ""
|
||||||
imageSourceHover: model.modelData.imageSourceHovered ? model.modelData.imageSourceHovered + UserModel.currentUser.headerTextColor : ""
|
imageSourceHover: model.modelData.imageSourceHovered ? model.modelData.imageSourceHovered + UserModel.currentUser.headerTextColor : ""
|
||||||
|
|
||||||
textColor: primary ? root.adjustedHeaderColor : Style.ncTextColor
|
onClicked: isTalkReplyButton ? root.showReplyField() : root.triggerAction(model.index)
|
||||||
textColorHovered: primary ? UserModel.currentUser.headerTextColor : Style.ncTextColor
|
|
||||||
|
|
||||||
primaryButton: primary
|
|
||||||
|
|
||||||
onClicked: !isTalkReplyButton ? root.triggerAction(model.index) : root.showReplyField()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ Button {
|
||||||
|
|
||||||
property string imageSource: ""
|
property string imageSource: ""
|
||||||
property string imageSourceHover: ""
|
property string imageSourceHover: ""
|
||||||
property Image iconItem: icon
|
|
||||||
|
|
||||||
property string toolTipText: ""
|
property string toolTipText: ""
|
||||||
|
|
||||||
|
@ -21,11 +20,9 @@ Button {
|
||||||
|
|
||||||
property real bgOpacity: 0.3
|
property real bgOpacity: 0.3
|
||||||
|
|
||||||
background: Rectangle {
|
background: NCButtonBackground {
|
||||||
id: bgRectangle
|
id: bgRectangle
|
||||||
color: "transparent"
|
hovered: root.hovered
|
||||||
opacity: parent.hovered ? 1.0 : bgOpacity
|
|
||||||
radius: width / 2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
leftPadding: root.text === "" ? 5 : 10
|
leftPadding: root.text === "" ? 5 : 10
|
||||||
|
@ -36,32 +33,13 @@ Button {
|
||||||
visible: root.toolTipText !== "" && root.hovered
|
visible: root.toolTipText !== "" && root.hovered
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: RowLayout {
|
contentItem: NCButtonContents {
|
||||||
Image {
|
hovered: root.hovered
|
||||||
id: icon
|
imageSourceHover: root.imageSourceHover
|
||||||
|
imageSource: root.imageSource
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
text: root.text
|
||||||
|
textColor: root.textColor
|
||||||
source: root.hovered ? root.imageSourceHover : root.imageSource
|
textColorHovered: root.textColorHovered
|
||||||
fillMode: Image.PreserveAspectFit
|
bold: root.bold
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
Layout.maximumWidth: icon.width > 0 ? parent.width - icon.width - parent.spacing : parent.width
|
|
||||||
Layout.fillWidth: icon.status !== Image.Ready
|
|
||||||
|
|
||||||
text: root.text
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
font.bold: root.bold
|
|
||||||
|
|
||||||
visible: root.text !== ""
|
|
||||||
|
|
||||||
color: root.hovered ? root.textColorHovered : root.textColor
|
|
||||||
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
|
|
||||||
elide: Text.ElideRight
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
import QtQuick 2.15
|
|
||||||
import QtQuick.Controls 2.3
|
|
||||||
import Style 1.0
|
|
||||||
|
|
||||||
Label {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
property string toolTipText: ""
|
|
||||||
property Action action: null
|
|
||||||
property alias acceptedButtons: mouseArea.acceptedButtons
|
|
||||||
property bool hovered: mouseArea.containsMouse
|
|
||||||
|
|
||||||
height: implicitHeight
|
|
||||||
|
|
||||||
property color textColor: Style.ncTextColor
|
|
||||||
property color textColorHovered: Style.ncSecondaryTextColor
|
|
||||||
|
|
||||||
Accessible.role: Accessible.Button
|
|
||||||
Accessible.name: text
|
|
||||||
Accessible.onPressAction: root.clicked(null)
|
|
||||||
|
|
||||||
text: action ? action.text : ""
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
enabled: !action || action.enabled
|
|
||||||
onClicked: if (action) action.trigger()
|
|
||||||
|
|
||||||
font.underline: true
|
|
||||||
color: root.hovered ? root.textColorHovered : root.textColor
|
|
||||||
horizontalAlignment: Text.AlignLeft
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
elide: Text.ElideRight
|
|
||||||
|
|
||||||
signal pressed(QtObject mouse)
|
|
||||||
signal clicked(QtObject mouse)
|
|
||||||
|
|
||||||
NCToolTip {
|
|
||||||
text: root.toolTipText
|
|
||||||
visible: root.toolTipText !== "" && root.hovered
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: mouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
|
|
||||||
onClicked: root.clicked(mouse)
|
|
||||||
onPressed: root.pressed(mouse)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) by Claudio Cambra <claudio.cambra@nextcloud.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.15
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
property bool hovered: false
|
||||||
|
property real normalOpacity: 0.3
|
||||||
|
property real hoverOpacity: 1.0
|
||||||
|
|
||||||
|
color: "transparent"
|
||||||
|
opacity: hovered ? hoverOpacity : normalOpacity
|
||||||
|
radius: width / 2
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) by Claudio Cambra <claudio.cambra@nextcloud.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
|
import QtQuick.Layouts 1.15
|
||||||
|
|
||||||
|
import Style 1.0
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property bool hovered: false
|
||||||
|
property string imageSourceHover: ""
|
||||||
|
property string imageSource: ""
|
||||||
|
property string text: ""
|
||||||
|
|
||||||
|
property color textColor: Style.ncTextColor
|
||||||
|
property color textColorHovered: textColor
|
||||||
|
property bool bold: false
|
||||||
|
|
||||||
|
Image {
|
||||||
|
id: icon
|
||||||
|
|
||||||
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||||
|
|
||||||
|
source: root.hovered ? root.imageSourceHover : root.imageSource
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
Layout.maximumWidth: icon.width > 0 ? parent.width - icon.width - parent.spacing : parent.width
|
||||||
|
Layout.fillWidth: icon.status !== Image.Ready
|
||||||
|
|
||||||
|
text: root.text
|
||||||
|
textFormat: Text.PlainText
|
||||||
|
font.bold: root.bold
|
||||||
|
|
||||||
|
visible: root.text !== ""
|
||||||
|
|
||||||
|
color: root.hovered ? root.textColorHovered : root.textColor
|
||||||
|
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) by Claudio Cambra <claudio.cambra@nextcloud.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.15
|
||||||
|
import QtQuick.Controls 2.15
|
||||||
|
import QtQuick.Layouts 1.15
|
||||||
|
|
||||||
|
import Style 1.0
|
||||||
|
|
||||||
|
Label {
|
||||||
|
property bool hovered: false
|
||||||
|
property color textColor: Style.ncTextColor
|
||||||
|
property color textColorHovered: Style.ncSecondaryTextColor
|
||||||
|
property bool bold: false
|
||||||
|
|
||||||
|
textFormat: Text.PlainText
|
||||||
|
font.underline: true
|
||||||
|
font.bold: bold
|
||||||
|
color: hovered ? textColorHovered : textColor
|
||||||
|
|
||||||
|
horizontalAlignment: Text.AlignLeft
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue