@@ -4,6 +4,7 @@ import Sailfish.Silica 1.0
4
4
import Sailfish.Pickers 1.0
5
5
import Sailfish.WebView 1.0
6
6
import Sailfish.WebEngine 1.0
7
+ import Nemo.Configuration 1.0
7
8
8
9
import '../generic/utils.js' as QmlJs
9
10
import '../components' as PlatformComponents
@@ -31,20 +32,43 @@ WebViewPage {
31
32
width: page .width
32
33
}
33
34
35
+ Component .onCompleted : {
36
+ pageStack .busyChanged .connect (function () {
37
+ if (! hasOpenedFile) {
38
+ return
39
+ }
40
+
41
+ if (! pageStack .busy ) {
42
+ page .isMenuEnabled = false
43
+ }
44
+ })
45
+ }
46
+
47
+ ConfigurationValue {
48
+ id: configToolbarVisibility
49
+ key: " /apps/harbour-seabass/settings/is_toolbar_visible"
50
+ defaultValue: false
51
+ }
52
+
53
+ ConfigurationValue {
54
+ id: configFontSize
55
+ key: " /apps/harbour-seabass/settings/font_size"
56
+ defaultValue: 12
57
+ }
58
+
59
+ ConfigurationValue {
60
+ id: configUseWrapMode
61
+ key: " /apps/harbour-seabass/settings/soft_wrap_enabled"
62
+ defaultValue: true
63
+ }
64
+
34
65
GenericComponents .EditorState {
35
66
id: editorState
36
67
isDarkTheme: Theme .colorScheme === Theme .LightOnDark
68
+ directory: api .homeDir
69
+ fontSize: configFontSize .value
70
+ useWrapMode: configUseWrapMode .value
37
71
verticalHtmlOffset: headerHeight / WebEngineSettings .pixelRatio
38
-
39
- onFilePathChanged: {
40
- isMenuEnabled = false
41
- }
42
-
43
- onDirectoryChanged: {
44
- api .postMessage (' setSailfishPreferences' , {
45
- directory: directory
46
- })
47
- }
48
72
}
49
73
50
74
GenericComponents .EditorApi {
@@ -57,9 +81,6 @@ WebViewPage {
57
81
58
82
// API methods
59
83
onAppLoaded : function (data ) {
60
- toolbar .open = data .isToolbarOpened || false
61
- // use `data.directory || api.homeDir` to restore last opened directory when opening app
62
- editorState .directory = api .homeDir
63
84
editorState .loadTheme ()
64
85
editorState .updateViewport ()
65
86
}
@@ -87,7 +108,7 @@ WebViewPage {
87
108
page: page
88
109
title: hasOpenedFile
89
110
? ((editorState .hasChanges ? ' *' : ' ' ) + QmlJs .getFileName (filePath))
90
- : qsTr (' Seabass v%1' ).arg (' 0.10 .0' )
111
+ : qsTr (' Seabass v%1' ).arg (' 0.11 .0' )
91
112
description: hasOpenedFile
92
113
? QmlJs .getPrintableDirPath (QmlJs .getDirPath (filePath), api .homeDir )
93
114
: qsTr (' Release notes' )
@@ -169,6 +190,12 @@ WebViewPage {
169
190
toolbar .open = ! toolbar .open
170
191
}
171
192
}
193
+ MenuItem {
194
+ text: qsTr (' Settings' )
195
+ onClicked: {
196
+ pageStack .push (settings)
197
+ }
198
+ }
172
199
MenuItem {
173
200
text: qsTr (' About' )
174
201
onClicked: {
@@ -183,7 +210,7 @@ WebViewPage {
183
210
width: parent .width
184
211
height: Theme .itemSizeMedium
185
212
focus: false
186
- open: false
213
+ open: configToolbarVisibility . value
187
214
background: Rectangle {
188
215
// default background doesn't look good when virtual keyboard is opened
189
216
// hence the workaround with Rectangle
@@ -193,9 +220,7 @@ WebViewPage {
193
220
}
194
221
195
222
onOpenChanged: {
196
- api .postMessage (' setSailfishPreferences' , {
197
- isToolbarOpened: open
198
- })
223
+ configToolbarVisibility .value = open
199
224
}
200
225
201
226
PlatformComponents .Toolbar {
@@ -290,6 +315,21 @@ WebViewPage {
290
315
}
291
316
}
292
317
318
+ Component {
319
+ id: settings
320
+ Settings {
321
+ fontSize: configFontSize .value
322
+ useWrapMode: configUseWrapMode .value
323
+
324
+ onFontSizeChanged: {
325
+ configFontSize .value = fontSize
326
+ }
327
+ onUseWrapModeChanged: {
328
+ configUseWrapMode .value = useWrapMode
329
+ }
330
+ }
331
+ }
332
+
293
333
/**
294
334
* Displays error message
295
335
* @param {string} [errorMessage] - error message to display
0 commit comments