-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcgetmasterkey.py
More file actions
65 lines (53 loc) · 2.17 KB
/
Copy pathcgetmasterkey.py
File metadata and controls
65 lines (53 loc) · 2.17 KB
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
# encfsgui Ask for master key
#
import os
import sys
import time
import datetime
import string
from PyQt5 import uic
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import *
from PyQt5 import QtCore
from PyQt5.QtWidgets import QMessageBox, QSystemTrayIcon, QMenu, QAction, QStyle
import encfsgui_globals
from encfsgui_globals import *
import encfsgui_helper
from encfsgui_helper import *
class CMasterKeyWindow(QtWidgets.QDialog):
def __init__(self):
encfsgui_helper.print_debug("Start CMasterKeyWindow %s" % inspect.stack()[0][3])
super(CMasterKeyWindow, self).__init__()
uic.loadUi('encfsgui_masterkey.ui', self)
# disable/remove buttons
self.setWindowFlags(self.windowFlags() | QtCore.Qt.CustomizeWindowHint | QtCore.Qt.WindowStaysOnTopHint)
self.setWindowFlag(QtCore.Qt.WindowMaximizeButtonHint, False)
self.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False)
self.okbutton = self.findChild(QtWidgets.QPushButton, 'btn_OK')
self.okbutton.clicked.connect(self.OKButtonClicked)
self.cancelbutton = self.findChild(QtWidgets.QPushButton, 'btn_cancel')
self.cancelbutton.clicked.connect(self.CancelButtonClicked)
self.txt_password = self.findChild(QtWidgets.QLineEdit, 'txt_password')
self._password_accepted = False
def getPassword(self):
encfsgui_helper.print_debug("Start %s" % inspect.stack()[0][3])
if not self._password_accepted:
return ""
if self.txt_password.text() == "":
return ""
pw = encfsgui_helper.makePW32(self.txt_password.text()[0:31])
return pw
def OKButtonClicked(self):
encfsgui_helper.print_debug("Start %s" % inspect.stack()[0][3])
if self.txt_password.text() == "":
QtWidgets.QMessageBox.critical(None, "Error", "Master password cannot be empty.")
return
self._password_accepted = True
self.accept()
return
def CancelButtonClicked(self):
encfsgui_helper.print_debug("Start %s" % inspect.stack()[0][3])
self._password_accepted = False
self.txt_password.setText("")
self.reject()
return