diff options
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/fileencryptionwidget.cpp | 46 | ||||
-rw-r--r-- | widgets/fileencryptionwidget.h | 32 | ||||
-rw-r--r-- | widgets/keydetailswidget.h | 1 |
3 files changed, 79 insertions, 0 deletions
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; |