13 changed files with 363 additions and 30 deletions
@ -1,37 +1,47 @@ |
|||
import QtQuick 2.13 |
|||
import "./SepantaUiKit/SKBtn" |
|||
import "./SepantaUiKit" |
|||
import "./SepantaUiKit/SKBtn" |
|||
import "./SepantaUiKit/SKBtnIcon" |
|||
import "./SepantaUiKit/SKMultiOption" |
|||
import "./SepantaUiKit/aCommon" |
|||
|
|||
Item { |
|||
anchors.fill: parent |
|||
Grid { |
|||
Column { |
|||
anchors.fill: parent |
|||
spacing: 20 |
|||
anchors.margins: 20 |
|||
anchors.fill: parent |
|||
SKBtn { |
|||
text: "Enable P" |
|||
} |
|||
SKBtn { |
|||
text: "Disable P" |
|||
isEnable: false |
|||
Row { |
|||
spacing: 20 |
|||
SKBtn { |
|||
text: "Enable P" |
|||
} |
|||
SKBtn { |
|||
text: "Disable P" |
|||
isEnable: false |
|||
} |
|||
SKBtn { |
|||
text: "Enable S" |
|||
buttonType: Setting.Secondary |
|||
} |
|||
SKBtn { |
|||
text: "Disable S" |
|||
isEnable: false |
|||
buttonType: Setting.Secondary |
|||
} |
|||
SKBtn { |
|||
text: "Enable T" |
|||
buttonType: Setting.Tertiary |
|||
} |
|||
SKBtn { |
|||
text: "Disable T" |
|||
isEnable: false |
|||
buttonType: Setting.Tertiary |
|||
} |
|||
} |
|||
SKBtn { |
|||
text: "Enable S" |
|||
buttonType: Setting.Secondary |
|||
} |
|||
SKBtn { |
|||
text: "Disable S" |
|||
isEnable: false |
|||
buttonType: Setting.Secondary |
|||
} |
|||
SKBtn { |
|||
text: "Enable T" |
|||
buttonType: Setting.Tertiary |
|||
} |
|||
SKBtn { |
|||
text: "Disable T" |
|||
isEnable: false |
|||
buttonType: Setting.Tertiary |
|||
|
|||
Row { |
|||
SKMultiOption {} |
|||
} |
|||
} |
|||
} |
|||
|
@ -1,5 +1,23 @@ |
|||
import QtQuick 2.13 |
|||
import "../" |
|||
import "../aCommon" |
|||
|
|||
Item { |
|||
width: 16 |
|||
height: 16 |
|||
property string iconPath: "" |
|||
property bool isEnable: true |
|||
|
|||
Rectangle { |
|||
anchors.fill: parent |
|||
color: Colors.black |
|||
border.width: 1 |
|||
border.color: Colors.tertiaryEnable |
|||
radius: Setting.smallRadius |
|||
UImage { |
|||
anchors.fill: parent |
|||
color: Colors.tertiaryEnable |
|||
source: "qrc:/SepantaUiKit/icons/person.svg" |
|||
} |
|||
} |
|||
} |
|||
|
@ -0,0 +1,95 @@ |
|||
import QtQuick 2.13 |
|||
import QtQml 2.13 |
|||
import QtQuick.Layouts 1.13 |
|||
import QtGraphicalEffects 1.13 |
|||
import "../" |
|||
import "../aCommon" |
|||
|
|||
Item { |
|||
id: root |
|||
property bool isSelected: false |
|||
property var stateOfComponent: Setting.Enable |
|||
property var indexManager |
|||
property var myIndex |
|||
property var currentIndex: indexManager.currentIndex |
|||
|
|||
property bool rightHasRadius: false |
|||
property bool leftHasRadius: false |
|||
|
|||
property int radius: 0 |
|||
|
|||
onCurrentIndexChanged: { |
|||
if (currentIndex === myIndex) { |
|||
isSelected = true |
|||
} else |
|||
isSelected = false |
|||
} |
|||
|
|||
onIsSelectedChanged: buildComponent() |
|||
property alias text: idText.text |
|||
Layout.fillHeight: true |
|||
Layout.fillWidth: true |
|||
|
|||
RectangleWithRadius { |
|||
id: idBackGround |
|||
anchors.fill: parent |
|||
topLeftRadiusEnable: leftHasRadius |
|||
buttonLeftRadiusEnable: leftHasRadius |
|||
|
|||
topRightRadiusEnable: rightHasRadius |
|||
buttonRighttRadiusEnable: rightHasRadius |
|||
|
|||
radius: root.radius |
|||
Behavior on color { |
|||
ColorAnimation { |
|||
duration: Setting.animationDuration |
|||
} |
|||
} |
|||
} |
|||
|
|||
Text { |
|||
id: idText |
|||
anchors.fill: parent |
|||
horizontalAlignment: Text.AlignHCenter |
|||
verticalAlignment: Text.AlignVCenter |
|||
font: Fonts.h5 |
|||
color: Colors.tertiaryEnable |
|||
Behavior on color { |
|||
ColorAnimation { |
|||
duration: Setting.animationDuration |
|||
} |
|||
} |
|||
} |
|||
MouseArea { |
|||
anchors.fill: parent |
|||
hoverEnabled: true |
|||
onHoveredChanged: { |
|||
if (containsMouse) { |
|||
stateOfComponent = Setting.Hoverd |
|||
} else { |
|||
stateOfComponent = Setting.Enable |
|||
} |
|||
} |
|||
onPressed: { |
|||
stateOfComponent = Setting.Pressed |
|||
indexManager.clicked(myIndex) |
|||
} |
|||
onReleased: { |
|||
stateOfComponent = Setting.Enable |
|||
} |
|||
} |
|||
|
|||
function buildComponent() { |
|||
if (isSelected) { |
|||
idBackGround.color = Colors.primaryEnable |
|||
idText.color = Colors.black |
|||
} else { |
|||
idBackGround.color = "transparent" |
|||
idText.color = Colors.tertiaryEnable |
|||
} |
|||
} |
|||
|
|||
Component.onCompleted: { |
|||
buildComponent() |
|||
} |
|||
} |
@ -1,5 +1,95 @@ |
|||
import QtQuick 2.13 |
|||
import QtQml 2.13 |
|||
import QtQuick.Layouts 1.13 |
|||
import "../" |
|||
import "../aCommon" |
|||
|
|||
Item { |
|||
id: root |
|||
height: 38 |
|||
width: 400 |
|||
|
|||
property var listOfObj: [] |
|||
property var options: ["High", "Low", "Medium"] |
|||
property var currentText: options[currentIndex] |
|||
property var currentIndex: 0 |
|||
|
|||
property var stateOfComponent: Setting.Enable |
|||
Item { |
|||
anchors.fill: parent |
|||
|
|||
RowLayout { |
|||
id: idLayout |
|||
anchors.fill: parent |
|||
spacing: 0 |
|||
} |
|||
} |
|||
|
|||
Rectangle { |
|||
id: idBackGround |
|||
anchors.fill: parent |
|||
radius: Setting.mediumRadius |
|||
color: "transparent" |
|||
border.color: Colors.tertiaryEnable |
|||
border.width: 1 |
|||
clip: true |
|||
} |
|||
|
|||
CurrentSelectedManager { |
|||
id: indexManager |
|||
} |
|||
|
|||
function buildComponent() { |
|||
|
|||
let lengthOfList = listOfObj.length |
|||
for (var k = 0; k < lengthOfList; k++) { |
|||
listOfObj[k].destroy() |
|||
} |
|||
listOfObj = [] |
|||
|
|||
let numberOfBtns = options.length |
|||
let numberOfLines = numberOfBtns - 1 |
|||
|
|||
let btnCompoent = Qt.createComponent("MultiOptionBtn.qml") |
|||
let lineComponent = Qt.createComponent( |
|||
"qrc:/SepantaUiKit/aCommon/Line.qml") |
|||
|
|||
if (numberOfLines > 0) { |
|||
let lengthOfEachBtn = root.width / numberOfBtns |
|||
for (var j = 0; j < numberOfBtns; j++) { |
|||
let rightHasRadius = false |
|||
let leftHasRadius = false |
|||
if (j === 0) { |
|||
leftHasRadius = true |
|||
} else if (j === numberOfBtns - 1) { |
|||
rightHasRadius = true |
|||
} |
|||
|
|||
let sprite = btnCompoent.createObject(idLayout, { |
|||
"text": options[j], |
|||
"indexManager": indexManager, |
|||
"myIndex": j, |
|||
"leftHasRadius": leftHasRadius, |
|||
"rightHasRadius": rightHasRadius, |
|||
"radius": idBackGround.radius |
|||
}) |
|||
listOfObj.push(sprite) |
|||
|
|||
if (j !== numberOfBtns - 1) { |
|||
let spriteL = lineComponent.createObject(idLayout, { |
|||
"color": Colors.tertiaryEnable, |
|||
"Layout.fillHeight": true, |
|||
"width": 1 |
|||
}) |
|||
listOfObj.push(spriteL) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
Line {} |
|||
|
|||
Component.onCompleted: { |
|||
buildComponent() |
|||
} |
|||
} |
|||
|
@ -0,0 +1,13 @@ |
|||
import QtQuick 2.13 |
|||
|
|||
Item { |
|||
id: root |
|||
|
|||
//from child component |
|||
signal clicked(var index) |
|||
onClicked: { |
|||
currentIndex = index |
|||
} |
|||
|
|||
property int currentIndex: 0 |
|||
} |
@ -0,0 +1,7 @@ |
|||
import QtQuick 2.13 |
|||
import QtQuick.Layouts 1.13 |
|||
|
|||
Rectangle { |
|||
Layout.preferredWidth: width |
|||
Layout.preferredHeight: height |
|||
} |
@ -0,0 +1,48 @@ |
|||
import QtQuick 2.13 |
|||
|
|||
Item { |
|||
id: root |
|||
property int radius |
|||
property string color: "white" |
|||
property bool topLeftRadiusEnable: false |
|||
property bool topRightRadiusEnable: false |
|||
property bool buttonLeftRadiusEnable: false |
|||
property bool buttonRighttRadiusEnable: false |
|||
layer.enabled: true |
|||
Rectangle { |
|||
id: main |
|||
anchors.fill: parent |
|||
color: root.color |
|||
radius: root.radius |
|||
} |
|||
Rectangle { |
|||
visible: !topLeftRadiusEnable |
|||
width: main.radius |
|||
height: main.radius |
|||
color: root.color |
|||
} |
|||
|
|||
Rectangle { |
|||
visible: !topRightRadiusEnable |
|||
width: main.radius |
|||
height: main.radius |
|||
x: parent.width - width |
|||
color: root.color |
|||
} |
|||
Rectangle { |
|||
visible: !buttonLeftRadiusEnable |
|||
width: main.radius |
|||
height: main.radius |
|||
y: parent.height - height |
|||
color: root.color |
|||
} |
|||
|
|||
Rectangle { |
|||
visible: !buttonRighttRadiusEnable |
|||
width: main.radius |
|||
height: main.radius |
|||
x: parent.width - width |
|||
y: parent.height - height |
|||
color: root.color |
|||
} |
|||
} |
@ -0,0 +1,19 @@ |
|||
import QtQuick 2.13 |
|||
import QtGraphicalEffects 1.13 |
|||
|
|||
Item { |
|||
property alias color: idOverlay.color |
|||
property alias source: idImage.source |
|||
Image { |
|||
id: idImage |
|||
visible: false |
|||
fillMode: Image.PreserveAspectFit |
|||
sourceSize.width: width |
|||
sourceSize.height: height |
|||
} |
|||
ColorOverlay { |
|||
id: idOverlay |
|||
anchors.fill: parent |
|||
source: idImage |
|||
} |
|||
} |
@ -0,0 +1,5 @@ |
|||
import QtQuick 2.15 |
|||
|
|||
Item { |
|||
|
|||
} |
Loading…
Reference in new issue