[weather] Treat Details & Notices views the same WRT content & visibility

parent 0c87abc2
......@@ -55,7 +55,15 @@ Item {
horizontalCenter: parent.horizontalCenter
}
visible: detailsView.model.length > 0
visible: detailsView.hasContent || noticesView.hasContent
function fallBackToFiveDaysIfInvisble(tabButton) {
// PlasmaComponents.TabBar does not handle this (yet), so let's do it ourselves
if (!tabButton.visible && (currentTab == tabButton)) {
currentTab = fiveDaysTabButton;
mainTabGroup.currentTab = fiveDaysTabButton.tab;
}
}
PlasmaComponents.TabButton {
id: fiveDaysTabButton
......@@ -64,8 +72,14 @@ Item {
tab: fiveDaysView
}
PlasmaComponents.TabButton {
id: detailsTabButton
text: i18n("Details")
visible: detailsView.hasContent
tab: detailsView
onVisibleChanged: {
tabBar.fallBackToFiveDaysIfInvisble(detailsTabButton);
}
}
PlasmaComponents.TabButton {
id: noticesTabButton
......@@ -74,11 +88,7 @@ Item {
visible: noticesView.hasContent
tab: noticesView
onVisibleChanged: {
// PlasmaComponents.TabBar does not handle this, so let's do it ourselves
if (!visible && (tabBar.currentTab == noticesTabButton)) {
tabBar.currentTab = fiveDaysTabButton;
mainTabGroup.currentTab = fiveDaysTabButton.tab;
}
tabBar.fallBackToFiveDaysIfInvisble(noticesTabButton);
}
}
}
......
......@@ -26,6 +26,8 @@ Column {
// ensure text fits in rectangle, relies on delegates only using labels with theme.defaultFont
property int rowHeight: theme.mSize(theme.defaultFont).height
readonly property bool hasContent: model && model.length > 0
spacing: (root.height - (repeater.count*rowHeight)) / (repeater.count-1)
Repeater {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment