Skip to content

Commit

Permalink
Merge branch 'master' into master_numberInput
Browse files Browse the repository at this point in the history
  • Loading branch information
iiLubos authored Dec 21, 2023
2 parents 6a6ef29 + 96c4a2c commit 7c7e8c5
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
78 changes: 78 additions & 0 deletions app/qml/inputs/MMButtonInputEditor.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/***************************************************************************
* *
* 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 "../components"

MMAbstractEditor {
id: root

property var parentValue: parent.value ?? ""
property bool parentValueIsNull: parent.valueIsNull ?? false
property bool isReadOnly: parent.readOnly ?? false

property alias placeholderText: textField.placeholderText
property alias text: textField.text
property alias buttonText: buttonText.text
property alias buttonEnabled: rightButton.enabled

signal editorValueChanged( var newValue, var isNull )
signal buttonClicked()

hasFocus: textField.activeFocus

content: TextField {
id: textField

anchors.verticalCenter: parent.verticalCenter
width: parent.width + rightButton.x

text: root.parentValue
color: root.enabled ? __style.nightColor : __style.mediumGreenColor
placeholderTextColor: __style.nightAlphaColor
font: __style.p5
hoverEnabled: true

background: Rectangle {
color: __style.transparentColor
}
}

rightAction: Button {
id: rightButton

property bool transparent: false

x: 10 * __dp - buttonText.width
height: 34 * __dp
anchors.verticalCenter: parent.verticalCenter

contentItem: Text {
id: buttonText

anchors.centerIn: rightButton
font: __style.t3
color: rightButton.enabled ? rightButton.down || rightButton.hovered ? __style.grassColor : __style.forestColor : __style.deepOceanColor
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}

background: Rectangle {
color: rightButton.enabled ? rightButton.down || rightButton.hovered ? __style.forestColor : __style.grassColor : __style.mediumGreenColor
radius: height / 2
}

onClicked: {
textField.forceActiveFocus()
root.buttonClicked()
}
}
}
1 change: 1 addition & 0 deletions gallery/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@
<file>../app/qml/components/MMIconCheckBoxHorizontal.qml</file>
<file>../app/qml/components/MMIconCheckBoxVertical.qml</file>
<file>../app/qml/inputs/MMNumberEditor.qml</file>
<file>../app/qml/inputs/MMButtonInputEditor.qml</file>
</qresource>
</RCC>
20 changes: 20 additions & 0 deletions gallery/qml/pages/EditorsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,26 @@ ScrollView {
checkboxChecked: false
}

MMButtonInputEditor {
title: "MMButtonInputEditor"
placeholderText: "Write something"
text: "Text to copy"
buttonText: "Copy"
enabled: checkbox.checked
width: parent.width
onButtonClicked: console.log("Copy pressed")
buttonEnabled: text.length > 0
}

MMButtonInputEditor {
title: "MMButtonInputEditor"
placeholderText: "Píš"
buttonText: "Kopíruj"
enabled: checkbox.checked
width: parent.width
buttonEnabled: text.length > 0
}

MMInputEditor {
title: "MMInputEditor"
placeholderText: "Placeholder"
Expand Down

1 comment on commit 7c7e8c5

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 23.12.501211 just submitted!

Please sign in to comment.