diff options
| author | Andreas Grois <andi@grois.info> | 2022-10-10 21:30:02 +0200 |
|---|---|---|
| committer | Andreas Grois <andi@grois.info> | 2022-10-10 21:37:15 +0200 |
| commit | e4ad766315879e1ff05bb111229f073f8f0ed68e (patch) | |
| tree | 4b043ff47c78b2c00c80c94ebda622c32c8b6d3d /qml/pages/ProfilesPage.qml | |
PassFish: Initial Commit
Well, that's a lie. But nobody needs to see all the iterations I decided
to sweep under the rug.
That said, I think the repo is, while not clean, clean enough now, to
not be embarrassed by uploading it to github.
Diffstat (limited to 'qml/pages/ProfilesPage.qml')
| -rw-r--r-- | qml/pages/ProfilesPage.qml | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/qml/pages/ProfilesPage.qml b/qml/pages/ProfilesPage.qml new file mode 100644 index 0000000..a2df8af --- /dev/null +++ b/qml/pages/ProfilesPage.qml @@ -0,0 +1,129 @@ +import QtQuick 2.6 +import Sailfish.Silica 1.0 +import "../components" + +Page { + id: profilesSelector + SilicaListView { + id : profilesView + anchors.fill: parent + model : passwordmaker.profiles + + function store_profile_with_error_message() { + var worked = profilesView.model.store(); + if(!worked) { + storeFailureNotice.show(); + } + } + + PullDownMenu { + MenuItem { + text: qsTr("Add Profile") + onClicked: { + profilesView.model.insertRows(profilesView.model.rowCount(),1); + profilesView.store_profile_with_error_message(); + } + } + } + header: PageHeader { + title: qsTr("Select/Edit Profiles") + } + delegate: ListItem { + id: delegate + width: parent.width + ListView.onAdd: AddAnimation { + target: delegate + } + ListView.onRemove: RemoveAnimation { + target: delegate + } + Label { + x: Theme.horizontalPageMargin + text: name + anchors.verticalCenter: parent.verticalCenter + color: index === profilesView.model.current_profile ? Theme.highlightColor : Theme.primaryColor + } + menu: ContextMenu { + MenuItem { + text: qsTr("Edit") + onClicked: { + var pg = pageStack.animatorPush(Qt.resolvedUrl("ProfileEditor.qml"), + { + profileName : name, + useProtocol : use_protocol, + useSubdomain : use_subdomains, + useDomain : use_domain, + usePortPath : use_port_path, + passwordLength : password_length, + hashAlgorithm : hash_algorithm, + useLeet : use_leet, + leetLevel : leet_level > 0 ? leet_level : 1, + characters : characters, + username : username, + modifier : modifier, + prefix : prefix, + suffix : suffix, + useUserInfo : use_user_info, + useDefaultFallbackForProtocol : use_undefined_as_protocol_fallback + }); + pg.pageCompleted.connect(function(pg) { + pg.accepted.connect(function() { + name = pg.profileName; + use_protocol = pg.useProtocol; + use_subdomains = pg.useSubdomain; + use_domain = pg.useDomain; + use_port_path = pg.usePortPath; + password_length = pg.passwordLength; + hash_algorithm = pg.hashAlgorithm; + use_leet = pg.useLeet; + leet_level = pg.leetLevel; + characters = pg.characters; + username = pg.username; + modifier = pg.modifier; + prefix = pg.prefix; + suffix = pg.suffix; + use_user_info = pg.useUserInfo; + use_undefined_as_protocol_fallback = pg.useDefaultFallbackForProtocol; + + if(index === profilesView.model.current_profile) + passwordmaker.profile_changed(); + + profilesView.store_profile_with_error_message(); + }) + }) + } + } + MenuItem { + text: qsTr("Remove") + enabled: profilesView.count > 1 + onClicked: { + delegate.remorseDelete(function() { + var bWasCurrentProfile = index === profilesView.model.current_profile; + + profilesView.model.removeRows(index,1); + profilesView.store_profile_with_error_message(); + + if(bWasCurrentProfile) + passwordmaker.profile_changed(); + }) + } + } + } + onClicked: { + if(profilesView.model.current_profile !== index) + { + profilesView.model.current_profile = index; + passwordmaker.profile_changed(); + } + pageContainer.navigateBack(PageStackAction.Animated); + } + } + NoticeOptional { + id: storeFailureNotice + text: qsTr("Saving profiles failed.") + useNotificationFallback: true + } + + VerticalScrollDecorator {} + } +} |
