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 ****************************************************************************/
39 // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
41 import com.nokia.meego 1.0
42 import 'UIConstants.js' as UI
48 property variant fontInfo
52 function installFont(checked)
54 if (!checked && controller.fontExists(fontInfo))
55 openOverwriteFontDialog()
57 controller.installFont(fontInfo);
60 Component.onDestruction: {
68 anchors.top: parent.top
69 anchors.left: parent.left
70 anchors.right: parent.right
71 text: qsTr("Install Font")
76 anchors.top: pageHeader.bottom
77 anchors.bottom: parent.bottom
78 anchors.left: parent.left
79 anchors.right: parent.right
83 anchors.top: parent.top
84 anchors.left: parent.left
85 anchors.right: parent.right
86 anchors.bottom: bottomField.top
87 anchors.topMargin: UI.DEFAULT_MARGIN / 2
88 anchors.bottomMargin: UI.DEFAULT_MARGIN / 2
89 anchors.leftMargin: UI.DEFAULT_MARGIN / 2
90 anchors.rightMargin: UI.DEFAULT_MARGIN / 2
94 contentHeight: contentColumn.height
99 spacing: UI.DEFAULT_MARGIN
103 model: fontInfo.families
107 height: itemColumn.height + UI.DEFAULT_MARGIN * 2
109 width: parent.width - 1
110 height: parent.height - 1
115 anchors.top: parent.top
116 anchors.left: parent.left
117 anchors.right: parent.right
118 // width: parent.width
119 anchors.margins: UI.DEFAULT_MARGIN
120 spacing: UI.DEFAULT_MARGIN
123 text: qsTr("<b>Font Family</b>: %1").arg(modelData)
127 text: qsTr("<b>Example</b>: ")
130 width: parent.width - UI.DEFAULT_MARGIN * 2
132 text: qsTr("The quick brown fox jumps over the lazy dog")
133 font.family: modelData
135 FontsConfProperties {
138 fontconf: fontInfo.fontProperty(modelData)
140 target: fontInstallPage
161 anchors.bottom: parent.bottom
162 anchors.left: parent.left
163 anchors.right: parent.right
164 height: installButton.height + UI.DEFAULT_MARGIN * 2
170 GradientStop { position: 0.0; color: Qt.lighter("#76221d") }
171 GradientStop { position: 1.0; color: Qt.lighter("#bd543d") }
177 anchors.centerIn: parent
178 text: qsTr("Install")
181 if (!controller.fontDirExists)
182 openCreateFontDirDialog()
191 function openCreateFontDirDialog()
193 queryDialog.titleText = qsTr("Create it?")
194 queryDialog.message = qsTr("Local fonts directory '%1' does not exists! Create it now?").arg(controller.fontDir)
195 queryDialog.acceptButtonText = qsTr("OK")
196 queryDialog.rejectButtonText = qsTr("Cancel")
197 queryDialog.accepted.connect(createFontDir)
201 function createFontDir()
203 queryDialog.accepted.disconnect(createFontDir)
204 controller.createFontDir()
208 function openOverwriteFontDialog()
210 queryDialog.titleText = qsTr("Overwrite it?")
211 queryDialog.message = qsTr("Local font '%1' already exists! Overwrite it?").arg(fontInfo.fileName)
212 queryDialog.acceptButtonText = qsTr("OK")
213 queryDialog.rejectButtonText = qsTr("Cancel")
214 queryDialog.accepted.connect(overwriteFont)
218 function overwriteFont()
220 queryDialog.accepted.disconnect(overwriteFont)
227 platformIconId: "toolbar-back"
228 onClicked: pageStack.pop()