qparol 1.0.3

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/qparol +263 -0
  3. metadata +85 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a9cf9749c7630e7a0c4ee609477a7da7f2e8cb6f
4
+ data.tar.gz: 41296459c5b5259fc08955787bb7548169437b36
5
+ SHA512:
6
+ metadata.gz: 11b34d80c21dbdae9e4f4977ff78d17c5180d00b00a9ab8302ddc2c4a8f0aa9c5d2d6dca06ea41abc82ca98a7de578cbd893292877f10152529bb7681d66a4ba
7
+ data.tar.gz: 4bea4ce5f63781bcc1db82dfd70fbe866cc1959177f53b225fa738ad6a1f08e344313e5e2675350fcfbdc3177a704882d39df39f433526a6f0bf17852b51140e
@@ -0,0 +1,263 @@
1
+ #!/usr/bin/env ruby
2
+ require 'Qt'
3
+ require 'parol'
4
+
5
+ # password: rL8CQ3C9pMBfDn9epQyjX6nNycKP3ZGh
6
+
7
+ class Qparol < Qt::MainWindow
8
+ slots 'about_me()', 'about_qparol()', 'parol_load()', 'parol_save()', 'close()', 'new()', 'add_row()', 'remove_rows()'
9
+ @parol_sym = [:program, :login, :password, :notes]
10
+
11
+ def initialize
12
+ super
13
+
14
+ initWindow
15
+ initMenu
16
+ initView
17
+ resetDatabaseVar
18
+
19
+ show
20
+ end
21
+
22
+ def initWindow
23
+ setWindowTitle 'QParol'
24
+
25
+ setMinimumSize 800, 400
26
+
27
+ # centerWindow
28
+ screenGeometry = Qt::Application::desktop.screenGeometry
29
+ x = (screenGeometry.width - width) / 2
30
+ y = (screenGeometry.height - height) / 2
31
+ move x, y
32
+ end
33
+
34
+ def initMenu
35
+ # Actions
36
+ @fileMenu_new = Qt::Action.new '&New', self
37
+ @fileMenu_load = Qt::Action.new '&Load', self
38
+ @fileMenu_save = Qt::Action.new '&Save', self
39
+ @fileMenu_close = Qt::Action.new '&Close', self
40
+ fileMenu_exit = Qt::Action.new '&Exit', self
41
+
42
+ # Shortcuts
43
+ @fileMenu_new.setShortcut 'Ctrl+N'
44
+ @fileMenu_load.setShortcut 'Ctrl+L'
45
+ @fileMenu_save.setShortcut 'Ctrl+S'
46
+ @fileMenu_close.setShortcut 'Ctrl+C'
47
+ fileMenu_exit.setShortcut 'Ctrl+Q'
48
+
49
+ # Enableds
50
+ @fileMenu_save.enabled = false
51
+ @fileMenu_close.enabled = false
52
+
53
+ # fileMenu
54
+ fileMenu = menuBar.addMenu '&File'
55
+ fileMenu.addAction @fileMenu_new
56
+ fileMenu.addAction @fileMenu_load
57
+ fileMenu.addAction @fileMenu_save
58
+ fileMenu.addAction @fileMenu_close
59
+ fileMenu.addSeparator
60
+ fileMenu.addAction fileMenu_exit
61
+
62
+ # Connect
63
+ connect @fileMenu_new, SIGNAL('triggered()'), self, SLOT('new()')
64
+ connect @fileMenu_load, SIGNAL('triggered()'), self, SLOT('parol_load()')
65
+ connect @fileMenu_save, SIGNAL('triggered()'), self, SLOT('parol_save()')
66
+ connect @fileMenu_close, SIGNAL('triggered()'), self, SLOT('close()')
67
+ connect fileMenu_exit, SIGNAL('triggered()'), Qt::Application.instance, SLOT('quit()')
68
+
69
+ # Actions
70
+ aboutMenu_me = Qt::Action.new '&Me', self
71
+ aboutMenu_QParol = Qt::Action.new '&QParol', self
72
+ aboutMenu_Qt = Qt::Action.new '&Qt', self
73
+
74
+ # aboutMenu
75
+ aboutMenu = menuBar.addMenu '&About'
76
+ aboutMenu.addAction aboutMenu_me
77
+ aboutMenu.addAction aboutMenu_QParol
78
+ aboutMenu.addAction aboutMenu_Qt
79
+
80
+ # Shortcuts
81
+ aboutMenu_me.setShortcut 'Ctrl+M'
82
+ aboutMenu_QParol.setShortcut 'Ctrl+P'
83
+ aboutMenu_Qt.setShortcut 'Ctrl+Alt+Q'
84
+
85
+ # Connects
86
+ connect aboutMenu_me, SIGNAL('triggered()'), self, SLOT('about_me()')
87
+ connect aboutMenu_QParol, SIGNAL('triggered()'), self, SLOT('about_qparol()')
88
+ connect aboutMenu_Qt, SIGNAL('triggered()'), Qt::Application.instance, SLOT('aboutQt()')
89
+ end
90
+
91
+ def initView
92
+ @tableWidget = Qt::TableWidget.new
93
+
94
+ # Columns
95
+ @tableWidget.setColumnCount 4
96
+ @tableWidget.setHorizontalHeaderLabels %w(Program Username Password Comment)
97
+ @tableWidget.setColumnWidth 0, 200
98
+ @tableWidget.setColumnWidth 1, 160
99
+ @tableWidget.setColumnWidth 2, 180
100
+ @tableWidget.horizontalHeader.setStretchLastSection true
101
+
102
+ # Selection
103
+ @tableWidget.setSelectionBehavior Qt::AbstractItemView::SelectRows
104
+
105
+ setCentralWidget @tableWidget
106
+ end
107
+
108
+ def resetDatabaseVar
109
+ @database = nil::NilClass
110
+ @database_file = ''
111
+ @database_password = ''
112
+ end
113
+
114
+ ##
115
+ ## SLOTS
116
+ ##
117
+
118
+ # aboutMenu
119
+ def about_me
120
+ Qt::MessageBox.information self, 'About Me', 'I am a French Coder, my name is Ogromny.'
121
+ end
122
+
123
+ def about_qparol
124
+ Qt::MessageBox.information self, 'About QParol', 'A GUI in Qt for Parol.'
125
+ end
126
+
127
+ # fileMenu
128
+ def new
129
+ # DatabaseVar
130
+ @database_file = Qt::FileDialog::getSaveFileName self, 'Save database', ENV['HOME'], 'Parol Database (*)'
131
+ @database_password = Qt::InputDialog::getText self, 'Database password', 'Password:'
132
+ @database = Parol::Database.new @database_file, @database_password
133
+
134
+ # @tableWidget
135
+ @tableWidget.setRowCount 0
136
+
137
+ # fileMenu enableds
138
+ @fileMenu_new.enabled = false
139
+ @fileMenu_load.enabled = false
140
+ @fileMenu_save.enabled = true
141
+ @fileMenu_close.enabled = true
142
+
143
+ # window
144
+ setWindowTitle "QParol::#{@database_file}"
145
+
146
+ rescue Parol::BadPasswordLength
147
+ Qt::MessageBox.critical self, 'Database password', 'Password must be 32 of length'
148
+ end
149
+
150
+ def parol_load
151
+ # databaseVar
152
+ @database_file = Qt::FileDialog::getOpenFileName self, 'Load database', ENV['HOME'], 'Parol Database (*)'
153
+ @database_password = Qt::InputDialog::getText self, 'Database password', 'Password:'
154
+ @database = Parol::Database.new @database_file, @database_password
155
+
156
+ # load accounts into @tableWidget
157
+ @database.accounts do |account|
158
+ currentRow = @tableWidget.rowCount
159
+ @tableWidget.setRowCount currentRow + 1
160
+
161
+ # 4 columns
162
+ 0.upto 3 do |column|
163
+ symbol = @parol_sym[column]
164
+ item = Qt::TableWidgetItem.new account[symbol]
165
+
166
+ @tableWidget.setItem currentRow, column, item
167
+ end
168
+ end
169
+
170
+ # fileMenu enableds
171
+ @fileMenu_new.enabled = false
172
+ @fileMenu_load.enabled = false
173
+ @fileMenu_save.enabled = true
174
+ @fileMenu_close.enabled = true
175
+
176
+ # window
177
+ setWindowTitle "QParol::#{@database_file}"
178
+
179
+ rescue Parol::BadPasswordLength
180
+ Qt::MessageBox.critical self, 'Database password', 'Password must be 32 of length'
181
+ rescue Parol::DecryptionFailed
182
+ Qt::MessageBox.critical self, 'Database password', "Wrong password\nOr\nWrong file"
183
+ end
184
+
185
+ def parol_save
186
+ rowCount = @tableWidget.rowCount - 1
187
+ data = []
188
+
189
+ # all rows
190
+ 0.upto rowCount do |row|
191
+ parol = {}
192
+
193
+ # 4 columns
194
+ 0.upto 3 do |column|
195
+ item = @tableWidget.item row, column
196
+ symbol = @parol_sym[column]
197
+
198
+ parol[symbol] = item ? item.text : ''
199
+ end
200
+
201
+ data << parol
202
+ end
203
+
204
+ @database.save data
205
+
206
+ Qt::MessageBox.information self, 'Success', 'Successfully saved the database !'
207
+ end
208
+
209
+ def close
210
+ # @tableWidget
211
+ @tableWidget.setRowCount 0
212
+
213
+ resetDatabaseVar
214
+
215
+ # fileMenu enableds
216
+ @fileMenu_new.enabled = true
217
+ @fileMenu_load.enabled = true
218
+ @fileMenu_save.enabled = false
219
+ @fileMenu_close.enabled = false
220
+
221
+ # window
222
+ setWindowTitle 'QParol'
223
+ end
224
+
225
+ # window
226
+ def contextMenuEvent event
227
+ # Actions
228
+ menu_addRow = Qt::Action.new '&Add row', self
229
+ menu_removeRows = Qt::Action.new '&Remove row(s)', self
230
+
231
+ # menu
232
+ menu = Qt::Menu.new self
233
+ menu.addAction menu_addRow
234
+ menu.addAction menu_removeRows
235
+ menu.popup Qt::Cursor.pos
236
+
237
+ # connects
238
+ connect menu_addRow, SIGNAL('triggered()'), self, SLOT('add_row()')
239
+ connect menu_removeRows, SIGNAL('triggered()'), self, SLOT('remove_rows()')
240
+ end
241
+
242
+ def add_row
243
+ current_row = @tableWidget.rowCount
244
+ @tableWidget.setRowCount current_row + 1
245
+ end
246
+
247
+ def remove_rows
248
+ select = @tableWidget.selectionModel
249
+ selected = select.selectedRows
250
+
251
+ reponse = Qt::MessageBox.warning self, 'Are you sure ?', 'Do you really want to delete selected rows ?', Qt::MessageBox::Yes|Qt::MessageBox::No
252
+
253
+ selected.each do |index|
254
+ row = index.row
255
+ @tableWidget.removeRow row
256
+ end if reponse == 16384 # YES
257
+ end
258
+
259
+ end
260
+
261
+ app = Qt::Application.new ARGV
262
+ Qparol.new
263
+ app.exec
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qparol
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Ogromny
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: qtbindings
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.8'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 4.8.6.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '4.8'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 4.8.6.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: parol
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.5'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 3.5.1
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.5'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 3.5.1
53
+ description: A secure password manager
54
+ email: ogromny@openmailbox.org
55
+ executables:
56
+ - qparol
57
+ extensions: []
58
+ extra_rdoc_files: []
59
+ files:
60
+ - bin/qparol
61
+ homepage: https://github.com/Ogromny/Qparol/
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 2.2.6
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.6.8
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: qparol
85
+ test_files: []