-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- MMInputEditor (optional left icon) - MMPasswordEditor (with eye button) - MMSliderEditor See how to use it in EditorsPage.qml
- Loading branch information
Showing
8 changed files
with
598 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
/*************************************************************************** | ||
* * | ||
* 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. * | ||
* * | ||
***************************************************************************/ | ||
|
||
import QtQuick | ||
import QtQuick.Controls | ||
import QtQml.Models | ||
import QtQuick.Layouts | ||
|
||
import ".." | ||
|
||
Item { | ||
id: root | ||
|
||
signal contentClicked() | ||
signal leftActionClicked() | ||
signal rightActionClicked() | ||
|
||
property alias title: titleItem.text | ||
property alias leftAction: leftActionContainer.children | ||
property alias content: contentContainer.children | ||
property alias rightAction: rightActionContainer.children | ||
property string warningMsg | ||
property string errorMsg | ||
property bool hasFocus: false | ||
|
||
readonly property real spacing: 15 * __dp | ||
|
||
width: parent.width | ||
height: mainColumn.height | ||
|
||
Column { | ||
id: mainColumn | ||
|
||
spacing: 6 * __dp | ||
anchors.left: parent.left | ||
anchors.right: parent.right | ||
// anchors.leftMargin: root.spacing | ||
// anchors.rightMargin: root.spacing | ||
|
||
Text { | ||
id: titleItem | ||
|
||
width: parent.width | ||
font: StyleV2.p6 | ||
wrapMode: Text.WordWrap | ||
visible: text.length > 0 | ||
} | ||
|
||
Item { | ||
height: 50 * __dp | ||
anchors.left: parent.left | ||
anchors.right: parent.right | ||
|
||
Rectangle { | ||
id: background | ||
|
||
width: parent.width | ||
height: parent.height | ||
border.color: root.hasFocus ? ( errorMsg.length > 0 ? StyleV2.negativeColor : warningMsg.length > 0 ? StyleV2.warningColor : StyleV2.forestColor ) : StyleV2.transparentColor | ||
border.width: 2 * __dp | ||
color: StyleV2.whiteColor | ||
radius: 12 * __dp | ||
} | ||
|
||
Row { | ||
height: parent.height | ||
anchors.left: parent.left | ||
anchors.right: parent.right | ||
anchors.leftMargin: root.spacing | ||
anchors.rightMargin: root.spacing | ||
|
||
Item { | ||
id: leftActionContainer | ||
|
||
property bool actionAllowed: leftActionContainer.children.length > 1 && (leftActionContainer.children[1]?.visible ?? false) | ||
|
||
height: parent.height | ||
width: actionAllowed ? height/2 : 0 | ||
|
||
Rectangle { | ||
color: StyleV2.transparentColor | ||
anchors.centerIn: parent | ||
width: leftActionContainer.actionAllowed ? parent.width + root.spacing/2 : 0 | ||
height: parent.height | ||
|
||
MouseArea { | ||
anchors.fill: parent | ||
onReleased: root.leftActionClicked() | ||
} | ||
} | ||
} | ||
|
||
Item { | ||
id: contentContainer | ||
|
||
height: parent.height | ||
width: parent.width - (leftActionContainer.actionAllowed ? leftActionContainer.width : 0) - (rightActionContainer.actionAllowed ? rightActionContainer.width : 0) //- 2 * root.spacing - ( leftActionContainer.actionAllowed ? root.spacing : 0 ) | ||
|
||
MouseArea { | ||
anchors.fill: parent | ||
|
||
onClicked: { | ||
root.contentClicked() | ||
} | ||
} | ||
} | ||
|
||
Item { | ||
id: rightActionContainer | ||
|
||
property bool actionAllowed: rightActionContainer.children.length > 1 && (rightActionContainer.children[1]?.visible ?? false) | ||
|
||
height: parent.height | ||
width: actionAllowed ? height/2 : 0 | ||
|
||
Rectangle { | ||
color: StyleV2.transparentColor | ||
anchors.centerIn: parent | ||
width: rightActionContainer.actionAllowed ? parent.width + root.spacing/2 : 0 | ||
height: parent.height | ||
|
||
MouseArea { | ||
anchors.fill: parent | ||
onReleased: root.rightActionClicked() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
Item { | ||
id: messageItem | ||
|
||
width: parent.width | ||
height: msgRow.height | ||
|
||
Row { | ||
id: msgRow | ||
|
||
spacing: 4 * __dp | ||
|
||
MMIcon { | ||
id: msgIcon | ||
|
||
source: visible ? StyleV2.errorIcon : "" | ||
color: errorMsg.length > 0 ? StyleV2.negativeColor : StyleV2.warningColor | ||
visible: errorMsg.length > 0 || warningMsg.length > 0 | ||
} | ||
Text { | ||
text: root.errorMsg.length > 0 ? root.errorMsg : root.warningMsg | ||
font: StyleV2.t4 | ||
wrapMode: Text.WordWrap | ||
width: messageItem.width - msgRow.spacing - msgIcon.width | ||
visible: root.errorMsg.length > 0 || root.warningMsg.length > 0 | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/*************************************************************************** | ||
range.qml | ||
-------------------------------------- | ||
Date : 2019 | ||
Copyright : (C) 2019 by Viktor Sklencar | ||
Email : [email protected] | ||
*************************************************************************** | ||
* * | ||
* 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. * | ||
* * | ||
***************************************************************************/ | ||
|
||
import QtQuick | ||
import QtQuick.Controls | ||
import QtQuick.Controls.Basic | ||
import QtQuick.Layouts | ||
import Qt5Compat.GraphicalEffects | ||
import ".." | ||
|
||
//import lc 1.0 | ||
|
||
MMAbstractEditor { | ||
id: root | ||
|
||
/*required*/ property var parentValue: parent.value ?? "" | ||
/*required*/ property bool parentValueIsNull: parent.valueIsNull ?? false | ||
/*required*/ property bool isReadOnly: parent.readOnly ?? false | ||
|
||
property url leftIconSource: "" | ||
property alias placeholderText: textField.placeholderText | ||
readonly property alias text: textField.text | ||
|
||
signal editorValueChanged( var newValue, var isNull ) | ||
|
||
hasFocus: textField.activeFocus | ||
|
||
leftAction: MMIcon { | ||
id: leftIcon | ||
|
||
source: root.leftIconSource | ||
color: errorMsg.length > 0 ? StyleV2.negativeColor : | ||
warningMsg.length > 0 ? StyleV2.warningColor : | ||
root.enabled ? StyleV2.forestColor : StyleV2.mediumGreenColor | ||
height: parent.height | ||
visible: root.leftIconSource != "" | ||
} | ||
|
||
content: TextField { | ||
id: textField | ||
|
||
anchors.fill: parent | ||
|
||
text: root.parentValue | ||
color: root.enabled ? StyleV2.nightColor : StyleV2.mediumGreenColor | ||
placeholderTextColor: StyleV2.nightAlphaColor | ||
font: StyleV2.p5 | ||
hoverEnabled: true | ||
|
||
background: Rectangle { | ||
color: StyleV2.transparentColor | ||
} | ||
} | ||
|
||
rightAction: MMIcon { | ||
id: rightIcon | ||
|
||
source: StyleV2.xMarkIcon | ||
color: root.enabled ? StyleV2.forestColor : StyleV2.mediumGreenColor | ||
height: parent.height | ||
visible: textField.activeFocus && textField.text.length>0 | ||
} | ||
|
||
onRightActionClicked: textField.text = "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/*************************************************************************** | ||
range.qml | ||
-------------------------------------- | ||
Date : 2019 | ||
Copyright : (C) 2019 by Viktor Sklencar | ||
Email : [email protected] | ||
*************************************************************************** | ||
* * | ||
* 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. * | ||
* * | ||
***************************************************************************/ | ||
|
||
import QtQuick | ||
import QtQuick.Controls | ||
import QtQuick.Controls.Basic | ||
import QtQuick.Layouts | ||
import Qt5Compat.GraphicalEffects | ||
import ".." | ||
|
||
//import lc 1.0 | ||
|
||
MMAbstractEditor { | ||
id: root | ||
|
||
/*required*/ property var parentValue: parent.value | ||
/*required*/ property bool parentValueIsNull: parent.valueIsNull ?? false | ||
/*required*/ property bool isReadOnly: parent.readOnly ?? false | ||
|
||
required property string regexp | ||
property alias placeholderText: textField.placeholderText | ||
readonly property alias text: textField.text | ||
|
||
signal editorValueChanged( var newValue, var isNull ) | ||
|
||
hasFocus: textField.activeFocus | ||
|
||
content: TextField { | ||
id: textField | ||
|
||
text: root.parentValue | ||
anchors.fill: parent | ||
color: root.enabled ? StyleV2.nightColor : StyleV2.mediumGreenColor | ||
placeholderTextColor: StyleV2.nightAlphaColor | ||
font: StyleV2.p5 | ||
hoverEnabled: true | ||
anchors.verticalCenter: parent.verticalCenter | ||
echoMode: eyeButton.pressed ? TextInput.Normal : TextInput.Password | ||
background: Rectangle { | ||
color: StyleV2.transparentColor | ||
} | ||
} | ||
|
||
rightAction: MMIcon { | ||
id: eyeButton | ||
|
||
property bool pressed: false | ||
|
||
source: pressed ? StyleV2.hideIcon : StyleV2.showIcon | ||
color: root.enabled ? StyleV2.forestColor : StyleV2.mediumGreenColor | ||
height: parent.height | ||
} | ||
|
||
onRightActionClicked: eyeButton.pressed = !eyeButton.pressed | ||
|
||
function isPasswordCorrect(pwd) { | ||
let pwdRegexp = new RegExp(root.regexp) | ||
return pwdRegexp.test(pwd) | ||
} | ||
} |
Oops, something went wrong.
33f68fa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iOS - version 23.11.489711 just submitted!