ruby-pass-qt 2.0.7 → 2.1.0
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/.rubocop.yml +4 -0
- data/lib/pass-qt/app/views/browsestoresdialog/ui.rb +77 -0
- data/lib/pass-qt/app/views/browsestoresdialog.rb +3 -69
- data/lib/pass-qt/app/{components → views/mainwindow/components}/passinfowidget/helpers.rb +1 -1
- data/lib/pass-qt/app/{components/passinfowidget.rb → views/mainwindow/components/passinfowidget/ui.rb} +21 -86
- data/lib/pass-qt/app/views/mainwindow/components/passinfowidget.rb +75 -0
- data/lib/pass-qt/app/{components → views/mainwindow/components}/passlistwidget/treewidget/helpers.rb +1 -1
- data/lib/pass-qt/app/{components → views/mainwindow/components}/passlistwidget/treewidget/treebuilder.rb +1 -1
- data/lib/pass-qt/app/{components → views/mainwindow/components}/passlistwidget/treewidget/treefilter.rb +1 -1
- data/lib/pass-qt/app/views/mainwindow/components/passlistwidget/treewidget/ui.rb +36 -0
- data/lib/pass-qt/app/{components → views/mainwindow/components}/passlistwidget/treewidget.rb +3 -30
- data/lib/pass-qt/app/{components/passlistwidget.rb → views/mainwindow/components/passlistwidget/ui.rb} +13 -47
- data/lib/pass-qt/app/views/mainwindow/components/passlistwidget.rb +45 -0
- data/lib/pass-qt/app/views/mainwindow/ui.rb +39 -0
- data/lib/pass-qt/app/views/mainwindow.rb +5 -61
- data/lib/pass-qt/app/views/newonetimepassworddialog/ui.rb +90 -0
- data/lib/pass-qt/app/views/newonetimepassworddialog.rb +15 -93
- data/lib/pass-qt/app/views/newpassworddialog/ui.rb +111 -0
- data/lib/pass-qt/app/views/newpassworddialog.rb +18 -117
- data/lib/pass-qt/app.rb +2 -2
- data/lib/pass-qt/config/initializers/qt6.rb +1 -1
- data/lib/pass-qt/lib/{contrib/sighandler.rb → ctrlc/handler.rb} +6 -4
- data/lib/pass-qt/lib/ctrlc.rb +1 -0
- data/lib/pass-qt/lib/pass/{clients → backend}/gopass.rb +4 -4
- data/lib/pass-qt/lib/pass/{clients → backend}/pass.rb +6 -6
- data/lib/pass-qt/lib/pass/backend.rb +2 -0
- data/lib/pass-qt/lib/{contrib → pass}/process.rb +1 -1
- data/lib/pass-qt/lib/pass.rb +13 -11
- data/lib/pass-qt/lib.rb +1 -1
- data/lib/pass-qt/version.rb +1 -1
- metadata +22 -17
- data/lib/pass-qt/app/assets/README.md +0 -5
- data/lib/pass-qt/app/assets/app.svg +0 -1
- data/lib/pass-qt/lib/contrib.rb +0 -2
- data/lib/pass-qt/lib/pass/clients.rb +0 -2
- /data/lib/pass-qt/app/{components.rb → views/mainwindow/components.rb} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
class MainWindow < RubyQt6::Bando::QMainWindow
|
|
2
|
+
private
|
|
3
|
+
|
|
4
|
+
def initialize_ui
|
|
5
|
+
initialize_toolbar
|
|
6
|
+
initialize_central_widget
|
|
7
|
+
|
|
8
|
+
set_context_menu_policy(Qt::NoContextMenu)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def initialize_toolbar
|
|
12
|
+
browse_action = QAction.new(QIcon.from_theme(QIcon::ThemeIcon::Computer), "Browse", self)
|
|
13
|
+
browse_action.set_tool_tip("Browse password stores")
|
|
14
|
+
browse_action.triggered.connect(self, :_on_browse_action_triggered)
|
|
15
|
+
|
|
16
|
+
toolbar = add_tool_bar("ToolBar")
|
|
17
|
+
toolbar.set_object_name("mainwindow_toolbar")
|
|
18
|
+
toolbar.set_movable(false)
|
|
19
|
+
toolbar.add_action(browse_action)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def initialize_central_widget
|
|
23
|
+
@passlistwidget = MainWindowPassListWidget.new
|
|
24
|
+
@passinfowidget = MainWindowPassInfoWidget.new
|
|
25
|
+
|
|
26
|
+
@passlistwidget.store_changed.connect(@passinfowidget, :activate_infocard)
|
|
27
|
+
@passlistwidget.nil_selected.connect(@passinfowidget, :activate_infocard)
|
|
28
|
+
@passlistwidget.passfile_selected.connect(@passinfowidget, :activate_passfilecard)
|
|
29
|
+
@passlistwidget.passfolder_selected.connect(@passinfowidget, :activate_passfoldercard)
|
|
30
|
+
|
|
31
|
+
centralwidget = QWidget.new
|
|
32
|
+
mainlayout = QHBoxLayout.new(centralwidget)
|
|
33
|
+
mainlayout.add_widget(@passlistwidget)
|
|
34
|
+
mainlayout.add_widget(@passinfowidget)
|
|
35
|
+
mainlayout.set_stretch(0, 2)
|
|
36
|
+
mainlayout.set_stretch(1, 3)
|
|
37
|
+
set_central_widget(centralwidget)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -1,84 +1,28 @@
|
|
|
1
|
+
require_relative "mainwindow/components"
|
|
2
|
+
require_relative "mainwindow/ui"
|
|
3
|
+
|
|
1
4
|
class MainWindow < RubyQt6::Bando::QMainWindow
|
|
2
5
|
q_object do
|
|
3
6
|
slot "_on_browse_action_triggered()"
|
|
4
|
-
slot "_on_browsestoresdialog_stores_changed()"
|
|
5
|
-
slot "_on_passlistwidget_store_changed(QString)"
|
|
6
|
-
slot "_on_passlistwidget_nil_selected(QString)"
|
|
7
|
-
slot "_on_passlistwidget_passfile_selected(QString,QString)"
|
|
8
|
-
slot "_on_passlistwidget_passfolder_selected(QString,QString)"
|
|
9
7
|
end
|
|
10
8
|
|
|
11
9
|
def initialize
|
|
12
10
|
super
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
initialize_central_widget
|
|
16
|
-
|
|
17
|
-
set_context_menu_policy(Qt::NoContextMenu)
|
|
12
|
+
initialize_ui
|
|
18
13
|
PassQt.settings.GET_mainwindow_geometry_and_restore_to(self)
|
|
19
14
|
end
|
|
20
15
|
|
|
21
16
|
def close_event(evt)
|
|
22
17
|
PassQt.settings.PUT_mainwindow_geometry(self)
|
|
23
|
-
|
|
24
18
|
_close_event(evt)
|
|
25
19
|
end
|
|
26
20
|
|
|
27
21
|
private
|
|
28
22
|
|
|
29
|
-
def initialize_toolbar
|
|
30
|
-
browse_action = QAction.new(QIcon.from_theme(QIcon::ThemeIcon::Computer), "Browse", self)
|
|
31
|
-
browse_action.set_tool_tip("Browse password stores")
|
|
32
|
-
browse_action.triggered.connect(self, :_on_browse_action_triggered)
|
|
33
|
-
|
|
34
|
-
toolbar = add_tool_bar("ToolBar")
|
|
35
|
-
toolbar.set_object_name("mainwindow_toolbar")
|
|
36
|
-
toolbar.set_movable(false)
|
|
37
|
-
toolbar.add_action(browse_action)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def initialize_central_widget
|
|
41
|
-
@passlistwidget = PassListWidget.new
|
|
42
|
-
@passlistwidget.store_changed.connect(self, :_on_passlistwidget_store_changed)
|
|
43
|
-
@passlistwidget.nil_selected.connect(self, :_on_passlistwidget_nil_selected)
|
|
44
|
-
@passlistwidget.passfile_selected.connect(self, :_on_passlistwidget_passfile_selected)
|
|
45
|
-
@passlistwidget.passfolder_selected.connect(self, :_on_passlistwidget_passfolder_selected)
|
|
46
|
-
|
|
47
|
-
@passinfowidget = PassInfoWidget.new
|
|
48
|
-
|
|
49
|
-
centralwidget = QWidget.new
|
|
50
|
-
mainlayout = QHBoxLayout.new(centralwidget)
|
|
51
|
-
mainlayout.add_widget(@passlistwidget)
|
|
52
|
-
mainlayout.add_widget(@passinfowidget)
|
|
53
|
-
mainlayout.set_stretch(0, 2)
|
|
54
|
-
mainlayout.set_stretch(1, 3)
|
|
55
|
-
|
|
56
|
-
set_central_widget(centralwidget)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
23
|
def _on_browse_action_triggered
|
|
60
24
|
dialog = BrowseStoresDialog.new
|
|
61
|
-
dialog.stores_changed.connect(
|
|
25
|
+
dialog.stores_changed.connect(@passlistwidget, :refresh)
|
|
62
26
|
dialog.show
|
|
63
27
|
end
|
|
64
|
-
|
|
65
|
-
def _on_browsestoresdialog_stores_changed
|
|
66
|
-
@passlistwidget.refresh
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def _on_passlistwidget_store_changed(_store)
|
|
70
|
-
@passinfowidget.use_infocard
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def _on_passlistwidget_nil_selected(_store)
|
|
74
|
-
@passinfowidget.use_infocard
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def _on_passlistwidget_passfile_selected(store, passname)
|
|
78
|
-
@passinfowidget.use_passfilecard(store, passname)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def _on_passlistwidget_passfolder_selected(store, passname)
|
|
82
|
-
@passinfowidget.use_passfoldercard(store, passname)
|
|
83
|
-
end
|
|
84
28
|
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
class NewOneTimePasswordDialog < RubyQt6::Bando::QDialog
|
|
2
|
+
private
|
|
3
|
+
|
|
4
|
+
def initialize_ui
|
|
5
|
+
initialize_form
|
|
6
|
+
initialize_btngroup
|
|
7
|
+
initialize_layout
|
|
8
|
+
|
|
9
|
+
set_attribute(Qt::WA_DeleteOnClose)
|
|
10
|
+
set_modal(true)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def initialize_form
|
|
14
|
+
titlelabel = QLabel.new("<center><b>Insert New OTP Password</b></center>")
|
|
15
|
+
|
|
16
|
+
@errinfolabel = QLabel.new("")
|
|
17
|
+
@errinfolabel.set_style_sheet("background: white; color: red; padding: 8px; margin: 4px;")
|
|
18
|
+
@errinfolabel.set_hidden(true)
|
|
19
|
+
|
|
20
|
+
placeholder = (@folder == "") ? "example.com-otp" : "#{@folder}/example.com-otp"
|
|
21
|
+
@passnamelabel = initialize_form_label("File")
|
|
22
|
+
@passnameinput = initialize_form_inputfield(placeholder)
|
|
23
|
+
@passnameinput.set_text(placeholder)
|
|
24
|
+
set_focus_proxy(@passnameinput)
|
|
25
|
+
|
|
26
|
+
@passwordlabel = initialize_form_label("OTP URI")
|
|
27
|
+
@passwordinput = initialize_form_inputfield("otpauth://totp/GitHub...")
|
|
28
|
+
|
|
29
|
+
@form = QWidget.new
|
|
30
|
+
@form.set_object_name("newonetimepassworddialog_form")
|
|
31
|
+
@form.set_style_sheet("
|
|
32
|
+
#newonetimepassworddialog_form {
|
|
33
|
+
min-width: 600px;
|
|
34
|
+
}
|
|
35
|
+
")
|
|
36
|
+
|
|
37
|
+
layout = QGridLayout.new(@form)
|
|
38
|
+
layout.add_widget(titlelabel, 0, 0, 1, 2)
|
|
39
|
+
layout.set_row_minimum_height(1, 10)
|
|
40
|
+
layout.add_widget(@errinfolabel, 2, 0, 1, 2)
|
|
41
|
+
layout.add_widget(@passnamelabel, 3, 0)
|
|
42
|
+
layout.add_widget(@passnameinput, 3, 1)
|
|
43
|
+
layout.add_widget(@passwordlabel, 4, 0)
|
|
44
|
+
layout.add_widget(@passwordinput, 4, 1)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def initialize_form_label(text)
|
|
48
|
+
label = QLabel.new(text)
|
|
49
|
+
label.set_alignment(Qt::AlignRight)
|
|
50
|
+
label.set_style_sheet("min-width: 80px; padding-right: 4px;")
|
|
51
|
+
label
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def initialize_form_inputfield(placeholder)
|
|
55
|
+
input = QLineEdit.new
|
|
56
|
+
input.set_placeholder_text(placeholder)
|
|
57
|
+
input
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def initialize_btngroup
|
|
61
|
+
@btngroup = QDialogButtonBox.new(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal)
|
|
62
|
+
@btngroup.accepted.connect(self, :_on_okbutton_clicked)
|
|
63
|
+
@btngroup.rejected.connect(self, :_on_cancelbutton_clicked)
|
|
64
|
+
|
|
65
|
+
okbutton = @btngroup.button(QDialogButtonBox::Ok)
|
|
66
|
+
okbutton.set_text("Create")
|
|
67
|
+
okbutton.set_default(true)
|
|
68
|
+
okbutton.set_auto_default(true)
|
|
69
|
+
|
|
70
|
+
cancelbutton = @btngroup.button(QDialogButtonBox::Cancel)
|
|
71
|
+
cancelbutton.set_auto_default(true)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def initialize_layout
|
|
75
|
+
mainlayout = QVBoxLayout.new(self)
|
|
76
|
+
mainlayout.add_widget(@form)
|
|
77
|
+
mainlayout.add_widget(@btngroup)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def update_form_errinfo(info)
|
|
81
|
+
if info.empty?
|
|
82
|
+
@errinfolabel.set_text("")
|
|
83
|
+
@errinfolabel.set_hidden(true)
|
|
84
|
+
return
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
@errinfolabel.set_text(info)
|
|
88
|
+
@errinfolabel.set_hidden(false)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require_relative "newonetimepassworddialog/ui"
|
|
2
|
+
|
|
1
3
|
class NewOneTimePasswordDialog < RubyQt6::Bando::QDialog
|
|
2
4
|
q_object do
|
|
3
5
|
slot "_on_okbutton_clicked()"
|
|
@@ -11,92 +13,26 @@ class NewOneTimePasswordDialog < RubyQt6::Bando::QDialog
|
|
|
11
13
|
@folder = folder
|
|
12
14
|
@on_success = on_success
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
initialize_btngroup
|
|
16
|
-
|
|
17
|
-
mainlayout = QVBoxLayout.new(self)
|
|
18
|
-
mainlayout.add_widget(@form)
|
|
19
|
-
mainlayout.add_widget(@btngroup)
|
|
20
|
-
|
|
21
|
-
set_attribute(Qt::WA_DeleteOnClose)
|
|
22
|
-
set_modal(true)
|
|
16
|
+
initialize_ui
|
|
23
17
|
end
|
|
24
18
|
|
|
25
19
|
private
|
|
26
20
|
|
|
27
|
-
def
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
@errinfolabel = QLabel.new("")
|
|
31
|
-
@errinfolabel.set_style_sheet("background: white; color: red; padding: 8px; margin: 4px;")
|
|
32
|
-
@errinfolabel.set_hidden(true)
|
|
33
|
-
|
|
34
|
-
placeholder = (@folder == "") ? "example.com-otp" : "#{@folder}/example.com-otp"
|
|
35
|
-
@passnamelabel = initialize_form_label("File")
|
|
36
|
-
@passnameinput = initialize_form_inputfield(placeholder)
|
|
37
|
-
@passnameinput.set_text(placeholder)
|
|
38
|
-
set_focus_proxy(@passnameinput)
|
|
39
|
-
|
|
40
|
-
@passwordlabel = initialize_form_label("OTP URI")
|
|
41
|
-
@passwordinput = initialize_form_inputfield("otpauth://totp/GitHub...")
|
|
42
|
-
|
|
43
|
-
@form = QWidget.new
|
|
44
|
-
@form.set_object_name("newonetimepassworddialog_form")
|
|
45
|
-
@form.set_style_sheet("
|
|
46
|
-
#newonetimepassworddialog_form {
|
|
47
|
-
min-width: 600px;
|
|
48
|
-
}
|
|
49
|
-
")
|
|
50
|
-
|
|
51
|
-
layout = QGridLayout.new(@form)
|
|
52
|
-
layout.add_widget(titlelabel, 0, 0, 1, 2)
|
|
53
|
-
layout.set_row_minimum_height(1, 10)
|
|
54
|
-
layout.add_widget(@errinfolabel, 2, 0, 1, 2)
|
|
55
|
-
layout.add_widget(@passnamelabel, 3, 0)
|
|
56
|
-
layout.add_widget(@passnameinput, 3, 1)
|
|
57
|
-
layout.add_widget(@passwordlabel, 4, 0)
|
|
58
|
-
layout.add_widget(@passwordinput, 4, 1)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def initialize_form_label(text)
|
|
62
|
-
label = QLabel.new(text)
|
|
63
|
-
label.set_alignment(Qt::AlignRight)
|
|
64
|
-
label.set_style_sheet("min-width: 80px; padding-right: 4px;")
|
|
65
|
-
label
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def initialize_form_inputfield(placeholder)
|
|
69
|
-
input = QLineEdit.new
|
|
70
|
-
input.set_placeholder_text(placeholder)
|
|
71
|
-
input
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def initialize_btngroup
|
|
75
|
-
@btngroup = QDialogButtonBox.new(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal)
|
|
76
|
-
@btngroup.accepted.connect(self, :_on_okbutton_clicked)
|
|
77
|
-
@btngroup.rejected.connect(self, :_on_cancelbutton_clicked)
|
|
78
|
-
|
|
79
|
-
okbutton = @btngroup.button(QDialogButtonBox::Ok)
|
|
80
|
-
okbutton.set_text("Create")
|
|
81
|
-
okbutton.set_default(true)
|
|
82
|
-
okbutton.set_auto_default(true)
|
|
83
|
-
|
|
84
|
-
cancelbutton = @btngroup.button(QDialogButtonBox::Cancel)
|
|
85
|
-
cancelbutton.set_auto_default(true)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def update_form_errinfo(info)
|
|
89
|
-
if info.empty?
|
|
90
|
-
@errinfolabel.set_text("")
|
|
91
|
-
@errinfolabel.set_hidden(true)
|
|
92
|
-
return
|
|
93
|
-
end
|
|
21
|
+
def _on_okbutton_clicked
|
|
22
|
+
return unless _on_okbutton_clicked_validate_form
|
|
94
23
|
|
|
95
|
-
@
|
|
96
|
-
@
|
|
24
|
+
store = @store
|
|
25
|
+
passname = @passnameinput.text
|
|
26
|
+
password = @passwordinput.text
|
|
27
|
+
Pass.otp_insert(store, passname, password, on_success: ->(_) {
|
|
28
|
+
@on_success.call(passname)
|
|
29
|
+
close
|
|
30
|
+
}, on_failure: ->(data) {
|
|
31
|
+
update_form_errinfo(data["stderr"].strip)
|
|
32
|
+
})
|
|
97
33
|
end
|
|
98
34
|
|
|
99
|
-
def
|
|
35
|
+
def _on_okbutton_clicked_validate_form
|
|
100
36
|
update_form_errinfo("")
|
|
101
37
|
|
|
102
38
|
{
|
|
@@ -112,20 +48,6 @@ class NewOneTimePasswordDialog < RubyQt6::Bando::QDialog
|
|
|
112
48
|
true
|
|
113
49
|
end
|
|
114
50
|
|
|
115
|
-
def _on_okbutton_clicked
|
|
116
|
-
return unless validate_form
|
|
117
|
-
|
|
118
|
-
store = @store
|
|
119
|
-
passname = @passnameinput.text
|
|
120
|
-
password = @passwordinput.text
|
|
121
|
-
Pass.otp_insert(store, passname, password, on_success: ->(_) {
|
|
122
|
-
@on_success.call(passname)
|
|
123
|
-
close
|
|
124
|
-
}, on_failure: ->(data) {
|
|
125
|
-
update_form_errinfo(data["stderr"].strip)
|
|
126
|
-
})
|
|
127
|
-
end
|
|
128
|
-
|
|
129
51
|
def _on_cancelbutton_clicked
|
|
130
52
|
close
|
|
131
53
|
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
class NewPasswordDialog < RubyQt6::Bando::QDialog
|
|
2
|
+
private
|
|
3
|
+
|
|
4
|
+
def initialize_ui
|
|
5
|
+
initialize_form
|
|
6
|
+
initialize_btngroup
|
|
7
|
+
initialize_layout
|
|
8
|
+
|
|
9
|
+
set_attribute(Qt::WA_DeleteOnClose)
|
|
10
|
+
set_modal(true)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def initialize_form
|
|
14
|
+
titlelabel = QLabel.new("<center><b>Insert New Password</b></center>")
|
|
15
|
+
|
|
16
|
+
@errinfolabel = QLabel.new("")
|
|
17
|
+
@errinfolabel.set_style_sheet("background: white; color: red; padding: 8px; margin: 4px;")
|
|
18
|
+
@errinfolabel.set_hidden(true)
|
|
19
|
+
|
|
20
|
+
placeholder = (@folder == "") ? "example.com" : "#{@folder}/example.com"
|
|
21
|
+
@passnamelabel = initialize_form_label("File")
|
|
22
|
+
@passnameinput = initialize_form_inputfield(placeholder)
|
|
23
|
+
@passnameinput.set_text(placeholder)
|
|
24
|
+
set_focus_proxy(@passnameinput)
|
|
25
|
+
|
|
26
|
+
@passwordlabel = initialize_form_label("Password")
|
|
27
|
+
@passwordinput = initialize_form_inputfield("")
|
|
28
|
+
initialize_form_inputfield_viewaction(@passwordinput)
|
|
29
|
+
|
|
30
|
+
@passwordinput.set_echo_mode(QLineEdit::Password)
|
|
31
|
+
Pass.pwgen(16, on_success: ->(data) {
|
|
32
|
+
@passwordinput.set_text(data["stdout"].lines[0].strip)
|
|
33
|
+
}, on_failure: ->(_) {})
|
|
34
|
+
|
|
35
|
+
@usernamelabel = initialize_form_label("Username")
|
|
36
|
+
@usernameinput = initialize_form_inputfield("johndoe")
|
|
37
|
+
|
|
38
|
+
@websitelabel = initialize_form_label("Website")
|
|
39
|
+
@websiteinput = initialize_form_inputfield("https://github.com/login")
|
|
40
|
+
|
|
41
|
+
@form = QWidget.new
|
|
42
|
+
@form.set_object_name("newpassworddialog_form")
|
|
43
|
+
@form.set_style_sheet("
|
|
44
|
+
#newpassworddialog_form {
|
|
45
|
+
min-width: 600px;
|
|
46
|
+
}
|
|
47
|
+
")
|
|
48
|
+
|
|
49
|
+
layout = QGridLayout.new(@form)
|
|
50
|
+
layout.add_widget(titlelabel, 0, 0, 1, 2)
|
|
51
|
+
layout.set_row_minimum_height(1, 10)
|
|
52
|
+
layout.add_widget(@errinfolabel, 2, 0, 1, 2)
|
|
53
|
+
layout.add_widget(@passnamelabel, 3, 0)
|
|
54
|
+
layout.add_widget(@passnameinput, 3, 1)
|
|
55
|
+
layout.add_widget(@usernamelabel, 4, 0)
|
|
56
|
+
layout.add_widget(@usernameinput, 4, 1)
|
|
57
|
+
layout.add_widget(@passwordlabel, 5, 0)
|
|
58
|
+
layout.add_widget(@passwordinput, 5, 1)
|
|
59
|
+
layout.add_widget(@websitelabel, 6, 0)
|
|
60
|
+
layout.add_widget(@websiteinput, 6, 1)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def initialize_form_label(text)
|
|
64
|
+
label = QLabel.new(text)
|
|
65
|
+
label.set_alignment(Qt::AlignRight)
|
|
66
|
+
label.set_style_sheet("min-width: 80px; padding-right: 4px;")
|
|
67
|
+
label
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def initialize_form_inputfield(placeholder)
|
|
71
|
+
input = QLineEdit.new
|
|
72
|
+
input.set_placeholder_text(placeholder)
|
|
73
|
+
input
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def initialize_form_inputfield_viewaction(input)
|
|
77
|
+
action = input.add_action(QIcon.from_theme(QIcon::ThemeIcon::DocumentPrintPreview), QLineEdit::TrailingPosition)
|
|
78
|
+
action.triggered.connect(self, :_on_view_action_triggered)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def initialize_btngroup
|
|
82
|
+
@btngroup = QDialogButtonBox.new(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal)
|
|
83
|
+
@btngroup.accepted.connect(self, :_on_okbutton_clicked)
|
|
84
|
+
@btngroup.rejected.connect(self, :_on_cancelbutton_clicked)
|
|
85
|
+
|
|
86
|
+
okbutton = @btngroup.button(QDialogButtonBox::Ok)
|
|
87
|
+
okbutton.set_text("Create")
|
|
88
|
+
okbutton.set_default(true)
|
|
89
|
+
okbutton.set_auto_default(true)
|
|
90
|
+
|
|
91
|
+
cancelbutton = @btngroup.button(QDialogButtonBox::Cancel)
|
|
92
|
+
cancelbutton.set_auto_default(true)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def initialize_layout
|
|
96
|
+
mainlayout = QVBoxLayout.new(self)
|
|
97
|
+
mainlayout.add_widget(@form)
|
|
98
|
+
mainlayout.add_widget(@btngroup)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def update_form_errinfo(info)
|
|
102
|
+
if info.empty?
|
|
103
|
+
@errinfolabel.set_text("")
|
|
104
|
+
@errinfolabel.set_hidden(true)
|
|
105
|
+
return
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
@errinfolabel.set_text(info)
|
|
109
|
+
@errinfolabel.set_hidden(false)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require_relative "newpassworddialog/ui"
|
|
2
|
+
|
|
1
3
|
class NewPasswordDialog < RubyQt6::Bando::QDialog
|
|
2
4
|
q_object do
|
|
3
5
|
slot "_on_okbutton_clicked()"
|
|
@@ -12,113 +14,29 @@ class NewPasswordDialog < RubyQt6::Bando::QDialog
|
|
|
12
14
|
@folder = folder
|
|
13
15
|
@on_success = on_success
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
initialize_btngroup
|
|
17
|
-
|
|
18
|
-
mainlayout = QVBoxLayout.new(self)
|
|
19
|
-
mainlayout.add_widget(@form)
|
|
20
|
-
mainlayout.add_widget(@btngroup)
|
|
21
|
-
|
|
22
|
-
set_attribute(Qt::WA_DeleteOnClose)
|
|
23
|
-
set_modal(true)
|
|
17
|
+
initialize_ui
|
|
24
18
|
end
|
|
25
19
|
|
|
26
20
|
private
|
|
27
21
|
|
|
28
|
-
def
|
|
29
|
-
|
|
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 == "") ? "example.com" : "#{@folder}/example.com"
|
|
36
|
-
@passnamelabel = initialize_form_label("File")
|
|
37
|
-
@passnameinput = initialize_form_inputfield(placeholder)
|
|
38
|
-
@passnameinput.set_text(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
|
|
77
|
-
|
|
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
|
|
84
|
-
|
|
85
|
-
def initialize_form_inputfield(placeholder)
|
|
86
|
-
input = QLineEdit.new
|
|
87
|
-
input.set_placeholder_text(placeholder)
|
|
88
|
-
input
|
|
89
|
-
end
|
|
90
|
-
|
|
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
|
|
95
|
-
|
|
96
|
-
def initialize_btngroup
|
|
97
|
-
@btngroup = QDialogButtonBox.new(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal)
|
|
98
|
-
@btngroup.accepted.connect(self, :_on_okbutton_clicked)
|
|
99
|
-
@btngroup.rejected.connect(self, :_on_cancelbutton_clicked)
|
|
100
|
-
|
|
101
|
-
okbutton = @btngroup.button(QDialogButtonBox::Ok)
|
|
102
|
-
okbutton.set_text("Create")
|
|
103
|
-
okbutton.set_default(true)
|
|
104
|
-
okbutton.set_auto_default(true)
|
|
105
|
-
|
|
106
|
-
cancelbutton = @btngroup.button(QDialogButtonBox::Cancel)
|
|
107
|
-
cancelbutton.set_auto_default(true)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def update_form_errinfo(info)
|
|
111
|
-
if info.empty?
|
|
112
|
-
@errinfolabel.set_text("")
|
|
113
|
-
@errinfolabel.set_hidden(true)
|
|
114
|
-
return
|
|
115
|
-
end
|
|
22
|
+
def _on_okbutton_clicked
|
|
23
|
+
return unless _on_okbutton_clicked_validate_form
|
|
116
24
|
|
|
117
|
-
@
|
|
118
|
-
@
|
|
25
|
+
store = @store
|
|
26
|
+
passname = @passnameinput.text
|
|
27
|
+
password = @passwordinput.text
|
|
28
|
+
username = @usernameinput.text
|
|
29
|
+
website = @websiteinput.text
|
|
30
|
+
extra = "Username: #{username}\nWebsite: #{website}\n"
|
|
31
|
+
Pass.insert(store, passname, password, extra, on_success: ->(_) {
|
|
32
|
+
@on_success.call(passname)
|
|
33
|
+
close
|
|
34
|
+
}, on_failure: ->(data) {
|
|
35
|
+
update_form_errinfo(data["stderr"].strip)
|
|
36
|
+
})
|
|
119
37
|
end
|
|
120
38
|
|
|
121
|
-
def
|
|
39
|
+
def _on_okbutton_clicked_validate_form
|
|
122
40
|
update_form_errinfo("")
|
|
123
41
|
|
|
124
42
|
{
|
|
@@ -136,23 +54,6 @@ class NewPasswordDialog < RubyQt6::Bando::QDialog
|
|
|
136
54
|
true
|
|
137
55
|
end
|
|
138
56
|
|
|
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
|
|
155
|
-
|
|
156
57
|
def _on_cancelbutton_clicked
|
|
157
58
|
close
|
|
158
59
|
end
|
data/lib/pass-qt/app.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require_relative "config"
|
|
2
2
|
require_relative "lib"
|
|
3
3
|
|
|
4
|
-
require_relative "app/components"
|
|
5
4
|
require_relative "app/views"
|
|
6
5
|
|
|
7
6
|
module PassQt
|
|
@@ -16,7 +15,8 @@ module PassQt
|
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
def exec
|
|
19
|
-
|
|
18
|
+
handler = Ctrlc::Handler.new
|
|
19
|
+
handler.exec
|
|
20
20
|
|
|
21
21
|
@mainwindow.show
|
|
22
22
|
@app.exec
|
|
@@ -4,5 +4,5 @@ QApplication.set_application_name("PassQt")
|
|
|
4
4
|
root_path = File.expand_path("../..", __dir__)
|
|
5
5
|
QDir.add_search_path("assets", File.join(root_path, "app/assets"))
|
|
6
6
|
|
|
7
|
-
icon = QIcon.
|
|
7
|
+
icon = QIcon.from_theme("enpass")
|
|
8
8
|
QApplication.set_window_icon(icon)
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
module
|
|
2
|
-
class
|
|
1
|
+
module Ctrlc
|
|
2
|
+
class Handler < RubyQt6::Bando::QObject
|
|
3
3
|
q_object do
|
|
4
4
|
slot "_noop()"
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
def initialize
|
|
8
|
-
super
|
|
7
|
+
def initialize
|
|
8
|
+
super($qApp)
|
|
9
|
+
end
|
|
9
10
|
|
|
11
|
+
def exec
|
|
10
12
|
["INT", "TERM"].each do |sig|
|
|
11
13
|
Signal.trap(sig) { |_| QApplication.quit }
|
|
12
14
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require_relative "ctrlc/handler"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Pass
|
|
2
|
-
module
|
|
3
|
-
class GoPass < ::Pass::
|
|
2
|
+
module Backend
|
|
3
|
+
class GoPass < ::Pass::Backend::Pass
|
|
4
4
|
def initialize
|
|
5
5
|
@program = "gopass"
|
|
6
6
|
end
|
|
@@ -9,12 +9,12 @@ module Pass
|
|
|
9
9
|
arguments = QStringList.new << "insert" << passname
|
|
10
10
|
stdin = password
|
|
11
11
|
envs = {PASSWORD_STORE_DIR: store}
|
|
12
|
-
|
|
12
|
+
Process.execute(@program, arguments, stdin:, envs:, on_success:, on_failure:)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def pwgen(pw_length, on_success:, on_failure:)
|
|
16
16
|
arguments = QStringList.new << "pwgen" << "-By1" << pw_length.to_s
|
|
17
|
-
|
|
17
|
+
Process.execute(@program, arguments, on_success:, on_failure:)
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
end
|