~osomon/webbrowser-app/locationBarController

« back to all changes in this revision

Viewing changes to src/app/ChromeController.qml

  • Committer: Olivier Tilloy
  • Date: 2015-03-25 11:21:51 UTC
  • Revision ID: olivier.tilloy@canonical.com-20150325112151-jeudcyu6uyqs0tbm
Factor out duplicated code into the common ChromeController component.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
    property var webview
26
26
    property bool chromeless: false
 
27
    property bool forceHide: false
27
28
 
28
29
    readonly property bool nearBottom: webview ? ((webview.contentY + webview.viewportHeight) / webview.contentHeight) >= 0.98 : false
29
30
 
30
31
    readonly property int mode: {
31
 
        if (chromeless) {
 
32
        if (chromeless || forceHide) {
32
33
            return Oxide.LocationBarController.ModeHidden
33
 
        } else if (webview.loading || forceShow) {
 
34
        } else if (webview.loading || internal.forceShow) {
34
35
            return Oxide.LocationBarController.ModeShown
35
36
        } else if (webview.fullscreen) {
36
37
            return Oxide.LocationBarController.ModeHidden
44
45
    // Work around the lack of a show() method on the location bar controller
45
46
    // (https://launchpad.net/bugs/1422920) by forcing its mode to ModeShown
46
47
    // for long enough (1000ms) to allow the animation to be committed.
47
 
    property bool forceShow: false
 
48
    QtObject {
 
49
        id: internal
 
50
        property bool forceShow: false
 
51
    }
48
52
    Timer {
49
53
        id: delayedResetMode
50
54
        interval: 1000
51
 
        onTriggered: forceShow = false
 
55
        onTriggered: internal.forceShow = false
52
56
    }
53
57
    Connections {
54
58
        target: webview
55
59
        onFullscreenChanged: {
56
60
            if (!webview.fullscreen) {
57
 
                forceShow = true
 
61
                internal.forceShow = true
58
62
                delayedResetMode.restart()
59
63
            }
60
64
        }