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

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

Loading…
Cancel
Save