Initial commit
This commit is contained in:
commit
3e6a08231c
17 changed files with 2054 additions and 0 deletions
41
bouquin/key_prompt.py
Normal file
41
bouquin/key_prompt.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from PySide6.QtWidgets import (
|
||||
QDialog,
|
||||
QVBoxLayout,
|
||||
QLabel,
|
||||
QLineEdit,
|
||||
QPushButton,
|
||||
QDialogButtonBox,
|
||||
)
|
||||
|
||||
|
||||
class KeyPrompt(QDialog):
|
||||
def __init__(
|
||||
self,
|
||||
parent=None,
|
||||
title: str = "Unlock database",
|
||||
message: str = "Enter SQLCipher key",
|
||||
):
|
||||
super().__init__(parent)
|
||||
self.setWindowTitle(title)
|
||||
v = QVBoxLayout(self)
|
||||
v.addWidget(QLabel(message))
|
||||
self.edit = QLineEdit()
|
||||
self.edit.setEchoMode(QLineEdit.Password)
|
||||
v.addWidget(self.edit)
|
||||
toggle = QPushButton("Show")
|
||||
toggle.setCheckable(True)
|
||||
toggle.toggled.connect(
|
||||
lambda c: self.edit.setEchoMode(
|
||||
QLineEdit.Normal if c else QLineEdit.Password
|
||||
)
|
||||
)
|
||||
v.addWidget(toggle)
|
||||
bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
||||
bb.accepted.connect(self.accept)
|
||||
bb.rejected.connect(self.reject)
|
||||
v.addWidget(bb)
|
||||
|
||||
def key(self) -> str:
|
||||
return self.edit.text()
|
||||
Loading…
Add table
Add a link
Reference in a new issue