From 6c36bde43f174cc0c655a158d72de39fce861c09 Mon Sep 17 00:00:00 2001 From: ubbo Date: Fri, 11 Oct 2013 01:07:50 +0000 Subject: show some keydata in qml git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@1045 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- mainwindow.cpp | 6 +++--- qml/keydetails.qml | 36 ++++++++++++++++++++++++++++++++++-- qmlpage.cpp | 6 ++++-- qmlpage.h | 3 ++- textedit.cpp | 4 ++-- textedit.h | 3 ++- 6 files changed, 47 insertions(+), 11 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 674be9f..0c0fee5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1255,11 +1255,11 @@ void MainWindow::slotShowKeyDetails() return; } - // TODO: get qml working here ;-) - edit->slotNewQMLTab("KeyDetailsQML", "TODO"); - KgpgCore::KgpgKey key = mCtx->getKeyDetails(mKeyList->getSelected()->first()); if (key.id() != "") { + // TODO: get qml working here ;-) + edit->slotNewQMLTab("KeyDetailsQML", key); + new KeyDetailsDialog(mCtx, key, this); } diff --git a/qml/keydetails.qml b/qml/keydetails.qml index 5c5a35d..8ddf0c0 100644 --- a/qml/keydetails.qml +++ b/qml/keydetails.qml @@ -9,11 +9,43 @@ Rectangle { //color: "red" Text { // qsTr() for internationalisation, like tr() - text: qsTr("var:") + text: qsTr("id:") } Text { x: 54 y: 0 - text: var1 + text: id + } + + Text { + id: text1 + x: 0 + y: 21 + text: qsTr("email") + font.pixelSize: 12 + } + + Text { + id: text2 + x: 54 + y: 21 + text: email + font.pixelSize: 12 + } + + Text { + id: text3 + x: -4 + y: 38 + text: qsTr("name") + font.pixelSize: 12 + } + + Text { + id: text4 + x: 54 + y: 38 + text: name + font.pixelSize: 12 } } diff --git a/qmlpage.cpp b/qmlpage.cpp index 213315a..eb40fca 100644 --- a/qmlpage.cpp +++ b/qmlpage.cpp @@ -5,7 +5,7 @@ #include -QMLPage::QMLPage(const QString qmlfile, QWidget *parent) : +QMLPage::QMLPage(KgpgCore::KgpgKey key, QWidget *parent) : QWidget(parent) { @@ -15,7 +15,9 @@ QMLPage::QMLPage(const QString qmlfile, QWidget *parent) : qmlView->setSource(QUrl("qrc:/qml/keydetails.qml")); QDeclarativeContext *context = qmlView->rootContext(); - context->setContextProperty("var1", "derText"); + context->setContextProperty("id", key.id()); + context->setContextProperty("email", key.email()); + context->setContextProperty("name", key.name()); qDebug() << "qml:::::" << QUrl::fromLocalFile("keydetails.qml"); diff --git a/qmlpage.h b/qmlpage.h index 578f79d..04c4383 100644 --- a/qmlpage.h +++ b/qmlpage.h @@ -2,6 +2,7 @@ #define QMLPAGE_H #include +#include "kgpg/core/kgpgkey.h" class QMLPage : public QWidget { @@ -9,7 +10,7 @@ class QMLPage : public QWidget Q_OBJECT public: - QMLPage(const QString qmlfile, QWidget *parent = 0); + QMLPage(KgpgCore::KgpgKey key, QWidget *parent = 0); }; diff --git a/textedit.cpp b/textedit.cpp index e40a4af..22473aa 100644 --- a/textedit.cpp +++ b/textedit.cpp @@ -66,8 +66,8 @@ void TextEdit::slotNewHelpTab(QString title, QString path) } -void TextEdit::slotNewQMLTab(QString title, QString qmlfile) { - QMLPage *page = new QMLPage(qmlfile); +void TextEdit::slotNewQMLTab(QString title, KgpgCore::KgpgKey key) { + QMLPage *page = new QMLPage(key); tabWidget->addTab(page, title); tabWidget->setCurrentIndex(tabWidget->count() - 1); } diff --git a/textedit.h b/textedit.h index b5afb07..689be23 100644 --- a/textedit.h +++ b/textedit.h @@ -25,6 +25,7 @@ #include "editorpage.h" #include "helppage.h" #include "quitdialog.h" +#include "kgpg/core/kgpgkey.h" QT_BEGIN_NAMESPACE class QDebug; @@ -147,7 +148,7 @@ public slots: */ void slotNewHelpTab(QString title, QString path); - void slotNewQMLTab(QString title, QString qmlfile); + void slotNewQMLTab(QString title, KgpgCore::KgpgKey key); /** * @details put a * in front of current tabs title, if current textedit is modified -- cgit v1.2.3