-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
executable file
·180 lines (140 loc) · 5.31 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import Qt.labs.platform 1.0
import QtQuick.Dialogs 1.2
import QtQuick.Window 2.0
import QtWebSockets 1.1
import PasswordListModel 1.0
ApplicationWindow {
id: applicationWindow
visible: false
title: "Passwords manager"
//anchors.fill: parent
SystemTrayIcon {
visible: true
iconSource: "qrc:/images/key-icon.png"
menu: Menu {
MenuItem {
text: qsTr("Quit")
onTriggered: Qt.quit()
}
}
onActivated: {
if(reason !== SystemTrayIcon.Context) {
applicationWindow.show()
applicationWindow.raise()
applicationWindow.requestActivate()
}
}
}
Connections {
target: applicationWindow
onClosing: {
console.log('onClosing');
if (sOSType != "Mobile") {
applicationWindow.hide();
close.accepted = false
console.log('onClosing', close.accepted);
}
}
onVisibilityChanged: {
console.log("onVisibilityChanged", applicationWindow.visibility, applicationWindow.visible);
}
}
onXChanged: {
oSettingsModel.fnUpdateStringValue("applicationWindow.x", applicationWindow.x);
oSettingsModel.fnSave();
}
onYChanged: {
oSettingsModel.fnUpdateStringValue("applicationWindow.y", applicationWindow.y);
oSettingsModel.fnSave();
}
function fnStart()
{
console.log('fnStart');
stackView.oExportFilesListModel = oExportFilesListModel;
stackView.oImportFilesListModel = oImportFilesListModel;
applicationWindow.visible = sOSType == "Mobile";
if (sOSType != "Mobile") {
applicationWindow.setWidth(640);
applicationWindow.setHeight(480);
}
console.log('Set window position: ', oSettingsModel.fnGetStringValue("applicationWindow.x"), oSettingsModel.fnGetStringValue("applicationWindow.y"));
applicationWindow.setX(oSettingsModel.fnGetStringValue("applicationWindow.x"));
applicationWindow.setY(oSettingsModel.fnGetStringValue("applicationWindow.y"));
if (!oPasswordListModel.fnFileExists()) {
stackView.masterPasswordEnterPageStatusLabelText = "File with passwords not found.<br> Will be created new.";
}
}
PasswordSyncServer { id: passwordSyncServer }
Timer {
id: connectionTimeout;
repeat: false;
interval: 1000;
onTriggered: {
connectionTimeout.stop();
passwordSyncClient.sStatus = "Error";
if (passwordSyncClient.fnErrorCallBack)
passwordSyncClient.fnErrorCallBack("Client error: "+passwordSyncClient.sHost+":"+passwordSyncClient.sPort+" - connection timeout");
}
}
PasswordSyncClient { id: passwordSyncClient }
Keys.onReleased: {
console.log("Keys.onReleased", event.key);
if (event.key == Qt.Key_Back) {
console.log("Back button captured - wunderbar !")
event.accepted = true
quit();
}
}
StackView {
id: stackView
initialItem: masterPasswordEnterPage
anchors.fill: parent
property var oExportFilesListModel
property var oImportFilesListModel
property var oPasswordsListViewModel
property var oServersListViewModel
property var oPasswordsChangeHistoryListViewModel
property int iHistroyRecordIndex
property int iEditedRecordIndex
property bool bPasswordsListIsNewItem: false
property string sName: ""
property string sUser: ""
property string sPassword: ""
property string sAdditional: ""
property bool settingsPageSynchronizeOnUpdate
property bool settingsPageShowIdInList
property bool settingsPageShowUserInList
property bool settingsPageShowPasswordInList
property bool settingsPageShowCreatedAtInList
property bool settingsPageShowUpdatedAtInList
property var settingsPageStyleModel
property int settingsPageStyleCurrentIndex
property string settingsPageServerHostText
property string settingsPageServerPortText
property string settingsPageServerStatusLabelText
property string syncPageServerIP
property string syncPageSyncMethod
property string changePasswordPageOldPasswordText: ""
property string changePasswordPageNewPasswordText: ""
property string masterPasswordEnterPageStatusLabelText: ""
focus: true
onCurrentItemChanged: {
if (currentItem && currentItem.defaultFocusItem) {
currentItem.defaultFocusItem.focus = true
}
}
MasterPasswordEnterPage { id: masterPasswordEnterPage }
PasswordsListViewPage { id: passwordsListViewPage }
ExportPage { id: exportPage }
ImportPage { id: importPage }
PasswordsChangeHistoryPage { id: passwordsChangeHistoryPage }
PasswordEditPage { id: passwordEditPage }
SettingsPage { id: settingsPage }
SyncPage { id: syncPage }
ServersListViewPage { id: serversListViewPage }
ChangePasswordPage { id: changePasswordPage }
}
}