~larryprice/acolyterm/release-0.1

« back to all changes in this revision

Viewing changes to src/app/qml/ubuntu-terminal-app.qml

  • Committer: Larry Price
  • Date: 2016-06-16 20:27:27 UTC
  • Revision ID: larry.price@canonical.com-20160616202727-qlucqgtow0bulut9
updating name in most instances (notably not autopilot tests)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright: 2016 Canonical, Ltd
3
 
 *
4
 
 * This file is part of acolyterm
5
 
 *
6
 
 * ubuntu-terminal-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, either version 3 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * ubuntu-terminal-app is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
 *
19
 
 */
20
 
 
21
 
import QtQuick 2.4
22
 
import QtGraphicalEffects 1.0
23
 
import Ubuntu.Components 1.3
24
 
import "KeyboardRows"
25
 
 
26
 
import QMLTermWidget 1.0
27
 
 
28
 
// Mouse/Touchpad and keyboard support
29
 
import QtSystemInfo 5.5
30
 
 
31
 
MainView {
32
 
    // objectName for functional testing purposes (autopilot-qt5)
33
 
    id: mview
34
 
    objectName: "terminal"
35
 
    applicationName: "com.ubuntu.terminal"
36
 
    automaticOrientation: true
37
 
 
38
 
    AuthenticationService {
39
 
        id: authService
40
 
        onDenied: Qt.quit();
41
 
    }
42
 
 
43
 
    TerminalSettings {
44
 
        id: settings
45
 
    }
46
 
 
47
 
    TerminalComponent {
48
 
        id: terminalComponent
49
 
    }
50
 
 
51
 
    TabsModel {
52
 
        id: tabsModel
53
 
        Component.onCompleted: addTab();
54
 
    }
55
 
 
56
 
    JsonTranslator {
57
 
        id: translator
58
 
    }
59
 
 
60
 
    PageStack {
61
 
        id: pageStack
62
 
        Component.onCompleted: push(terminalPage)
63
 
 
64
 
        property bool prevKeyboardVisible: false
65
 
 
66
 
        onCurrentPageChanged: {
67
 
            if(currentPage == terminalPage) {
68
 
                // Restore previous keyboard state.
69
 
                if (prevKeyboardVisible) {
70
 
                    Qt.inputMethod.show();
71
 
                } else {
72
 
                    Qt.inputMethod.hide();
73
 
                }
74
 
 
75
 
                // Force the focus on the widget when the terminal shown.
76
 
                if (terminalPage.terminal) {
77
 
                    terminalPage.terminal.forceActiveFocus();
78
 
                }
79
 
            } else {
80
 
                // Force the focus out of the terminal widget.
81
 
                currentPage.forceActiveFocus();
82
 
                prevKeyboardVisible = Qt.inputMethod.visible;
83
 
                Qt.inputMethod.hide();
84
 
            }
85
 
        }
86
 
 
87
 
        TerminalPage {
88
 
            id: terminalPage
89
 
 
90
 
            // TODO: decide between the expandable button or the two buttons.
91
 
//            ExpandableButton {
92
 
//                size: units.gu(6)
93
 
//                anchors {right: parent.right; top: parent.top; margins: units.gu(1);}
94
 
//                rotation: 1
95
 
//                childComponent: Component {
96
 
//                    Rectangle {
97
 
//                        color: "#99000000" // Transparent black
98
 
//                        radius: width * 0.5
99
 
//                        border.color: UbuntuColors.orange;
100
 
//                        border.width: units.dp(3)
101
 
//                    }
102
 
//                }
103
 
 
104
 
//                Icon {
105
 
//                    width: units.gu(3)
106
 
//                    height: width
107
 
//                    anchors.centerIn: parent
108
 
//                    name: "settings"
109
 
//                    color: "Grey"
110
 
//                }
111
 
 
112
 
//                actions: [
113
 
//                    Action {
114
 
//                        iconName: "settings"
115
 
//                        onTriggered: pageStack.push(settingsPage)
116
 
//                    },
117
 
//                    Action {
118
 
//                        iconName: "browser-tabs"
119
 
//                        onTriggered: pageStack.push(tabsPage)
120
 
//                    }
121
 
//                ]
122
 
//            }
123
 
        }
124
 
 
125
 
        TabsPage {
126
 
            id: tabsPage
127
 
            visible: false
128
 
        }
129
 
 
130
 
        SettingsPage {
131
 
            id: settingsPage
132
 
            visible: false
133
 
        }
134
 
 
135
 
        LayoutsPage {
136
 
            id: layoutsPage
137
 
            visible: false
138
 
        }
139
 
 
140
 
        ColorSchemePage {
141
 
            id: colorSchemePage
142
 
            visible: false
143
 
 
144
 
            // TODO This is a workaround at the moment.
145
 
            // The application should get them from the c++.
146
 
            model: ["GreenOnBlack","WhiteOnBlack","BlackOnWhite","BlackOnRandomLight","Linux","cool-retro-term","DarkPastels","BlackOnLightYellow", "Ubuntu"]
147
 
 
148
 
            // TRANSLATORS: This is the name of a terminal color scheme which is displayed in the settings
149
 
            namesModel: [i18n.tr("Green on black"),i18n.tr("White on black"),i18n.tr("Black on white"),i18n.tr("Black on random light"),i18n.tr("Linux"),i18n.tr("Cool retro term"),i18n.tr("Dark pastels / Ubuntu (old)"),i18n.tr("Black on light yellow"),i18n.tr("Ubuntu")]
150
 
        }
151
 
    }
152
 
 
153
 
    Component.onCompleted: {
154
 
        tabsModel.selectTab(0);
155
 
 
156
 
        // The margins for the terminal canvas are 2px
157
 
        // Hardcoded value from TerminalDisplay.h
158
 
        width = 80 * terminalPage.terminal.fontMetrics.width + 2
159
 
        height = 24 * terminalPage.terminal.fontMetrics.height + 2
160
 
    }
161
 
 
162
 
    InputDeviceManager {
163
 
        id: keyboardsModel
164
 
        filter: InputInfo.Keyboard
165
 
    }
166
 
 
167
 
    InputDeviceManager {
168
 
        id: miceModel
169
 
        filter: InputInfo.Mouse
170
 
    }
171
 
 
172
 
    InputDeviceManager {
173
 
        id: touchpadsModel
174
 
        filter: InputInfo.TouchPad
175
 
    }
176
 
 
177
 
    // WORKAROUND: Not yet implemented in the SDK
178
 
    Binding {
179
 
        target: QuickUtils
180
 
        property: "mouseAttached"
181
 
        value: miceModel.count > 0 || touchpadsModel.count > 0
182
 
    }
183
 
 
184
 
    // WORKAROUND: Not yet implemented in the SDK
185
 
    Binding {
186
 
        target: QuickUtils
187
 
        property: "keyboardAttached"
188
 
        value: keyboardsModel.count > 0
189
 
    }
190
 
}