-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add delete dialog component; Copy the device type detection code from DFM. Log: Add delete confirmation dialog Bug: https://pms.uniontech.com/bug-view-167807.html
- Loading branch information
Showing
17 changed files
with
606 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
import QtQuick 2.11 | ||
import QtQuick.Layouts 1.11 | ||
import org.deepin.dtk 1.0 | ||
|
||
DialogWindow { | ||
id: dialog | ||
|
||
property alias fileName: textMetics.text | ||
property int nameMaxWidth: 200 | ||
|
||
// 操作结束 true: 允许删除 false: 取消 | ||
signal finished(bool ret) | ||
|
||
flags: Qt.Window | Qt.WindowCloseButtonHint | Qt.WindowStaysOnTopHint | ||
height: 180 | ||
maximumHeight: 180 | ||
maximumWidth: 400 | ||
minimumHeight: 180 | ||
minimumWidth: 400 | ||
modality: Qt.WindowModal | ||
visible: false | ||
width: 400 | ||
|
||
header: DialogTitleBar { | ||
enableInWindowBlendBlur: true | ||
|
||
// 仅保留默认状态,否则 hover 上会有变化效果 | ||
icon { | ||
mode: DTK.NormalState | ||
name: "user-trash-full-opened" | ||
} | ||
} | ||
|
||
Component.onCompleted: { | ||
setX(window.x + window.width / 2 - width / 2); | ||
setY(window.y + window.height / 2 - height / 2); | ||
show(); | ||
} | ||
onClosing: { | ||
finished(false); | ||
} | ||
|
||
ColumnLayout { | ||
height: parent.height | ||
width: parent.width | ||
|
||
ColumnLayout { | ||
Layout.alignment: Qt.AlignCenter | ||
Layout.fillWidth: true | ||
Layout.maximumHeight: 80 | ||
Layout.minimumHeight: 80 | ||
Layout.preferredHeight: 80 | ||
|
||
Label { | ||
id: notifyText | ||
|
||
property Palette textColor: Palette { | ||
normal: ("black") | ||
normalDark: ("white") | ||
} | ||
|
||
Layout.alignment: Qt.AlignCenter | ||
Layout.fillWidth: true | ||
color: ColorSelector.textColor | ||
font: DTK.fontManager.t5 | ||
horizontalAlignment: Text.AlignHCenter | ||
text: qsTr("Cannot move \"%1\" to the trash. Do you want to permanently delete it?").arg(textMetics.elidedText) | ||
wrapMode: Text.Wrap | ||
|
||
TextMetrics { | ||
id: textMetics | ||
|
||
elide: Text.ElideMiddle | ||
elideWidth: nameMaxWidth | ||
font: notifyText.font | ||
} | ||
} | ||
|
||
Label { | ||
id: messageText | ||
|
||
Layout.alignment: Qt.AlignHCenter | ||
Layout.fillHeight: true | ||
font: DTK.fontManager.t6 | ||
text: qsTr("This action cannot be undone") | ||
width: dialog.width | ||
} | ||
} | ||
|
||
Row { | ||
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom | ||
Layout.fillHeight: true | ||
spacing: 10 | ||
|
||
Button { | ||
height: 36 | ||
text: qsTr("Cancel") | ||
width: 185 | ||
|
||
onClicked: { | ||
finished(false); | ||
} | ||
} | ||
|
||
RecommandButton { | ||
height: 36 | ||
text: qsTr("Confirm") | ||
width: 185 | ||
|
||
onClicked: { | ||
finished(true); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.