QClipboardProxy QML type renamed to ClipboardUtils

Additionally, copyTextToClipboard is renamed to setText, mimicking
QClipboard naming.
This commit is contained in:
Michał Cieślak 2024-08-27 15:42:45 +02:00 committed by Michał
parent 781133238a
commit 7757f4e615
8 changed files with 17 additions and 17 deletions

View File

@ -37,7 +37,7 @@ SplitView {
padding: 0 padding: 0
text: "📋" text: "📋"
font.pixelSize: 10 font.pixelSize: 10
onClicked: QClipboardProxy.copyTextToClipboard(textLabel.text) onClicked: ClipboardUtils.setText(textLabel.text)
ToolTip.text: "Copy color name" ToolTip.text: "Copy color name"
ToolTip.visible: hovered ToolTip.visible: hovered
} }
@ -58,7 +58,7 @@ SplitView {
padding: 0 padding: 0
text: "📋" text: "📋"
font.pixelSize: 10 font.pixelSize: 10
onClicked: QClipboardProxy.copyTextToClipboard(colorLabel.text) onClicked: ClipboardUtils.setText(colorLabel.text)
ToolTip.text: "Copy color value" ToolTip.text: "Copy color value"
ToolTip.visible: hovered ToolTip.visible: hovered
} }

View File

@ -200,7 +200,7 @@ Item {
compare(amountToSend.empty, true) compare(amountToSend.empty, true)
compare(amountToSend.amount, "0") compare(amountToSend.amount, "0")
QClipboardProxy.copyTextToClipboard("1.0005") ClipboardUtils.setText("1.0005")
const textField = findChild(amountToSend, "amountToSend_textField") const textField = findChild(amountToSend, "amountToSend_textField")
verify(!!textField) verify(!!textField)

View File

@ -41,7 +41,7 @@ Item {
controlUnderTest = createTemporaryObject(componentUnderTest, root) controlUnderTest = createTemporaryObject(componentUnderTest, root)
signalSpyClearClicked.clear() signalSpyClearClicked.clear()
signalSpyValidateInputRequested.clear() signalSpyValidateInputRequested.clear()
QClipboardProxy.clear() ClipboardUtils.clear()
} }
function test_basicGeometry() { function test_basicGeometry() {

View File

@ -52,7 +52,7 @@ public:
return new ClipboardUtils; return new ClipboardUtils;
} }
Q_INVOKABLE void copyTextToClipboard(const QString& text); Q_INVOKABLE void setText(const QString& text);
Q_INVOKABLE void clear(); Q_INVOKABLE void clear();
signals: signals:

View File

@ -72,7 +72,7 @@ QList<QUrl> ClipboardUtils::urls() const
return m_clipboard->mimeData()->urls(); return m_clipboard->mimeData()->urls();
} }
void ClipboardUtils::copyTextToClipboard(const QString &text) void ClipboardUtils::setText(const QString &text)
{ {
m_clipboard->setText(text); m_clipboard->setText(text);
} }

View File

@ -78,7 +78,7 @@ public:
qmlRegisterType<WritableProxyModel>("StatusQ", 0, 1, "WritableProxyModel"); qmlRegisterType<WritableProxyModel>("StatusQ", 0, 1, "WritableProxyModel");
qmlRegisterType<FormattedDoubleProperty>("StatusQ", 0, 1, "FormattedDoubleProperty"); qmlRegisterType<FormattedDoubleProperty>("StatusQ", 0, 1, "FormattedDoubleProperty");
qmlRegisterSingletonType<ClipboardUtils>("StatusQ", 0, 1, "QClipboardProxy", &ClipboardUtils::qmlInstance); qmlRegisterSingletonType<ClipboardUtils>("StatusQ", 0, 1, "ClipboardUtils", &ClipboardUtils::qmlInstance);
qmlRegisterSingletonType<UrlUtils>("StatusQ", 0, 1, "UrlUtils", &UrlUtils::qmlInstance); qmlRegisterSingletonType<UrlUtils>("StatusQ", 0, 1, "UrlUtils", &UrlUtils::qmlInstance);
qmlRegisterType<ModelEntry>("StatusQ", 0, 1, "ModelEntry"); qmlRegisterType<ModelEntry>("StatusQ", 0, 1, "ModelEntry");

View File

@ -38,7 +38,7 @@ StatusInput {
focusPolicy: Qt.NoFocus focusPolicy: Qt.NoFocus
onClicked: { onClicked: {
root.input.edit.forceActiveFocus() root.input.edit.forceActiveFocus()
root.text = QClipboardProxy.text // paste plain text root.text = ClipboardUtils.text // paste plain text
root.input.edit.cursorPosition = root.input.edit.length root.input.edit.cursorPosition = root.input.edit.length
root.validateInputRequested() root.validateInputRequested()
} }
@ -66,7 +66,7 @@ StatusInput {
function onKeyPressed(event) { function onKeyPressed(event) {
if (event.matches(StandardKey.Paste)) { if (event.matches(StandardKey.Paste)) {
event.accepted = true event.accepted = true
root.text = QClipboardProxy.text // paste plain text root.text = ClipboardUtils.text // paste plain text
} }
} }
} }

View File

@ -143,7 +143,7 @@ Rectangle {
property int leftOfMentionIndex: -1 property int leftOfMentionIndex: -1
property int rightOfMentionIndex: -1 property int rightOfMentionIndex: -1
readonly property int nbEmojisInClipboard: StatusQUtils.Emoji.nbEmojis(QClipboardProxy.html) readonly property int nbEmojisInClipboard: StatusQUtils.Emoji.nbEmojis(ClipboardUtils.html)
property bool emojiPopupOpened: false property bool emojiPopupOpened: false
property bool stickersPopupOpened: false property bool stickersPopupOpened: false
@ -449,12 +449,12 @@ Rectangle {
} }
if (event.matches(StandardKey.Paste)) { if (event.matches(StandardKey.Paste)) {
if (QClipboardProxy.hasImage) { if (ClipboardUtils.hasImage) {
const clipboardImage = QClipboardProxy.imageBase64 const clipboardImage = ClipboardUtils.imageBase64
validateImagesAndShowImageArea([clipboardImage]) validateImagesAndShowImageArea([clipboardImage])
event.accepted = true event.accepted = true
} else if (QClipboardProxy.hasText) { } else if (ClipboardUtils.hasText) {
const clipboardText = Utils.plainText(QClipboardProxy.text) const clipboardText = Utils.plainText(ClipboardUtils.text)
// prevent repetitive & huge clipboard paste, where huge is total char count > than messageLimitHard // prevent repetitive & huge clipboard paste, where huge is total char count > than messageLimitHard
const selectionLength = messageInputField.selectionEnd - messageInputField.selectionStart; const selectionLength = messageInputField.selectionEnd - messageInputField.selectionStart;
if ((messageLength + clipboardText.length - selectionLength) > control.messageLimitHard) if ((messageLength + clipboardText.length - selectionLength) > control.messageLimitHard)
@ -500,8 +500,8 @@ Rectangle {
d.copiedTextFormatted = "" d.copiedTextFormatted = ""
d.copiedMentionsPos = [] d.copiedMentionsPos = []
messageInputField.insert(d.copyTextStart, ((d.nbEmojisInClipboard === 0) ? messageInputField.insert(d.copyTextStart, ((d.nbEmojisInClipboard === 0) ?
("<div style='white-space: pre-wrap'>" + StatusQUtils.StringUtils.escapeHtml(QClipboardProxy.text) + "</div>") ("<div style='white-space: pre-wrap'>" + StatusQUtils.StringUtils.escapeHtml(ClipboardUtils.text) + "</div>")
: StatusQUtils.Emoji.deparse(QClipboardProxy.html))); : StatusQUtils.Emoji.deparse(ClipboardUtils.html)));
} }
event.accepted = true event.accepted = true
} }
@ -676,7 +676,7 @@ Rectangle {
if (messageInputField.readOnly) { if (messageInputField.readOnly) {
messageInputField.readOnly = false; messageInputField.readOnly = false;
messageInputField.cursorPosition = (d.copyTextStart + QClipboardProxy.text.length + d.nbEmojisInClipboard); messageInputField.cursorPosition = (d.copyTextStart + ClipboardUtils.text.length + d.nbEmojisInClipboard);
} }