mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-23 02:00:20 +07:00
Share page refactoring part 1
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import Qt.labs.platform 1.0
|
||||
|
||||
Menu {
|
||||
property var textObj
|
||||
|
||||
MenuItem {
|
||||
text: qsTr("C&ut")
|
||||
shortcut: StandardKey.Cut
|
||||
enabled: textObj.selectedText
|
||||
onTriggered: textObj.cut()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("&Copy")
|
||||
shortcut: StandardKey.Copy
|
||||
enabled: textObj.selectedText
|
||||
onTriggered: textObj.copy()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("&Paste")
|
||||
shortcut: StandardKey.Paste
|
||||
enabled: textObj.canPaste
|
||||
onTriggered: textObj.paste()
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: qsTr("&SelectAll")
|
||||
shortcut: StandardKey.SelectAll
|
||||
enabled: textObj.length > 0
|
||||
onTriggered: textObj.selectAll()
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import QtQuick.Controls 2.12
|
||||
|
||||
BasicButtonType {
|
||||
id: root
|
||||
height: 40
|
||||
background: Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: 4
|
||||
|
||||
@@ -5,9 +5,7 @@ import QtGraphicalEffects 1.12
|
||||
Item {
|
||||
id: root
|
||||
property bool active: false
|
||||
property Component content: undefined
|
||||
property string text: ""
|
||||
width: 360
|
||||
height: active ? contentLoader.item.height + 40 + 5 * 2 : 40
|
||||
signal clicked()
|
||||
|
||||
@@ -64,12 +62,5 @@ Item {
|
||||
onClicked: root.clicked()
|
||||
}
|
||||
}
|
||||
Loader {
|
||||
x: 0
|
||||
y: 40 + 5
|
||||
id: contentLoader
|
||||
sourceComponent: root.content
|
||||
visible: root.active
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import QtQuick 2.12
|
||||
import QtQuick.Controls 2.12
|
||||
import Qt.labs.platform 1.0
|
||||
|
||||
Flickable
|
||||
{
|
||||
property alias textArea: root
|
||||
id: flickable
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
clip: true
|
||||
TextArea.flickable:
|
||||
|
||||
TextArea {
|
||||
id: root
|
||||
property bool error: false
|
||||
|
||||
width: parent.width - 80
|
||||
height: 40
|
||||
anchors.topMargin: 5
|
||||
selectByMouse: false
|
||||
|
||||
|
||||
selectionColor: "darkgray"
|
||||
font.pixelSize: 16
|
||||
color: "#333333"
|
||||
background: Rectangle {
|
||||
implicitWidth: 200
|
||||
implicitHeight: 40
|
||||
border.width: 1
|
||||
color: {
|
||||
if (root.error) {
|
||||
return Qt.rgba(213, 40, 60, 255)
|
||||
}
|
||||
return root.enabled ? "#F4F4F4" : Qt.rgba(127, 127, 127, 255)
|
||||
}
|
||||
border.color: {
|
||||
if (!root.enabled) {
|
||||
return Qt.rgba(127, 127, 127, 255)
|
||||
}
|
||||
if (root.error) {
|
||||
return Qt.rgba(213, 40, 60, 255)
|
||||
}
|
||||
if (root.focus) {
|
||||
return "#A7A7A7"
|
||||
}
|
||||
return "#A7A7A7"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,29 +44,8 @@ TextField {
|
||||
onClicked: contextMenu.open()
|
||||
}
|
||||
|
||||
Menu {
|
||||
ContextMenu {
|
||||
id: contextMenu
|
||||
|
||||
onAboutToShow: console.log("aboutToShow")
|
||||
onAboutToHide: console.log("aboutToHide")
|
||||
|
||||
MenuItem {
|
||||
text: qsTr("C&ut")
|
||||
shortcut: StandardKey.Cut
|
||||
enabled: root.selectedText
|
||||
onTriggered: root.cut()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("&Copy")
|
||||
shortcut: StandardKey.Copy
|
||||
enabled: root.selectedText
|
||||
onTriggered: root.copy()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("&Paste")
|
||||
shortcut: StandardKey.Paste
|
||||
enabled: root.canPaste
|
||||
onTriggered: root.paste()
|
||||
}
|
||||
textObj: root
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user