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.
@@ -1,169 +1,167 @@
1
- module PassQt
2
- class NewPasswordDialog < RubyQt6::Bando::QDialog
3
- q_object do
4
- slot "_on_okbutton_clicked()"
5
- slot "_on_cancelbutton_clicked()"
6
- slot "_on_view_action_triggered()"
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
- set_attribute(Qt::WA_DeleteOnClose)
24
- set_modal(true)
25
- end
8
+ def initialize(store, folder, on_success:)
9
+ super()
26
10
 
27
- private
11
+ @store = store
12
+ @folder = folder
13
+ @on_success = on_success
28
14
 
29
- def initialize_form
30
- titlelabel = QLabel.new("<center><b>Insert New Password</b></center>")
15
+ initialize_form
16
+ initialize_btngroup
31
17
 
32
- @errinfolabel = QLabel.new("")
33
- @errinfolabel.set_style_sheet("background: white; color: red; padding: 8px; margin: 4px;")
34
- @errinfolabel.set_hidden(true)
18
+ mainlayout = QVBoxLayout.new(self)
19
+ mainlayout.add_widget(@form)
20
+ mainlayout.add_widget(@btngroup)
35
21
 
36
- placeholder = (@folder == "") ? "github.com" : "#{@folder}/github.com"
37
- @passnamelabel = initialize_form_label("File")
38
- @passnameinput = initialize_form_inputfield(placeholder)
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
- def initialize_form_label(text)
79
- label = QLabel.new(text)
80
- label.set_alignment(Qt::AlignRight)
81
- label.set_style_sheet("min-width: 80px; padding-right: 4px;")
82
- label
83
- end
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
- def initialize_form_inputfield(placeholder)
86
- input = QLineEdit.new
87
- input.set_placeholder_text(placeholder)
88
- input
89
- end
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
- def initialize_form_inputfield_viewaction(input)
92
- action = input.add_action(QIcon.from_theme(QIcon::ThemeIcon::DocumentPrintPreview), QLineEdit::TrailingPosition)
93
- action.triggered.connect(self, :_on_view_action_triggered)
94
- end
84
+ def initialize_form_inputfield(placeholder)
85
+ input = QLineEdit.new
86
+ input.set_placeholder_text(placeholder)
87
+ input
88
+ end
95
89
 
96
- def initialize_btngroup
97
- @okbutton = QPushButton.new("Create")
98
- @okbutton.clicked.connect(self, :_on_okbutton_clicked)
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
- @cancelbutton = QPushButton.new("Cancel")
101
- @cancelbutton.clicked.connect(self, :_on_cancelbutton_clicked)
95
+ def initialize_btngroup
96
+ @okbutton = QPushButton.new("Create")
97
+ @okbutton.clicked.connect(self, :_on_okbutton_clicked)
102
98
 
103
- @btngroup = QWidget.new
104
- layout = QHBoxLayout.new(@btngroup)
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
- def update_form_errinfo(info)
111
- if info.empty?
112
- @errinfolabel.set_text("")
113
- @errinfolabel.set_hidden(true)
114
- return
115
- end
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
- @errinfolabel.set_text(info)
118
- @errinfolabel.set_hidden(false)
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
- def validate_form
122
- update_form_errinfo("")
116
+ @errinfolabel.set_text(info)
117
+ @errinfolabel.set_hidden(false)
118
+ end
123
119
 
124
- {
125
- "File" => @passnameinput,
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
- update_form_errinfo("#{k} can't be blank")
133
- return false
134
- end
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
- true
131
+ update_form_errinfo("#{k} can't be blank")
132
+ return false
137
133
  end
138
134
 
139
- def _on_okbutton_clicked
140
- return unless validate_form
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
- def _on_cancelbutton_clicked
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
- end
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
- def _on_view_action_triggered
161
- input = sender.parent
162
- case input.echo_mode
163
- when QLineEdit::Normal then input.set_echo_mode(QLineEdit::Password)
164
- when QLineEdit::Password then input.set_echo_mode(QLineEdit::Normal)
165
- else raise "unreachable!"
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
@@ -1,5 +1,4 @@
1
1
  require_relative "config/initializers/qt6"
2
-
3
2
  require_relative "config/settings"
4
3
 
5
4
  module PassQt
@@ -1,3 +1,3 @@
1
1
  module PassQt
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-pass-qt
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Doe