Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*.a

build*/
obj-x86_64-linux-gnu/
include*/

*.txt.user*
Expand Down
50 changes: 48 additions & 2 deletions src/qml/InformationDialog/PropertyActionItemDelegate.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -39,6 +39,9 @@ Control {
}
property string title

// 允许组件接收焦点(用于转移焦点)
focus: true

signal clicked

function dealShowPicLabelClick() {
Expand All @@ -56,11 +59,27 @@ Control {
}
}

// 复位当前属性编辑组件,关闭编辑框
// 复位当前属性编辑组件,关闭编辑框(不保存)
function reset() {
showPicLabel.visible = true;
}

// 提交更改并关闭编辑框(保存文件名)
function commitAndClose() {
if (!showPicLabel.visible) {
var name = nameedit.text;
if (!IV.FileControl.isShowToolTip(IV.GControl.currentSource, name) && name.length > 0) {
IV.FileControl.slotFileReName(name, IV.GControl.currentSource);
}
showPicLabel.visible = true;
}
}

// 检查是否处于编辑状态
function isEditing() {
return !showPicLabel.visible;
}

bottomPadding: 4
leftPadding: 10
rightPadding: 10
Expand Down Expand Up @@ -116,6 +135,33 @@ Control {
}
}

// 焦点变化时处理 - 失去焦点时保存文件名
onActiveFocusChanged: {
// 失去焦点且输入框可见时,保存文件名
if (!activeFocus && visible && !showPicLabel.visible) {
// 延迟执行,避免与其他焦点事件冲突
commitAndCloseTimer.restart();
}
}

// 失去焦点时保存文件名(备用方案)
onEditingFinished: {
// 只有当输入框可见时才处理(避免在 reset 时触发)
if (visible && !showPicLabel.visible) {
dealShowPicLabelClick();
}
}

Timer {
id: commitAndCloseTimer
interval: 10
onTriggered: {
if (!nameedit.activeFocus && nameedit.visible && !showPicLabel.visible) {
dealShowPicLabelClick();
}
}
}

anchors {
leftMargin: 10
topMargin: 5
Expand Down
14 changes: 13 additions & 1 deletion src/qml/InformationDialog/PropertyItemDelegate.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -42,6 +42,18 @@ Control {

signal clicked

// 允许接收焦点,点击时可以转移其他元素的焦点
focus: true

// 点击时获取焦点,使用 forceActiveFocus 确保能跨焦点作用域抢走焦点
MouseArea {
anchors.fill: parent
onClicked: {
control.forceActiveFocus();
}
cursorShape: Qt.ArrowCursor
}

bottomPadding: 4
implicitWidth: contrlImplicitWidth
leftPadding: 10
Expand Down
Loading