--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Takumi Asaki
+** All rights reserved.
+** Contact: Takumi Asaki (takumi.asaki@gmail.com)
+**
+** This file is part of the fontmanager application.
+**
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+****************************************************************************/
+
+// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
+import QtQuick 1.1
+import com.nokia.meego 1.0
+import com.nokia.extras 1.1
+import 'UIConstants.js' as UI
+import 'EditorHelper.js' as Helper
+
+Page {
+ id: editorPage
+
+ property string family
+ property string familyName
+ property variant editorController
+
+ property string curSection
+ property string curSectionName
+
+
+ Label {
+ id: pageHeader
+ anchors.top: parent.top
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.margins: UI.DEFAULT_MARGIN
+
+ horizontalAlignment: Text.AlignHCenter
+ font.pixelSize: UI.FONT_LARGE
+ font.bold: true
+ text: qsTr("Edit Fonts Config: %1").arg(familyName)
+ }
+
+ onEditorControllerChanged: {
+ if (editorController) {
+ modelSyncConnections.createObject(editorPage, {target: editorController})
+ editorController.syncFamilyList()
+ }
+ }
+
+ function addHeader(section, sectionName)
+ {
+ Helper.setIndex(curSection, preferFamilyList.count)
+ curSection = section
+ curSectionName = sectionName
+ preferFamilyList.append({
+ "title": qsTr("Priority: %1").arg(sectionName),
+ "subtitle": "",
+ "systemFont": false,
+ "header": true,
+ "priority": section
+ })
+ Helper.setIndex(curSection, preferFamilyList.count)
+ }
+
+ function insertFamily(family, priority, systemFont)
+ {
+ var index = Helper.index(priority)
+ preferFamilyList.insert(index, {
+ "title": family,
+ "subtitle": (systemFont ? qsTr("System Font") : qsTr("User Font")),
+ "systemFont": systemFont,
+ "header": false,
+ "priority": priority,
+ "family": family,
+ })
+ Helper.updateInsertIndexes(index)
+ }
+
+ function addFamily(section, family, priority, systemFont)
+ {
+ preferFamilyList.append({
+ "title": family,
+ "subtitle": (systemFont ? qsTr("System Font") : qsTr("User Font")),
+ "systemFont": systemFont,
+ "header": false,
+ "priority": curSection,
+ "family": family,
+ })
+ Helper.setIndex(curSection, preferFamilyList.count)
+ }
+
+ function removeFamily(index)
+ {
+ var item = preferFamilyList.get(index)
+ editorController.removeFamily(item.family, item.priority)
+ preferFamilyList.remove(index)
+ Helper.updateRemoveIndexes(index)
+ }
+
+ Component {
+ id: modelSyncConnections
+ Connections {
+ onClearFamilyList: {
+ preferFamilyList.clear()
+ Helper.init()
+ }
+ onStartSection: addHeader(section, sectionName)
+ onAppendFamilyToList: addFamily(section, family, priority, systemFont)
+ }
+ }
+
+ ListModel {
+ id: preferFamilyList
+ }
+
+ Item {
+ anchors.top: pageHeader.bottom
+ anchors.bottom: importButton.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.topMargin: UI.DEFAULT_MARGIN
+ anchors.bottomMargin: UI.DEFAULT_MARGIN
+ clip: true
+
+ ListView {
+ id: preferFamilyListView
+ anchors.fill: parent
+ anchors.leftMargin: UI.DEFAULT_MARGIN
+ anchors.rightMargin: UI.DEFAULT_MARGIN
+
+ model: preferFamilyList
+ delegate: editorListDelegate
+ }
+
+ ScrollDecorator {
+ flickableItem: preferFamilyListView
+ }
+
+ // SectionScroller {
+ // listView: preferFamilyListView
+ // }
+
+ }
+
+ Button {
+ id: importButton
+ anchors.horizontalCenter: parent.horizontalCenter
+ // width: parent.width - UI.DEFAULT_MARGIN * 2
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: UI.DEFAULT_MARGIN
+ text: qsTr("Import System Settings")
+ onClicked: {
+ controller.importSystemSettings(family)
+ }
+ }
+
+ ButtonStyle {
+ id: buttonStyle
+ }
+
+ Component {
+ id: editorListDelegate
+
+ Item {
+ id: listItem
+
+ signal clicked
+ property bool pressed: false
+
+ property int titleSize: (model.header ? UI.FONT_XLARGE : UI.FONT_DEFAULT)
+ property int titleWeight: Font.Bold
+ property color titleColor: theme.inverted ? (model.header ? UI.COLOR_FOREGROUND : UI.COLOR_INVERTED_FOREGROUND) : (UI.COLOR_FOREGROUND)
+
+ property int subtitleSize: UI.FONT_XSMALL
+ property int subtitleWeight: Font.Light
+ property color subtitleColor: theme.inverted ? UI.COLOR_SECONDARY_FOREGROUND : UI.COLOR_INVERTED_SECONDARY_FOREGROUND
+
+ height: UI.LIST_ITEM_HEIGHT_SMALL
+ width: parent.width
+
+ Rectangle {
+ anchors.fill: parent
+ anchors.leftMargin: -UI.MARGIN_XLARGE
+ anchors.rightMargin: -UI.MARGIN_XLARGE
+ color: model.header ? UI.COLOR_SELECT : UI.COLOR_BACKGROUND
+ }
+
+ Row {
+ anchors.fill: parent
+ spacing: UI.DEFAULT_MARGIN
+
+ Item { width: UI.DEFAULT_MARGIN; height: 1; visible: !model.header }
+
+ Image {
+ anchors.verticalCenter: parent.verticalCenter
+ visible: model.iconSource ? true : false
+ width: UI.SIZE_ICON_DEFAULT
+ height: UI.SIZE_ICON_DEFAULT
+ source: model.iconSource ? model.iconSource : ""
+ }
+
+ Column {
+ anchors.verticalCenter: parent.verticalCenter
+
+
+ Label {
+ id: mainText
+ text: model.title
+ font.weight: listItem.titleWeight
+ font.pixelSize: listItem.titleSize
+ color: listItem.titleColor
+ }
+
+ Label {
+ id: subText
+ text: model.subtitle
+ font.weight: listItem.subtitleWeight
+ font.pixelSize: listItem.subtitleSize
+ color: listItem.subtitleColor
+
+ visible: text != ""
+ }
+ }
+ }
+ // MouseArea {
+ // id: mouseArea;
+ // anchors.fill: parent
+ // onClicked: {
+ // listItem.clicked();
+ // }
+ // }
+
+ ListButton {
+ anchors.right: parent.right
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.rightMargin: UI.DEFAULT_MARGIN
+ iconSource: (model.header ? "image://theme/icon-m-toolbar-add" : "image://theme/icon-m-toolbar-delete")
+ onClicked: {
+ if (model.header) {
+ controller.syncInstallableFamilyFor(editorPage.family)
+ editorTabPage.currentPriority = model.priority
+ selectInstallFamily.selectedIndexes = []
+ selectInstallFamily.open()
+ } else {
+ removeFamily(model.index)
+ }
+ }
+ }
+
+ }
+ }
+
+}