diff --git a/resources.qrc b/resources.qrc index 6d41588b5..16864dfa1 100644 --- a/resources.qrc +++ b/resources.qrc @@ -28,7 +28,9 @@ src/gui/tray/UnifiedSearchResultNothingFound.qml src/gui/tray/UnifiedSearchResultSectionItem.qml src/gui/tray/CustomButton.qml - src/gui/tray/CustomTextButton.qml + src/gui/tray/NCButtonContents.qml + src/gui/tray/NCButtonBackground.qml + src/gui/tray/TextButtonContents.qml src/gui/tray/ActivityItemContextMenu.qml src/gui/tray/ActivityItemActions.qml src/gui/tray/ActivityItemContent.qml diff --git a/src/gui/tray/ActivityActionButton.qml b/src/gui/tray/ActivityActionButton.qml index a6b0d70da..2c5a0e57e 100644 --- a/src/gui/tray/ActivityActionButton.qml +++ b/src/gui/tray/ActivityActionButton.qml @@ -1,13 +1,11 @@ import QtQuick 2.15 import QtQuick.Controls 2.3 -import QtQuick.Layouts 1.15 import Style 1.0 import com.nextcloud.desktopclient 1.0 -Item { +AbstractButton { id: root - property string text: "" property string toolTipText: "" property bool primaryButton: false @@ -15,52 +13,65 @@ Item { property string imageSource: "" property string imageSourceHover: "" - property color textColor: Style.ncTextColor - property color textColorHovered: Style.ncSecondaryTextColor + property color adjustedHeaderColor: Style.ncBlue + 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 { - anchors.fill: parent - text: root.text - toolTipText: root.toolTipText + contentItem: Loader { + id: contentItemLoader + active: true + sourceComponent: root.primaryButton ? primaryButtonContent : textButtonContent + } - textColor: root.textColor - textColorHovered: root.textColorHovered - - onClicked: root.clicked() + ToolTip { + id: customTextButtonTooltip + text: root.toolTipText + 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 { - active: root.primaryButton - - anchors.fill: parent - - sourceComponent: CustomButton { + Component { + id: textButtonContent + TextButtonContents { anchors.fill: parent - anchors.topMargin: Style.roundedButtonBackgroundVerticalMargins - anchors.bottomMargin: Style.roundedButtonBackgroundVerticalMargins - + hovered: root.hovered text: root.text - toolTipText: root.toolTipText - textColor: root.textColor textColorHovered: root.textColorHovered bold: root.primaryButton + } + } - imageSource: root.imageSource + Component { + id: primaryButtonContent + NCButtonContents { + anchors.fill: parent + hovered: root.hovered imageSourceHover: root.imageSourceHover - - bgColor: UserModel.currentUser.headerColor - - onClicked: root.clicked() + imageSource: root.imageSource + text: root.text + textColor: root.textColor + textColorHovered: root.textColorHovered + bold: root.primaryButton } } } diff --git a/src/gui/tray/ActivityItemActions.qml b/src/gui/tray/ActivityItemActions.qml index 130a51566..57230cc56 100644 --- a/src/gui/tray/ActivityItemActions.qml +++ b/src/gui/tray/ActivityItemActions.qml @@ -33,25 +33,22 @@ RowLayout { ActivityActionButton { id: activityActionButton - readonly property string verb: model.modelData.verb - readonly property bool primary: (model.index === 0 && verb !== "DELETE") || model.modelData.primary - readonly property bool isTalkReplyButton: verb === "REPLY" + Layout.minimumWidth: primaryButton ? Style.activityItemActionPrimaryButtonMinWidth : Style.activityItemActionSecondaryButtonMinWidth + Layout.preferredHeight: parent.height + Layout.preferredWidth: primaryButton ? -1 : parent.height - Layout.minimumWidth: primary ? Style.activityItemActionPrimaryButtonMinWidth : Style.activityItemActionSecondaryButtonMinWidth - Layout.preferredHeight: primary ? parent.height : parent.height * 0.3 - Layout.preferredWidth: primary ? -1 : parent.height + verb: model.modelData.verb + primaryButton: (model.index === 0 && verb !== "DELETE") || model.modelData.primary + isTalkReplyButton: verb === "REPLY" text: model.modelData.label + adjustedHeaderColor: root.adjustedHeaderColor + imageSource: model.modelData.imageSource ? model.modelData.imageSource + root.adjustedHeaderColor : "" imageSourceHover: model.modelData.imageSourceHovered ? model.modelData.imageSourceHovered + UserModel.currentUser.headerTextColor : "" - textColor: primary ? root.adjustedHeaderColor : Style.ncTextColor - textColorHovered: primary ? UserModel.currentUser.headerTextColor : Style.ncTextColor - - primaryButton: primary - - onClicked: !isTalkReplyButton ? root.triggerAction(model.index) : root.showReplyField() + onClicked: isTalkReplyButton ? root.showReplyField() : root.triggerAction(model.index) } } diff --git a/src/gui/tray/CustomButton.qml b/src/gui/tray/CustomButton.qml index 70693c7df..e9a75c663 100644 --- a/src/gui/tray/CustomButton.qml +++ b/src/gui/tray/CustomButton.qml @@ -8,7 +8,6 @@ Button { property string imageSource: "" property string imageSourceHover: "" - property Image iconItem: icon property string toolTipText: "" @@ -21,11 +20,9 @@ Button { property real bgOpacity: 0.3 - background: Rectangle { + background: NCButtonBackground { id: bgRectangle - color: "transparent" - opacity: parent.hovered ? 1.0 : bgOpacity - radius: width / 2 + hovered: root.hovered } leftPadding: root.text === "" ? 5 : 10 @@ -36,32 +33,13 @@ Button { visible: root.toolTipText !== "" && root.hovered } - contentItem: RowLayout { - 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 - } + contentItem: NCButtonContents { + hovered: root.hovered + imageSourceHover: root.imageSourceHover + imageSource: root.imageSource + text: root.text + textColor: root.textColor + textColorHovered: root.textColorHovered + bold: root.bold } } diff --git a/src/gui/tray/CustomTextButton.qml b/src/gui/tray/CustomTextButton.qml deleted file mode 100644 index 9268b194d..000000000 --- a/src/gui/tray/CustomTextButton.qml +++ /dev/null @@ -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) - } -} diff --git a/src/gui/tray/NCButtonBackground.qml b/src/gui/tray/NCButtonBackground.qml new file mode 100644 index 000000000..678c5902b --- /dev/null +++ b/src/gui/tray/NCButtonBackground.qml @@ -0,0 +1,25 @@ +/* + * Copyright (C) by Claudio Cambra + * + * 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 +} diff --git a/src/gui/tray/NCButtonContents.qml b/src/gui/tray/NCButtonContents.qml new file mode 100644 index 000000000..806cc0843 --- /dev/null +++ b/src/gui/tray/NCButtonContents.qml @@ -0,0 +1,59 @@ +/* + * Copyright (C) by Claudio Cambra + * + * 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 + } +} diff --git a/src/gui/tray/TextButtonContents.qml b/src/gui/tray/TextButtonContents.qml new file mode 100644 index 000000000..8699faa35 --- /dev/null +++ b/src/gui/tray/TextButtonContents.qml @@ -0,0 +1,37 @@ +/* + * Copyright (C) by Claudio Cambra + * + * 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 +} +