Initial commit

This commit is contained in:
Miguel Jacq 2025-10-31 16:00:54 +11:00
commit 3e6a08231c
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
17 changed files with 2054 additions and 0 deletions

41
bouquin/key_prompt.py Normal file
View 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()