~jpakkane/ubuntu-ui-toolkit/albumart

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/Themes/Ambiance/TabBarStyle.qml

  • Committer: CI bot
  • Author(s): tpeeters
  • Date: 2014-03-01 12:52:42 UTC
  • mfrom: (947.5.3 fixTabTests)
  • Revision ID: ps-jenkins@lists.canonical.com-20140301125242-97ffy36cfv49qosv
Fix autopilot and unit tests for TabBar. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
        target: styledItem
69
69
 
70
70
        onSelectionModeChanged: {
71
 
            if (styledItem.selectionMode) {
72
 
                activatingTimer.restart();
73
 
            } else {
 
71
            if (!styledItem.selectionMode) {
74
72
                buttonView.selectButton(styledItem.selectedIndex);
75
73
            }
76
74
        }
77
75
    }
78
76
 
79
 
    /*!
80
 
      \internal
81
 
      Avoid interpreting a click to enter selection mode as a button click.
82
 
     */
83
 
    Timer {
84
 
        id: activatingTimer
85
 
        interval: 800 // same as pressAndHold time
86
 
    }
87
 
 
88
77
    Connections {
89
78
        target: styledItem
90
79
        onSelectedIndexChanged: buttonView.selectButton(styledItem.selectedIndex)
91
80
    }
92
81
 
 
82
    /*
 
83
      Prevent events that are not accepted by tab buttons or mouseArea below
 
84
      from passing through the TabBar.
 
85
     */
 
86
    MouseArea {
 
87
        anchors.fill: parent
 
88
        onReleased: {
 
89
            mouseArea.enteringSelectionMode = false;
 
90
        }
 
91
    }
 
92
 
93
93
    Component {
94
94
        id: tabButtonRow
95
95
        Row {
207
207
                    }
208
208
 
209
209
                    onClicked: {
210
 
                        if (!activatingTimer.running) {
 
210
                        if (mouseArea.enteringSelectionMode) {
 
211
                            mouseArea.enteringSelectionMode = false;
 
212
                        } else if (opacity > 0.0) {
211
213
                            styledItem.selectedIndex = index;
212
214
                            if (!styledItem.alwaysSelectionMode) {
213
215
                                styledItem.selectionMode = false;
214
216
                            }
215
217
                            button.select();
216
 
                        } else {
217
 
                            activatingTimer.stop();
218
218
                        }
219
219
                    }
220
220
 
320
320
        onDragEnded: {
321
321
            // unset interacting which was set in mouseArea.onPressed
322
322
            mouseArea.interacting = false;
 
323
            mouseArea.enteringSelectionMode = false;
323
324
        }
324
325
 
325
326
        Timer {
362
363
        property bool interacting: false
363
364
        onInteractingChanged: idleTimer.conditionalRestartOrStop()
364
365
 
 
366
        // When pressing to enter selection mode, a release should not be interpreted
 
367
        //  as a click on a button to select a new tab.
 
368
        property bool enteringSelectionMode: false
 
369
 
365
370
        // This MouseArea is always enabled, even when the tab bar is in selection mode,
366
371
        //  so that press events are detected and tabBarStyle.pressed is updated.
367
372
        onPressed: {
368
373
            mouseArea.interacting = true;
 
374
            if (!styledItem.selectionMode) {
 
375
                mouseArea.enteringSelectionMode = true;
 
376
            }
369
377
            styledItem.selectionMode = true;
370
378
            mouse.accepted = false;
371
379
        }