This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_account.py
565 lines (519 loc) · 30.7 KB
/
edit_account.py
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDialog, QFrame, QLabel, QLineEdit, QPushButton, QMessageBox, QApplication, QCompleter
from PyQt5.QtGui import QIcon
from delete_account import delete
import random
from additions.cryptography import *
from additions.constants import *
class EditAccount(QDialog):
def __init__(self, main_self, index):
super().__init__(None, Qt.WindowCloseButtonHint | Qt.WindowTitleHint)
# hide the window
self.hide()
# make the window modal
self.setWindowModality(Qt.ApplicationModal)
# access the main self
self.index = index
self.main_self = main_self
part: list[str] = self.main_self.liste[index]
self.accName = part[0]
self.accAlias = part[1]
self.accID = part[2]
self.accEmail = part[3]
self.accPassword = part[4]
# build the window
self.build()
def build(self):
# différentes polices:
self.fontLabel = QFont('Arial Nova Light', 12)
self.fontEntry = QFont('Arial Nova Light', 10)
self.fontError = QFont('Arial Nova Light', 8)
# window
# give an icon to the window
self.setWindowIcon(QIcon('resources/pama.ico'))
# set a fix size to the window
self.setFixedSize(700, 550)
# background
self.background = QFrame(self)
self.background.setStyleSheet('background: #ffffff;')
self.background.setFixedSize(self.width(), self.height())
self.background.move(0, 0)
# # Folder
# # choose_folderLabel
# self.choose_folderLabel = QLabel(self)
# self.choose_folderLabel.setFont(self.fontLabel)
# self.choose_folderLabel.move(10, 10)
# # choose_folderComboBox
# self.choose_folderComboBox = QComboBox(self.background)
# self.choose_folderComboBox.activated.connect(lambda: self.choose_folderComboBox.clearFocus())
# self.choose_folderComboBox.setFixedSize(100, 25)
# self.choose_folderComboBox.move(self.choose_folderLabel.geometry().x(), self.choose_folderLabel.geometry().y() + 30)
# self.choose_folderComboBox.addItems(self.folderList_copy)
# if self.accFolder != default_folder_name:
# self.choose_folderComboBox.setCurrentIndex(self.folderList_copy.index(self.accFolder))
# else:
# self.choose_folderComboBox.setCurrentIndex(0)
# # self.choose_folderComboBox.setPlaceholderText("Choisissez le dossier")
# # add_folderButton
# self.add_folderButton = QPushButton(self)
# self.add_folderButton.setFont(self.fontEntry)
# self.add_folderButton.setFixedSize(120, 25)
# self.add_folderButton.clicked.connect(self.add_folder)
# self.add_folderButton.move(self.choose_folderComboBox.width() + self.choose_folderComboBox.geometry().x() + 10,
# self.choose_folderLabel.geometry().y() + 30)
# # choose_folderError
# self.choose_folderError = QLabel(self)
# self.choose_folderError.setFont(self.fontError)
# self.choose_folderError.setFixedWidth(300)
# self.choose_folderError.move(self.choose_folderLabel.geometry().x(), self.add_folderButton.geometry().y() + 28)
# New account name
# new_accName_label
self.new_accName_label = QLabel(self)
self.new_accName_label.setFont(self.fontLabel)
self.new_accName_label.move(10, 10)
# QLineEdit Name
self.new_accName = QLineEdit(self)
self.new_accName.setFont(self.fontEntry)
self.new_accName.resize(350, self.new_accName.height())
self.new_accName.move(self.new_accName_label.geometry().x(), self.new_accName_label.geometry().y() + 30)
self.new_accName.insert(self.accName)
# new_accNameError
self.new_accNameError = QLabel(self)
self.new_accNameError.setFont(self.fontError)
self.new_accNameError.setFixedWidth(300)
self.new_accNameError.move(self.new_accName_label.geometry().x(), self.new_accName.geometry().y() + 32)
# New account alias
# new_accAlias_label
self.new_accAlias_label = QLabel(self)
self.new_accAlias_label.setFont(self.fontLabel)
self.new_accAlias_label.move(self.new_accName_label.geometry().x(), self.new_accNameError.geometry().y() + 20)
# QLineEdit Alias
self.new_accAlias = QLineEdit(self)
self.new_accAlias.setFont(self.fontEntry)
self.new_accAlias.resize(350, self.new_accAlias.height())
self.new_accAlias.move(self.new_accAlias_label.geometry().x(), self.new_accAlias_label.geometry().y() + 30)
self.new_accAlias.insert("".join(self.accAlias))
# new_accAliasError
self.new_accAliasError = QLabel(self)
self.new_accAliasError.setFont(self.fontError)
self.new_accAliasError.setFixedWidth(300)
self.new_accAliasError.move(self.new_accAlias_label.geometry().x(), self.new_accAlias.geometry().y() + 32)
# New account id
# new_accID_label
self.new_accID_label = QLabel(self)
self.new_accID_label.setFont(self.fontLabel)
self.new_accID_label.move(self.new_accName_label.geometry().x(), self.new_accAliasError.geometry().y() + 20)
# QLineEdit ID
self.new_accID = QLineEdit(self)
self.new_accID.setFont(self.fontEntry)
self.new_accID.resize(350, self.new_accID.height())
self.new_accID.move(self.new_accID_label.geometry().x(), self.new_accID_label.geometry().y() + 30)
self.new_accID.insert(self.accID)
# new_accIDError
self.new_accIDError = QLabel(self)
self.new_accIDError.setFont(self.fontError)
self.new_accIDError.setFixedWidth(300)
self.new_accIDError.move(self.new_accID_label.geometry().x(), self.new_accID.geometry().y() + 32)
# New account email
# new_accEmail_label
self.new_accEmail_label = QLabel(self)
self.new_accEmail_label.setFont(self.fontLabel)
self.new_accEmail_label.move(self.new_accName_label.geometry().x(), self.new_accIDError.geometry().y() + 20)
# QLineEdit Email
self.new_accEmail = QLineEdit(self)
self.new_accEmail.setFont(self.fontEntry)
self.new_accEmail.resize(350, self.new_accEmail.height())
self.new_accEmail.move(self.new_accEmail_label.geometry().x(), self.new_accEmail_label.geometry().y() + 30)
self.new_accEmail.insert(self.accEmail)
self.addressesList = [i for i in list(set(self.main_self.email_list)) if i != '']
self.addressesCompleter = QCompleter(self.addressesList, self)
self.addressesCompleter.setCaseSensitivity(Qt.CaseInsensitive)
self.popupAddressesCompleter = self.addressesCompleter.popup()
self.new_accEmail.setCompleter(self.addressesCompleter)
# new_accEmailError
self.new_accEmailError = QLabel(self)
self.new_accEmailError.setFont(self.fontError)
self.new_accEmailError.setFixedWidth(300)
self.new_accEmailError.move(self.new_accEmail_label.geometry().x(), self.new_accEmail.geometry().y() + 32)
# New account password
# new_accPassword_label
self.new_accPassword_label = QLabel(self)
self.new_accPassword_label.setFont(self.fontLabel)
self.new_accPassword_label.move(self.new_accName_label.geometry().x(),
self.new_accEmailError.geometry().y() + 20)
# QLineEdit password
self.new_accPassword = QLineEdit(self)
self.new_accPassword.setFont(self.fontEntry)
self.new_accPassword.resize(350, self.new_accPassword.height())
self.new_accPassword.move(self.new_accPassword_label.geometry().x(),
self.new_accPassword_label.geometry().y() + 30)
self.new_accPassword.insert(self.accPassword)
# new_accPasswordError
self.new_accPasswordError = QLabel(self)
self.new_accPasswordError.setFont(self.fontError)
self.new_accPasswordError.setFixedWidth(300)
self.new_accPasswordError.move(self.new_accPassword_label.geometry().x(),
self.new_accPassword.geometry().y() + 32)
# see / not to see
self.new_accPassword.setEchoMode(QLineEdit.Password)
self.password_isVisible = False
self.is_visible = QPushButton(self.new_accPassword)
self.is_visible.setCursor(Qt.ArrowCursor)
if self.main_self.theme == dark:
self.is_visible.setIcon(QIcon('resources/dark_open_eye.svg'))
elif self.main_self.theme == bright:
self.is_visible.setIcon(QIcon('resources/open_eye.svg'))
self.is_visible.setStyleSheet('border: 0px;')
self.is_visible.clicked.connect(self.visible)
self.is_visible.move(self.new_accPassword.width() - 30, 5)
# generate password
self.generate_password_button = QPushButton(self)
self.generate_password_button.setFont(QFont('Arial Nova Light', 10))
self.generate_password_button.clicked.connect(self.generatePassword)
self.generate_password_button.move(self.new_accPassword_label.geometry().x(),
self.new_accPasswordError.geometry().y() + 20)
# confirmButton
self.confirmButton = QPushButton(self)
self.confirmButton.setFont(QFont('Times', 17))
self.confirmButton.setFixedSize(130, 30)
self.confirmButton.move(self.width() - self.confirmButton.width() - 30,
self.height() - self.confirmButton.height() - 30)
self.confirmButton.pressed.connect(self.try_save_account_informations)
# translate
self.translate(self.main_self.language)
# setTheme
self.setTheme(self.main_self.theme)
# display window
self.show()
# focus on new_accName
self.new_accName.setFocus()
@staticmethod
def in_each(comparing_list: list, compared_list: list) -> bool:
res = False
for comparing in comparing_list:
for compared in compared_list:
if comparing in compared:
res = True
return res
def try_save_account_informations(self):
new_acc_list = [self.new_accName, self.new_accAlias, self.new_accID, self.new_accEmail, self.new_accPassword]
new_acc_error_list = [self.new_accNameError, self.new_accAliasError, self.new_accIDError,
self.new_accEmailError, self.new_accPasswordError]
# reset the correct StyleSheet on all entries
if self.main_self.theme == dark:
for i in new_acc_list:
i.setStyleSheet(
f'background: #{dark_background}; color: #{dark_color}; border: 1px solid #{dark_entry_border};'
f'border-radius: 1px;')
elif self.main_self.theme == bright:
for i in new_acc_list:
i.setStyleSheet(
f'background: #{bright_background}; border: 1px solid #{bright_entry_border}; border-radius: 1px;')
# reset error messages
for i in new_acc_error_list:
i.setText('')
# retrieve keystrokes and put them in variables
new_name = self.new_accName.text()
new_alias = self.new_accAlias.text()
new_id = self.new_accID.text()
new_email = self.new_accEmail.text().replace(' ', '')
new_password = self.new_accPassword.text().replace(' ', '')
new_list: list = [new_name, new_alias, new_id, new_email, new_password]
new_list_plus = [new_name, new_alias, new_id, new_email, new_password]
list_plus = [self.accName, self.accAlias, self.accID, self.accEmail, self.accPassword]
run = False
for i in range(len(new_list_plus)):
if new_list_plus[i] != list_plus[i]:
run = True
if run:
# create error_list that contains all non-encrypt-able characters and delete duplicates with set()
error_list = list(set(i for i in "".join(new_list) if i not in alpha))
# create a list for each QLineEdit
new_error_list = [[], [], [], [], []]
if error_list:
for i in error_list:
for j in range(len(new_list)):
if i in new_list[j]:
if self.main_self.theme == dark:
new_acc_list[j].setStyleSheet(
f'background: #{dark_background}; color: #{dark_color}; border: 1px solid '
f'#{dark_entry_border}; border-radius: 1px; border-bottom-color: #{dark_alert};')
elif self.main_self.theme == bright:
new_acc_list[j].setStyleSheet(
f'background: #{bright_background}; border: 1px solid #{bright_entry_border}; '
f'border-radius: 1px; border-bottom: 2px solid #{bright_alert};')
new_error_list[j].append(i)
if self.main_self.language == french:
for i in range(len(new_error_list)):
if new_error_list[i]:
new_acc_error_list[i].setText(
f'Vous ne pouvez pas utiliser le{"s" if len(new_error_list[i]) > 1 else ""} '
f'caractère{"s" if len(new_error_list[i]) > 1 else ""}: {"".join(new_error_list[i])}!')
elif self.main_self.language == english:
for i in range(len(new_error_list)):
if new_error_list[i]:
new_acc_error_list[i].setText(
f'You cannot use the character{"s" if len(new_error_list[i]) > 1 else ""}: '
f'{"".join(new_error_list[i])}!')
elif self.in_each(['--', '::', '//', '%%', ';;'], new_list):
message = ""
if self.main_self.language == french:
message = "Vous ne pouvez pas utiliser '::', '//', '%%' ni ';;'."
elif self.main_self.language == english:
message = "You cannot use '::', '//', '%%' or ';;'."
for i in range(len(new_list)):
if ('--' in new_list[i] or '::' in new_list[i] or '//' in new_list[i] or '%%' in new_list[i] or
';;' in new_list[i]):
if self.main_self.theme == dark:
new_acc_list[i].setStyleSheet(
f'background: #{dark_background}; color: #{dark_color}; border: 1px solid '
f'#{dark_entry_border}; border-radius: 1px; border-bottom-color: #{dark_alert};')
new_acc_error_list[i].setText(message)
elif self.main_self.theme == bright:
new_acc_list[i].setStyleSheet(
f'background: #{bright_background}; border: 1px solid #{bright_entry_border};'
f'border-radius: 1px; border-bottom: 2px solid #{bright_alert};')
new_acc_error_list[i].setText(message)
elif new_name == '' or new_password == '':
if not new_name:
if self.main_self.theme == dark:
self.new_accName.setStyleSheet(
f'background: #{dark_background}; color: #{dark_color}; border: 1px solid '
f'#{dark_entry_border}; border-radius: 1px; border-bottom-color: #{dark_alert};')
elif self.main_self.theme == bright:
self.new_accName.setStyleSheet(
f'background: #{bright_background}; border: 1px solid #{bright_entry_border};'
f'border-radius: 1px; border-bottom: 2px solid #{bright_alert};')
if self.main_self.language == french:
self.new_accNameError.setText('Ce champ de texte est obligatoire')
elif self.main_self.language == english:
self.new_accNameError.setText('This text field is mandatory')
if not new_password:
if self.main_self.theme == dark:
self.new_accPassword.setStyleSheet(
f'background: #{dark_background}; color: #{dark_color}; border: 1px solid '
f'#{dark_entry_border}; border-radius: 1px; border-bottom-color: #{dark_alert};')
elif self.main_self.theme == bright:
self.new_accPassword.setStyleSheet(
f'background: #{bright_background}; border: 1px solid #{bright_entry_border};'
f'border-radius: 1px; border-bottom: 2px solid #{bright_alert};')
if self.main_self.language == french:
self.new_accPasswordError.setText('Ce champ de texte est obligatoire')
elif self.main_self.language == english:
self.new_accPasswordError.setText('This text field is mandatory')
elif new_name in [i for i in self.main_self.name_list if i != self.accName]:
if self.main_self.theme == dark:
self.new_accName.setStyleSheet(
f'background: #{dark_background}; color: #{dark_color}; border: 1px solid #{dark_entry_border};'
f'border-radius: 1px; border-bottom-color: #{dark_alert};')
elif self.main_self.theme == bright:
self.new_accName.setStyleSheet(
f'background: #{bright_background}; border: 1px solid #{bright_entry_border}; '
f'border-radius: 1px; border-bottom: 2px solid #{bright_alert};')
if self.main_self.language == french:
self.new_accNameError.setText('Le nom est déjà pris...')
elif self.main_self.language == english:
self.new_accNameError.setText('The name is already taken...')
elif (new_alias in [i for i in self.main_self.name_list if i != self.accName] or
new_alias in [i for i in self.main_self.alias_list if i != '' and i != self.accAlias] or
new_alias == new_name):
if self.main_self.theme == dark:
self.new_accAlias.setStyleSheet(
f'background: #{dark_background}; color: #{dark_color}; border: 1px solid #{dark_entry_border};'
f'border-radius: 1px; border-bottom-color: #{dark_alert};')
elif self.main_self.theme == bright:
self.new_accAlias.setStyleSheet(
f'background: #{bright_background}; border: 1px solid #{bright_entry_border}; border-radius: 1px; border-bottom: 2px solid #{bright_alert};')
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if self.main_self.language == french:
self.new_accAliasError.setText('Le nom est déjà pris...')
elif self.main_self.language == english:
self.new_accAliasError.setText('The name is already taken...')
else:
exitMessage = QMessageBox()
exitMessage.setIcon(QMessageBox.Question)
exitMessage.setWindowIcon(QIcon('resources/pama.ico'))
if self.main_self.language == french:
exitMessage.setWindowTitle('Enregistrer')
exitMessage.setText('Voulez-vous vraiment enregistrer les modifications ?')
exitMessage.addButton("&Oui", QMessageBox.YesRole)
exitMessage.addButton("&Non", QMessageBox.NoRole)
elif self.main_self.language == english:
exitMessage.setWindowTitle('Save')
exitMessage.setText('Do you really want to save the changes ?')
exitMessage.addButton("&Yes", QMessageBox.YesRole)
exitMessage.addButton("&No", QMessageBox.NoRole)
exitMessage.exec_()
if exitMessage.clickedButton().text() == '&Yes' or exitMessage.clickedButton().text() == '&Oui':
delete(self.main_self, self.index, False)
with open('files/password.txt', 'a') as f:
f.write(convert_txt_bin(new_alias + '--', self.main_self.seed) + '\n')
f.write(convert_txt_bin(new_name + '::', self.main_self.seed) + '\n')
f.write(convert_txt_bin(new_id + '//', self.main_self.seed) + '\n')
f.write(convert_txt_bin(new_email + '%%', self.main_self.seed) + '\n')
f.write(convert_txt_bin(new_password + ';;', self.main_self.seed) + '\n')
f.close()
self.main_self.name_list.append(new_name)
self.main_self.alias_list.append(new_alias)
self.main_self.email_list.append(new_email)
self.main_self.liste.append([new_name, new_alias, new_id, new_email, new_password])
# update
self.main_self.data_in_table(self.main_self)
self.main_self.search()
self.close()
else:
self.close()
def generatePassword(self):
characters = list(alpha)
random.seed()
random.shuffle(characters)
password_ = ""
for i in range(30):
password_ += random.choice(characters)
if '--' in password_ or '::' in password_ or '//' in password_ or '%%' in password_ or ';;' in password_:
password_ = ""
self.generatePassword()
self.new_accPassword.clear()
self.new_accPassword.insert(password_)
QApplication.clipboard().setText(password_)
def setTheme(self, theme):
if theme == dark:
self.background.setStyleSheet(f'background: #{dark_background};')
# account name
self.new_accName_label.setStyleSheet(f'color: #{dark_color}')
self.new_accName.setStyleSheet(
f'background: #{dark_background}; color: #{dark_color}; border: 1px solid #{dark_entry_border}; border-radius: 1px;')
self.new_accNameError.setStyleSheet(f'color: #{dark_alert}')
# account alias
self.new_accAlias_label.setStyleSheet(f'color: #{dark_color}')
self.new_accAlias.setStyleSheet(
f'background: #{dark_background}; color: #{dark_color}; border: 1px solid #{dark_entry_border}; border-radius: 1px;')
self.new_accAliasError.setStyleSheet(f'color: #{dark_alert}')
# account id
self.new_accID_label.setStyleSheet(f'color: #{dark_color}')
self.new_accID.setStyleSheet(
f'background: #{dark_background}; color: #{dark_color}; border: 1px solid #{dark_entry_border}; border-radius: 1px;')
self.new_accIDError.setStyleSheet(f'color: #{dark_alert}')
# account email
self.new_accEmail_label.setStyleSheet(f'color: #{dark_color}')
self.new_accEmail.setStyleSheet(
f'background: #{dark_background}; color: #{dark_color}; border: 1px solid #{dark_entry_border}; border-radius: 1px;')
self.popupAddressesCompleter.setStyleSheet(f'background: #{dark_background}; color: #{dark_color};')
self.new_accEmailError.setStyleSheet(f'color: #{dark_alert}')
# account password
self.new_accPassword_label.setStyleSheet(f'color: #{dark_color}')
self.new_accPassword.setStyleSheet(
f'background: #{dark_background}; color: #{dark_color}; border: 1px solid #{dark_entry_border}; border-radius: 1px;')
self.new_accPasswordError.setStyleSheet(f'color: #{dark_alert}')
# generate password button
self.generate_password_button.setStyleSheet(
'QPushButton{background: #' + dark_background + '; color: #' + dark_color + '; border: 1px solid #' + dark_border + '; border-radius: 2px;}' +
'QPushButton:hover{background: #' + dark_background_hover + ';}')
# confirm button
self.confirmButton.setStyleSheet(
'QPushButton{background: #' + dark_background + '; color: #' + dark_color + '; border: 1px solid #' + dark_border + '; border-radius: 2px;}' +
'QPushButton:hover{background: #' + dark_background_hover + ';}')
elif theme == bright:
self.background.setStyleSheet(f'background: #{bright_background};')
# account name
self.new_accName.setStyleSheet(
f'background: #{bright_background}; border: 1px solid #{bright_entry_border}; border-radius: 1px;')
self.new_accNameError.setStyleSheet(f'color: #{bright_alert}')
# account alias
self.new_accAlias.setStyleSheet(
f'background: #{bright_background}; border: 1px solid #{bright_entry_border}; border-radius: 1px;')
self.new_accAliasError.setStyleSheet(f'color: #{bright_alert}')
# account id
self.new_accID.setStyleSheet(
f'background: #{bright_background}; border: 1px solid #{bright_entry_border}; border-radius: 1px;')
self.new_accIDError.setStyleSheet(f'color: #{bright_alert}')
# account email
self.new_accEmail.setStyleSheet(
f'background: #{bright_background}; border: 1px solid #{bright_entry_border}; border-radius: 1px;')
self.popupAddressesCompleter.setStyleSheet(f'background: #{bright_background}; color: #{bright_color};')
self.new_accEmailError.setStyleSheet(f'color: #{bright_alert}')
# account password
self.new_accPassword.setStyleSheet(
f'background: #{bright_background}; border: 1px solid #{bright_entry_border}; border-radius: 1px;')
self.new_accPasswordError.setStyleSheet(f'color: #{bright_alert}')
# generate password button
self.generate_password_button.setStyleSheet(
'QPushButton{background: #' + bright_background + '; border: 1px solid #' + bright_border + '; border-radius: 2px;}' +
'QPushButton:hover{background: #' + bright_background_hover + ';}')
# confirm button
self.confirmButton.setStyleSheet(
'QPushButton{background: #' + bright_background + '; border: 1px solid #' + bright_border + '; border-radius: 2px;}' +
'QPushButton:hover{background: #' + bright_background_hover + ';}')
def translate(self, language):
if language == french:
self.setWindowTitle('Modifier le compte')
# self.choose_folderLabel.setText('Dossier (facultatif):')
# self.add_folderButton.setText("Ajouter un dossier")
self.new_accName_label.setText('Nom du compte:')
self.new_accAlias_label.setText('Alias (facultatif):')
self.new_accID_label.setText('Identifiant (facultatif):')
self.new_accEmail_label.setText('Email (facultatif):')
self.new_accPassword_label.setText('Mot de passe:')
self.generate_password_button.setText('Générer un mot de passe')
self.generate_password_button.setFixedSize(195, 25)
self.confirmButton.setText('Sauvegarder')
elif language == english:
self.setWindowTitle('Edit the account')
# self.choose_folderLabel.setText('Folder (optional):')
# self.add_folderButton.setText("Add a folder")
self.new_accName_label.setText('Account name:')
self.new_accAlias_label.setText('Alias (optional):')
self.new_accID_label.setText('Identifier (optional):')
self.new_accEmail_label.setText('Email (optional):')
self.new_accPassword_label.setText('Password:')
self.generate_password_button.setText('Generate a password')
self.generate_password_button.setFixedSize(165, 25)
self.confirmButton.setText('Save')
def visible(self):
if not self.password_isVisible:
self.new_accPassword.setEchoMode(QLineEdit.Normal)
if self.main_self.theme == dark:
self.is_visible.setIcon(QIcon('resources/dark_close_eye.svg'))
elif self.main_self.theme == bright:
self.is_visible.setIcon(QIcon('resources/close_eye.svg'))
self.password_isVisible = True
else:
self.new_accPassword.setEchoMode(QLineEdit.Password)
if self.main_self.theme == dark:
self.is_visible.setIcon(QIcon('resources/dark_open_eye.svg'))
elif self.main_self.theme == bright:
self.is_visible.setIcon(QIcon('resources/open_eye.svg'))
self.password_isVisible = False
def keyPressEvent(self, event):
if event.modifiers() & Qt.ControlModifier:
if event.key() == Qt.Key_Q:
self.quit()
if event.key() == Qt.Key_S:
self.try_save_account_informations()
if event.key() == Qt.Key_Return:
self.try_save_account_informations()
def quit(self):
if self.new_accName.text().replace(' ', '') != self.accName or self.new_accAlias.text().replace(' ',
'') != "".join(
self.accAlias) or \
self.new_accID.text().replace(' ', '') != self.accID or self.new_accEmail.text().replace(' ',
'') != self.accEmail or \
self.new_accPassword.text().replace(' ', '') != self.accPassword:
exitMessage = QMessageBox()
exitMessage.setIcon(QMessageBox.Question)
exitMessage.setWindowIcon(QIcon('resources/pama.ico'))
if self.main_self.language == french:
exitMessage.setWindowTitle('Quitter')
exitMessage.setText('Voulez-vous vraiment fermer la fenêtre ?')
exitMessage.addButton("&Oui", QMessageBox.YesRole)
exitMessage.addButton("&Non", QMessageBox.NoRole)
elif self.main_self.language == english:
exitMessage.setWindowTitle('Exit')
exitMessage.setText('Do you really want to close the window ?')
exitMessage.addButton("&Yes", QMessageBox.YesRole)
exitMessage.addButton("&No", QMessageBox.NoRole)
exitMessage.exec_()
if exitMessage.clickedButton().text() == '&Yes' or exitMessage.clickedButton().text() == '&Oui':
self.close()
else:
self.close()