File: TerminalSettings.qml

package info (click to toggle)
lomiri-terminal-app 2.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,780 kB
  • sloc: javascript: 415; cpp: 361; python: 160; makefile: 15
file content (140 lines) | stat: -rw-r--r-- 6,050 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
 * Copyright (C) 2014 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored-by: Filippo Scognamiglio <flscogna@gmail.com>
 */
import QtQuick 2.4
import Qt.labs.settings 1.0
import Terminal 0.1

import "KeyboardRows/jsonParser.js" as Parser

QtObject {
    property alias fontSize: innerSettings.fontSize
    property alias fontStyle: innerSettings.fontStyle
    property alias colorScheme: innerSettings.colorScheme
    property alias shortcutNewWindow: innerSettings.shortcutNewWindow
    property alias shortcutNewTab: innerSettings.shortcutNewTab
    property alias shortcutCloseTab: innerSettings.shortcutCloseTab
    property alias shortcutCloseAllTabs: innerSettings.shortcutCloseAllTabs
    property alias shortcutPreviousTab: innerSettings.shortcutPreviousTab
    property alias shortcutNextTab: innerSettings.shortcutNextTab
    property alias shortcutPreviousActiveTab: innerSettings.shortcutPreviousActiveTab
    property alias shortcutCopy: innerSettings.shortcutCopy
    property alias shortcutPaste: innerSettings.shortcutPaste
    property alias shortcutFullscreen: innerSettings.shortcutFullscreen
    property alias shortcutSplitHorizontally: innerSettings.shortcutSplitHorizontally
    property alias shortcutSplitVertically: innerSettings.shortcutSplitVertically
    property alias shortcutMoveToTileAbove: innerSettings.shortcutMoveToTileAbove
    property alias shortcutMoveToTileBelow: innerSettings.shortcutMoveToTileBelow
    property alias shortcutMoveToTileLeft: innerSettings.shortcutMoveToTileLeft
    property alias shortcutMoveToTileRight: innerSettings.shortcutMoveToTileRight
    property alias authenticationRequired: innerSettings.authenticationRequired
    property alias shortcutTileResizeDown: innerSettings.shortcutTileResizeDown
    property alias shortcutTileResizeUp: innerSettings.shortcutTileResizeUp
    property alias shortcutTileResizeLeft: innerSettings.shortcutTileResizeLeft
    property alias shortcutTileResizeRight: innerSettings.shortcutTileResizeRight

    readonly property int defaultFontSize: 12
    readonly property int minFontSize: 4
    readonly property int maxFontSize: 50

    property alias jsonVisibleProfiles: innerSettings.jsonVisibleProfiles

    property ListModel profilesList: ListModel {}

    signal profilesChanged();

    onProfilesChanged: saveProfileVisibleStrings();

    function saveProfileVisibleStrings() {
        var result = {};

        for (var i = 0; i < profilesList.count; i++) {
            var profileObject = profilesList.get(i);
            result[profileObject.file] = profileObject.profileVisible;
        }

        jsonVisibleProfiles = JSON.stringify(result);
    }

    property Settings innerSettings: Settings {
        id: innerSettings
        property int fontSize: defaultFontSize
        property string fontStyle: "Noto Mono"
        property string colorScheme: "Ubuntu"
        property string jsonVisibleProfiles: "[]"
        property string shortcutNewWindow: "Ctrl+Shift+N"
        property string shortcutNewTab: "Ctrl+Shift+T"
        property string shortcutCloseTab: "Ctrl+Shift+W"
        property string shortcutCloseAllTabs: "Ctrl+Shift+Q"
        property string shortcutPreviousTab: "Ctrl+PgUp"
        property string shortcutNextTab: "Ctrl+PgDown"
        property string shortcutPreviousActiveTab: "Ctrl+Tab"
        property string shortcutCopy: "Ctrl+Shift+C"
        property string shortcutPaste: "Ctrl+Shift+V"
        property string shortcutFullscreen: "F11"
        property string shortcutSplitHorizontally: "Ctrl+Shift+O"
        property string shortcutSplitVertically: "Ctrl+Shift+E"
        property string shortcutMoveToTileAbove: "Alt+Up"
        property string shortcutMoveToTileBelow: "Alt+Down"
        property string shortcutMoveToTileLeft: "Alt+Left"
        property string shortcutMoveToTileRight: "Alt+Right"
        property bool authenticationRequired: true
        property string shortcutTileResizeDown: "Ctrl+Shift+Down"
        property string shortcutTileResizeUp: "Ctrl+Shift+Up"
        property string shortcutTileResizeLeft: "Ctrl+Shift+Left"
        property string shortcutTileResizeRight: "Ctrl+Shift+Right"
    }

    // Load the keyboard profiles.
    Component.onCompleted: {
        var visibleProfiles = undefined;
        try {
            visibleProfiles = JSON.parse(innerSettings.jsonVisibleProfiles);
        } catch (e) {}

        function isProfileVisible(profilePath) {
            return !(visibleProfiles[profilePath] === false);
        }

        for (var i = 0; i < keyboardLayouts.length; i++) {
            var filePath = keyboardLayouts[i];
            var isVisible = isProfileVisible(filePath);

            try {
                var profileObject = Parser.parseJson(FileIO.read(filePath));

                var name = "";
                if (profileObject.id)
                    name = translator.getTranslatedNameById(translator.name, profileObject.id);
                if (name === "")
                    name = profileObject.name;

                profilesList.append(
                        {
                            file: filePath,
                            profileVisible: isVisible,
                            object: profileObject,
                            name: name
                        });
            } catch (e) {
                console.error("Error in profile", filePath);
                console.error(e);
            }
        }
        profilesChanged();
    }
}