Don't nest all content in background rect

This way we don't have an extra identation depth, makes it a bit easier to read

CURA-8726
This commit is contained in:
Jaime van Kessel 2022-02-22 15:47:48 +01:00
parent a05650f64c
commit ac6375d17b

View File

@ -46,196 +46,195 @@ Window
{ {
anchors.fill: parent anchors.fill: parent
color: UM.Theme.getColor("main_background") color: UM.Theme.getColor("main_background")
}
//The Marketplace can have a page in front of everything with package details. The stack view controls its visibility.
StackView
{
id: contextStack
anchors.fill: parent
//The Marketplace can have a page in front of everything with package details. The stack view controls its visibility. initialItem: packageBrowse
StackView
ColumnLayout
{ {
id: contextStack id: packageBrowse
anchors.fill: parent
initialItem: packageBrowse spacing: UM.Theme.getSize("narrow_margin").height
ColumnLayout // Page title.
Item
{ {
id: packageBrowse implicitWidth: parent.width
implicitHeight: childrenRect.height + UM.Theme.getSize("default_margin").height
spacing: UM.Theme.getSize("narrow_margin").height Label
// Page title.
Item
{ {
Layout.preferredWidth: parent.width id: pageTitle
Layout.preferredHeight: childrenRect.height + UM.Theme.getSize("default_margin").height anchors
Label
{ {
id: pageTitle left: parent.left
anchors leftMargin: UM.Theme.getSize("default_margin").width
{ right: parent.right
left: parent.left rightMargin: UM.Theme.getSize("default_margin").width
leftMargin: UM.Theme.getSize("default_margin").width bottom: parent.bottom
right: parent.right
rightMargin: UM.Theme.getSize("default_margin").width
bottom: parent.bottom
}
font: UM.Theme.getFont("large")
color: UM.Theme.getColor("text")
text: content.item ? content.item.pageTitle: catalog.i18nc("@title", "Loading...")
} }
font: UM.Theme.getFont("large")
color: UM.Theme.getColor("text")
text: content.item ? content.item.pageTitle: catalog.i18nc("@title", "Loading...")
} }
}
OnboardBanner OnboardBanner
{
visible: content.item && content.item.bannerVisible
text: content.item && content.item.bannerText
icon: content.item && content.item.bannerIcon
onRemove: content.item && content.item.onRemoveBanner
readMoreUrl: content.item && content.item.bannerReadMoreUrl
Layout.fillWidth: true
Layout.leftMargin: UM.Theme.getSize("default_margin").width
Layout.rightMargin: UM.Theme.getSize("default_margin").width
}
// Search & Top-Level Tabs
Item
{
Layout.preferredHeight: childrenRect.height
Layout.preferredWidth: parent.width - 2 * UM.Theme.getSize("default_margin").width
Layout.alignment: Qt.AlignHCenter
RowLayout
{ {
visible: content.item && content.item.bannerVisible width: parent.width
text: content.item && content.item.bannerText height: UM.Theme.getSize("button_icon").height + UM.Theme.getSize("default_margin").height
icon: content.item && content.item.bannerIcon spacing: UM.Theme.getSize("thin_margin").width
onRemove: content.item && content.item.onRemoveBanner
readMoreUrl: content.item && content.item.bannerReadMoreUrl
Layout.fillWidth: true Cura.SearchBar
Layout.leftMargin: UM.Theme.getSize("default_margin").width
Layout.rightMargin: UM.Theme.getSize("default_margin").width
}
// Search & Top-Level Tabs
Item
{
Layout.preferredHeight: childrenRect.height
Layout.preferredWidth: parent.width - 2 * UM.Theme.getSize("default_margin").width
Layout.alignment: Qt.AlignHCenter
RowLayout
{ {
width: parent.width id: searchBar
height: UM.Theme.getSize("button_icon").height + UM.Theme.getSize("default_margin").height Layout.preferredHeight: UM.Theme.getSize("button_icon").height
spacing: UM.Theme.getSize("thin_margin").width Layout.fillWidth: true
onTextEdited: searchStringChanged(text)
}
Cura.SearchBar // Page selection.
TabBar
{
id: pageSelectionTabBar
Layout.alignment: Qt.AlignRight
height: UM.Theme.getSize("button_icon").height
spacing: 0
background: Rectangle { color: "transparent" }
currentIndex: manager.tabShown
onCurrentIndexChanged:
{ {
id: searchBar manager.tabShown = currentIndex
Layout.preferredHeight: UM.Theme.getSize("button_icon").height searchBar.text = "";
Layout.fillWidth: true searchBar.visible = currentItem.hasSearch;
onTextEdited: searchStringChanged(text) content.source = currentItem.sourcePage;
} }
// Page selection. PackageTypeTab
TabBar
{ {
id: pageSelectionTabBar id: pluginTabText
Layout.alignment: Qt.AlignRight width: implicitWidth
height: UM.Theme.getSize("button_icon").height text: catalog.i18nc("@button", "Plugins")
spacing: 0 property string sourcePage: "Plugins.qml"
background: Rectangle { color: "transparent" } property bool hasSearch: true
currentIndex: manager.tabShown }
PackageTypeTab
{
id: materialsTabText
width: implicitWidth
text: catalog.i18nc("@button", "Materials")
property string sourcePage: "Materials.qml"
property bool hasSearch: true
}
ManagePackagesButton
{
property string sourcePage: "ManagedPackages.qml"
property bool hasSearch: false
onCurrentIndexChanged: Cura.NotificationIcon
{ {
manager.tabShown = currentIndex anchors
searchBar.text = "";
searchBar.visible = currentItem.hasSearch;
content.source = currentItem.sourcePage;
}
PackageTypeTab
{
id: pluginTabText
width: implicitWidth
text: catalog.i18nc("@button", "Plugins")
property string sourcePage: "Plugins.qml"
property bool hasSearch: true
}
PackageTypeTab
{
id: materialsTabText
width: implicitWidth
text: catalog.i18nc("@button", "Materials")
property string sourcePage: "Materials.qml"
property bool hasSearch: true
}
ManagePackagesButton
{
property string sourcePage: "ManagedPackages.qml"
property bool hasSearch: false
Cura.NotificationIcon
{ {
anchors horizontalCenter: parent.right
{ verticalCenter: parent.top
horizontalCenter: parent.right }
verticalCenter: parent.top visible: CuraApplication.getPackageManager().packagesWithUpdate.length > 0
}
visible: CuraApplication.getPackageManager().packagesWithUpdate.length > 0
labelText: labelText:
{ {
const itemCount = CuraApplication.getPackageManager().packagesWithUpdate.length const itemCount = CuraApplication.getPackageManager().packagesWithUpdate.length
return itemCount > 9 ? "9+" : itemCount return itemCount > 9 ? "9+" : itemCount
}
} }
} }
} }
}
TextMetrics TextMetrics
{ {
id: pluginTabTextMetrics id: pluginTabTextMetrics
text: pluginTabText.text text: pluginTabText.text
font: pluginTabText.font font: pluginTabText.font
} }
TextMetrics TextMetrics
{ {
id: materialsTabTextMetrics id: materialsTabTextMetrics
text: materialsTabText.text text: materialsTabText.text
font: materialsTabText.font font: materialsTabText.font
}
} }
} }
}
FontMetrics FontMetrics
{ {
id: fontMetrics id: fontMetrics
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")
} }
Cura.TertiaryButton Cura.TertiaryButton
{ {
text: catalog.i18nc("@info", "Search in the browser") text: catalog.i18nc("@info", "Search in the browser")
iconSource: UM.Theme.getIcon("LinkExternal") iconSource: UM.Theme.getIcon("LinkExternal")
visible: pageSelectionTabBar.currentItem.hasSearch visible: pageSelectionTabBar.currentItem.hasSearch
isIconOnRightSide: true isIconOnRightSide: true
height: fontMetrics.height height: fontMetrics.height
textFont: fontMetrics.font textFont: fontMetrics.font
textColor: UM.Theme.getColor("text") textColor: UM.Theme.getColor("text")
onClicked: content.item && Qt.openUrlExternally(content.item.searchInBrowserUrl) onClicked: content.item && Qt.openUrlExternally(content.item.searchInBrowserUrl)
} }
// Page contents.
Rectangle
{
Layout.preferredWidth: parent.width
Layout.fillHeight: true
color: UM.Theme.getColor("detail_background")
// Page contents. // Page contents.
Rectangle Loader
{ {
Layout.preferredWidth: parent.width id: content
Layout.fillHeight: true anchors.fill: parent
color: UM.Theme.getColor("detail_background") anchors.margins: UM.Theme.getSize("default_margin").width
source: "Plugins.qml"
// Page contents. Connections
Loader
{ {
id: content target: content
anchors.fill: parent function onLoaded()
anchors.margins: UM.Theme.getSize("default_margin").width
source: "Plugins.qml"
Connections
{ {
target: content pageTitle.text = content.item.pageTitle
function onLoaded() searchStringChanged.connect(handleSearchStringChanged)
{ }
pageTitle.text = content.item.pageTitle function handleSearchStringChanged(new_search)
searchStringChanged.connect(handleSearchStringChanged) {
} content.item.model.searchString = new_search
function handleSearchStringChanged(new_search)
{
content.item.model.searchString = new_search
}
} }
} }
} }