Cannot hide individual tabs

Bug #1190972 reported by David Planella
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Ubuntu UI Toolkit
Won't Fix
Medium
Unassigned

Bug Description

It seems setting the 'visible' property on an individual tab does not work: the tab and its contents are not hidden as expected:

MainView {
    Tabs {
        Tab {
            title: "tab 1"
            page: Text {
                text: "This is the first tab."
            }
        Tab {
            title: "tab 2"
            visible: false // This does not work
            page: Text {
                text: "This tab should not be visible."
            }
        }
}

In my use case, I have a Debug tab I use to display debug messages when running on a device. I wanted to make this tab's visibility dependent on a debugMode variable, but as the 'visible' property on individual tabs is always 'true' regardless of what I set it to, I cannot hide the Debug tab.

Tags: tabs
David Planella (dpm)
summary: - Cannot hide tabs
+ Cannot hide individual tabs
Changed in ubuntu-ui-toolkit:
status: New → Confirmed
importance: Undecided → Medium
Tim Peeters (tpeeters)
tags: added: tabs
Revision history for this message
Michael Spencer (ibelieve) wrote :

Here is a simple hack that I've been using that seems to work well:

Tab {
    property bool show: false //true to show or false to hide
    __isPageTreeNode: !show

    onShowChanged: {
        __isPageTreeNode = show
        parent.updateTabList()
    }
}

Revision history for this message
Michael Spencer (ibelieve) wrote :

Sorry, the method I posted before actually breaks toolbars. Here is a better method that involves generating the list of tabs manually, taking into account the show property:

Tabs {
    id: tabs

    Tab {
        property bool show: // true to show or false to hide
        onShowChanged: {
            parent.tabList = tabs.customUpdateTabList(parent)
        }
    }

    function customUpdateTabList(tabsModel) {
        var list = [];
        for (var i=0; i < tabsModel.children.length; i++) {
            if (isTab(tabsModel.children[i])) list.push(tabsModel.children[i]);
        }
        return list
    }

    function isTab(item) {
        print("Checking tabs")
        if (item && item.hasOwnProperty("__isPageTreeNode")
                && item.__isPageTreeNode && item.hasOwnProperty("title")
                && item.hasOwnProperty("page")
                && (item.hasOwnProperty("show") ? item.show : true)) {
            return true;
        } else {
            return false;
        }
    }
}

Tim Peeters (tpeeters)
Changed in ubuntu-ui-toolkit:
assignee: nobody → Tim Peeters (tpeeters)
Revision history for this message
Tim Peeters (tpeeters) wrote :

dynamic tabs will land soon which can be used for this purpose

Changed in ubuntu-ui-toolkit:
assignee: Tim Peeters (tpeeters) → nobody
Zsombor Egri (zsombi)
Changed in ubuntu-ui-toolkit:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.