2021-09-30 09:43:29 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 1.0 as QQC1
|
|
|
|
|
2022-03-11 11:00:59 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
2021-09-30 09:43:29 +00:00
|
|
|
import "../controls/styles"
|
|
|
|
|
|
|
|
QQC1.TabView {
|
|
|
|
id: tabs
|
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
property var currentWebEngineProfile
|
2021-09-30 09:43:29 +00:00
|
|
|
property var tabComponent
|
2021-12-07 23:15:17 +00:00
|
|
|
property var determineRealURL: function(url) {}
|
|
|
|
readonly property int tabHeight: 40
|
|
|
|
|
|
|
|
signal openNewTabTriggered()
|
2021-09-30 09:43:29 +00:00
|
|
|
|
|
|
|
function createEmptyTab(profile, createAsStartPage) {
|
|
|
|
var tab = addTab("", tabComponent);
|
|
|
|
// We must do this first to make sure that tab.active gets set so that tab.item gets instantiated immediately.
|
|
|
|
tab.active = true;
|
|
|
|
createAsStartPage = createAsStartPage || tabs.count === 1
|
|
|
|
tab.title = Qt.binding(function() {
|
2022-03-11 11:00:59 +00:00
|
|
|
var tabTitle = ""
|
2021-09-30 09:43:29 +00:00
|
|
|
if (tab.item.title) {
|
2022-03-11 11:00:59 +00:00
|
|
|
tabTitle = tab.item.title
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
2022-03-11 11:00:59 +00:00
|
|
|
else if (createAsStartPage) {
|
2022-04-04 11:26:30 +00:00
|
|
|
tabTitle = qsTr("Start Page")
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
2022-03-11 11:00:59 +00:00
|
|
|
else {
|
2022-04-04 11:26:30 +00:00
|
|
|
tabTitle = qsTr("New Tab")
|
2022-03-11 11:00:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Utils.escapeHtml(tabTitle);
|
2021-09-30 09:43:29 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
if (createAsStartPage) {
|
|
|
|
tab.item.url = "https://dap.ps"
|
|
|
|
}
|
|
|
|
|
|
|
|
tab.item.profile = profile;
|
2021-10-20 09:50:50 +00:00
|
|
|
if (localAccountSensitiveSettings.browserHomepage !== "") {
|
2021-11-09 09:12:51 +00:00
|
|
|
tab.item.url = determineRealURL(localAccountSensitiveSettings.browserHomepage)
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
|
|
|
return tab;
|
|
|
|
}
|
|
|
|
|
|
|
|
function createDownloadTab(profile) {
|
|
|
|
var tab = addTab("", tabComponent);
|
|
|
|
tab.active = true;
|
2022-04-04 11:26:30 +00:00
|
|
|
tab.title = qsTr("Downloads Page")
|
2021-09-30 09:43:29 +00:00
|
|
|
tab.item.profile = profile
|
|
|
|
tab.item.url = "status://downloads";
|
|
|
|
}
|
|
|
|
|
|
|
|
function indexOfView(view) {
|
|
|
|
for (let i = 0; i < tabs.count; ++i)
|
|
|
|
if (tabs.getTab(i).item === view)
|
|
|
|
return i
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
2021-12-07 23:15:17 +00:00
|
|
|
function openNewTabClicked() {
|
|
|
|
openNewTabTriggered()
|
|
|
|
}
|
|
|
|
|
2021-09-30 09:43:29 +00:00
|
|
|
function removeView(index) {
|
|
|
|
if (tabs.count === 1) {
|
2021-12-07 23:15:17 +00:00
|
|
|
tabs.createEmptyTab(currentWebEngineProfile, true)
|
2021-09-30 09:43:29 +00:00
|
|
|
}
|
|
|
|
tabs.removeTab(index)
|
|
|
|
}
|
|
|
|
|
|
|
|
function closeButtonClicked(index) {
|
|
|
|
removeView(index)
|
|
|
|
}
|
|
|
|
|
|
|
|
style: BrowserTabStyle {}
|
|
|
|
}
|