bouquin 0.4.1__py3-none-any.whl
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.
- bouquin/__init__.py +0 -0
- bouquin/__main__.py +4 -0
- bouquin/bug_report_dialog.py +128 -0
- bouquin/db.py +1010 -0
- bouquin/find_bar.py +206 -0
- bouquin/flow_layout.py +88 -0
- bouquin/history_dialog.py +177 -0
- bouquin/key_prompt.py +106 -0
- bouquin/locales/en.json +242 -0
- bouquin/locales/fr.json +137 -0
- bouquin/locales/it.json +136 -0
- bouquin/lock_overlay.py +50 -0
- bouquin/main.py +26 -0
- bouquin/main_window.py +1664 -0
- bouquin/markdown_editor.py +1227 -0
- bouquin/markdown_highlighter.py +287 -0
- bouquin/save_dialog.py +38 -0
- bouquin/search.py +208 -0
- bouquin/settings.py +62 -0
- bouquin/settings_dialog.py +310 -0
- bouquin/statistics_dialog.py +355 -0
- bouquin/strings.py +39 -0
- bouquin/tag_browser.py +253 -0
- bouquin/tags_widget.py +259 -0
- bouquin/theme.py +260 -0
- bouquin/time_log.py +1217 -0
- bouquin/toolbar.py +195 -0
- bouquin-0.4.1.dist-info/LICENSE +674 -0
- bouquin-0.4.1.dist-info/METADATA +104 -0
- bouquin-0.4.1.dist-info/RECORD +32 -0
- bouquin-0.4.1.dist-info/WHEEL +4 -0
- bouquin-0.4.1.dist-info/entry_points.txt +3 -0
bouquin/__init__.py
ADDED
|
File without changes
|
bouquin/__main__.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import importlib.metadata
|
|
4
|
+
|
|
5
|
+
import requests
|
|
6
|
+
|
|
7
|
+
from PySide6.QtWidgets import (
|
|
8
|
+
QDialog,
|
|
9
|
+
QVBoxLayout,
|
|
10
|
+
QLabel,
|
|
11
|
+
QTextEdit,
|
|
12
|
+
QDialogButtonBox,
|
|
13
|
+
QMessageBox,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
from . import strings
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
BUG_REPORT_HOST = "https://nr.mig5.net"
|
|
20
|
+
ROUTE = "forms/bouquin/bugs"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class BugReportDialog(QDialog):
|
|
24
|
+
"""
|
|
25
|
+
Dialog to collect a bug report
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
MAX_CHARS = 5000
|
|
29
|
+
|
|
30
|
+
def __init__(self, parent=None):
|
|
31
|
+
super().__init__(parent)
|
|
32
|
+
self.setWindowTitle(strings._("report_a_bug"))
|
|
33
|
+
|
|
34
|
+
layout = QVBoxLayout(self)
|
|
35
|
+
|
|
36
|
+
header = QLabel(strings._("bug_report_explanation"))
|
|
37
|
+
header.setWordWrap(True)
|
|
38
|
+
layout.addWidget(header)
|
|
39
|
+
|
|
40
|
+
self.text_edit = QTextEdit()
|
|
41
|
+
self.text_edit.setPlaceholderText(strings._("bug_report_placeholder"))
|
|
42
|
+
layout.addWidget(self.text_edit)
|
|
43
|
+
|
|
44
|
+
self.text_edit.textChanged.connect(self._enforce_max_length)
|
|
45
|
+
|
|
46
|
+
# Buttons: Cancel / Send
|
|
47
|
+
button_box = QDialogButtonBox(QDialogButtonBox.Cancel)
|
|
48
|
+
button_box.addButton(strings._("send"), QDialogButtonBox.AcceptRole)
|
|
49
|
+
button_box.accepted.connect(self._send)
|
|
50
|
+
button_box.rejected.connect(self.reject)
|
|
51
|
+
layout.addWidget(button_box)
|
|
52
|
+
|
|
53
|
+
self.setMinimumWidth(560)
|
|
54
|
+
|
|
55
|
+
self.text_edit.setFocus()
|
|
56
|
+
|
|
57
|
+
# ------------Helpers ------------ #
|
|
58
|
+
|
|
59
|
+
def _enforce_max_length(self):
|
|
60
|
+
text = self.text_edit.toPlainText()
|
|
61
|
+
if len(text) <= self.MAX_CHARS:
|
|
62
|
+
return
|
|
63
|
+
|
|
64
|
+
# Remember cursor position
|
|
65
|
+
cursor = self.text_edit.textCursor()
|
|
66
|
+
pos = cursor.position()
|
|
67
|
+
|
|
68
|
+
# Trim and restore without re-entering this slot
|
|
69
|
+
self.text_edit.blockSignals(True)
|
|
70
|
+
self.text_edit.setPlainText(text[: self.MAX_CHARS])
|
|
71
|
+
self.text_edit.blockSignals(False)
|
|
72
|
+
|
|
73
|
+
# Clamp cursor position to end of text
|
|
74
|
+
if pos > self.MAX_CHARS:
|
|
75
|
+
pos = self.MAX_CHARS
|
|
76
|
+
|
|
77
|
+
cursor.setPosition(pos)
|
|
78
|
+
self.text_edit.setTextCursor(cursor)
|
|
79
|
+
|
|
80
|
+
def _send(self):
|
|
81
|
+
text = self.text_edit.toPlainText().strip()
|
|
82
|
+
if not text:
|
|
83
|
+
QMessageBox.warning(
|
|
84
|
+
self,
|
|
85
|
+
strings._("report_a_bug"),
|
|
86
|
+
strings._("bug_report_empty"),
|
|
87
|
+
)
|
|
88
|
+
return
|
|
89
|
+
|
|
90
|
+
# Get current app version
|
|
91
|
+
try:
|
|
92
|
+
version = importlib.metadata.version("bouquin")
|
|
93
|
+
except importlib.metadata.PackageNotFoundError:
|
|
94
|
+
version = "unknown"
|
|
95
|
+
|
|
96
|
+
payload: dict[str, str] = {
|
|
97
|
+
"message": text,
|
|
98
|
+
"version": version,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# POST as JSON
|
|
102
|
+
try:
|
|
103
|
+
resp = requests.post(
|
|
104
|
+
f"{BUG_REPORT_HOST}/{ROUTE}",
|
|
105
|
+
json=payload,
|
|
106
|
+
timeout=10,
|
|
107
|
+
)
|
|
108
|
+
except Exception as e:
|
|
109
|
+
QMessageBox.critical(
|
|
110
|
+
self,
|
|
111
|
+
strings._("report_a_bug"),
|
|
112
|
+
strings._("bug_report_send_failed") + f"\n{e}",
|
|
113
|
+
)
|
|
114
|
+
return
|
|
115
|
+
|
|
116
|
+
if resp.status_code == 201:
|
|
117
|
+
QMessageBox.information(
|
|
118
|
+
self,
|
|
119
|
+
strings._("report_a_bug"),
|
|
120
|
+
strings._("bug_report_sent_ok"),
|
|
121
|
+
)
|
|
122
|
+
self.accept()
|
|
123
|
+
else:
|
|
124
|
+
QMessageBox.critical(
|
|
125
|
+
self,
|
|
126
|
+
strings._("report_a_bug"),
|
|
127
|
+
strings._("bug_report_send_failed") + f" (HTTP {resp.status_code})",
|
|
128
|
+
)
|