OSDN Git Service

Version: 0.3
[fontmanager/fontmanager.git] / qml / fontmanager / MainPage.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Takumi Asaki
4 ** All rights reserved.
5 ** Contact: Takumi Asaki (takumi.asaki@gmail.com)
6 **
7 ** This file is part of the fontmanager application.
8 **
9 ** You may use this file under the terms of the BSD license as follows:
10 **
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
13 ** met:
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
19 **     distribution.
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
23 **     permission.
24 **
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."
36 **
37 ****************************************************************************/
38
39 import QtQuick 1.1
40 import com.nokia.meego 1.0
41 import com.nokia.extras 1.1
42 import 'UIConstants.js' as UI
43
44 Page {
45     tools: mainTools
46
47     Label {
48         id: pageHeader
49         anchors.top: parent.top
50         anchors.horizontalCenter: parent.horizontalCenter
51         anchors.margins: UI.DEFAULT_MARGIN
52
53         horizontalAlignment: Text.AlignHCenter
54         font.pixelSize: UI.FONT_LARGE
55         font.bold: true
56         text: qsTr("Installed Fonts")
57     }
58
59     Connections {
60         target: controller
61         onClearInstalledFontList: {
62             installedFontList.clear()
63         }
64         onAppendInstalledFont: {
65             installedFontList.append({ "title": family, "subtitle": fullname })
66         }
67     }
68
69     ListModel {
70         id: installedFontList
71     }
72
73     ListView {
74         id: listView
75         anchors.top: pageHeader.bottom
76         anchors.bottom: parent.bottom
77         anchors.left: parent.left
78         anchors.right: parent.right
79         anchors.margins: UI.DEFAULT_MARGIN
80         clip: true
81
82         model: installedFontList
83
84         delegate: ListDelegate {
85             onClicked: {
86                 if (mainMenu.status != DialogStatus.Closed)
87                     mainMenu.close()
88                 pageStack.push(installedFontInfoPage, { "fontInfo": controller.fontInfo(title) } );
89             }
90         }
91
92     }
93
94     Text {
95         id: warningText
96         anchors.centerIn: parent
97         text: qsTr("No Fonts Found!")
98         font.pixelSize: UI.FONT_XLARGE
99         font.bold: true
100         color: "gray"
101         visible: listView.count == 0
102     }
103
104     Component {
105         id: installedFontInfoPage
106         InstalledFontInfoPage { }
107     }
108
109     Component {
110         id: fontsConfViewPageComponent
111         FontsConfViewPage { }
112     }
113
114     ToolBarLayout {
115         id: mainTools
116         visible: true
117         ToolIcon {
118             platformIconId: "toolbar-add"
119             onClicked: {
120                 if (mainMenu.status != DialogStatus.Closed)
121                     mainMenu.close()
122                 pageStack.push(fontSelectPage)
123             }
124         }
125         ToolIcon {
126             platformIconId: "toolbar-view-menu"
127             anchors.right: (parent === undefined) ? undefined : parent.right
128             onClicked: (mainMenu.status == DialogStatus.Closed) ? mainMenu.open() : mainMenu.close()
129         }
130     }
131
132     Menu {
133         id: mainMenu
134         visualParent: pageStack
135         MenuLayout {
136             MenuItem {
137                 text: qsTr("View current fonts config");
138                 enabled: controller.localFontsConfExists
139                 onClicked: {
140                     mainMenu.close()
141                     pageStack.push(fontsConfViewPageComponent, { "text": controller.localFontsConf } )
142                 }
143             }
144             MenuItem {
145                 text: qsTr("Remove uninstalled fonts from config");
146                 enabled: controller.configHasUninstalledFonts
147                 onClicked: {
148                     mainMenu.close()
149                     controller.removeUninstalledFontsFromConfig()
150                     controller.saveFontsConf()
151                 }
152             }
153         }
154     }
155
156 }