diff --git a/.astylerc b/.astylerc index 4d2a18b..fee7f0f 100644 --- a/.astylerc +++ b/.astylerc @@ -5,8 +5,7 @@ suffix=none --align-reference=name --convert-tabs --attach-namespaces ---max-code-length=100 ---max-instatement-indent=120 +--max-code-length=120 --pad-header --pad-oper --lineend=linux diff --git a/clickable.yaml b/clickable.yaml index 406cae9..1a85269 100644 --- a/clickable.yaml +++ b/clickable.yaml @@ -4,9 +4,10 @@ kill: UTPass scripts: style: >- - echo 'Astyle :' && astyle --options=.astylerc main.cpp && astyle - --options=.astylerc --recursive 'plugins/*.cpp,*.h' && echo 'QmlFmt :' && - qmlfmt -l tests && qmlfmt -w tests && qmlfmt -l qml && qmlfmt -w qml + echo 'Astyle :' && astyle --options=.astylerc main.cpp && astyle --options=.astylerc --recursive 'plugins/*.cpp,*.h' && echo 'Running QmlFormat' && find . -name "*.qml" -exec qmlformat -i {} \; && echo 'Success' + + + dependencies_target: - libgpgmepp-dev diff --git a/plugins/Git/git.cpp b/plugins/Git/git.cpp index f1ea083..d9163cc 100644 --- a/plugins/Git/git.cpp +++ b/plugins/Git/git.cpp @@ -19,7 +19,7 @@ bool Git::clone(QString url, QString destination_dir_path) qDebug() << "Cloning " << url << " to tmp dir " << tmp_dir.absolutePath(); auto ret = LibGit::instance()->clone(url, tmp_dir.absolutePath()); // TODO Better error handling - if(ret) { + if (ret) { qDebug() << "Removing password_store " << destination_dir_path; QDir destination_dir(destination_dir_path); destination_dir.removeRecursively(); diff --git a/plugins/Git/libgit.cpp b/plugins/Git/libgit.cpp index 95f6354..fcbb610 100644 --- a/plugins/Git/libgit.cpp +++ b/plugins/Git/libgit.cpp @@ -13,12 +13,13 @@ LibGit::LibGit() git_libgit2_init(); } -LibGit::~LibGit() { +LibGit::~LibGit() +{ git_libgit2_shutdown(); } int LibGit::credentials_cb(git_cred **out, const char *url, const char *username_from_url, - unsigned int allowed_types, void *payload) + unsigned int allowed_types, void *payload) { int error; const char *user, *pass; @@ -38,7 +39,8 @@ int LibGit::credentials_cb(git_cred **out, const char *url, const char *username return GIT_EUSER; } -bool LibGit::clone(QString url, QString path) { +bool LibGit::clone(QString url, QString path) +{ git_repository *repo = NULL; git_clone_options opts = GIT_CLONE_OPTIONS_INIT; opts.fetch_opts.callbacks.credentials = *credentials_cb; diff --git a/plugins/Git/libgit.h b/plugins/Git/libgit.h index 08ee5d7..dc4ab0d 100644 --- a/plugins/Git/libgit.h +++ b/plugins/Git/libgit.h @@ -13,7 +13,7 @@ class LibGit private: LibGit(); static int credentials_cb(git_cred **out, const char *url, const char *username_from_url, - unsigned int allowed_types, void *payload); + unsigned int allowed_types, void *payload); public: diff --git a/plugins/Pass/gpg.cpp b/plugins/Pass/gpg.cpp index a8e134b..c30f2d6 100644 --- a/plugins/Pass/gpg.cpp +++ b/plugins/Pass/gpg.cpp @@ -63,7 +63,8 @@ QString Gpg::initGpgHome() } -QString Gpg::findCommandPath(const QString &command) { +QString Gpg::findCommandPath(const QString &command) +{ // Retrieve the PATH environment variable QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QString pathEnv = env.value("PATH"); @@ -111,10 +112,10 @@ void Gpg::initGpgConfig() agentConf.close(); auto err = gpgme_set_engine_info ( - GPGME_PROTOCOL_OpenPGP, - exec.toLocal8Bit().data(), - home.toLocal8Bit().data() - ); + GPGME_PROTOCOL_OpenPGP, + exec.toLocal8Bit().data(), + home.toLocal8Bit().data() + ); if (err != GPG_ERR_NO_ERROR) { qDebug() << "Error code : " << err; qDebug() << "Error str : " << gpg_strerror(err); @@ -198,13 +199,13 @@ Error Gpg::encryptToFile(QString str, QString path, QString uid, bool ascii_armo QPair> Gpg::getAllKeys ( bool remote, const bool include_sigs, - bool validate ) + bool validate ) { return getKeys(QString(""), remote, include_sigs, validate); } -QPair> Gpg::getKeys(QString pattern_uid, bool remote, bool include_sigs, - bool validate) +QPair> Gpg::getKeys(QString pattern_uid, bool remote, bool include_sigs, + bool validate) { qDebug() << "Getting the keys " << pattern_uid; auto job = std::unique_ptr(openpgp()->keyListJob(remote, include_sigs, validate)); @@ -213,7 +214,7 @@ QPair> Gpg::getKeys(QString pattern_uid, bool remote, bo auto result = job->exec(QStringList() << pattern_uid, false, keys); qDebug() << "Got the keys " << pattern_uid; - return QPair>(result.error(), keys); + return QPair> (result.error(), keys); } diff --git a/plugins/Pass/gpg.h b/plugins/Pass/gpg.h index 7b24eee..4f4c349 100644 --- a/plugins/Pass/gpg.h +++ b/plugins/Pass/gpg.h @@ -42,10 +42,10 @@ public: QPair> getAllKeys(bool remote = false, bool include_sigs = {}, bool - validate = false); - QPair> getKeys( QString pattern_uid, bool remote = false, - bool include_sigs = false, - bool validate = false); + validate = false); + QPair> getKeys( QString pattern_uid, bool remote = false, + bool include_sigs = false, + bool validate = false); QPair getKey( QString uid, bool remote = false, bool include_sigs = false, bool validate = false); QPair decrypt( QByteArray cipherText); diff --git a/plugins/Pass/pass.h b/plugins/Pass/pass.h index 0598b90..b592510 100644 --- a/plugins/Pass/pass.h +++ b/plugins/Pass/pass.h @@ -23,7 +23,10 @@ public: Pass(); ~Pass() override = default; - QString password_store() const { return m_password_store; } + QString password_store() const + { + return m_password_store; + } Q_INVOKABLE void init(QObject *window); Q_INVOKABLE void decrypt(QUrl url); diff --git a/plugins/Utils/utils.cpp b/plugins/Utils/utils.cpp index 48acf26..b3c9493 100644 --- a/plugins/Utils/utils.cpp +++ b/plugins/Utils/utils.cpp @@ -29,7 +29,7 @@ bool Utils::unzip(QUrl zip_url, QString dir_out_path) qDebug() << "Guessing if it should remove a single root folder"; QStringList files_in_tmp_dir = tmp_dir.entryList(QDir::AllEntries | QDir::Hidden | - QDir::NoDotAndDotDot); + QDir::NoDotAndDotDot); auto dir_import_path = files_in_tmp_dir.length() == 1 ? diff --git a/qml/Main.qml b/qml/Main.qml index 5c92be5..1f22bcc 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -1,49 +1,46 @@ -import QtQuick 2.4 -import QtQuick.Layouts 1.1 import Lomiri.Components 1.3 import Lomiri.Components.Popups 1.3 import Pass 1.0 +import QtQuick 2.4 +import QtQuick.Layouts 1.1 import "dialogs" MainView { id: root - objectName: "mainView" - applicationName: "utpass.qrouland" - - automaticOrientation: false - - width: units.gu(48) - height: units.gu(80) signal responsePassphraseDialog(bool canceled, string passphrase) function initPass(rootView) { - Pass.init(rootView) + Pass.init(rootView); pageStack.push(Qt.resolvedUrl("pages/PasswordList.qml")); } function callPassphraseDialog(useridHint, description, previousWasBad) { //TODO use parameters to impove passphrase dialog - var passphraseDialog = PopupUtils.open( - Qt.resolvedUrl("dialogs/PassphraseDialog.qml")) - passphraseDialog.activateFocus() - - var validated = function (passphrase) { - responsePassphraseDialog(false, passphrase) - } - - var canceled = function () { - responsePassphraseDialog(true, "") - } - - passphraseDialog.validated.connect(validated) - passphraseDialog.canceled.connect(canceled) + var passphraseDialog = PopupUtils.open(Qt.resolvedUrl("dialogs/PassphraseDialog.qml")); + passphraseDialog.activateFocus(); + var validated = function validated(passphrase) { + responsePassphraseDialog(false, passphrase); + }; + var canceled = function canceled() { + responsePassphraseDialog(true, ""); + }; + passphraseDialog.validated.connect(validated); + passphraseDialog.canceled.connect(canceled); } + objectName: "mainView" + applicationName: "utpass.qrouland" + automaticOrientation: false + width: units.gu(48) + height: units.gu(80) + PageStack { id: pageStack - anchors.fill: parent - Component.onCompleted: {} + anchors.fill: parent + Component.onCompleted: { + } } + } diff --git a/qml/components/CopyText.qml b/qml/components/CopyText.qml index 8d45053..dc1e2f8 100644 --- a/qml/components/CopyText.qml +++ b/qml/components/CopyText.qml @@ -1,11 +1,11 @@ -import QtQuick 2.4 -import Lomiri.Components 1.3 import "../styles" +import Lomiri.Components 1.3 +import QtQuick 2.4 Item { id: copyText - property string text + property string text property bool commonBorder: true property int lBorderwidth: 0 property int rBorderwidth: 0 @@ -39,20 +39,21 @@ Item { MouseArea { anchors.fill: parent onPressed: { - parent.color = LomiriColors.warmGrey + parent.color = LomiriColors.warmGrey; } onClicked: { - var mimeData = Clipboard.newData() - mimeData.text = copyText.text - Clipboard.push(mimeData) + var mimeData = Clipboard.newData(); + mimeData.text = copyText.text; + Clipboard.push(mimeData); } onReleased: { - parent.color = theme.palette.normal.background + parent.color = theme.palette.normal.background; } } CustomBorder { id: cb + commonBorder: copyText.commonBorder lBorderwidth: copyText.lBorderwidth rBorderwidth: copyText.rBorderwidth @@ -60,5 +61,7 @@ Item { bBorderwidth: copyText.bBorderwidth borderColor: copyText.borderColor } + } + } diff --git a/qml/components/ExternalLink.qml b/qml/components/ExternalLink.qml index e1c1533..7de1038 100644 --- a/qml/components/ExternalLink.qml +++ b/qml/components/ExternalLink.qml @@ -1,13 +1,12 @@ -import QtQuick 2.4 -import Lomiri.Components 1.3 import "../styles" +import Lomiri.Components 1.3 +import QtQuick 2.4 Item { id: externalLink property string url property string text - property bool commonBorder: true property int lBorderwidth: 0 property int rBorderwidth: 0 @@ -42,12 +41,13 @@ Item { MouseArea { anchors.fill: parent onClicked: { - Qt.openUrlExternally(externalLink.url) + Qt.openUrlExternally(externalLink.url); } } CustomBorder { id: cb + commonBorder: externalLink.commonBorder lBorderwidth: externalLink.lBorderwidth rBorderwidth: externalLink.rBorderwidth @@ -55,5 +55,7 @@ Item { bBorderwidth: externalLink.bBorderwidth borderColor: externalLink.borderColor } + } + } diff --git a/qml/components/FileDir.qml b/qml/components/FileDir.qml index 8633374..9f637d0 100644 --- a/qml/components/FileDir.qml +++ b/qml/components/FileDir.qml @@ -1,13 +1,14 @@ -import QtQuick 2.4 +import "../dialogs" +import "../styles" import Lomiri.Components 1.3 import Lomiri.Components.Popups 1.3 import Pass 1.0 -import "../styles" -import "../dialogs" +import QtQuick 2.4 Component { Rectangle { id: fileDir + property string activePasswordName anchors.right: parent.right @@ -34,24 +35,20 @@ Component { anchors.fill: parent onClicked: { if (fileIsDir) { - folderModel.folder = folderModel.folder + "/" + fileName - backAction.visible = true + folderModel.folder = folderModel.folder + "/" + fileName; + backAction.visible = true; } else { - fileDir.activePasswordName = fileBaseName - - Pass.onDecrypted.connect(function (text) { - pageStack.push(Qt.resolvedUrl("../pages/Password.qml"), - { - "plainText": text, - "title": fileDir.activePasswordName - }) - }) - - Pass.onDecryptFailed.connect(function () { - PopupUtils.open(passwordPageDecryptError) - }) - - Pass.decrypt(folderModel.folder + "/" + fileName) + fileDir.activePasswordName = fileBaseName; + Pass.onDecrypted.connect(function(text) { + pageStack.push(Qt.resolvedUrl("../pages/Password.qml"), { + "plainText": text, + "title": fileDir.activePasswordName + }); + }); + Pass.onDecryptFailed.connect(function() { + PopupUtils.open(passwordPageDecryptError); + }); + Pass.decrypt(folderModel.folder + "/" + fileName); } } } @@ -67,9 +64,13 @@ Component { Component { id: passwordPageDecryptError + ErrorDialog { textError: i18n.tr("Decryption failed !") } + } + } + } diff --git a/qml/components/PageStackLink.qml b/qml/components/PageStackLink.qml index fa7ce31..1c64cc3 100644 --- a/qml/components/PageStackLink.qml +++ b/qml/components/PageStackLink.qml @@ -1,16 +1,14 @@ -import QtQuick 2.4 -import Lomiri.Components 1.3 import "../styles" +import Lomiri.Components 1.3 +import QtQuick 2.4 Item { id: pageStackLink property string page property var params: { - } property string text - property bool commonBorder: true property int lBorderwidth: 0 property int rBorderwidth: 0 @@ -45,12 +43,13 @@ Item { MouseArea { anchors.fill: parent onClicked: { - pageStack.push(page, params) + pageStack.push(page, params); } } CustomBorder { id: cb + commonBorder: pageStackLink.commonBorder lBorderwidth: pageStackLink.lBorderwidth rBorderwidth: pageStackLink.rBorderwidth @@ -58,5 +57,7 @@ Item { bBorderwidth: pageStackLink.bBorderwidth borderColor: pageStackLink.borderColor } + } + } diff --git a/qml/dialogs/DoubleValidationDialog.qml b/qml/dialogs/DoubleValidationDialog.qml index be39aa2..c673a0f 100644 --- a/qml/dialogs/DoubleValidationDialog.qml +++ b/qml/dialogs/DoubleValidationDialog.qml @@ -1,6 +1,6 @@ -import QtQuick 2.4 import Lomiri.Components 1.3 import Lomiri.Components.Popups 1.3 +import QtQuick 2.4 Dialog { id: doubleValidationDialog @@ -9,8 +9,8 @@ Dialog { property string text1 property string text2 - signal doubleValidated - signal canceled + signal doubleValidated() + signal canceled() Text { visible: nb_validation == 0 @@ -27,26 +27,27 @@ Dialog { Button { text: i18n.tr("Ok") color: LomiriColors.green - onClicked: { if (nb_validation == 1) { - nb_validation = 0 - doubleValidated() - PopupUtils.close(doubleValidationDialog) + nb_validation = 0; + doubleValidated(); + PopupUtils.close(doubleValidationDialog); } else { - nb_validation += 1 + nb_validation += 1; } } } Button { id: cancelButton + text: i18n.tr("Cancel") color: LomiriColors.red onClicked: { - nb_validation = 0 - canceled() - PopupUtils.close(doubleValidationDialog) + nb_validation = 0; + canceled(); + PopupUtils.close(doubleValidationDialog); } } + } diff --git a/qml/dialogs/ErrorDialog.qml b/qml/dialogs/ErrorDialog.qml index eabe3bb..630cd5d 100644 --- a/qml/dialogs/ErrorDialog.qml +++ b/qml/dialogs/ErrorDialog.qml @@ -1,22 +1,24 @@ -import QtQuick 2.4 import Lomiri.Components 1.3 import Lomiri.Components.Popups 1.3 +import QtQuick 2.4 Dialog { id: dialogError property string textError - signal dialogClosed + signal dialogClosed() title: i18n.tr("Error !") text: textError + Button { text: i18n.tr("Close") color: LomiriColors.red - onClicked: function () { - dialogClosed() - PopupUtils.close(dialogError) + onClicked: function() { + dialogClosed(); + PopupUtils.close(dialogError); } } + } diff --git a/qml/dialogs/PassphraseDialog.qml b/qml/dialogs/PassphraseDialog.qml index 7ab3212..f000675 100644 --- a/qml/dialogs/PassphraseDialog.qml +++ b/qml/dialogs/PassphraseDialog.qml @@ -1,25 +1,25 @@ -import QtQuick 2.4 import Lomiri.Components 1.3 import Lomiri.Components.Popups 1.3 +import QtQuick 2.4 Dialog { id: passphraseProvider - title: i18n.tr("Authentication required") - text: i18n.tr("Enter passphrase:") signal validated(string passphrase) - signal canceled + signal canceled() function activateFocus() { - passphraseField.forceActiveFocus() + passphraseField.forceActiveFocus(); } + title: i18n.tr("Authentication required") + text: i18n.tr("Enter passphrase:") + TextField { id: passphraseField placeholderText: i18n.tr("passphrase") echoMode: TextInput.Password - onAccepted: okButton.clicked(text) } @@ -28,23 +28,22 @@ Dialog { text: i18n.tr("Ok") color: LomiriColors.green - onClicked: { - validated(passphraseField.text) - passphraseField.text = "" - PopupUtils.close(passphraseProvider) + validated(passphraseField.text); + passphraseField.text = ""; + PopupUtils.close(passphraseProvider); } } Button { id: cancelButton + text: i18n.tr("Cancel") - color: LomiriColors.red - onClicked: { - canceled() - PopupUtils.close(passphraseProvider) + canceled(); + PopupUtils.close(passphraseProvider); } } + } diff --git a/qml/dialogs/SimpleValidationDialog.qml b/qml/dialogs/SimpleValidationDialog.qml index bb4b56a..f512f35 100644 --- a/qml/dialogs/SimpleValidationDialog.qml +++ b/qml/dialogs/SimpleValidationDialog.qml @@ -1,14 +1,14 @@ -import QtQuick 2.4 import Lomiri.Components 1.3 import Lomiri.Components.Popups 1.3 +import QtQuick 2.4 Dialog { id: doubleValidationDialog property string text - signal validated - signal canceled + signal validated() + signal canceled() Text { horizontalAlignment: Text.AlignHCenter @@ -18,20 +18,21 @@ Dialog { Button { text: i18n.tr("Ok") color: LomiriColors.green - onClicked: { - validated() - PopupUtils.close(doubleValidationDialog) + validated(); + PopupUtils.close(doubleValidationDialog); } } Button { id: cancelButton + text: i18n.tr("Cancel") color: LomiriColors.red onClicked: { - canceled() - PopupUtils.close(doubleValidationDialog) + canceled(); + PopupUtils.close(doubleValidationDialog); } } + } diff --git a/qml/dialogs/SuccessDialog.qml b/qml/dialogs/SuccessDialog.qml index 4898dfd..a46d020 100644 --- a/qml/dialogs/SuccessDialog.qml +++ b/qml/dialogs/SuccessDialog.qml @@ -1,22 +1,24 @@ -import QtQuick 2.4 import Lomiri.Components 1.3 import Lomiri.Components.Popups 1.3 +import QtQuick 2.4 Dialog { id: dialogSuccess property string textSuccess - signal dialogClosed + signal dialogClosed() title: i18n.tr("Success !") text: textSuccess + Button { text: i18n.tr("OK") color: LomiriColors.green - onClicked: function () { - dialogClosed() - PopupUtils.close(dialogSuccess) + onClicked: function() { + dialogClosed(); + PopupUtils.close(dialogSuccess); } } + } diff --git a/qml/pages/Info.qml b/qml/pages/Info.qml index 1273e1a..c9d09ec 100644 --- a/qml/pages/Info.qml +++ b/qml/pages/Info.qml @@ -1,14 +1,19 @@ -import QtQuick 2.4 -import Lomiri.Components 1.3 -import "headers" import "../components" +import Lomiri.Components 1.3 +import QtQuick 2.4 +import "headers" Page { id: infoPage - header: StackHeader { - id: infoHeader - title: i18n.tr('Info') + Component.onCompleted: { + var xhr = new XMLHttpRequest(); + xhr.open("GET", "../../manifest_.json", false); + xhr.send(); + var mJson = JSON.parse(xhr.responseText); + manifestTitle.text = "" + mJson.title + ""; + manifestVersion.text = mJson.version + "
" + mJson.framework + "@" + mJson.architecture; + manifestMaintener.text = mJson.maintainer; } Flow { @@ -24,6 +29,7 @@ Page { Text { id: manifestTitle + horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter width: parent.width @@ -35,12 +41,14 @@ Page { Rectangle { width: parent.width height: units.gu(12) + Image { source: "../../assets/logo.svg" width: units.gu(12) height: units.gu(12) anchors.horizontalCenter: parent.horizontalCenter } + } Text { @@ -54,6 +62,7 @@ Page { Text { id: manifestVersion + horizontalAlignment: Text.AlignHCenter width: parent.width height: units.gu(4) @@ -72,12 +81,14 @@ Page { Text { id: manifestMaintener + horizontalAlignment: Text.AlignHCenter width: parent.width height: units.gu(2) fontSizeMode: Text.Fit font.pixelSize: 72 } + } Flow { @@ -85,14 +96,17 @@ Page { anchors.bottom: parent.bottom anchors.right: parent.right anchors.left: parent.left + ExternalLink { url: "https://github.com/QRouland/UTPass/issues" text: i18n.tr("Suggest improvement(s) or report a bug(s)") } + ExternalLink { url: "https://github.com/QRouland/UTPass" text: i18n.tr("Access to the source code") } + Text { width: parent.width height: units.gu(2) @@ -100,17 +114,13 @@ Page { verticalAlignment: Text.AlignVCenter text: i18n.tr("Released under the terms of the GNU GPL v3") } + } - Component.onCompleted: { - var xhr = new XMLHttpRequest() - xhr.open("GET", "../../manifest_.json", false) - xhr.send() + header: StackHeader { + id: infoHeader - var mJson = JSON.parse(xhr.responseText) - - manifestTitle.text = "" + mJson.title + "" - manifestVersion.text = mJson.version + "
" + mJson.framework + "@" + mJson.architecture - manifestMaintener.text = mJson.maintainer + title: i18n.tr('Info') } + } diff --git a/qml/pages/Password.qml b/qml/pages/Password.qml index 8f78021..78eaa37 100644 --- a/qml/pages/Password.qml +++ b/qml/pages/Password.qml @@ -1,6 +1,6 @@ -import QtQuick 2.4 import Lomiri.Components 1.3 import Lomiri.Components.Popups 1.3 +import QtQuick 2.4 import "headers" Page { @@ -10,38 +10,15 @@ Page { property string plainText property var objects - header: PageHeader { - id: passwordPageHeader - width: parent.width - height: units.gu(6) - title: passwordPage.title - - contents: Item { - height: parent.height - width: parent.width - Label { - id: labelTitle - text: passwordPage.title - anchors.verticalCenter: parent.verticalCenter + Component.onCompleted: { + var text_split = passwordPage.plainText.split('\n'); + var component = Qt.createComponent("../components/CopyText.qml"); + for (var i = 0; i < text_split.length; i++) { + if (text_split[i]) { + var object = component.createObject(container); + object.text = text_split[i]; } } - - leadingActionBar.height: units.gu(4) - leadingActionBar.actions: [ - Action { - id: backAction - iconName: "back" - text: "Back" - onTriggered: { - passwordPage.plainText = "" - for (var object in objects) { - object.text = "" - object.destroy() - } - pageStack.pop() - } - } - ] } Rectangle { @@ -52,18 +29,49 @@ Page { Flow { id: container + anchors.fill: parent } + } - Component.onCompleted: { - var text_split = passwordPage.plainText.split('\n') - var component = Qt.createComponent("../components/CopyText.qml") - for (var i = 0; i < text_split.length; i++) { - if (text_split[i]) { - var object = component.createObject(container) - object.text = text_split[i] + header: PageHeader { + id: passwordPageHeader + + width: parent.width + height: units.gu(6) + title: passwordPage.title + leadingActionBar.height: units.gu(4) + leadingActionBar.actions: [ + Action { + id: backAction + + iconName: "back" + text: "Back" + onTriggered: { + passwordPage.plainText = ""; + for (var object in objects) { + object.text = ""; + object.destroy(); + } + pageStack.pop(); + } } + ] + + contents: Item { + height: parent.height + width: parent.width + + Label { + id: labelTitle + + text: passwordPage.title + anchors.verticalCenter: parent.verticalCenter + } + } + } + } diff --git a/qml/pages/PasswordList.qml b/qml/pages/PasswordList.qml index 83ef4bb..b87cba5 100644 --- a/qml/pages/PasswordList.qml +++ b/qml/pages/PasswordList.qml @@ -1,8 +1,8 @@ -import QtQuick 2.4 -import Lomiri.Components 1.3 -import Qt.labs.folderlistmodel 2.1 -import Pass 1.0 import "../components" +import Lomiri.Components 1.3 +import Pass 1.0 +import Qt.labs.folderlistmodel 2.1 +import QtQuick 2.4 import "headers" Page { @@ -11,25 +11,8 @@ Page { property string passwordStorePath anchors.fill: parent - - header: MainHeader { - id: passwordListHeader - - leadingActionBar.height: units.gu(4) - leadingActionBar.actions: [ - Action { - id: backAction - iconName: "back" - text: i18n.tr("Back") - visible: false - onTriggered: { - folderModel.folder = folderModel.parentFolder - if (folderModel.rootFolder === folderModel.folder) { - backAction.visible = false - } - } - } - ] + Component.onCompleted: { + passwordStorePath = "file:" + Pass.password_store; } Rectangle { @@ -38,13 +21,14 @@ Page { anchors.right: parent.right anchors.left: parent.left visible: folderModel.count == 0 + Text { - text: i18n.tr( - "No password found
You can import a password store zip in the settings") + text: i18n.tr("No password found
You can import a password store zip in the settings") anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter horizontalAlignment: Text.AlignHCenter } + } ListView { @@ -56,17 +40,38 @@ Page { model: FolderListModel { id: folderModel + nameFilters: ["*.gpg"] rootFolder: passwordStorePath folder: passwordStorePath showDirs: true } + delegate: FileDir { id: fileDelegate } + } - Component.onCompleted: { - passwordStorePath = "file:" + Pass.password_store + header: MainHeader { + id: passwordListHeader + + leadingActionBar.height: units.gu(4) + leadingActionBar.actions: [ + Action { + id: backAction + + iconName: "back" + text: i18n.tr("Back") + visible: false + onTriggered: { + folderModel.folder = folderModel.parentFolder; + if (folderModel.rootFolder === folderModel.folder) + backAction.visible = false; + + } + } + ] } + } diff --git a/qml/pages/headers/MainHeader.qml b/qml/pages/headers/MainHeader.qml index 6874a24..4d50fac 100644 --- a/qml/pages/headers/MainHeader.qml +++ b/qml/pages/headers/MainHeader.qml @@ -1,40 +1,15 @@ -import QtQuick 2.4 import Lomiri.Components 1.3 +import QtQuick 2.4 PageHeader { id: mainHeader + width: parent.width height: units.gu(6) title: i18n.tr("UTPass") - - contents: Item { - height: parent.height - width: parent.width - Label { - id: labelTitle - text: mainHeader.title - anchors.verticalCenter: parent.verticalCenter - visible: true - } - TextField { - id: searchBar - anchors.right: parent.right - anchors.left: parent.left - placeholderText: i18n.tr("Search") - height: units.gu(4) - visible: false - anchors.verticalCenter: parent.verticalCenter - onFocusChanged: { - - } - } - } - trailingActionBar.height: units.gu(4) trailingActionBar.numberOfSlots: 2 trailingActionBar.actions: [ - - /*Action { TODO iconName: "search" text: i18n.tr("Search") @@ -50,15 +25,43 @@ PageHeader { iconName: "settings" text: i18n.tr("Settings") onTriggered: { - pageStack.push(Qt.resolvedUrl("../settings/Settings.qml")) + pageStack.push(Qt.resolvedUrl("../settings/Settings.qml")); } }, Action { iconName: "info" text: i18n.tr("Info") onTriggered: { - pageStack.push(Qt.resolvedUrl("../Info.qml")) + pageStack.push(Qt.resolvedUrl("../Info.qml")); } } ] + + contents: Item { + height: parent.height + width: parent.width + + Label { + id: labelTitle + + text: mainHeader.title + anchors.verticalCenter: parent.verticalCenter + visible: true + } + + TextField { + id: searchBar + + anchors.right: parent.right + anchors.left: parent.left + placeholderText: i18n.tr("Search") + height: units.gu(4) + visible: false + anchors.verticalCenter: parent.verticalCenter + onFocusChanged: { + } + } + + } + } diff --git a/qml/pages/headers/StackHeader.qml b/qml/pages/headers/StackHeader.qml index 5395316..0c6f6f4 100644 --- a/qml/pages/headers/StackHeader.qml +++ b/qml/pages/headers/StackHeader.qml @@ -1,31 +1,36 @@ -import QtQuick 2.4 import Lomiri.Components 1.3 +import QtQuick 2.4 PageHeader { id: stackHeader + width: parent.width height: units.gu(6) title: i18n.tr("UTPass") - - contents: Item { - height: parent.height - width: parent.width - Label { - id: labelTitle - text: stackHeader.title - anchors.verticalCenter: parent.verticalCenter - } - } - leadingActionBar.height: units.gu(4) leadingActionBar.actions: [ Action { id: backAction + iconName: "back" text: "Back" onTriggered: { - pageStack.pop() + pageStack.pop(); } } ] + + contents: Item { + height: parent.height + width: parent.width + + Label { + id: labelTitle + + text: stackHeader.title + anchors.verticalCenter: parent.verticalCenter + } + + } + } diff --git a/qml/pages/settings/ImportGitClone.qml b/qml/pages/settings/ImportGitClone.qml index a0bcdd8..3d5c813 100644 --- a/qml/pages/settings/ImportGitClone.qml +++ b/qml/pages/settings/ImportGitClone.qml @@ -1,18 +1,17 @@ -import QtQuick 2.4 -import Lomiri.Components 1.3 -import Lomiri.Components.Popups 1.3 -import Git 1.0 -import Pass 1.0 -import "../headers" import "../../components" import "../../dialogs" +import "../headers" +import Git 1.0 +import Lomiri.Components 1.3 +import Lomiri.Components.Popups 1.3 +import Pass 1.0 +import QtQuick 2.4 Page { id: importGitClonePage - header: StackHeader { - id: importGitCloneHeader - title: i18n.tr('Git Clone Import') + Component.onCompleted: { + PopupUtils.open(importGitCloneValidation, importGitClonePage); } Flow { @@ -30,6 +29,7 @@ Page { Text { id: repoUrlLabe + horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter width: parent.width @@ -38,6 +38,7 @@ Page { TextField { id: textFieldInput + horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter width: parent.width @@ -46,51 +47,58 @@ Page { Button { id: buttonAdd + width: parent.width text: i18n.tr('Clone') onClicked: { - var ret = Git.clone(textFieldInput.text, Pass.password_store) - if(ret) { - PopupUtils.open(dialogImportGitCloneSuccess) - } else { - PopupUtils.open(importGitCloneError, importGitClonePage) - } - - + var ret = Git.clone(textFieldInput.text, Pass.password_store); + if (ret) + PopupUtils.open(dialogImportGitCloneSuccess); + else + PopupUtils.open(importGitCloneError, importGitClonePage); } } + } Component { - id: importGitCloneValidation - SimpleValidationDialog { - text: i18n.tr( - "Importing a git repo will delete
any existing password store!
Continue ?") - onCanceled: { - pageStack.pop() - } - } + id: importGitCloneValidation + + SimpleValidationDialog { + text: i18n.tr("Importing a git repo will delete
any existing password store!
Continue ?") + onCanceled: { + pageStack.pop(); + } + } + } Component { - id: importGitCloneError + id: importGitCloneError + ErrorDialog { textError: i18n.tr("An error occured during git clone !") } + } Component { id: dialogImportGitCloneSuccess + SuccessDialog { textSuccess: i18n.tr("Password store sucessfully imported !") onDialogClosed: { - pageStack.pop() - pageStack.pop() + pageStack.pop(); + pageStack.pop(); } } + } - Component.onCompleted: { - PopupUtils.open(importGitCloneValidation, importGitClonePage) + header: StackHeader { + id: importGitCloneHeader + + title: i18n.tr('Git Clone Import') } + } diff --git a/qml/pages/settings/ImportKeyFile.qml b/qml/pages/settings/ImportKeyFile.qml index b545896..89d58e0 100644 --- a/qml/pages/settings/ImportKeyFile.qml +++ b/qml/pages/settings/ImportKeyFile.qml @@ -1,82 +1,80 @@ -import QtQuick 2.4 -import Lomiri.Components 1.3 -import Lomiri.Content 1.3 -import Lomiri.Components.Popups 1.3 -import Pass 1.0 -import Utils 1.0 -import "../headers" import "../../dialogs" +import "../headers" +import Lomiri.Components 1.3 +import Lomiri.Components.Popups 1.3 +import Lomiri.Content 1.3 +import Pass 1.0 +import QtQuick 2.4 +import Utils 1.0 Page { id: importKeyFilePage property var activeTransfer - header: StackHeader { - id: importKeyHeader - title: i18n.tr("GPG Key Import") - } - ContentPeerPicker { anchors.top: importKeyHeader.bottom anchors.bottom: parent.bottom anchors.topMargin: importKeyFilePage.header.height - width: parent.width - visible: parent.visible showTitle: false contentType: ContentType.Text handler: ContentHandler.Source - onPeerSelected: { - peer.selectionType = ContentTransfer.Single - importKeyFilePage.activeTransfer = peer.request() - - importKeyFilePage.activeTransfer.stateChanged.connect(function () { + peer.selectionType = ContentTransfer.Single; + importKeyFilePage.activeTransfer = peer.request(); + importKeyFilePage.activeTransfer.stateChanged.connect(function() { if (importKeyFilePage.activeTransfer.state === ContentTransfer.Charged) { - console.log("Charged") - console.log(importKeyFilePage.activeTransfer.items[0].url) - - var status = Pass.gpgImportKeyFromFile( - importKeyFilePage.activeTransfer.items[0].url) - - Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url) - if (status) { - PopupUtils.open(dialogImportKeyPageSucess) - } else { - PopupUtils.open(dialogImportKeyPageError) - } - importKeyFilePage.activeTransfer = null + console.log("Charged"); + console.log(importKeyFilePage.activeTransfer.items[0].url); + var status = Pass.gpgImportKeyFromFile(importKeyFilePage.activeTransfer.items[0].url); + Utils.rmFile(importKeyFilePage.activeTransfer.items[0].url); + if (status) + PopupUtils.open(dialogImportKeyPageSucess); + else + PopupUtils.open(dialogImportKeyPageError); + importKeyFilePage.activeTransfer = null; } - }) + }); } - onCancelPressed: { - pageStack.pop() + pageStack.pop(); } } ContentTransferHint { id: transferHint + anchors.fill: parent activeTransfer: importKeyFilePage.activeTransfer } Component { id: dialogImportKeyPageError + ErrorDialog { textError: i18n.tr("Key import failed !") } + } Component { id: dialogImportKeyPageSucess + SuccessDialog { textSuccess: i18n.tr("Key successfully imported !") onDialogClosed: { - pageStack.pop() + pageStack.pop(); } } + } + + header: StackHeader { + id: importKeyHeader + + title: i18n.tr("GPG Key Import") + } + } diff --git a/qml/pages/settings/ImportZip.qml b/qml/pages/settings/ImportZip.qml index 812406f..8ca8836 100644 --- a/qml/pages/settings/ImportZip.qml +++ b/qml/pages/settings/ImportZip.qml @@ -1,100 +1,97 @@ -import QtQuick 2.4 -import Lomiri.Components 1.3 -import Lomiri.Content 1.3 -import Lomiri.Components.Popups 1.3 -import Pass 1.0 -import Utils 1.0 -import "../headers" import "../../dialogs" +import "../headers" +import Lomiri.Components 1.3 +import Lomiri.Components.Popups 1.3 +import Lomiri.Content 1.3 +import Pass 1.0 +import QtQuick 2.4 +import Utils 1.0 Page { id: importZipPage property var activeTransfer - header: StackHeader { - id: importZipHeader - title: i18n.tr("Zip Password Store Import") + Component.onCompleted: { + PopupUtils.open(importZipPageImportValidation, importZipPage); } ContentPeerPicker { anchors.top: importZipHeader.bottom anchors.bottom: parent.bottom anchors.topMargin: importZipPage.header.height - width: parent.width - visible: parent.visible showTitle: false contentType: ContentType.Text handler: ContentHandler.Source - onPeerSelected: { - peer.selectionType = ContentTransfer.Single - importZipPage.activeTransfer = peer.request() - - importZipPage.activeTransfer.stateChanged.connect(function () { + peer.selectionType = ContentTransfer.Single; + importZipPage.activeTransfer = peer.request(); + importZipPage.activeTransfer.stateChanged.connect(function() { if (importZipPage.activeTransfer.state === ContentTransfer.Charged) { - console.log("Charged") - console.log(importZipPage.activeTransfer.items[0].url) - - var status = Utils.unzip( - importZipPage.activeTransfer.items[0].url, - Pass.getPasswordStore()) - - Utils.rmFile(importZipPage.activeTransfer.items[0].url) - - if (status) { - PopupUtils.open(dialogImportZipPageSuccess) - } else { - PopupUtils.open(dialogImportZipPageError) - } - importZipPage.activeTransfer = null + console.log("Charged"); + console.log(importZipPage.activeTransfer.items[0].url); + var status = Utils.unzip(importZipPage.activeTransfer.items[0].url, Pass.getPasswordStore()); + Utils.rmFile(importZipPage.activeTransfer.items[0].url); + if (status) + PopupUtils.open(dialogImportZipPageSuccess); + else + PopupUtils.open(dialogImportZipPageError); + importZipPage.activeTransfer = null; } - }) + }); } - onCancelPressed: { - pageStack.pop() + pageStack.pop(); } } ContentTransferHint { id: transferHint + anchors.fill: parent activeTransfer: importZipPage.activeTransfer } Component { id: importZipPageImportValidation + SimpleValidationDialog { - text: i18n.tr( - "Importing a new zip will delete
any existing password store!
Continue ?") + text: i18n.tr("Importing a new zip will delete
any existing password store!
Continue ?") onCanceled: { - pageStack.pop() + pageStack.pop(); } } + } Component { id: dialogImportZipPageError + ErrorDialog { textError: i18n.tr("Password store import failed !") } + } Component { id: dialogImportZipPageSuccess + SuccessDialog { textSuccess: i18n.tr("Password store sucessfully imported !") onDialogClosed: { - pageStack.pop() - pageStack.pop() + pageStack.pop(); + pageStack.pop(); } } + } - Component.onCompleted: { - PopupUtils.open(importZipPageImportValidation, importZipPage) + header: StackHeader { + id: importZipHeader + + title: i18n.tr("Zip Password Store Import") } + } diff --git a/qml/pages/settings/InfoKeys.qml b/qml/pages/settings/InfoKeys.qml index 237420c..95a4e99 100644 --- a/qml/pages/settings/InfoKeys.qml +++ b/qml/pages/settings/InfoKeys.qml @@ -1,28 +1,23 @@ -import QtQuick 2.4 +import "../../components" +import "../../dialogs" +import "../headers" import Lomiri.Components 1.3 import Lomiri.Components.Popups 1.3 import Pass 1.0 -import "../headers" -import "../../components" -import "../../dialogs" +import QtQuick 2.4 Page { id: infoKeysPage property string currentKey - header: StackHeader { - id: infoKeysHeader - title: i18n.tr('Info Keys') - } - ListView { id: infoKeysListView + anchors.top: infoKeysHeader.bottom anchors.bottom: parent.bottom anchors.right: parent.right anchors.left: parent.left - model: Pass.gpgGetAllKeysModel() delegate: Grid { @@ -38,6 +33,7 @@ Page { Text { id: uidKey + width: parent.width horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -46,11 +42,12 @@ Page { Button { id: buttonDeleteKey + text: i18n.tr("Delete this key") color: LomiriColors.red onClicked: { - infoKeysPage.currentKey = model.modelData.uid - PopupUtils.open(infoKeysPageDeleteValidation, infoKeysPage) + infoKeysPage.currentKey = model.modelData.uid; + PopupUtils.open(infoKeysPageDeleteValidation, infoKeysPage); } } @@ -58,43 +55,53 @@ Page { width: parent.width height: units.gu(1) } + } + } Component { id: infoKeysPageDeleteValidation + DoubleValidationDialog { - text1: i18n.tr( - "You're are about to delete
%1
Continue ?").arg( - infoKeysPage.currentKey) - text2: i18n.tr( - "%1
will be definitively removed.
Continue ?").arg( - infoKeysPage.currentKey) + text1: i18n.tr("You're are about to delete
%1
Continue ?").arg(infoKeysPage.currentKey) + text2: i18n.tr("%1
will be definitively removed.
Continue ?").arg(infoKeysPage.currentKey) onDoubleValidated: { - var status = Pass.gpgDeleteKeyId(infoKeysPage.currentKey) - if (status) { - PopupUtils.open(infoKeysPageDeleteSuccess) - } else { - PopupUtils.open(infoKeysPageDeleteError) - } + var status = Pass.gpgDeleteKeyId(infoKeysPage.currentKey); + if (status) + PopupUtils.open(infoKeysPageDeleteSuccess); + else + PopupUtils.open(infoKeysPageDeleteError); } } + } Component { id: infoKeysPageDeleteError + ErrorDialog { textError: i18n.tr("Key removal failed !") } + } Component { id: infoKeysPageDeleteSuccess + SuccessDialog { textSuccess: i18n.tr("Key successfully deleted !") onDialogClosed: { - infoKeysListView.model = Pass.gpgGetAllKeysModel() + infoKeysListView.model = Pass.gpgGetAllKeysModel(); } } + } + + header: StackHeader { + id: infoKeysHeader + + title: i18n.tr('Info Keys') + } + } diff --git a/qml/pages/settings/Settings.qml b/qml/pages/settings/Settings.qml index 20f789c..dc45af5 100644 --- a/qml/pages/settings/Settings.qml +++ b/qml/pages/settings/Settings.qml @@ -1,19 +1,14 @@ -import QtQuick 2.4 +import "../../components" +import "../headers" import Lomiri.Components 1.3 import Pass 1.0 -import "../headers" -import "../../components" +import QtQuick 2.4 Page { id: settingsPage property string gpgKeyId: "" - header: StackHeader { - id: settingsHeader - title: i18n.tr('Settings') - } - Flow { anchors.top: settingsHeader.bottom anchors.bottom: parent.bottom @@ -27,14 +22,17 @@ Page { height: units.gu(4) text: i18n.tr('GPG') } + PageStackLink { page: Qt.resolvedUrl("ImportKeyFile.qml") text: i18n.tr('Import a GPG key file') } + PageStackLink { page: Qt.resolvedUrl("InfoKeys.qml") text: i18n.tr('Show GPG keys') } + Text { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -42,22 +40,32 @@ Page { height: units.gu(4) text: i18n.tr('Password Store') } + PageStackLink { page: Qt.resolvedUrl("ImportGitClone.qml") text: i18n.tr('Import a Password Store using Git') } + PageStackLink { page: Qt.resolvedUrl("ImportZip.qml") text: i18n.tr('Import a Password Store Zip') } + Text { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter width: parent.width height: units.gu(4) color: LomiriColors.red - text: i18n.tr( - 'Warning: importing delete any exiting Password Store') + text: i18n.tr('Warning: importing delete any exiting Password Store') } + } + + header: StackHeader { + id: settingsHeader + + title: i18n.tr('Settings') + } + } diff --git a/qml/styles/CustomBorder.qml b/qml/styles/CustomBorder.qml index 96f7921..88c5775 100644 --- a/qml/styles/CustomBorder.qml +++ b/qml/styles/CustomBorder.qml @@ -4,18 +4,14 @@ import QtQuick 2.4 Rectangle { property bool commonBorder: true - property int lBorderwidth: 1 property int rBorderwidth: 1 property int tBorderwidth: 1 property int bBorderwidth: 1 - property int commonBorderWidth: 1 - - z: -1 - property string borderColor: "white" + z: -1 color: borderColor anchors { @@ -23,10 +19,10 @@ Rectangle { right: parent.right top: parent.top bottom: parent.bottom - topMargin: commonBorder ? -commonBorderWidth : -tBorderwidth bottomMargin: commonBorder ? -commonBorderWidth : -bBorderwidth leftMargin: commonBorder ? -commonBorderWidth : -lBorderwidth rightMargin: commonBorder ? -commonBorderWidth : -rBorderwidth } + }