mirror of
https://github.com/QRouland/UTPass.git
synced 2025-06-24 22:42:28 +00:00
Refactor cloning feature and ui
This commit is contained in:
@ -2,13 +2,14 @@ import "../components"
|
||||
import Lomiri.Components 1.3
|
||||
import QtQuick 2.4
|
||||
import "headers"
|
||||
import Utils 1.0
|
||||
|
||||
Page {
|
||||
id: infoPage
|
||||
|
||||
Component.onCompleted: {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "../../manifest_.json", false);
|
||||
xhr.open("GET", Utils.manifestPath(), false);
|
||||
xhr.send();
|
||||
var mJson = JSON.parse(xhr.responseText);
|
||||
manifestTitle.text = "<b>" + mJson.title + "</b>";
|
||||
|
@ -1,128 +0,0 @@
|
||||
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
|
||||
|
||||
Component.onCompleted: {
|
||||
PopupUtils.open(importGitCloneValidation, importGitClonePage);
|
||||
}
|
||||
|
||||
Flow {
|
||||
anchors.top: importGitCloneHeader.bottom
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: units.gu(2)
|
||||
anchors.rightMargin: units.gu(2)
|
||||
spacing: units.gu(1)
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: units.gu(1)
|
||||
}
|
||||
|
||||
Text {
|
||||
id: repoUrlLabel
|
||||
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
width: parent.width
|
||||
text: i18n.tr('Repo Url')
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: repoUrlInput
|
||||
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
Text {
|
||||
id: repoPasswordLabel
|
||||
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
width: parent.width
|
||||
text: i18n.tr('Password')
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: repoPasswordInput
|
||||
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
width: parent.width
|
||||
echoMode: TextInput.Password
|
||||
}
|
||||
|
||||
Button {
|
||||
id: buttonAdd
|
||||
|
||||
width: parent.width
|
||||
color: theme.palette.normal.positive
|
||||
text: i18n.tr('Clone')
|
||||
onClicked: {
|
||||
var ret = false;
|
||||
if (repoPasswordInput.text === "")
|
||||
ret = Git.clone_http(repoUrlInput.text, Pass.password_store);
|
||||
else
|
||||
ret = Git.clone_http_pass(repoUrlInput.text, Pass.password_store, repoPasswordInput.text);
|
||||
if (ret)
|
||||
PopupUtils.open(dialogImportGitCloneSuccess);
|
||||
else
|
||||
PopupUtils.open(importGitCloneError, importGitClonePage);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Component {
|
||||
id: importGitCloneValidation
|
||||
|
||||
SimpleValidationDialog {
|
||||
text: i18n.tr("Importing a git repo will delete<br>any existing password store!<br>Continue ?")
|
||||
continueText: i18n.tr("Yes")
|
||||
continueColor: theme.palette.normal.negative
|
||||
onCanceled: {
|
||||
pageStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Component {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header: StackHeader {
|
||||
id: importGitCloneHeader
|
||||
|
||||
title: i18n.tr('Git Clone Import')
|
||||
}
|
||||
|
||||
}
|
@ -44,7 +44,7 @@ Page {
|
||||
}
|
||||
|
||||
PageStackLink {
|
||||
page: Qt.resolvedUrl("ImportGitClone.qml")
|
||||
page: Qt.resolvedUrl("git/ImportGitClone.qml")
|
||||
text: i18n.tr('Import a Password Store using Git')
|
||||
}
|
||||
|
||||
|
38
qml/pages/settings/git/GitCloneHttp.qml
Normal file
38
qml/pages/settings/git/GitCloneHttp.qml
Normal file
@ -0,0 +1,38 @@
|
||||
import QtQuick 2.4
|
||||
import Git 1.0
|
||||
import Lomiri.Components 1.3
|
||||
import Pass 1.0
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: units.gu(1)
|
||||
|
||||
Text {
|
||||
id: repoUrlLabel
|
||||
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
width: parent.width
|
||||
text: i18n.tr('Repo Url')
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: repoUrlInput
|
||||
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
Button {
|
||||
id: buttonClone
|
||||
|
||||
width: parent.width
|
||||
color: theme.palette.normal.positive
|
||||
text: i18n.tr('Clone')
|
||||
onClicked: {
|
||||
Git.cloneHttp(repoUrlInput.text, Pass.password_store);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
56
qml/pages/settings/git/GitCloneHttpAuth.qml
Normal file
56
qml/pages/settings/git/GitCloneHttpAuth.qml
Normal file
@ -0,0 +1,56 @@
|
||||
import QtQuick 2.4
|
||||
import Git 1.0
|
||||
import Lomiri.Components 1.3
|
||||
import Pass 1.0
|
||||
|
||||
Column {
|
||||
anchors.top: parent.fill
|
||||
spacing: units.gu(1)
|
||||
|
||||
Text {
|
||||
id: repoUrlLabel
|
||||
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
width: parent.width
|
||||
text: i18n.tr('Repo Url')
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: repoUrlInput
|
||||
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
Text {
|
||||
id: repoPasswordLabel
|
||||
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
width: parent.width
|
||||
text: i18n.tr('Password')
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: repoPasswordInput
|
||||
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
width: parent.width
|
||||
echoMode: TextInput.Password
|
||||
}
|
||||
|
||||
Button {
|
||||
id: buttonClone
|
||||
|
||||
width: parent.width
|
||||
color: theme.palette.normal.positive
|
||||
text: i18n.tr('Clone')
|
||||
onClicked: {
|
||||
Git.cloneHttpPass(repoUrlInput.text, Pass.password_store, repoPasswordInput.text);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
31
qml/pages/settings/git/GitModeOptionSelector.qml
Normal file
31
qml/pages/settings/git/GitModeOptionSelector.qml
Normal file
@ -0,0 +1,31 @@
|
||||
import QtQuick 2.4
|
||||
import Git 1.0
|
||||
import Lomiri.Components 1.3
|
||||
import Lomiri.Components.Pickers 1.3
|
||||
|
||||
OptionSelector {
|
||||
id: combo
|
||||
width : parent.width
|
||||
model: ["HTTP", "HTTP AUTH"]
|
||||
onDelegateClicked: function(i) {
|
||||
if(i===0) {
|
||||
timer.setTimeout(function(){importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttp.qml") }, 500);
|
||||
} else if (i===1) {
|
||||
timer.setTimeout( function(){importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttpAuth.qml") }, 500);
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: timer
|
||||
function setTimeout(cb, delayTime) {
|
||||
timer.interval = delayTime;
|
||||
timer.repeat = false;
|
||||
timer.triggered.connect(cb);
|
||||
timer.triggered.connect(function release () {
|
||||
timer.triggered.disconnect(cb); // This is important
|
||||
timer.triggered.disconnect(release); // This is important as well
|
||||
});
|
||||
timer.start();
|
||||
}
|
||||
}
|
||||
}
|
91
qml/pages/settings/git/ImportGitClone.qml
Normal file
91
qml/pages/settings/git/ImportGitClone.qml
Normal file
@ -0,0 +1,91 @@
|
||||
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
|
||||
|
||||
Component.onCompleted: {
|
||||
Git.onCloneSucceed.connect(function() {
|
||||
PopupUtils.open(dialogGitCloneSuccess);
|
||||
});
|
||||
Git.onCloneFailed.connect(function() {
|
||||
PopupUtils.open(dialogGitCloneError);
|
||||
});
|
||||
PopupUtils.open(importGitCloneValidation, importGitClonePage);
|
||||
importGitCloneForm.source = Qt.resolvedUrl("GitCloneHttp.qml")
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.top: importGitCloneHeader.bottom
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.leftMargin: units.gu(2)
|
||||
anchors.rightMargin: units.gu(2)
|
||||
spacing: units.gu(1)
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: units.gu(1)
|
||||
}
|
||||
|
||||
GitModeOptionSelector {
|
||||
id: combo
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: importGitCloneForm
|
||||
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: importGitCloneValidation
|
||||
|
||||
SimpleValidationDialog {
|
||||
text: i18n.tr("Importing a git repo will delete<br>any existing password store!<br>Continue ?")
|
||||
continueText: i18n.tr("Yes")
|
||||
continueColor: theme.palette.normal.negative
|
||||
onCanceled: {
|
||||
pageStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Component {
|
||||
id: dialogGitCloneError
|
||||
|
||||
ErrorDialog {
|
||||
textError: i18n.tr("An error occured during git clone !")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Component {
|
||||
id: dialogGitCloneSuccess
|
||||
|
||||
SuccessDialog {
|
||||
textSuccess: i18n.tr("Password store sucessfully imported !")
|
||||
onDialogClosed: {
|
||||
pageStack.pop();
|
||||
pageStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
header: StackHeader {
|
||||
id: importGitCloneHeader
|
||||
|
||||
title: i18n.tr('Git Clone Import')
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user