~osomon/webbrowser-app/maxCacheSizeHint

« back to all changes in this revision

Viewing changes to src/app/ChromeController.qml

  • Committer: Olivier Tilloy
  • Date: 2015-04-08 15:29:44 UTC
  • mfrom: (930.1.25 webbrowser-app)
  • Revision ID: olivier.tilloy@canonical.com-20150408152944-zg7hpedldixspgf7
Merge the latest changes from trunk and resolve a conflict.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2015 Canonical Ltd.
 
3
 *
 
4
 * This file is part of webbrowser-app.
 
5
 *
 
6
 * webbrowser-app is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; version 3.
 
9
 *
 
10
 * webbrowser-app is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
import QtQuick 2.0
 
20
import com.canonical.Oxide 1.5 as Oxide
 
21
 
 
22
Item {
 
23
    visible: false
 
24
 
 
25
    property var webview
 
26
    property bool forceHide: false
 
27
 
 
28
    readonly property int mode: {
 
29
        if (forceHide || webview.fullscreen) {
 
30
            return Oxide.LocationBarController.ModeHidden
 
31
        } else if (internal.forceShow) {
 
32
            return Oxide.LocationBarController.ModeShown
 
33
        } else {
 
34
            return Oxide.LocationBarController.ModeAuto
 
35
        }
 
36
    }
 
37
 
 
38
    // Work around the lack of a show() method on the location bar controller
 
39
    // (https://launchpad.net/bugs/1422920) by forcing its mode to ModeShown
 
40
    // for long enough (500ms) to allow the animation to be committed.
 
41
    QtObject {
 
42
        id: internal
 
43
        property bool forceShow: false
 
44
    }
 
45
    Timer {
 
46
        id: delayedResetMode
 
47
        interval: 500
 
48
        onTriggered: internal.forceShow = false
 
49
    }
 
50
    Connections {
 
51
        target: webview
 
52
        onFullscreenChanged: {
 
53
            if (!webview.fullscreen) {
 
54
                internal.forceShow = true
 
55
                delayedResetMode.restart()
 
56
            }
 
57
        }
 
58
        onLoadingChanged: {
 
59
            if (webview.loading && !webview.fullscreen) {
 
60
                internal.forceShow = true
 
61
                delayedResetMode.restart()
 
62
            }
 
63
        }
 
64
    }
 
65
}