aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2013-10-16 23:49:06 +0000
committerubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910>2013-10-16 23:49:06 +0000
commit4a2fdb5c969208927201b9778037ecc92483ea30 (patch)
tree562047e2028df52aa3e8c5161895769f17bf84e9
parentrename qmlpage to widgets/keydetailswidget and add licence (diff)
downloadgpg4usb-4a2fdb5c969208927201b9778037ecc92483ea30.tar.gz
gpg4usb-4a2fdb5c969208927201b9778037ecc92483ea30.zip
begin of fileencryptionwidget
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@1071 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--gpg4usb.pro9
-rw-r--r--gpg4usb.qrc1
-rw-r--r--keylist.cpp4
-rw-r--r--keylist.h3
-rw-r--r--mainwindow.cpp11
-rw-r--r--qml/fileencryption.qml109
-rw-r--r--qml/keydetails.qml2
-rw-r--r--textedit.cpp10
-rw-r--r--textedit.h7
-rw-r--r--widgets/fileencryptionwidget.cpp46
-rw-r--r--widgets/fileencryptionwidget.h32
-rw-r--r--widgets/keydetailswidget.h1
12 files changed, 223 insertions, 12 deletions
diff --git a/gpg4usb.pro b/gpg4usb.pro
index 65c3001..7c75718 100644
--- a/gpg4usb.pro
+++ b/gpg4usb.pro
@@ -46,7 +46,8 @@ HEADERS += attachments.h \
helppage.h \
gpgconstants.h \
findwidget.h \
- widgets/keydetailswidget.h
+ widgets/keydetailswidget.h \
+ widgets/fileencryptionwidget.h
SOURCES += attachments.cpp \
gpgcontext.cpp \
@@ -71,7 +72,8 @@ SOURCES += attachments.cpp \
helppage.cpp \
gpgconstants.cpp \
findwidget.cpp \
- widgets/keydetailswidget.cpp
+ widgets/keydetailswidget.cpp \
+ widgets/fileencryptionwidget.cpp
RC_FILE = gpg4usb.rc
@@ -101,6 +103,7 @@ OTHER_FILES += \
qml/Button.qml \
qml/TextField.qml \
qml/KeyInfoRow.qml \
- qml/ImageButton.qml
+ qml/ImageButton.qml \
+ qml/fileencryption.qml
diff --git a/gpg4usb.qrc b/gpg4usb.qrc
index 87d7448..ffd34a0 100644
--- a/gpg4usb.qrc
+++ b/gpg4usb.qrc
@@ -55,5 +55,6 @@
<file>qml/TextField.qml</file>
<file>qml/KeyInfoRow.qml</file>
<file>qml/ImageButton.qml</file>
+ <file>qml/fileencryption.qml</file>
</qresource>
</RCC>
diff --git a/keylist.cpp b/keylist.cpp
index 15d1d46..afd5ba1 100644
--- a/keylist.cpp
+++ b/keylist.cpp
@@ -34,7 +34,7 @@ KeyList::KeyList(GpgME::GpgContext *ctx, QWidget *parent)
mKeyList->setColumnWidth(1, 20);
mKeyList->sortByColumn(2, Qt::AscendingOrder);
mKeyList->setSelectionBehavior(QAbstractItemView::SelectRows);
- // hide id and fingerprint of key
+ // hide id and fingerprint of keyQVariant
mKeyList->setColumnHidden(4, true);
mKeyList->setColumnHidden(5, true);
@@ -51,6 +51,8 @@ KeyList::KeyList(GpgME::GpgContext *ctx, QWidget *parent)
mKeyList->setHorizontalHeaderLabels(labels);
mKeyList->horizontalHeader()->setStretchLastSection(true);
+ connect(mKeyList, SIGNAL(itemActivated(QTableWidgetItem*)), this, SIGNAL(keySelectionChanged()));
+
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(mKeyList);
layout->setContentsMargins(0, 0, 0, 0);
diff --git a/keylist.h b/keylist.h
index 9936e3d..fed27a1 100644
--- a/keylist.h
+++ b/keylist.h
@@ -58,6 +58,9 @@ public slots:
void slotRefresh();
void slotUploadKeyToServer(QByteArray *keys);
+signals:
+ void keySelectionChanged();
+
private:
void importKeys(QByteArray inBuffer);
GpgME::GpgContext *mCtx;
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 3ebf9db..16a2d3f 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -1228,7 +1228,7 @@ void MainWindow::slotShowKeyDetails()
KgpgCore::KgpgKey key = mCtx->getKeyDetails(mKeyList->getSelected()->first());
if (key.id() != "") {
// TODO: get qml working here ;-)
- edit->slotNewQMLTab(tr("Key: ") + key.name(), mCtx, key);
+ edit->slotNewKeyDetailsTab(tr("Key: ") + key.name(), mCtx, key);
}
}
@@ -1245,9 +1245,12 @@ void MainWindow::slotRefreshKeysFromKeyserver()
void MainWindow::slotFileEncrypt()
{
- QStringList *keyList;
- keyList = mKeyList->getChecked();
- new FileEncryptionDialog(mCtx, *keyList, FileEncryptionDialog::Encrypt, this);
+ edit->slotNewFileEncryptionTab(tr("Encrypt File"), mCtx, mKeyList);
+
+ QStringList *keyList;
+ keyList = mKeyList->getChecked();
+ new FileEncryptionDialog(mCtx, *keyList, FileEncryptionDialog::Encrypt, this);
+
}
void MainWindow::slotFileDecrypt()
diff --git a/qml/fileencryption.qml b/qml/fileencryption.qml
new file mode 100644
index 0000000..a879124
--- /dev/null
+++ b/qml/fileencryption.qml
@@ -0,0 +1,109 @@
+import QtQuick 1.1
+
+Rectangle {
+
+ id: fileencryption
+
+ signal okClicked
+ signal fileChooserClicked
+
+ property alias inputFilePath : inputFilePath.text
+ property alias outputFilePath : outputFilePath.text
+ property alias showNoKeySelected : noKeySelectInfo.visible
+
+ width: 400
+ height: 400
+
+ Text {
+ id: text3
+ x: 21
+ y: 16
+ text: qsTr("Encrypt File")
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: text1
+ x: 56
+ y: 65
+ text: qsTr("Input:")
+ font.pixelSize: 12
+ }
+
+ TextField {
+ id: inputFilePath
+ x: 146
+ y: 65
+ width: 150
+ height: 28
+ }
+
+ Button {
+ id: fileChooserButton
+ x: 327
+ y: 65
+ text: "..."
+ onClicked: {
+ console.log("fc click")
+ fileencryption.fileChooserClicked()
+ }
+ }
+
+ Text {
+ id: text2
+ x: 56
+ y: 104
+ text: qsTr("Output:")
+ font.pixelSize: 12
+ }
+
+ TextField {
+ id: outputFilePath
+ x: 146
+ y: 104
+ width: 150
+ height: 28
+ }
+
+ Button {
+ id: okButton
+ x: 270
+ y: 150
+ width: 97
+ height: 35
+ text: qsTr("OK")
+ onClicked: fileencryption.okClicked()
+ }
+
+ Rectangle {
+ id: noKeySelectInfo
+ x: 21
+ y: 150
+ width: 142
+ height: 35
+ color: "#ffffff"
+ border.width: 2
+ border.color: "#d95b1d"
+ visible: false
+
+ Text {
+ id: text4
+ x: 6
+ y: -1
+ text: qsTr("!")
+ font.bold: true
+ font.pointSize: 20
+ font.pixelSize: 12
+ }
+
+ Text {
+ id: text5
+ x: 31
+ y: 9
+ text: qsTr("No Key Selected")
+ font.pixelSize: 12
+ }
+ }
+
+
+}
diff --git a/qml/keydetails.qml b/qml/keydetails.qml
index c363210..682db20 100644
--- a/qml/keydetails.qml
+++ b/qml/keydetails.qml
@@ -8,7 +8,7 @@ Rectangle {
id: keydetails
- signal clicked
+ // signal clicked
signal exportPrivateKeyClicked
signal exportPublicKeyClicked
diff --git a/textedit.cpp b/textedit.cpp
index 1a987bf..4dabfd1 100644
--- a/textedit.cpp
+++ b/textedit.cpp
@@ -20,7 +20,6 @@
*/
#include "textedit.h"
-#include "widgets/keydetailswidget.h"
TextEdit::TextEdit()
{
@@ -66,13 +65,20 @@ void TextEdit::slotNewHelpTab(QString title, QString path)
}
-void TextEdit::slotNewQMLTab(QString title, GpgME::GpgContext *ctx, KgpgCore::KgpgKey key) {
+void TextEdit::slotNewKeyDetailsTab(QString title, GpgME::GpgContext *ctx, KgpgCore::KgpgKey key) {
KeyDetailsWidget *page = new KeyDetailsWidget(ctx, key);
// todo: should parent also be given?
tabWidget->addTab(page, title);
tabWidget->setCurrentIndex(tabWidget->count() - 1);
}
+void TextEdit::slotNewFileEncryptionTab(QString title, GpgME::GpgContext *ctx, KeyList *keyList) {
+ FileEncryptionWidget *page = new FileEncryptionWidget(ctx, keyList);
+ // todo: should parent also be given?
+ tabWidget->addTab(page, title);
+ tabWidget->setCurrentIndex(tabWidget->count() - 1);
+}
+
void TextEdit::slotOpen()
{
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open file"),
diff --git a/textedit.h b/textedit.h
index e8a09f6..54b2d11 100644
--- a/textedit.h
+++ b/textedit.h
@@ -27,6 +27,9 @@
#include "quitdialog.h"
#include "kgpg/core/kgpgkey.h"
#include "gpgcontext.h"
+#include "keylist.h"
+#include "widgets/keydetailswidget.h"
+#include "widgets/fileencryptionwidget.h"
QT_BEGIN_NAMESPACE
class QDebug;
@@ -149,7 +152,9 @@ public slots:
*/
void slotNewHelpTab(QString title, QString path);
- void slotNewQMLTab(QString title, GpgME::GpgContext *ctx, KgpgCore::KgpgKey key);
+ void slotNewKeyDetailsTab(QString title, GpgME::GpgContext *ctx, KgpgCore::KgpgKey key);
+
+ void slotNewFileEncryptionTab(QString title, GpgME::GpgContext *ctx, KeyList *keyList);
/**
* @details put a * in front of current tabs title, if current textedit is modified
diff --git a/widgets/fileencryptionwidget.cpp b/widgets/fileencryptionwidget.cpp
new file mode 100644
index 0000000..b225a33
--- /dev/null
+++ b/widgets/fileencryptionwidget.cpp
@@ -0,0 +1,46 @@
+#include "fileencryptionwidget.h"
+
+FileEncryptionWidget::FileEncryptionWidget(GpgME::GpgContext *ctx, KeyList *keyList, QWidget *parent)
+ : QWidget(parent), mCtx(ctx), mKeyList(keyList)
+{
+ QDeclarativeView *qmlView = new QDeclarativeView;
+ qmlView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ qmlView->setSource(QUrl("qrc:/qml/fileencryption.qml"));
+
+ qmlRoot = qmlView->rootObject();
+ connect( qmlRoot, SIGNAL(okClicked()), this, SLOT(slotEncryptFile()));
+ connect( qmlRoot, SIGNAL(fileChooserClicked()), this, SLOT(slotChooseFile()));
+
+ QHBoxLayout *mainLayout = new QHBoxLayout(this);
+ mainLayout->setSpacing(0);
+ mainLayout->setContentsMargins(0,0,0,0);
+ mainLayout->addWidget(qmlView);
+
+ connect(mKeyList, SIGNAL(keySelectionChanged()), this, SLOT(slotKeySelectionChanged()));
+}
+
+void FileEncryptionWidget::slotKeySelectionChanged() {
+ qDebug() << "keySelChanges Signal received in fileencwidget";
+ qmlRoot->setProperty("showNoKeySelected", (mKeyList->getSelected()->size() < 1));
+}
+
+void FileEncryptionWidget::slotEncryptFile() {
+
+ if(mKeyList->getSelected()->size() < 1) {
+ qmlRoot->setProperty("showNoKeySelected", true);
+ } else {
+ qDebug() << "fine, fine";
+ }
+
+}
+
+void FileEncryptionWidget::slotChooseFile() {
+ QString path = "";
+ if (qmlRoot->property("inputFilePath").toString().size() > 0) {
+ path = QFileInfo(qmlRoot->property("inputFilePath").toString()).absolutePath();
+ }
+
+ //QString infileName = QFileDialog::getOpenFileName(this, tr("Open File"), path, tr("Files") + tr("All Files (*)"));
+ QString infileName = QFileDialog::getOpenFileName(this, tr("Open File"), path);
+ qmlRoot->setProperty("inputFilePath", infileName);
+}
diff --git a/widgets/fileencryptionwidget.h b/widgets/fileencryptionwidget.h
new file mode 100644
index 0000000..38f11eb
--- /dev/null
+++ b/widgets/fileencryptionwidget.h
@@ -0,0 +1,32 @@
+#ifndef FILEENCRYPTIONWIDGET_H
+#define FILEENCRYPTIONWIDGET_H
+
+#include <QWidget>
+#include <QDeclarativeContext>
+#include <QtDeclarative/QDeclarativeView>
+#include <QGraphicsObject>
+#include "gpgcontext.h"
+#include "keylist.h"
+
+class FileEncryptionWidget : public QWidget
+{
+
+ Q_OBJECT
+
+public:
+ FileEncryptionWidget(GpgME::GpgContext *ctx, KeyList *keyList, QWidget *parent = 0);
+
+public slots:
+ void slotEncryptFile();
+ void slotChooseFile();
+
+private:
+ GpgME::GpgContext *mCtx;
+ QGraphicsObject *qmlRoot;
+ KeyList *mKeyList;
+
+private slots:
+ void slotKeySelectionChanged();
+};
+
+#endif // FILEENCRYPTIONWIDGET_H
diff --git a/widgets/keydetailswidget.h b/widgets/keydetailswidget.h
index 0491336..411f647 100644
--- a/widgets/keydetailswidget.h
+++ b/widgets/keydetailswidget.h
@@ -40,6 +40,7 @@ public slots:
void qmlClicked();
void slotExportPublicKey();
void slotExportPrivateKey();
+
private:
QDeclarativeContext *context;
QGraphicsObject *obj;