OSDN Git Service

Version 0.5
[fontmanager/fontmanager.git] / qml / fontmanager / InstalledFontInfoPage.qml
index c8ed7c7..9817ae8 100644 (file)
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2011 Takumi Asaki
+** Copyright (C) 2012 Takumi Asaki
 ** All rights reserved.
 ** Contact: Takumi Asaki (takumi.asaki@gmail.com)
 **
@@ -153,19 +153,23 @@ Page {
         }
     }
 
-    QueryDialog {
-        id: confirmDialog
-        property int fontcount: 1
-        property variant fontlist
-        titleText: qsTr("Delete Font?")
-        message: fontcount > 1 ?
-                     qsTr("This Font has %1 families(%2).  Do you really want to remove these fonts now?").arg(fontcount).arg(fontlist.join(qsTr(', '))) :
-                     qsTr("Do you really want to remove this font now?")
-        acceptButtonText: qsTr("OK")
-        rejectButtonText: qsTr("Cancel")
-        onAccepted: {
-            controller.uninstallFont(fontInfo.file)
-        }
+    function openDeleteConfirmDialog(fontcount, fontlist)
+    {
+        queryDialog.titleText = qsTr("Delete Font?")
+        if (fontcount > 1)
+            queryDialog.message = qsTr("This Font has %1 families(%2).  Do you really want to remove these fonts now?").arg(fontcount).arg(fontlist ? fontlist.join(qsTr(', ')) : qsTr("Unknown"))
+        else
+            queryDialog.message = qsTr("Do you really want to remove this font now?")
+        queryDialog.acceptButtonText = qsTr("OK")
+        queryDialog.rejectButtonText = qsTr("Cancel")
+        queryDialog.accepted.connect(uninstallFont)
+        queryDialog.open()
+    }
+
+    function uninstallFont()
+    {
+        queryDialog.accepted.disconnect(uninstallFont)
+        controller.uninstallFont(fontInfo.file)
     }
 
     ToolBarLayout {
@@ -180,11 +184,10 @@ Page {
         }
         ToolIcon {
             platformIconId: "toolbar-delete"
+            anchors.horizontalCenter: parent.horizontalCenter
             onClicked: {
                 var fontlist = controller.fontCount(fontInfo.file)
-                confirmDialog.fontcount = fontlist.length
-                confirmDialog.fontlist = fontlist
-                confirmDialog.open()
+                openDeleteConfirmDialog(fontlist.length, fontlist)
             }
         }
     }