mirror of
https://github.com/tnodir/fort
synced 2024-11-15 10:35:10 +00:00
UI: Add text context menu.
This commit is contained in:
parent
f28e93fe0a
commit
76b88cf4d4
@ -1,6 +1,8 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>qml/controls/TextAreaFrame.qml</file>
|
<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/main.qml</file>
|
||||||
<file>qml/pages/ActivityPage.qml</file>
|
<file>qml/pages/ActivityPage.qml</file>
|
||||||
<file>qml/pages/AddressesPage.qml</file>
|
<file>qml/pages/AddressesPage.qml</file>
|
||||||
|
@ -16,8 +16,10 @@ Frame {
|
|||||||
TextArea {
|
TextArea {
|
||||||
id: textArea
|
id: textArea
|
||||||
clip: true // to clip placeholder text
|
clip: true // to clip placeholder text
|
||||||
|
persistentSelection: true
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
onTextChanged: frame.textChanged()
|
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 2.9
|
||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.2
|
||||||
|
import "controls"
|
||||||
import "pages"
|
import "pages"
|
||||||
import com.fortfirewall 1.0
|
import com.fortfirewall 1.0
|
||||||
|
|
||||||
@ -40,6 +41,10 @@ ApplicationWindow {
|
|||||||
id: osUtil
|
id: osUtil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextContextMenu {
|
||||||
|
id: textContextMenu
|
||||||
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
sourceComponent: appWindow.visible ? mainPageComponent : undefined
|
sourceComponent: appWindow.visible ? mainPageComponent : undefined
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import QtQuick 2.9
|
import QtQuick 2.9
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.2
|
||||||
|
import "../controls"
|
||||||
import "apps"
|
import "apps"
|
||||||
import com.fortfirewall 1.0
|
import com.fortfirewall 1.0
|
||||||
|
|
||||||
@ -57,9 +58,9 @@ BasePage {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
TextField {
|
TextFieldFrame {
|
||||||
enabled: appGroupsCount < 16
|
|
||||||
id: editGroupName
|
id: editGroupName
|
||||||
|
enabled: appGroupsCount < 16
|
||||||
placeholderText: translationManager.dummyBool
|
placeholderText: translationManager.dummyBool
|
||||||
&& qsTranslate("qml", "Group Name")
|
&& qsTranslate("qml", "Group Name")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user