From 3adc7ee78033c4ad2be32a8bf38d0971c7eb30d5 Mon Sep 17 00:00:00 2001 From: ubbo Date: Mon, 14 Oct 2013 22:22:22 +0000 Subject: add keyinforow qml widget git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@1060 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- gpg4usb.pro | 3 ++- gpg4usb.qrc | 1 + qml/KeyInfoRow.qml | 24 ++++++++++++++++++++++++ qml/keydetails.qml | 49 +++++++++++++++++++++---------------------------- qmlpage.cpp | 4 +++- 5 files changed, 51 insertions(+), 30 deletions(-) create mode 100644 qml/KeyInfoRow.qml diff --git a/gpg4usb.pro b/gpg4usb.pro index cd51c59..a210fb2 100644 --- a/gpg4usb.pro +++ b/gpg4usb.pro @@ -103,6 +103,7 @@ contains(DEFINES, GPG4USB_NON_PORTABLE) { OTHER_FILES += \ qml/keydetails.qml \ qml/Button.qml \ - qml/TextField.qml + qml/TextField.qml \ + qml/KeyInfoRow.qml diff --git a/gpg4usb.qrc b/gpg4usb.qrc index 54bdb4d..d1a4bbd 100644 --- a/gpg4usb.qrc +++ b/gpg4usb.qrc @@ -53,5 +53,6 @@ release/icons/button_previous.png qml/Button.qml qml/TextField.qml + qml/KeyInfoRow.qml diff --git a/qml/KeyInfoRow.qml b/qml/KeyInfoRow.qml new file mode 100644 index 0000000..a1108dd --- /dev/null +++ b/qml/KeyInfoRow.qml @@ -0,0 +1,24 @@ +import QtQuick 1.1 + +Rectangle { + + id: keyinforow + + width: 200 + height: 23 + + property variant key + property variant value + + Text { + id: keyText + text: key + } + + Text { + id: valueText + x: 50 + y: 0 + text: value + } +} diff --git a/qml/keydetails.qml b/qml/keydetails.qml index e8a354c..141904f 100644 --- a/qml/keydetails.qml +++ b/qml/keydetails.qml @@ -15,6 +15,10 @@ Rectangle { property alias tf1Text: tf1.text property alias tf2Text: tf2.text +// property keyid : "" +// property email : "" +// property name : "" + //color: "red" Rectangle { id: rectangle2 @@ -34,44 +38,33 @@ Rectangle { color: "#978c79" } - Text { - // qsTr() for internationalisation, like tr() - x: 118 - y: 54 - text: qsTr("id:") - } - Text { - x: 172 + KeyInfoRow { + x: 119 y: 54 - text: id - } - - Text { - id: text1 - x: 118 - y: 75 - text: qsTr("email:") + // qsTr() for internationalisation, like tr() + key: qsTr("id:") + value: id } - Text { - id: text2 - x: 172 + KeyInfoRow { + x: 119 y: 75 - text: email + key: qsTr("email:") + value: email } - Text { - id: text3 + KeyInfoRow { x: 119 y: 96 - text: qsTr("name:") + key: qsTr("name:") + value: name } - Text { - id: text4 - x: 172 - y: 96 - text: name + KeyInfoRow { + x: 119 + y: 117 + key: qsTr("keysize") + value: key.size() / key.encyptionSize() } diff --git a/qmlpage.cpp b/qmlpage.cpp index 5d49f5d..64a8640 100644 --- a/qmlpage.cpp +++ b/qmlpage.cpp @@ -18,13 +18,15 @@ QMLPage::QMLPage(KgpgCore::KgpgKey key, QWidget *parent) : QDeclarativeView *qmlView = new QDeclarativeView; qmlView->setResizeMode(QDeclarativeView::SizeRootObjectToView); - qmlView->setSource(QUrl("qrc:/qml/keydetails.qml")); + context = qmlView->rootContext(); context->setContextProperty("id", key.id()); context->setContextProperty("email", key.email()); context->setContextProperty("name", key.name()); + qmlView->setSource(QUrl("qrc:/qml/keydetails.qml")); + /* or: http://xizhizhu.blogspot.de/2010/10/hybrid-application-using-qml-and-qt-c.html DeclarativePropertyMap map; -- cgit v1.2.3