// 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.0
import 'UIConstants.js' as UI
+import 'HelpDialog.js' as HelpHelper
+
Page {
id: editorTabPage
tools: editorTabTool
"Please check <a href=\"http://www.freedesktop.org/software/fontconfig/fontconfig-user.html\">fontconfig</a> for more details."
)
- property alias curTab: editFontsConfTab.currentTab
+ property Item selectionDialog: null
+
+ property int currentIndex: 0
+ ListModel {
+ id: familyModel
+ ListElement { family: "sans-serif"; name: QT_TR_NOOP("Sans Serif") }
+ ListElement { family: "serif"; name: QT_TR_NOOP("Serif") }
+ ListElement { family: "monospace"; name: QT_TR_NOOP("Monospace") }
+ ListElement { family: "Nokia Pure Text"; name: QT_TR_NOOP("System") }
+ }
PageHeader {
id: pageHeader
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
- text: qsTr("Edit Fonts Config: %1").arg(curTab.familyName)
- }
-
- TabGroup {
- id: editFontsConfTab
- anchors.top: pageHeader.bottom
- anchors.bottom: bottomButtons.top
-
- opacity: enabled ? 1.0 : 0.5
-
- currentTab: sansSerifTab
-
- FontsConfEditor {
- id: sansSerifTab
- family: "sans-serif"
- familyName: qsTr("Sans Serif")
- editorController: controller.editorController(family)
- }
-
- FontsConfEditor {
- id: serifTab
- family: "serif"
- familyName: qsTr("Serif")
- editorController: controller.editorController(family)
- }
-
- FontsConfEditor {
- id: monospaceTab
- family: "monospace"
- familyName: qsTr("Monospace")
- editorController: controller.editorController(family)
- }
-
- FontsConfEditor {
- id: systemTab
- family: "Nokia Pure Text"
- familyName: qsTr("System")
- editorController: controller.editorController(family)
- }
-
+ text: qsTr("Edit Fonts Config: %1").arg(confEditor.familyName)
+ enabled: !showHelp
}
Item {
- id: bottomButtons
-
- height: bottomItem.height + importButton.height + UI.DEFAULT_MARGIN * 2
+ id: contents
+ anchors.top: pageHeader.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
- Rectangle {
- anchors.fill: parent
- anchors.topMargin: UI.DEFAULT_MARGIN / 2
- gradient: Gradient {
- GradientStop { position: 0.0; color: Qt.lighter("#76221d") }
- GradientStop { position: 1.0; color: Qt.lighter("#bd543d") }
- }
- Component.onCompleted: {
- console.log("bottomButtons: " + width + " x " + height)
- }
- }
+ opacity: enabled ? 1.0 : 0.5
- Item {
- id: bottomItem
- anchors.bottom: importButton.top
+ FontsConfEditor {
+ id: confEditor
+ anchors.top: parent.top
+ anchors.bottom: bottomButtons.top
anchors.left: parent.left
anchors.right: parent.right
- height: UI.LIST_ITEM_HEIGHT_SMALL
-
- ListButton {
- anchors.left: parent.left
- anchors.leftMargin: UI.DEFAULT_MARGIN
- iconSource: "image://theme/icon-m-toolbar-down"
- onClicked: curTab.moveDownFamily()
- enabled: (curTab.listView.currentIndex >= 0 &&
- curTab.listView.currentIndex < curTab.listView.count - 1) &&
- (!curTab.listView.model.get(curTab.listView.currentIndex+1).header)
- }
- ListButton {
- anchors.horizontalCenter: parent.horizontalCenter
- iconSource: "image://theme/icon-m-toolbar-delete"
- onClicked: curTab.removeFamily()
- enabled: curTab.listView.currentIndex >= 0
- }
-
- ListButton {
- anchors.right: parent.right
- anchors.rightMargin: UI.DEFAULT_MARGIN
- iconSource: "image://theme/icon-m-toolbar-up"
- onClicked: curTab.moveUpFamily()
- enabled: (curTab.listView.currentIndex > 0) && (!curTab.listView.model.get(curTab.listView.currentIndex-1).header)
- }
+ family: familyModel.get(currentIndex).family
+ familyName: familyModel.get(currentIndex).name
+ editorController: controller.editorController(family)
}
- Button {
- id: importButton
- anchors.horizontalCenter: parent.horizontalCenter
+ BottomButtons {
+ id: bottomButtons
anchors.bottom: parent.bottom
- anchors.bottomMargin: UI.DEFAULT_MARGIN
- text: qsTr("Import System Settings")
- onClicked: {
- controller.importSystemSettings(editFontsConfTab.currentTab.family)
- }
+ anchors.left: parent.left
+ anchors.right: parent.right
+ targetTab: confEditor
}
- }
- MultiSelectionDialog {
- id: selectInstallFamily
- model: installableFamilyListModel
- acceptButtonText: qsTr("Add")
- titleText: qsTr("Add Family for %1").arg(curTab.familyName)
- onAccepted: {
- for (var i = 0; i < selectedIndexes.length; i++) {
- var idx = selectedIndexes[i]
- var sItem = installableFamilyListModel.get(idx)
- var tab = editFontsConfTab.currentTab
- tab.editorController.appendFamily(sItem.enfamily, currentPriority)
- tab.insertFamily(sItem.enfamily, currentPriority, sItem.systemFont)
- }
- }
}
ToolBarLayout {
pageStack.pop()
}
}
- ButtonRow {
- style: TabButtonStyle { }
- TabButton {
- text: sansSerifTab.familyName
- tab: sansSerifTab
- }
- TabButton {
- text: serifTab.familyName
- tab: serifTab
- }
- TabButton {
- text: monospaceTab.familyName
- tab: monospaceTab
+
+ Button {
+ text: confEditor.familyName
+
+ Image {
+ id: openImage
+ anchors.right: parent.right
+ anchors.rightMargin: UI.DEFAULT_MARGIN
+ anchors.verticalCenter: parent.verticalCenter
+ source: "image://theme/icon-m-common-expand"
}
- TabButton {
- text: systemTab.familyName
- tab: systemTab
+ onClicked: {
+ selectCurrentFamilyDialog.open()
}
}
+
ToolIcon {
platformIconId: "toolbar-view-menu"
anchors.right: (parent === undefined) ? undefined : parent.right
enabled: !controller.isEmptyFontsConf
onClicked: {
editMenu.close()
- removeConfirmDialog.open()
+ openRemoveConfirmDialog()
}
}
MenuItem {
text: qsTr("View current fonts config");
- // enabled: controller.localFontsConfExists
+ enabled: controller.localFontsConfExists
onClicked: {
editMenu.close()
- pageStack.push(fontsConfViewPageComponent, { "text": controller.localFontsConf } )
+ var component = Qt.createComponent("FontsConfViewPage.qml")
+ if (component.status === Component.Error)
+ console.log("Error: " + component.errorString())
+ pageStack.push(component, { "text": controller.localFontsConf } )
}
}
MenuItem {
text: qsTr("Help")
- onClicked: showHelp = true
+ onClicked: {
+ showHelp = true
+ HelpHelper.openHelpDialog(editorTabPage, contents, helpMessage, closeHelp)
+ }
}
}
}
- QueryDialog {
- id: removeConfirmDialog
- titleText: qsTr("Remove it?")
- message: qsTr("Existing fonts config %1 will be removed. Are you sure?").arg(controller.localFontsConfPath)
- acceptButtonText: qsTr("OK")
- rejectButtonText: qsTr("Cancel")
- onAccepted: controller.resetLocalFontsConf()
+ function closeHelp()
+ {
+ showHelp = false
+ }
+
+ function openRemoveConfirmDialog()
+ {
+ queryDialog.titleText = qsTr("Remove it?")
+ queryDialog.message = qsTr("Existing fonts config %1 will be removed. Are you sure?").arg(controller.localFontsConfPath)
+ queryDialog.acceptButtonText = qsTr("OK")
+ queryDialog.rejectButtonText = qsTr("Cancel")
+ queryDialog.accepted.connect(resetLocalFontsConf)
+ queryDialog.open()
}
- HelpDialog {
- id: helpDialog
- anchors.fill: editFontsConfTab
- message: helpMessage
- visible: showHelp
- onClicked: showHelp = false
+ function resetLocalFontsConf()
+ {
+ queryDialog.accepted.disconnect(resetLocalFontsConf)
+ controller.resetLocalFontsConf()
+ }
+
+ function openSelectInstallFamilyDialog(priority)
+ {
+ deleteSelectInstallFamilyDialog()
+ var dialogComponent = Qt.createComponent("SelectInstallFamilyDialog.qml")
+ if (dialogComponent.status === Component.Error)
+ console.log("Error: " + dialogComponent.errorString())
+ controller.syncInstallableFamilyFor(confEditor.family)
+ editorTabPage.currentPriority = priority
+ selectionDialog = dialogComponent.createObject(editorTabPage, { "editor": confEditor } )
+ selectionDialog.selectedIndexes = []
+ selectionDialog.accepted.connect(deleteSelectInstallFamilyDialog)
+ selectionDialog.rejected.connect(deleteSelectInstallFamilyDialog)
+ selectionDialog.open()
+ }
+
+ function deleteSelectInstallFamilyDialog()
+ {
+ if (selectionDialog)
+ selectionDialog.destroy()
+ selectionDialog = null
+ }
+
+ SelectionDialog {
+ id: selectCurrentFamilyDialog
+ model: familyModel
+ selectedIndex: currentIndex
+ titleText: qsTr("Select Family to edit")
+ onAccepted: {
+ currentIndex = selectedIndex
+ }
}
states: [
name: "showHelp"
when: showHelp
PropertyChanges {
- target: editFontsConfTab
+ target: contents
enabled: false
}
PropertyChanges {