2021-05-24 04:01:26 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 CutefishOS Team.
|
|
|
|
*
|
|
|
|
* Author: revenmartin <revenmartin@gmail.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 3 of the License, or
|
|
|
|
* 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 General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2021-03-16 00:02:20 -07:00
|
|
|
import QtQuick 2.12
|
2021-04-09 07:49:19 -07:00
|
|
|
import FishUI 1.0 as FishUI
|
2021-03-16 00:02:20 -07:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: control
|
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
|
|
|
|
property alias source: _image.source
|
2021-07-08 08:48:56 -07:00
|
|
|
property color backgroundColor: FishUI.Theme.darkMode ? Qt.lighter(FishUI.Theme.secondBackgroundColor, 1.3)
|
|
|
|
: FishUI.Theme.secondBackgroundColor
|
|
|
|
property color hoveredColor: FishUI.Theme.darkMode ? Qt.lighter(FishUI.Theme.secondBackgroundColor, 1.7)
|
|
|
|
: Qt.darker(FishUI.Theme.secondBackgroundColor, 1.2)
|
|
|
|
property color pressedColor: FishUI.Theme.darkMode ? Qt.lighter(FishUI.Theme.secondBackgroundColor, 1.4)
|
|
|
|
: Qt.darker(FishUI.Theme.secondBackgroundColor, 1.3)
|
2021-03-16 00:02:20 -07:00
|
|
|
|
|
|
|
signal clicked()
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: _background
|
|
|
|
anchors.fill: parent
|
2021-04-09 07:49:19 -07:00
|
|
|
radius: FishUI.Theme.smallRadius
|
2021-07-08 08:48:56 -07:00
|
|
|
color: _mouseArea.pressed ? pressedColor : _mouseArea.containsMouse ? control.hoveredColor : control.backgroundColor
|
2021-03-16 00:02:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: _image
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: control.height * 0.64
|
|
|
|
height: width
|
|
|
|
sourceSize: Qt.size(width, height)
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: _mouseArea
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
onClicked: control.clicked()
|
|
|
|
}
|
|
|
|
}
|