~ci-train-bot/ubuntu-system-settings/ubuntu-system-settings-ubuntu-zesty-2194

« back to all changes in this revision

Viewing changes to plugins/launcher/PageComponent.qml

  • Committer: Bileto Bot
  • Author(s): Jonas G. Drange
  • Date: 2016-11-29 11:11:21 UTC
  • mfrom: (1733.3.12 appearance-launcher)
  • Revision ID: ci-train-bot@canonical.com-20161129111121-oz2yn56nev9ff182
* Packaging change: depend on USC for testing
* Adds Launcher settings panel to System Settings
* Makes USS a gapplication as a requirement for the use of the qtdesktopwidget
* Adds gsetting qml mock

Approved by: Ken VanDine

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of system-settings
 
3
 *
 
4
 * Copyright (C) 2016 Canonical Ltd.
 
5
 *
 
6
 * This program is free software: you can redistribute it and/or modify it
 
7
 * under the terms of the GNU General Public License version 3, as published
 
8
 * by the Free Software Foundation.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful, but
 
11
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
12
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
13
 * PURPOSE.  See the GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License along
 
16
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
import GSettings 1.0
 
20
import QtQuick 2.4
 
21
import SystemSettings 1.0
 
22
import SystemSettings.ListItems 1.0 as SettingsListItems
 
23
import Ubuntu.Components 1.3
 
24
import Ubuntu.Settings.Components 0.1 as USC
 
25
import Ubuntu.Settings.Menus 0.1 as Menus
 
26
import Ubuntu.SystemSettings.Launcher 1.0
 
27
 
 
28
ItemPage {
 
29
    id: root
 
30
    objectName: "launcherPage"
 
31
    title: i18n.tr("Launcher")
 
32
 
 
33
    /* The introductory label “On large displays:” should be present if the
 
34
    current display does not fall into <the large screen> category (to explain
 
35
    why the settings aren’t applying to the display that you’re looking at). */
 
36
    property bool largeScreenAvailable: {
 
37
        var currentScreen = LauncherPanelPlugin.getCurrentScreenNumber();
 
38
        for (var i=0; i < LauncherPanelPlugin.screens; i++) {
 
39
            if (LauncherPanelPlugin.screenGeometry(i).width > units.gu(90)) {
 
40
                if (currentScreen === i) {
 
41
                    return false;
 
42
                }
 
43
            }
 
44
        }
 
45
        return true; // No large screens were the current one.
 
46
    }
 
47
 
 
48
    Flickable {
 
49
        id: flick
 
50
        anchors.fill: parent
 
51
        contentWidth: parent.width
 
52
        contentHeight: contentItem.childrenRect.height
 
53
        boundsBehavior: (contentHeight > root.height) ?
 
54
            Flickable.DragAndOvershootBounds : Flickable.StopAtBounds
 
55
 
 
56
        Column {
 
57
            anchors {
 
58
                left: parent.left
 
59
                right: parent.right
 
60
            }
 
61
            spacing: units.gu(1)
 
62
 
 
63
            SettingsItemTitle {
 
64
                text: i18n.tr("On large screens:")
 
65
                objectName: "largeScreenLabel"
 
66
                visible: largeScreenAvailable
 
67
            }
 
68
 
 
69
            SettingsListItems.Standard {
 
70
                id: alwaysShowLauncher
 
71
                objectName: "alwaysShowLauncher"
 
72
                text: i18n.tr("Always show the launcher")
 
73
                layout.subtitle.text: i18n.tr("Videos and full-screen games may hide it temporarily.")
 
74
 
 
75
                Switch {
 
76
                    id: alwaysShowLauncherSwitch
 
77
                    objectName: "alwaysShowLauncherSwitch"
 
78
                    checked: !unity8Settings.autohideLauncher
 
79
                    onTriggered: unity8Settings.autohideLauncher = !checked
 
80
                }
 
81
            }
 
82
 
 
83
            Menus.SliderMenu {
 
84
                text: i18n.tr("Icon size:")
 
85
 
 
86
                id: iconWidth
 
87
                objectName: "iconWidth"
 
88
                function formatValue(v) { return v.toFixed(2) }
 
89
                minimumValue: 6
 
90
                maximumValue: 12
 
91
                value: unity8Settings.launcherWidth
 
92
                live: true
 
93
 
 
94
                property real serverValue: unity8Settings.launcherWidth
 
95
                USC.ServerPropertySynchroniser {
 
96
                    userTarget: iconWidth
 
97
                    userProperty: "value"
 
98
                    serverTarget: iconWidth
 
99
                    serverProperty: "serverValue"
 
100
                    maximumWaitBufferInterval: 16
 
101
 
 
102
                    onSyncTriggered: unity8Settings.launcherWidth = value
 
103
                }
 
104
            }
 
105
        }
 
106
    }
 
107
 
 
108
    GSettings {
 
109
        id: unity8Settings
 
110
        objectName: "unity8Settings"
 
111
        schema.id: "com.canonical.Unity8"
 
112
    }
 
113
}