-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added input editors: #2923
Added input editors: #2923
Conversation
- MMInputEditor (optional left icon) - MMPasswordEditor (with eye button) - MMSliderEditor See how to use it in EditorsPage.qml
border.color: root.hasFocus ? ( errorMsg.length > 0 ? StyleV2.negativeColor : warningMsg.length > 0 ? StyleV2.warningColor : StyleV2.forestColor ) : StyleV2.transparentColor | ||
border.width: 2 * __dp | ||
color: root.bgColor | ||
radius: 12 * __dp |
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.
I would expect this radius value to be in __style
as it is likely reused in many other places
|
||
width: parent.width | ||
height: parent.height | ||
border.color: root.hasFocus ? ( errorMsg.length > 0 ? StyleV2.negativeColor : warningMsg.length > 0 ? StyleV2.warningColor : StyleV2.forestColor ) : StyleV2.transparentColor |
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.
In case of more complicated conditions like here, we should write them with proper if/else
statements. These are much easier to read, understand and update if needed. See for example: https://doc.qt.io/qt-6/qml-codingconventions.html#javascript-code
border.color: root.hasFocus ? ( errorMsg.length > 0 ? StyleV2.negativeColor : warningMsg.length > 0 ? StyleV2.warningColor : StyleV2.forestColor ) : StyleV2.transparentColor | |
border.color: { | |
if (root.hasFocus) { | |
if (errorMsg.length > 0) { | |
return __style.negativeColor | |
} | |
else if (warningMsg.length > 0) { | |
return __style.warningColor | |
} | |
} | |
else { | |
return __style.transparentColor | |
} | |
} |
Rectangle { | ||
color: StyleV2.transparentColor | ||
anchors.centerIn: parent | ||
width: leftActionContainer.actionAllowed ? parent.width + root.spacing/2 : 0 | ||
height: parent.height |
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.
What is the point of this rectangle?
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 ) |
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.
Commented out code
width: parent.width - (leftActionContainer.actionAllowed ? leftActionContainer.width : 0) - (rightActionContainer.actionAllowed ? rightActionContainer.width : 0) //- 2 * root.spacing - ( leftActionContainer.actionAllowed ? root.spacing : 0 ) | |
width: parent.width - (leftActionContainer.actionAllowed ? leftActionContainer.width : 0) - (rightActionContainer.actionAllowed ? rightActionContainer.width : 0) |
Item { | ||
id: leftActionContainer | ||
|
||
property bool actionAllowed: leftActionContainer.children.length > 1 && (leftActionContainer.children[1]?.visible ?? false) |
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.
What type of input changes the visibility state?
property bool actionAllowed: leftActionContainer.children.length > 1 && (leftActionContainer.children[1]?.visible ?? false) | |
property bool actionAllowed: leftActionContainer.children.length > 1 ) |
import Qt5Compat.GraphicalEffects | ||
import ".." | ||
|
||
//import lc 1.0 |
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.
Commented out code
/*required*/ property var parentValue: parent.value ?? "" | ||
/*required*/ property bool parentValueIsNull: parent.valueIsNull ?? false | ||
/*required*/ property bool isReadOnly: parent.readOnly ?? false |
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.
It is Qt6, we can finally start using the required
properties! :)) 🍾
/*required*/ property var parentValue: parent.value ?? "" | |
/*required*/ property bool parentValueIsNull: parent.valueIsNull ?? false | |
/*required*/ property bool isReadOnly: parent.readOnly ?? false | |
required property var parentValue: parent.value ?? "" | |
required property bool parentValueIsNull: parent.valueIsNull ?? false | |
required property bool isReadOnly: parent.readOnly ?? false |
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.
This applies to other files too
/*************************************************************************** | ||
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. * | ||
* * | ||
***************************************************************************/ |
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.
New file, new header :)
/*************************************************************************** | |
range.qml | |
-------------------------------------- | |
Date : 2019 | |
Copyright : (C) 2019 by Viktor Sklencar | |
Email : viktor.sklencar@lutraconsulting.co.uk | |
*************************************************************************** | |
* * | |
* 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. * | |
* * | |
***************************************************************************/ | |
/ *************************************************************************** | |
* * | |
* 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. * | |
* * | |
***************************************************************************/ |
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.
The same applies to all files
import Qt5Compat.GraphicalEffects | ||
import ".." | ||
|
||
//import lc 1.0 |
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.
commented out code
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.
The same applies to all files, please remove code that is commented out
/*required*/ property bool parentValueIsNull: parent.valueIsNull ?? false | ||
/*required*/ property bool isReadOnly: parent.readOnly ?? false | ||
|
||
required property string regexp |
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.
Validation of password goes through c++, not here. This field will instead receive an error is password is not strong enough
Done in #2944 |
MMInputEditor (optional left icon)
MMPasswordEditor (with eye button)
MMSliderEditor See how to use it in EditorsPage.qml