~aacid/unity8/drag_with_quicklist

« back to all changes in this revision

Viewing changes to plugins/Utils/EdgeBarrierSettings.qml

  • Committer: CI Train Bot
  • Author(s): Daniel d'Andrada
  • Date: 2015-11-26 13:50:39 UTC
  • mfrom: (2056.1.4 mouseEdgePush)
  • Revision ID: ci-train-bot@canonical.com-20151126135039-y1bj8jp4mycez05f
Mouse has to push against edges to show launcher or apps spread

edge-barrier-sensitivity is the property that should show up in the System Settings GUI.

edge-barrier-min-push and edge-barrier-max-push are exposed in GSettings merely as a convenience so you can tweak those values without having to restart unity8. But they should NOT show up in system settings. Fixes: #1510969
Approved by: Michael Zanetti

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2015 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
pragma Singleton
 
18
import QtQuick 2.4
 
19
import GSettings 1.0
 
20
 
 
21
QtObject {
 
22
    id: root
 
23
 
 
24
    // The only public property
 
25
    readonly property real pushThreshold:
 
26
            d.minPushThreshold + ((d.maxPushThreshold - d.minPushThreshold) * (1.0 - d.sensitivity))
 
27
 
 
28
    onPushThresholdChanged: {
 
29
        // Avoid calling d.printSettings() directly as it would spam the console during initialization
 
30
        d.printSettingsTimer.start();
 
31
    }
 
32
 
 
33
    property QtObject priv: QtObject {
 
34
        id: d
 
35
 
 
36
        property Timer printSettingsTimer: Timer {
 
37
            interval: 1
 
38
            onTriggered: printSettings();
 
39
        }
 
40
        function printSettings() {
 
41
            console.log("EdgeBarrierSettings: min="+(minPushThreshold/units.gu(1))+"gu("+minPushThreshold+"px)"
 
42
            +", max="+(maxPushThreshold/units.gu(1))+"gu("+maxPushThreshold+"px)"
 
43
            +", sensitivity="+sensitivity
 
44
            +", threshold="+(pushThreshold/units.gu(1))+"gu("+pushThreshold+"px)"
 
45
            );
 
46
        }
 
47
 
 
48
        property real defaultMinPushThreshold: units.gu(2)
 
49
        property real minPushThreshold: gsettings.edgeBarrierMinPush ? units.gu(gsettings.edgeBarrierMinPush) : defaultMinPushThreshold
 
50
        property real maxPushThreshold: {
 
51
            if (gsettings.edgeBarrierMaxPush && units.gu(gsettings.edgeBarrierMaxPush) > minPushThreshold) {
 
52
                return units.gu(gsettings.edgeBarrierMaxPush);
 
53
            } else if (minPushThreshold == defaultMinPushThreshold) {
 
54
                return units.gu(60);
 
55
            } else {
 
56
                return minPushThreshold * 10.0;
 
57
            }
 
58
        }
 
59
        // Value range is [0.0, 1.0]
 
60
        readonly property real sensitivity: gsettings.edgeBarrierSensitivity
 
61
            ? Math.min(Math.max(0, gsettings.edgeBarrierSensitivity), 100) / 100
 
62
            : 0.35
 
63
 
 
64
        property var gsettings: GSettings { schema.id: "com.canonical.Unity8" }
 
65
    }
 
66
}