~tpeeters/ubuntu-ui-toolkit/tabBar-pressed

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/MainView.qml

  • Committer: Tarmac
  • Author(s): tpeeters
  • Date: 2013-11-27 11:19:11 UTC
  • mfrom: (861.1.5 hide-bars-mainview)
  • Revision ID: tarmac-20131127111911-nkuev3lk49qsti34
Detect interaction with contents (in order to close toolbar/tabbar) from Page to MainView.

Approved by PS Jenkins bot, Tim Peeters, Christian Dywan.

Show diffs side-by-side

added added

removed removed

Lines of Context:
270
270
                    topMargin: -parent.y
271
271
                }
272
272
            }
 
273
 
 
274
            MouseArea {
 
275
                id: contentsArea
 
276
                anchors.fill: contents
 
277
                // This mouse area will be on top of the page contents, but
 
278
                // under the toolbar and header.
 
279
                // It is used for detecting interaction with the page contents
 
280
                // which can close the toolbar and take a tab bar out of selection mode.
 
281
 
 
282
                onPressed: {
 
283
                    mouse.accepted = false;
 
284
                    if (!toolbarItem.locked) {
 
285
                        toolbarItem.close();
 
286
                        }
 
287
                    if (headerItem.tabBar && !headerItem.tabBar.alwaysSelectionMode) {
 
288
                        headerItem.tabBar.selectionMode = false;
 
289
                    }
 
290
                }
 
291
                propagateComposedEvents: true
 
292
            }
273
293
        }
274
294
 
275
295
        Toolbar {
287
307
            objectName: "MainView_Header"
288
308
            id: headerItem
289
309
            property real bottomY: headerItem.y + headerItem.height
 
310
 
 
311
            property Item tabBar: null
 
312
            Binding {
 
313
                target: headerItem
 
314
                property: "tabBar"
 
315
                value: headerItem.contents
 
316
                when: headerItem.contents &&
 
317
                      headerItem.contents.hasOwnProperty("selectionMode") &&
 
318
                      headerItem.contents.hasOwnProperty("alwaysSelectionMode") &&
 
319
                      headerItem.contents.hasOwnProperty("selectedIndex")
 
320
            }
290
321
        }
291
322
    }
292
323