mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:35:08 +00:00
UI: Add text context menu.
This commit is contained in:
parent
f28e93fe0a
commit
76b88cf4d4
@ -1,6 +1,8 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>qml/controls/TextAreaFrame.qml</file>
|
||||
<file>qml/controls/TextContextMenu.qml</file>
|
||||
<file>qml/controls/TextFieldFrame.qml</file>
|
||||
<file>qml/main.qml</file>
|
||||
<file>qml/pages/ActivityPage.qml</file>
|
||||
<file>qml/pages/AddressesPage.qml</file>
|
||||
|
@ -16,8 +16,10 @@ Frame {
|
||||
TextArea {
|
||||
id: textArea
|
||||
clip: true // to clip placeholder text
|
||||
persistentSelection: true
|
||||
selectByMouse: true
|
||||
onTextChanged: frame.textChanged()
|
||||
onReleased: textContextMenu.show(event, textArea)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
51
src/ui/qml/controls/TextContextMenu.qml
Normal file
51
src/ui/qml/controls/TextContextMenu.qml
Normal file
@ -0,0 +1,51 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
Menu {
|
||||
id: contextMenu
|
||||
|
||||
property Item textField
|
||||
|
||||
onClosed: {
|
||||
textField = null;
|
||||
}
|
||||
|
||||
function show(mouseEvent, field) {
|
||||
if (mouseEvent.button !== Qt.RightButton)
|
||||
return;
|
||||
|
||||
mouseEvent.accepted = true;
|
||||
|
||||
textField = field;
|
||||
|
||||
const pos = textField.mapToItem(null, mouseEvent.x, mouseEvent.y);
|
||||
x = pos.x;
|
||||
y = pos.y;
|
||||
|
||||
open();
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: qsTranslate("qml", "Copy")
|
||||
enabled: textField && textField.selectedText
|
||||
onTriggered: textField.copy()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTranslate("qml", "Cut")
|
||||
enabled: textField && textField.selectedText
|
||||
onTriggered: textField.cut()
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTranslate("qml", "Paste")
|
||||
enabled: textField && textField.canPaste
|
||||
onTriggered: textField.paste()
|
||||
}
|
||||
|
||||
MenuSeparator {}
|
||||
|
||||
MenuItem {
|
||||
text: qsTranslate("qml", "Clear")
|
||||
enabled: textField && textField.text
|
||||
onTriggered: textField.clear()
|
||||
}
|
||||
}
|
8
src/ui/qml/controls/TextFieldFrame.qml
Normal file
8
src/ui/qml/controls/TextFieldFrame.qml
Normal file
@ -0,0 +1,8 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
TextField {
|
||||
id: textField
|
||||
persistentSelection: true
|
||||
onReleased: textContextMenu.show(event, textField)
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import "controls"
|
||||
import "pages"
|
||||
import com.fortfirewall 1.0
|
||||
|
||||
@ -40,6 +41,10 @@ ApplicationWindow {
|
||||
id: osUtil
|
||||
}
|
||||
|
||||
TextContextMenu {
|
||||
id: textContextMenu
|
||||
}
|
||||
|
||||
Loader {
|
||||
anchors.fill: parent
|
||||
sourceComponent: appWindow.visible ? mainPageComponent : undefined
|
||||
|
@ -1,6 +1,7 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Controls 2.2
|
||||
import "../controls"
|
||||
import "apps"
|
||||
import com.fortfirewall 1.0
|
||||
|
||||
@ -57,9 +58,9 @@ BasePage {
|
||||
anchors.fill: parent
|
||||
|
||||
RowLayout {
|
||||
TextField {
|
||||
enabled: appGroupsCount < 16
|
||||
TextFieldFrame {
|
||||
id: editGroupName
|
||||
enabled: appGroupsCount < 16
|
||||
placeholderText: translationManager.dummyBool
|
||||
&& qsTranslate("qml", "Group Name")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user