1 /****************************************************************************
3 ** Copyright (C) 2012 Takumi Asaki
4 ** All rights reserved.
5 ** Contact: Takumi Asaki (takumi.asaki@gmail.com)
7 ** This file is part of the fontmanager application.
9 ** You may use this file under the terms of the BSD license as follows:
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
14 ** * Redistributions of source code must retain the above copyright
15 ** notice, this list of conditions and the following disclaimer.
16 ** * Redistributions in binary form must reproduce the above copyright
17 ** notice, this list of conditions and the following disclaimer in
18 ** the documentation and/or other materials provided with the
20 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
21 ** the names of its contributors may be used to endorse or promote
22 ** products derived from this software without specific prior written
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
37 ****************************************************************************/
40 import com.nokia.meego 1.0
41 import com.nokia.extras 1.0
42 import 'UIConstants.js' as UI
44 import "HelpDialog.js" as HelpHelper
50 property bool disableTools: false
52 property bool showHelp: false
53 property string helpMessage: qsTr(
54 "<h1>How to use</h1>" +
57 "<p><img src=\"image://theme/icon-m-toolbar-add\">: Install font. Please copy font file(s) to this device in advance. Currently *.ttf and *.ttc are supported.</p>" +
58 "<p><img src=\"image://theme/icon-m-toolbar-settings\">: Configure fonts(expert). You can assign/unassign any fonts to Serif/Sans Serif/Monospace/System.</p>" +
60 "<h2>Menu(<img src=\"image://theme/icon-m-toolbar-view-menu\">)</h2>" +
61 "<p><b>Create Recommended Settings</b>: Create recommended settings. <i>Normal</i> priority is given to user installed font(s). System fonts have <i>Higher</i> priority. System CJK fonts conflicts your installed fonts have <i>Lower</i> priority.</p>" +
62 "<p><b>Backup Config</b>: Save current fonts config into ~/MyDocs/Documents</p>" +
63 "<p><b>Restore Config</b>: Restore fonts config from backuped file</p>"
68 onClearInstalledFontList: {
69 installedFontList.clear()
71 onAppendInstalledFont: {
72 installedFontList.append({ "title": family, "subtitle": fullname })
82 anchors.top: parent.top
83 anchors.left: parent.left
84 anchors.right: parent.right
85 enabled: !disableTools
86 text: qsTr("Installed Fonts")
91 anchors.top: pageHeader.bottom
92 anchors.bottom: parent.bottom
93 anchors.left: parent.left
94 anchors.right: parent.right
95 anchors.margins: UI.DEFAULT_MARGIN / 2
99 id: installedFontListView
101 enabled: !disableTools
102 opacity: enabled ? 1.0 : 0.5
104 model: installedFontList
106 delegate: ListDelegate {
108 if (mainMenu.status !== DialogStatus.Closed)
110 var component = Qt.createComponent("InstalledFontInfoPage.qml")
111 if (component.status === Component.Error)
112 console.log("Error: " + component.errorString())
113 pageStack.push(component, { "fontInfo": controller.fontInfo(title, subtitle) } );
123 contentHeight: helpText.paintedHeight
126 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
129 font.pixelSize: UI.FONT_DEFAULT
131 horizontalAlignment: Text.AlignLeft
137 flickableItem: installedFontListView
145 anchors.centerIn: parent
146 platformStyle: BusyIndicatorStyle { size: "large" }
147 running: mainPage.state == "busy"
154 enabled: !disableTools
155 opacity: enabled ? 1.0 : 0.5
157 platformIconId: "toolbar-add"
159 if (mainMenu.status !== DialogStatus.Closed)
161 pageStack.push(fontSelectionPage)
165 platformIconId: "toolbar-settings"
167 if (mainMenu.status !== DialogStatus.Closed)
169 var component = Qt.createComponent("EditFontsConfPage.qml")
170 if (component.status === Component.Error)
171 console.log("Error: " + component.errorString())
172 pageStack.push(component)
176 platformIconId: "toolbar-view-menu"
177 anchors.right: (parent === undefined) ? undefined : parent.right
179 if (mainMenu.status === DialogStatus.Closed)
189 visualParent: pageStack
192 id: createRecommendedSettingsItem
193 text: qsTr("Create Recommended Settings");
195 if (mainMenu.status !== DialogStatus.Closed)
197 // if (controller.installedFonts.length > 0) {
198 // console.log("Installed Fonts:" + controller.installedFonts)
200 if (controller.localFontsConfExists)
201 openCreateConfirmDialog()
203 createRecommendedSettings()
208 text: qsTr("Backup Config")
209 onClicked: backupConfig()
210 enabled: !controller.isEmptyFontsConf
213 id: restoreConfigItem
214 text: qsTr("Restore Config")
216 var component = Qt.createComponent("RestoreFontsConfPage.qml")
217 if (component.status === Component.Error)
218 console.log("Error: " + component.errorString())
219 pageStack.push(component)
224 onClicked: openAboutDialog()
230 HelpHelper.openHelpDialog(mainPage, contents, helpMessage, closeHelp)
236 function openCreateConfirmDialog()
238 queryDialog.titleText = qsTr("Replace it?")
239 queryDialog.message = qsTr("Existing %1 will be replaced by recommended settings. Are you sure?").arg(controller.localFontsConfPath)
240 queryDialog.acceptButtonText = qsTr("OK")
241 queryDialog.rejectButtonText = qsTr("Cancel")
242 queryDialog.accepted.connect(createRecommendedSettings)
246 function createRecommendedSettings()
248 queryDialog.accepted.disconnect(createRecommendedSettings)
249 controller.createRecommendedSettings()
252 function openAboutDialog()
254 queryDialog.titleText = qsTr("Font Manager for N9")
255 queryDialog.message = qsTr("Version: %1\nAuthor: Takumi Asaki <takumi.asaki@gmail.com>\n\nApplication Icon is created by hirao").arg(controller.version)
256 queryDialog.acceptButtonText = qsTr("Close")
257 queryDialog.rejectButtonText = ""
266 function backupConfig()
268 var filepath = controller.defaultBackupFilename()
269 controller.backupConfig(filepath)
275 when: (installedFontListView.count == 0) && !controller.working && !showHelp
277 target: createRecommendedSettingsItem
281 // target: installedFontListView
289 target: scrollDecorator
290 flickableItem: helpView
294 text: qsTr("No Fonts Installed")
299 when: controller.working && !showHelp