ruby-pass-qt 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/pass-qt/app/components/passinfowidget.rb +188 -190
- data/lib/pass-qt/app/components/passlistwidget/treewidget.rb +190 -192
- data/lib/pass-qt/app/components/passlistwidget.rb +68 -70
- data/lib/pass-qt/app/views/browsestoresdialog.rb +85 -87
- data/lib/pass-qt/app/views/mainwindow.rb +76 -78
- data/lib/pass-qt/app/views/newonetimepassworddialog.rb +108 -110
- data/lib/pass-qt/app/views/newpassworddialog.rb +141 -143
- data/lib/pass-qt/config.rb +0 -1
- data/lib/pass-qt/version.rb +1 -1
- metadata +1 -1
|
@@ -1,169 +1,167 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def initialize(store, folder, on_success:)
|
|
10
|
-
super()
|
|
11
|
-
|
|
12
|
-
@store = store
|
|
13
|
-
@folder = folder
|
|
14
|
-
@on_success = on_success
|
|
15
|
-
|
|
16
|
-
initialize_form
|
|
17
|
-
initialize_btngroup
|
|
18
|
-
|
|
19
|
-
mainlayout = QVBoxLayout.new(self)
|
|
20
|
-
mainlayout.add_widget(@form)
|
|
21
|
-
mainlayout.add_widget(@btngroup)
|
|
1
|
+
class NewPasswordDialog < RubyQt6::Bando::QDialog
|
|
2
|
+
q_object do
|
|
3
|
+
slot "_on_okbutton_clicked()"
|
|
4
|
+
slot "_on_cancelbutton_clicked()"
|
|
5
|
+
slot "_on_view_action_triggered()"
|
|
6
|
+
end
|
|
22
7
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
end
|
|
8
|
+
def initialize(store, folder, on_success:)
|
|
9
|
+
super()
|
|
26
10
|
|
|
27
|
-
|
|
11
|
+
@store = store
|
|
12
|
+
@folder = folder
|
|
13
|
+
@on_success = on_success
|
|
28
14
|
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
initialize_form
|
|
16
|
+
initialize_btngroup
|
|
31
17
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
mainlayout = QVBoxLayout.new(self)
|
|
19
|
+
mainlayout.add_widget(@form)
|
|
20
|
+
mainlayout.add_widget(@btngroup)
|
|
35
21
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
set_focus_proxy(@passnameinput)
|
|
40
|
-
|
|
41
|
-
@passwordlabel = initialize_form_label("Password")
|
|
42
|
-
@passwordinput = initialize_form_inputfield("")
|
|
43
|
-
initialize_form_inputfield_viewaction(@passwordinput)
|
|
44
|
-
|
|
45
|
-
@passwordinput.set_echo_mode(QLineEdit::Password)
|
|
46
|
-
Pass.pwgen(16, on_success: ->(data) {
|
|
47
|
-
@passwordinput.set_text(data["stdout"].lines[0].strip)
|
|
48
|
-
}, on_failure: ->(_) {})
|
|
49
|
-
|
|
50
|
-
@usernamelabel = initialize_form_label("Username")
|
|
51
|
-
@usernameinput = initialize_form_inputfield("johndoe")
|
|
52
|
-
|
|
53
|
-
@websitelabel = initialize_form_label("Website")
|
|
54
|
-
@websiteinput = initialize_form_inputfield("https://github.com/login")
|
|
55
|
-
|
|
56
|
-
@form = QWidget.new
|
|
57
|
-
@form.set_object_name("newpassworddialog_form")
|
|
58
|
-
@form.set_style_sheet("
|
|
59
|
-
#newpassworddialog_form {
|
|
60
|
-
min-width: 600px;
|
|
61
|
-
}
|
|
62
|
-
")
|
|
63
|
-
|
|
64
|
-
layout = QGridLayout.new(@form)
|
|
65
|
-
layout.add_widget(titlelabel, 0, 0, 1, 2)
|
|
66
|
-
layout.set_row_minimum_height(1, 10)
|
|
67
|
-
layout.add_widget(@errinfolabel, 2, 0, 1, 2)
|
|
68
|
-
layout.add_widget(@passnamelabel, 3, 0)
|
|
69
|
-
layout.add_widget(@passnameinput, 3, 1)
|
|
70
|
-
layout.add_widget(@usernamelabel, 4, 0)
|
|
71
|
-
layout.add_widget(@usernameinput, 4, 1)
|
|
72
|
-
layout.add_widget(@passwordlabel, 5, 0)
|
|
73
|
-
layout.add_widget(@passwordinput, 5, 1)
|
|
74
|
-
layout.add_widget(@websitelabel, 6, 0)
|
|
75
|
-
layout.add_widget(@websiteinput, 6, 1)
|
|
76
|
-
end
|
|
22
|
+
set_attribute(Qt::WA_DeleteOnClose)
|
|
23
|
+
set_modal(true)
|
|
24
|
+
end
|
|
77
25
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def initialize_form
|
|
29
|
+
titlelabel = QLabel.new("<center><b>Insert New Password</b></center>")
|
|
30
|
+
|
|
31
|
+
@errinfolabel = QLabel.new("")
|
|
32
|
+
@errinfolabel.set_style_sheet("background: white; color: red; padding: 8px; margin: 4px;")
|
|
33
|
+
@errinfolabel.set_hidden(true)
|
|
34
|
+
|
|
35
|
+
placeholder = (@folder == "") ? "github.com" : "#{@folder}/github.com"
|
|
36
|
+
@passnamelabel = initialize_form_label("File")
|
|
37
|
+
@passnameinput = initialize_form_inputfield(placeholder)
|
|
38
|
+
set_focus_proxy(@passnameinput)
|
|
39
|
+
|
|
40
|
+
@passwordlabel = initialize_form_label("Password")
|
|
41
|
+
@passwordinput = initialize_form_inputfield("")
|
|
42
|
+
initialize_form_inputfield_viewaction(@passwordinput)
|
|
43
|
+
|
|
44
|
+
@passwordinput.set_echo_mode(QLineEdit::Password)
|
|
45
|
+
Pass.pwgen(16, on_success: ->(data) {
|
|
46
|
+
@passwordinput.set_text(data["stdout"].lines[0].strip)
|
|
47
|
+
}, on_failure: ->(_) {})
|
|
48
|
+
|
|
49
|
+
@usernamelabel = initialize_form_label("Username")
|
|
50
|
+
@usernameinput = initialize_form_inputfield("johndoe")
|
|
51
|
+
|
|
52
|
+
@websitelabel = initialize_form_label("Website")
|
|
53
|
+
@websiteinput = initialize_form_inputfield("https://github.com/login")
|
|
54
|
+
|
|
55
|
+
@form = QWidget.new
|
|
56
|
+
@form.set_object_name("newpassworddialog_form")
|
|
57
|
+
@form.set_style_sheet("
|
|
58
|
+
#newpassworddialog_form {
|
|
59
|
+
min-width: 600px;
|
|
60
|
+
}
|
|
61
|
+
")
|
|
62
|
+
|
|
63
|
+
layout = QGridLayout.new(@form)
|
|
64
|
+
layout.add_widget(titlelabel, 0, 0, 1, 2)
|
|
65
|
+
layout.set_row_minimum_height(1, 10)
|
|
66
|
+
layout.add_widget(@errinfolabel, 2, 0, 1, 2)
|
|
67
|
+
layout.add_widget(@passnamelabel, 3, 0)
|
|
68
|
+
layout.add_widget(@passnameinput, 3, 1)
|
|
69
|
+
layout.add_widget(@usernamelabel, 4, 0)
|
|
70
|
+
layout.add_widget(@usernameinput, 4, 1)
|
|
71
|
+
layout.add_widget(@passwordlabel, 5, 0)
|
|
72
|
+
layout.add_widget(@passwordinput, 5, 1)
|
|
73
|
+
layout.add_widget(@websitelabel, 6, 0)
|
|
74
|
+
layout.add_widget(@websiteinput, 6, 1)
|
|
75
|
+
end
|
|
84
76
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
77
|
+
def initialize_form_label(text)
|
|
78
|
+
label = QLabel.new(text)
|
|
79
|
+
label.set_alignment(Qt::AlignRight)
|
|
80
|
+
label.set_style_sheet("min-width: 80px; padding-right: 4px;")
|
|
81
|
+
label
|
|
82
|
+
end
|
|
90
83
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
def initialize_form_inputfield(placeholder)
|
|
85
|
+
input = QLineEdit.new
|
|
86
|
+
input.set_placeholder_text(placeholder)
|
|
87
|
+
input
|
|
88
|
+
end
|
|
95
89
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
90
|
+
def initialize_form_inputfield_viewaction(input)
|
|
91
|
+
action = input.add_action(QIcon.from_theme(QIcon::ThemeIcon::DocumentPrintPreview), QLineEdit::TrailingPosition)
|
|
92
|
+
action.triggered.connect(self, :_on_view_action_triggered)
|
|
93
|
+
end
|
|
99
94
|
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
def initialize_btngroup
|
|
96
|
+
@okbutton = QPushButton.new("Create")
|
|
97
|
+
@okbutton.clicked.connect(self, :_on_okbutton_clicked)
|
|
102
98
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
layout.add_stretch
|
|
106
|
-
layout.add_widget(@okbutton)
|
|
107
|
-
layout.add_widget(@cancelbutton)
|
|
108
|
-
end
|
|
99
|
+
@cancelbutton = QPushButton.new("Cancel")
|
|
100
|
+
@cancelbutton.clicked.connect(self, :_on_cancelbutton_clicked)
|
|
109
101
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
102
|
+
@btngroup = QWidget.new
|
|
103
|
+
layout = QHBoxLayout.new(@btngroup)
|
|
104
|
+
layout.add_stretch
|
|
105
|
+
layout.add_widget(@okbutton)
|
|
106
|
+
layout.add_widget(@cancelbutton)
|
|
107
|
+
end
|
|
116
108
|
|
|
117
|
-
|
|
118
|
-
|
|
109
|
+
def update_form_errinfo(info)
|
|
110
|
+
if info.empty?
|
|
111
|
+
@errinfolabel.set_text("")
|
|
112
|
+
@errinfolabel.set_hidden(true)
|
|
113
|
+
return
|
|
119
114
|
end
|
|
120
115
|
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
@errinfolabel.set_text(info)
|
|
117
|
+
@errinfolabel.set_hidden(false)
|
|
118
|
+
end
|
|
123
119
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
"Username" => @usernameinput,
|
|
127
|
-
"Password" => @passwordinput,
|
|
128
|
-
"Website" => @websiteinput
|
|
129
|
-
}.each do |k, v|
|
|
130
|
-
next unless v.text.empty?
|
|
120
|
+
def validate_form
|
|
121
|
+
update_form_errinfo("")
|
|
131
122
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
123
|
+
{
|
|
124
|
+
"File" => @passnameinput,
|
|
125
|
+
"Username" => @usernameinput,
|
|
126
|
+
"Password" => @passwordinput,
|
|
127
|
+
"Website" => @websiteinput
|
|
128
|
+
}.each do |k, v|
|
|
129
|
+
next unless v.text.empty?
|
|
135
130
|
|
|
136
|
-
|
|
131
|
+
update_form_errinfo("#{k} can't be blank")
|
|
132
|
+
return false
|
|
137
133
|
end
|
|
138
134
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
store = @store
|
|
143
|
-
passname = @passnameinput.text
|
|
144
|
-
password = @passwordinput.text
|
|
145
|
-
username = @usernameinput.text
|
|
146
|
-
website = @websiteinput.text
|
|
147
|
-
extra = "Username: #{username}\nWebsite: #{website}\n"
|
|
148
|
-
Pass.insert(store, passname, password, extra, on_success: ->(_) {
|
|
149
|
-
@on_success.call(passname)
|
|
150
|
-
close
|
|
151
|
-
}, on_failure: ->(data) {
|
|
152
|
-
update_form_errinfo(data["stderr"].strip)
|
|
153
|
-
})
|
|
154
|
-
end
|
|
135
|
+
true
|
|
136
|
+
end
|
|
155
137
|
|
|
156
|
-
|
|
138
|
+
def _on_okbutton_clicked
|
|
139
|
+
return unless validate_form
|
|
140
|
+
|
|
141
|
+
store = @store
|
|
142
|
+
passname = @passnameinput.text
|
|
143
|
+
password = @passwordinput.text
|
|
144
|
+
username = @usernameinput.text
|
|
145
|
+
website = @websiteinput.text
|
|
146
|
+
extra = "Username: #{username}\nWebsite: #{website}\n"
|
|
147
|
+
Pass.insert(store, passname, password, extra, on_success: ->(_) {
|
|
148
|
+
@on_success.call(passname)
|
|
157
149
|
close
|
|
158
|
-
|
|
150
|
+
}, on_failure: ->(data) {
|
|
151
|
+
update_form_errinfo(data["stderr"].strip)
|
|
152
|
+
})
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def _on_cancelbutton_clicked
|
|
156
|
+
close
|
|
157
|
+
end
|
|
159
158
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
end
|
|
159
|
+
def _on_view_action_triggered
|
|
160
|
+
input = sender.parent
|
|
161
|
+
case input.echo_mode
|
|
162
|
+
when QLineEdit::Normal then input.set_echo_mode(QLineEdit::Password)
|
|
163
|
+
when QLineEdit::Password then input.set_echo_mode(QLineEdit::Normal)
|
|
164
|
+
else raise "unreachable!"
|
|
167
165
|
end
|
|
168
166
|
end
|
|
169
167
|
end
|
data/lib/pass-qt/config.rb
CHANGED
data/lib/pass-qt/version.rb
CHANGED