refactor: replace StatusCategoryButton with StatusQ component

This commit is contained in:
Pascal Precht 2021-10-25 13:48:23 +02:00 committed by Iuri Matias
parent 184e88d44f
commit 4bf23b3048
5 changed files with 32 additions and 85 deletions

View File

@ -1,57 +0,0 @@
import QtQuick 2.13
import QtGraphicalEffects 1.0
import utils 1.0
import "../../shared/panels"
Rectangle {
property bool active: false
property var changeCategory: function () {}
property url source: Style.svg("emojiCategories/recent")
id: categoryButton
width: 40
height: 40
color: Style.current.transparent
SVGImage {
width: 20
height: 20
fillMode: Image.PreserveAspectFit
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
source: categoryButton.source
ColorOverlay {
anchors.fill: parent
source: parent
color: categoryButton.active ? Style.current.primary : Style.current.transparent
}
Rectangle {
visible: categoryButton.active
width: parent.width
height: 2
radius: 1
color: Style.current.primary
anchors.bottom: parent.bottom
anchors.bottomMargin: -Style.current.smallPadding
}
}
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onClicked: function () {
categoryButton.changeCategory()
}
}
}
/*##^##
Designer {
D{i:0;formeditorColor:"#ffffff";height:440;width:360}
}
##^##*/

View File

@ -3,8 +3,10 @@ import QtQuick.Controls 2.13
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import StatusQ.Controls 0.1
import utils 1.0 import utils 1.0
import "../../shared"
import "../../shared/panels" import "../../shared/panels"
import "../../shared/controls" import "../../shared/controls"
@ -339,10 +341,10 @@ Popup {
Repeater { Repeater {
model: EmojiJSON.emojiCategories model: EmojiJSON.emojiCategories
StatusCategoryButton { StatusTabBarIconButton {
source: Style.svg(`emojiCategories/${modelData}`) icon.name: modelData
active: index === scrollView.activeCategory highlighted: index === scrollView.activeCategory
changeCategory: function () { onClicked: {
scrollView.activeCategory = index scrollView.activeCategory = index
scrollView.scrollToCategory(index) scrollView.scrollToCategory(index)
} }

View File

@ -4,7 +4,7 @@ import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import StatusQ.Components 0.1 import StatusQ.Components 0.1
import StatusQ.Controls 0.1 as StatusQControls import StatusQ.Controls 0.1
import utils 1.0 import utils 1.0
@ -115,7 +115,7 @@ Popup {
} }
} }
StatusQControls.StatusFlatRoundButton { StatusFlatRoundButton {
id: clearBtn id: clearBtn
implicitWidth: 14 implicitWidth: 14
implicitHeight: 14 implicitHeight: 14
@ -126,7 +126,7 @@ Popup {
visible: searchBox.text !== "" visible: searchBox.text !== ""
icon.width: 14 icon.width: 14
icon.height: 14 icon.height: 14
type: StatusQControls.StatusFlatRoundButton.Type.Tertiary type: StatusFlatRoundButton.Type.Tertiary
color: "transparent" color: "transparent"
onClicked: toggleCategory(previousCategory) onClicked: toggleCategory(previousCategory)
} }
@ -170,26 +170,29 @@ Popup {
rightPadding: Style.current.smallPadding / 2 rightPadding: Style.current.smallPadding / 2
spacing: 0 spacing: 0
StatusCategoryButton {
source: Style.svg("gifCategories/trending") StatusTabBarIconButton {
active: StatusGifPopup.Category.Trending === popup.currentCategory icon.name: "flash"
changeCategory: function () { highlighted: StatusGifPopup.Category.Trending === popup.currentCategory
onClicked: {
toggleCategory(StatusGifPopup.Category.Trending) toggleCategory(StatusGifPopup.Category.Trending)
} }
enabled: appSettings.isTenorWarningAccepted enabled: appSettings.isTenorWarningAccepted
} }
StatusCategoryButton {
source: Style.svg("gifCategories/recent") StatusTabBarIconButton {
active: StatusGifPopup.Category.Recent === popup.currentCategory icon.name: "time"
changeCategory: function () { highlighted: StatusGifPopup.Category.Recent === popup.currentCategory
onClicked: {
toggleCategory(StatusGifPopup.Category.Recent) toggleCategory(StatusGifPopup.Category.Recent)
} }
enabled: appSettings.isTenorWarningAccepted enabled: appSettings.isTenorWarningAccepted
} }
StatusCategoryButton {
source: Style.svg("gifCategories/favorite") StatusTabBarIconButton {
active: StatusGifPopup.Category.Favorite === popup.currentCategory icon.name: "favourite"
changeCategory: function () { highlighted: StatusGifPopup.Category.Favorite === popup.currentCategory
onClicked: {
toggleCategory(StatusGifPopup.Category.Favorite) toggleCategory(StatusGifPopup.Category.Favorite)
} }
enabled: appSettings.isTenorWarningAccepted enabled: appSettings.isTenorWarningAccepted
@ -249,7 +252,7 @@ Popup {
color: Style.current.secondaryText color: Style.current.secondaryText
} }
StatusQControls.StatusButton { StatusButton {
id: removeBtn id: removeBtn
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Enable") text: qsTr("Enable")
@ -285,7 +288,7 @@ Popup {
color: Style.current.secondaryText color: Style.current.secondaryText
} }
StatusQControls.StatusButton { StatusButton {
id: retryBtn id: retryBtn
anchors.top: emptyText.bottom anchors.top: emptyText.bottom
anchors.topMargin: Style.current.padding anchors.topMargin: Style.current.padding

View File

@ -1,10 +1,10 @@
var emojiCategories = [ var emojiCategories = [
"recent", "time",
"smileys", "smileys-and-people",
"nature", "animals-and-nature",
"food", "food-and-drinks",
"activity", "activity",
"travel", "travel-and-places",
"objects", "objects",
"symbols", "symbols",
"flags", "flags",

View File

@ -1,6 +1,5 @@
StatusChatCommandPopup 1.0 StatusChatCommandPopup.qml StatusChatCommandPopup 1.0 StatusChatCommandPopup.qml
StatusChatInput 1.0 StatusChatInput.qml StatusChatInput 1.0 StatusChatInput.qml
StatusCategoryButton 1.0 StatusCategoryButton.qml
StatusEmojiPopup 1.0 StatusEmojiPopup.qml StatusEmojiPopup 1.0 StatusEmojiPopup.qml
StatusEmojiSection 1.0 StatusEmojiSection.qml StatusEmojiSection 1.0 StatusEmojiSection.qml
StatusGifPopup 1.0 StatusGifPopup.qml StatusGifPopup 1.0 StatusGifPopup.qml