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 QtGraphicalEffects 1.0
import StatusQ.Controls 0.1
import utils 1.0
import "../../shared"
import "../../shared/panels"
import "../../shared/controls"
@ -339,10 +341,10 @@ Popup {
Repeater {
model: EmojiJSON.emojiCategories
StatusCategoryButton {
source: Style.svg(`emojiCategories/${modelData}`)
active: index === scrollView.activeCategory
changeCategory: function () {
StatusTabBarIconButton {
icon.name: modelData
highlighted: index === scrollView.activeCategory
onClicked: {
scrollView.activeCategory = index
scrollView.scrollToCategory(index)
}

View File

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

View File

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

View File

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