Merge remote-tracking branch 'upstream/main'

pull/17/head
titenko 4 years ago
commit 495d426407

@ -23,31 +23,37 @@ import QtQuick.Layouts 1.12
import QtQuick.Window 2.12
import FishUI 1.0 as FishUI
Dialog {
Window {
id: control
modal: true
property var contentWidth: _mainLayout.implicitWidth + FishUI.Units.largeSpacing * 2
property var contentHeight: _mainLayout.implicitHeight + FishUI.Units.largeSpacing * 2
width: _mainLayout.implicitWidth + FishUI.Units.largeSpacing * 3
height: _mainLayout.implicitHeight + FishUI.Units.largeSpacing * 3
flags: Qt.WindowStaysOnTopHint
modality: Qt.WindowModal
x: (parent.width - control.width) / 2
y: (parent.height - control.height) / 2
width: contentWidth
height: contentHeight
minimumWidth: contentWidth
minimumHeight: contentHeight
maximumWidth: contentWidth
maximumHeight: contentHeight
signal okBtnClicked
Rectangle {
anchors.fill: parent
color: FishUI.Theme.secondBackgroundColor
}
ColumnLayout {
id: _mainLayout
anchors.fill: parent
spacing: FishUI.Units.largeSpacing
anchors.leftMargin: FishUI.Units.smallSpacing
anchors.rightMargin: FishUI.Units.smallSpacing
anchors.topMargin: FishUI.Units.smallSpacing
anchors.bottomMargin: FishUI.Units.smallSpacing
anchors.margins: FishUI.Units.largeSpacing
Label {
text: qsTr("Process is running, are you sure you want to quit?")
Layout.alignment: Qt.AlignHCenter
}
RowLayout {

@ -47,7 +47,16 @@ FishUI.Window {
ExitPromptDialog {
id: exitPrompt
onOkBtnClicked: Qt.quit()
property var index: -1
onOkBtnClicked: {
if (index != -1) {
closeTab(index)
} else {
onOkBtnClicked: Qt.quit()
}
}
}
SettingsDialog {
@ -71,6 +80,7 @@ FishUI.Window {
for (var i = 0; i < tabsModel.count; ++i) {
var obj = tabsModel.get(i)
if (obj.session.hasActiveProcess) {
exitPrompt.index = -1
exitPrompt.visible = true
close.accepted = false
break
@ -160,7 +170,7 @@ FishUI.Window {
Layout.preferredWidth: 24
size: 24
source: "qrc:/images/" + (FishUI.Theme.darkMode || isCurrent ? "dark/" : "light/") + "close.svg"
onClicked: closeTab(index)
onClicked: closeProtection(index)
}
}
}
@ -227,6 +237,17 @@ FishUI.Window {
}
}
function closeProtection(index) {
var obj = tabsModel.get(index)
if (obj.session.hasActiveProcess) {
exitPrompt.index = index
exitPrompt.visible = true
return
}
closeTab(index)
}
function closeTab(index) {
tabsModel.remove(index)
@ -243,7 +264,7 @@ FishUI.Window {
}
function closeCurrentTab() {
closeTab(_view.currentIndex)
closeProtection(_view.currentIndex)
}
function toggleTab() {

Loading…
Cancel
Save