splitguides 0.10.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.
Files changed (39) hide show
  1. splitguides/__init__.py +1 -0
  2. splitguides/__main__.py +15 -0
  3. splitguides/_version.py +2 -0
  4. splitguides/build_ui.py +71 -0
  5. splitguides/exceptions.py +4 -0
  6. splitguides/hotkeys.py +54 -0
  7. splitguides/livesplit_client.py +303 -0
  8. splitguides/note_parser.py +260 -0
  9. splitguides/server/__init__.py +1 -0
  10. splitguides/server/__main__.py +58 -0
  11. splitguides/server/split_server.py +129 -0
  12. splitguides/settings.py +231 -0
  13. splitguides/static/desktop.css +146 -0
  14. splitguides/static/server.css +160 -0
  15. splitguides/static/streamlistener.js +18 -0
  16. splitguides/templates/desktop.html +25 -0
  17. splitguides/templates/server.html +12 -0
  18. splitguides/ui/__init__.py +0 -0
  19. splitguides/ui/color.py +50 -0
  20. splitguides/ui/custom_elements/__init__.py +18 -0
  21. splitguides/ui/hotkey_manager.py +92 -0
  22. splitguides/ui/layouts/__init__.py +8 -0
  23. splitguides/ui/layouts/build/__init__.py +0 -0
  24. splitguides/ui/layouts/build/main_window.py +61 -0
  25. splitguides/ui/layouts/build/server_settings.py +349 -0
  26. splitguides/ui/layouts/build/settings.py +318 -0
  27. splitguides/ui/layouts/main_window.ui +64 -0
  28. splitguides/ui/layouts/server_settings.ui +394 -0
  29. splitguides/ui/layouts/settings.ui +382 -0
  30. splitguides/ui/main.pyproject +3 -0
  31. splitguides/ui/main_window.py +492 -0
  32. splitguides/ui/server_settings_ui.py +191 -0
  33. splitguides/ui/settings_ui.py +241 -0
  34. splitguides-0.10.1.dist-info/METADATA +199 -0
  35. splitguides-0.10.1.dist-info/RECORD +39 -0
  36. splitguides-0.10.1.dist-info/WHEEL +5 -0
  37. splitguides-0.10.1.dist-info/entry_points.txt +3 -0
  38. splitguides-0.10.1.dist-info/licenses/COPYING +674 -0
  39. splitguides-0.10.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,146 @@
1
+ /*
2
+ Based on: https://github.com/jasonlong/cayman-theme/blob/master/css/cayman.css
3
+ Reduced to the main-content element and modified to remove most color variation.
4
+ */
5
+
6
+ * {
7
+ box-sizing: border-box;
8
+ }
9
+
10
+ body {
11
+ padding: 0;
12
+ margin: 0;
13
+ font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
14
+ line-height: 1.5;
15
+ }
16
+
17
+ a {
18
+ color: #1e6bb8;
19
+ text-decoration: none; }
20
+ a:hover {
21
+ text-decoration: underline; }
22
+
23
+ .main-content {
24
+ word-wrap: break-word; }
25
+ .main-content :first-child {
26
+ margin-top: 0; }
27
+ @media screen and (min-width: 64em) {
28
+ .main-content {
29
+ max-width: 64rem;
30
+ padding: 2rem 3rem;
31
+ margin: 0 auto;
32
+ font-size: 1.1rem; } }
33
+ @media screen and (min-width: 42em) and (max-width: 64em) {
34
+ .main-content {
35
+ padding: 2rem 2rem;
36
+ font-size: 1.1rem; } }
37
+ @media screen and (max-width: 42em) {
38
+ .main-content {
39
+ padding: 2rem 1rem;
40
+ font-size: 1rem; } }
41
+ .main-content img {
42
+ max-width: 100%; }
43
+ .main-content h1,
44
+ .main-content h2,
45
+ .main-content h3,
46
+ .main-content h4,
47
+ .main-content h5,
48
+ .main-content h6 {
49
+ margin-top: 2rem;
50
+ margin-bottom: 1rem;
51
+ font-weight: normal;
52
+ }
53
+ .main-content p {
54
+ margin-bottom: 1em; }
55
+ .main-content code {
56
+ padding: 2px 4px;
57
+ font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
58
+ font-size: 0.9rem;
59
+ border-radius: 0.3rem; }
60
+ .main-content pre {
61
+ padding: 0.8rem;
62
+ margin-top: 0;
63
+ margin-bottom: 1rem;
64
+ font: 1rem Consolas, "Liberation Mono", Menlo, Courier, monospace;
65
+ word-wrap: normal;
66
+ border: solid 1px #454d57;
67
+ border-radius: 0.3rem; }
68
+ .main-content pre > code {
69
+ padding: 0;
70
+ margin: 0;
71
+ font-size: 0.9rem;
72
+ word-break: normal;
73
+ white-space: pre;
74
+ background: transparent;
75
+ border: 0; }
76
+ .main-content .highlight {
77
+ margin-bottom: 1rem; }
78
+ .main-content .highlight pre {
79
+ margin-bottom: 0;
80
+ word-break: normal; }
81
+ .main-content .highlight pre,
82
+ .main-content pre {
83
+ padding: 0.8rem;
84
+ overflow: auto;
85
+ font-size: 0.9rem;
86
+ line-height: 1.45;
87
+ border-radius: 0.3rem;
88
+ -webkit-overflow-scrolling: touch; }
89
+ .main-content pre code,
90
+ .main-content pre tt {
91
+ display: inline;
92
+ max-width: initial;
93
+ padding: 0;
94
+ margin: 0;
95
+ overflow: initial;
96
+ line-height: inherit;
97
+ word-wrap: normal;
98
+ background-color: transparent;
99
+ border: 0; }
100
+ .main-content pre code:before, .main-content pre code:after,
101
+ .main-content pre tt:before,
102
+ .main-content pre tt:after {
103
+ content: normal; }
104
+ .main-content ul,
105
+ .main-content ol {
106
+ padding-top: 0;
107
+ padding-bottom: 0;
108
+ margin-top: 0;
109
+ margin-bottom:0;
110
+ }
111
+ .main-content blockquote {
112
+ padding: 0 1rem;
113
+ margin-left: 0;
114
+ border-left: 0.3rem solid #919ba5; }
115
+ .main-content blockquote > :first-child {
116
+ margin-top: 0; }
117
+ .main-content blockquote > :last-child {
118
+ margin-bottom: 0; }
119
+ .main-content table {
120
+ display: block;
121
+ width: 100%;
122
+ overflow: auto;
123
+ word-break: keep-all;
124
+ -webkit-overflow-scrolling: touch; }
125
+ .main-content table th {
126
+ font-weight: bold; }
127
+ .main-content table th,
128
+ .main-content table td {
129
+ padding: 0.5rem 1rem;
130
+ border: 1px solid #a1a3a4; }
131
+ .main-content dl {
132
+ padding: 0; }
133
+ .main-content dl dt {
134
+ padding: 0;
135
+ margin-top: 1rem;
136
+ font-size: 1rem;
137
+ font-weight: bold; }
138
+ .main-content dl dd {
139
+ padding: 0;
140
+ margin-bottom: 1rem; }
141
+ .main-content hr {
142
+ height: 2px;
143
+ padding: 0;
144
+ margin: 1rem 0;
145
+ background-color: #666666;
146
+ border: 0; }
@@ -0,0 +1,160 @@
1
+ /*
2
+ Based on: https://github.com/jasonlong/cayman-theme/blob/master/css/cayman.css
3
+ Reduced to the main-content element and modified to remove most color variation.
4
+ */
5
+
6
+ * {
7
+ box-sizing: border-box;
8
+ }
9
+
10
+ :root {
11
+ font-size: 24px;
12
+ padding-top: 0;
13
+ }
14
+
15
+ html {
16
+ text-size-adjust: none;
17
+ -ms-text-size-adjust: none;
18
+ -webkit-text-size-adjust: none;
19
+ -moz-text-size-adjust: none;
20
+ }
21
+
22
+ body {
23
+ color: #000000;
24
+ background-color: #f1f8ff;
25
+ padding: 0;
26
+ margin: 0;
27
+ font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
28
+ line-height: 1.5;
29
+ }
30
+
31
+ a {
32
+ color: #1e6bb8;
33
+ text-decoration: none; }
34
+ a:hover {
35
+ text-decoration: underline; }
36
+
37
+ .main-content {
38
+ word-wrap: break-word; }
39
+ .main-content :first-child {
40
+ margin-top: 0; }
41
+ @media screen and (min-width: 64em) {
42
+ .main-content {
43
+ max-width: 64rem;
44
+ padding: 2rem 3rem;
45
+ margin: 0 auto;
46
+ font-size: 1.1rem; } }
47
+ @media screen and (min-width: 42em) and (max-width: 64em) {
48
+ .main-content {
49
+ padding: 2rem 2rem;
50
+ font-size: 1.1rem; } }
51
+ @media screen and (max-width: 42em) {
52
+ .main-content {
53
+ padding: 2rem 1rem;
54
+ font-size: 1.0rem; } }
55
+ .main-content img {
56
+ max-width: 100%; }
57
+ .main-content h1,
58
+ .main-content h2,
59
+ .main-content h3,
60
+ .main-content h4,
61
+ .main-content h5,
62
+ .main-content h6 {
63
+ margin-top: 2rem;
64
+ margin-bottom: 1rem;
65
+ font-weight: normal;
66
+ }
67
+ .main-content p {
68
+ margin-bottom: 1em; }
69
+ .main-content code {
70
+ padding: 2px 4px;
71
+ font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
72
+ font-size: 0.9rem;
73
+ border-radius: 0.3rem; }
74
+ .main-content pre {
75
+ padding: 0.8rem;
76
+ margin-top: 0;
77
+ margin-bottom: 1rem;
78
+ font: 1rem Consolas, "Liberation Mono", Menlo, Courier, monospace;
79
+ word-wrap: normal;
80
+ border: solid 1px #454d57;
81
+ border-radius: 0.3rem; }
82
+ .main-content pre > code {
83
+ padding: 0;
84
+ margin: 0;
85
+ font-size: 0.9rem;
86
+ word-break: normal;
87
+ white-space: pre;
88
+ background: transparent;
89
+ border: 0; }
90
+ .main-content .highlight {
91
+ margin-bottom: 1rem; }
92
+ .main-content .highlight pre {
93
+ margin-bottom: 0;
94
+ word-break: normal; }
95
+ .main-content .highlight pre,
96
+ .main-content pre {
97
+ padding: 0.8rem;
98
+ overflow: auto;
99
+ font-size: 0.9rem;
100
+ line-height: 1.45;
101
+ border-radius: 0.3rem;
102
+ -webkit-overflow-scrolling: touch; }
103
+ .main-content pre code,
104
+ .main-content pre tt {
105
+ display: inline;
106
+ max-width: initial;
107
+ padding: 0;
108
+ margin: 0;
109
+ overflow: initial;
110
+ line-height: inherit;
111
+ word-wrap: normal;
112
+ background-color: transparent;
113
+ border: 0; }
114
+ .main-content pre code:before, .main-content pre code:after,
115
+ .main-content pre tt:before,
116
+ .main-content pre tt:after {
117
+ content: normal; }
118
+ .main-content ul,
119
+ .main-content ol {
120
+ padding-top: 0;
121
+ padding-bottom: 0;
122
+ margin-top: 0;
123
+ margin-bottom:0;
124
+ }
125
+ .main-content blockquote {
126
+ padding: 0 1rem;
127
+ margin-left: 0;
128
+ border-left: 0.3rem solid #919ba5; }
129
+ .main-content blockquote > :first-child {
130
+ margin-top: 0; }
131
+ .main-content blockquote > :last-child {
132
+ margin-bottom: 0; }
133
+ .main-content table {
134
+ display: block;
135
+ width: 100%;
136
+ overflow: auto;
137
+ word-break: keep-all;
138
+ -webkit-overflow-scrolling: touch; }
139
+ .main-content table th {
140
+ font-weight: bold; }
141
+ .main-content table th,
142
+ .main-content table td {
143
+ padding: 0.5rem 1rem;
144
+ border: 1px solid #a1a3a4; }
145
+ .main-content dl {
146
+ padding: 0; }
147
+ .main-content dl dt {
148
+ padding: 0;
149
+ margin-top: 1rem;
150
+ font-size: 1rem;
151
+ font-weight: bold; }
152
+ .main-content dl dd {
153
+ padding: 0;
154
+ margin-bottom: 1rem; }
155
+ .main-content hr {
156
+ height: 2px;
157
+ padding: 0;
158
+ margin: 1rem 0;
159
+ background-color: #666666;
160
+ border: 0; }
@@ -0,0 +1,18 @@
1
+ // This is the code to listen to server events sent by flask.
2
+
3
+ const splits = document.getElementById("splits")
4
+ const evtSource = new EventSource("splits")
5
+
6
+ splits.innerHTML = "<strong>Loading...</strong>"
7
+
8
+ console.log(evtSource)
9
+
10
+ evtSource.onmessage = function(e) {
11
+ if (e.data) {
12
+ splits.innerHTML = e.data
13
+ }
14
+ }
15
+
16
+ evtSource.onerror = function(err) {
17
+ console.error("EventSource failed:", err)
18
+ }
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>SplitGuides</title>
6
+ <style>
7
+ :root {
8
+ font-size: {{ font_size }}px;
9
+ color: {{ font_color }};
10
+ background-color: {{ bg_color }};
11
+ }
12
+ {{ css }}
13
+ </style>
14
+ </head>
15
+ <body>
16
+ <div id="splits" class="main-content">
17
+ {% for split in notes %}
18
+ {{ split }}
19
+ {% if not loop.last %}
20
+ <hr>
21
+ {% endif %}
22
+ {% endfor %}
23
+ </div>
24
+ </body>
25
+ </html>
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>SplitGuides - {{ notefile }}</title>
6
+ <link rel="stylesheet" href="{{ url_for('static', filename='server.css') }}">
7
+ </head>
8
+ <body>
9
+ <div id="splits" class="main-content"></div>
10
+ <script src="{{ url_for('static', filename='streamlistener.js') }}"></script>
11
+ </body>
12
+ </html>
File without changes
@@ -0,0 +1,50 @@
1
+ """
2
+ Helper functions for converting between different colour formats
3
+ """
4
+
5
+
6
+ from PySide6.QtGui import QColor
7
+
8
+
9
+ def rgba_to_qcolor(s: str) -> QColor:
10
+ """
11
+ Convert #rrggbbaa colour to a QColor object
12
+
13
+ QColor is used in the settings colour picker dialog
14
+
15
+ :param s: Colour as #rrggbbaa string
16
+ :return: QColor
17
+ """
18
+ if len(s) == 9 and s[0] == "#":
19
+ rgb, a = s[1:7], s[7:9]
20
+ return QColor(f"#{a}{rgb}")
21
+ else:
22
+ return QColor(s)
23
+
24
+
25
+ def qcolor_to_rgba(color: QColor) -> str:
26
+ """
27
+ Convert QColor back to an #rrggbbaa string
28
+
29
+ Used in the settings dialog
30
+
31
+ :param color: QColor object
32
+ :return: Colour as #rrggbbaa string
33
+ """
34
+ argb = color.name(QColor.NameFormat.HexArgb)
35
+ a, rgb = argb[1:3], argb[3:9]
36
+ return f"#{rgb}{a}"
37
+
38
+
39
+ def rgba_to_qss(s: str) -> str:
40
+ """
41
+ Convert hex #rrggbbaa string to a format used in Qt's own style sheets
42
+
43
+ This is used for the background of the notes widget itself.
44
+
45
+ :param s: Colour as #rrggbbaa string
46
+ :return: Colour as 'rgba(r, g, b, a) string
47
+ """
48
+ c = rgba_to_qcolor(s)
49
+ r, g, b, a = c.red(), c.green(), c.blue(), c.alpha()
50
+ return f"rgba({r}, {g}, {b}, {a})"
@@ -0,0 +1,18 @@
1
+ """
2
+ Replace the standard QWebEnginePage with one that launches links in the user's default browser
3
+ """
4
+ from PySide6.QtWebEngineCore import QWebEnginePage
5
+ from PySide6.QtGui import QDesktopServices
6
+
7
+
8
+ class ExtLinkWebEnginePage(QWebEnginePage):
9
+ """
10
+ QWebEnginePage that launches links in an external browser
11
+ """
12
+
13
+ def acceptNavigationRequest(self, url, _type, is_mainframe):
14
+ # Launch external browser for clicking links, otherwise do default behaviour
15
+ if _type == QWebEnginePage.NavigationTypeLinkClicked:
16
+ QDesktopServices.openUrl(url)
17
+ return False
18
+ return super().acceptNavigationRequest(url, _type, is_mainframe)
@@ -0,0 +1,92 @@
1
+ """
2
+ Handle the keyboard inputs and the thread waiting
3
+
4
+ I'm trying to isolate all keyboard module related code here because
5
+ I really don't like the design
6
+ (some confusing lambdas + all the actual code is in one 1k+ line __init__.py file)
7
+ but it's currently better than the alternative of writing a keyboard hook
8
+ library myself for this one small task.
9
+ """
10
+ import sys
11
+
12
+ import time
13
+ import json
14
+ from collections.abc import Callable
15
+
16
+ import keyboard
17
+ from PySide6 import QtCore
18
+
19
+ from ducktools.classbuilder.prefab import as_dict
20
+
21
+ from ..hotkeys import read_hotkey
22
+
23
+
24
+ IS_WINDOWS = sys.platform == "win32"
25
+
26
+
27
+ class HotkeyManager(QtCore.QObject):
28
+ hotkey_signal = QtCore.Signal(str)
29
+ increase_signal = QtCore.Signal()
30
+ decrease_signal = QtCore.Signal()
31
+
32
+ enabled: bool
33
+ increase_key: Callable[[], None] | None
34
+ decrease_key: Callable[[], None] | None
35
+
36
+ def __init__(self, parent):
37
+ super().__init__()
38
+ self.parent = parent
39
+ self.enabled = False
40
+
41
+ # Connect to the increase_offset and decrease_offset functions
42
+ self.increase_signal.connect(self.parent.increase_offset)
43
+ self.decrease_signal.connect(self.parent.decrease_offset)
44
+
45
+ # The keys for unbinding
46
+ self.increase_key = None
47
+ self.decrease_key = None
48
+
49
+ def enable_hotkeys(self, increase_key, decrease_key):
50
+ if IS_WINDOWS:
51
+ if increase_key:
52
+ self.increase_key = keyboard.add_hotkey(
53
+ tuple(increase_key), self.increase_signal.emit
54
+ )
55
+ if decrease_key:
56
+ self.decrease_key = keyboard.add_hotkey(
57
+ tuple(decrease_key), self.decrease_signal.emit
58
+ )
59
+ self.enabled = True
60
+
61
+ def disable_hotkeys(self):
62
+ if IS_WINDOWS:
63
+ if self.increase_key:
64
+ keyboard.remove_hotkey(self.increase_key)
65
+ if self.decrease_key:
66
+ keyboard.remove_hotkey(self.decrease_key)
67
+ self.enabled = False
68
+
69
+ @staticmethod
70
+ def disable_all():
71
+ """Backup method to just disable everything, used at close"""
72
+ if IS_WINDOWS:
73
+ keyboard.unhook_all()
74
+
75
+ def select_input(self, return_object):
76
+ """
77
+ Choose a hotkey to be used.
78
+ :param return_object: the function to call back with the hotkey value
79
+ """
80
+ if IS_WINDOWS:
81
+ self.hotkey_signal.connect(return_object)
82
+
83
+ # Sleep 100ms to allow inputs used to trigger
84
+ # The detection to clear first
85
+ time.sleep(0.1)
86
+ hotkey = read_hotkey(False)
87
+
88
+ # Esc, Backspace or Delete can be used to clear the input
89
+ if hotkey.name in ["esc", "backspace", "delete"]:
90
+ hotkey = None # Blank will be converted to None
91
+
92
+ self.hotkey_signal.emit(json.dumps(as_dict(hotkey))) # Needs to be a string
@@ -0,0 +1,8 @@
1
+ try:
2
+ from .build.main_window import Ui_MainWindow
3
+ from .build.settings import Ui_Settings
4
+ from .build.server_settings import Ui_ServerSettings
5
+ except ImportError:
6
+ raise FileNotFoundError(
7
+ "Dialog files could not be found, Ui files need to be rebuilt."
8
+ )
File without changes
@@ -0,0 +1,61 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ ################################################################################
4
+ ## Form generated from reading UI file 'main_window.ui'
5
+ ##
6
+ ## Created by: Qt User Interface Compiler version 6.9.1
7
+ ##
8
+ ## WARNING! All changes made in this file will be lost when recompiling UI file!
9
+ ################################################################################
10
+
11
+ from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
12
+ QMetaObject, QObject, QPoint, QRect,
13
+ QSize, QTime, QUrl, Qt)
14
+ from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
15
+ QFont, QFontDatabase, QGradient, QIcon,
16
+ QImage, QKeySequence, QLinearGradient, QPainter,
17
+ QPalette, QPixmap, QRadialGradient, QTransform)
18
+ from PySide6.QtWebEngineWidgets import QWebEngineView
19
+ from PySide6.QtWidgets import (QApplication, QGridLayout, QMainWindow, QMenuBar,
20
+ QSizePolicy, QStatusBar, QWidget)
21
+
22
+ class Ui_MainWindow(object):
23
+ def setupUi(self, MainWindow):
24
+ if not MainWindow.objectName():
25
+ MainWindow.setObjectName(u"MainWindow")
26
+ MainWindow.resize(800, 800)
27
+ font = QFont()
28
+ font.setPointSize(10)
29
+ MainWindow.setFont(font)
30
+ self.centralWidget = QWidget(MainWindow)
31
+ self.centralWidget.setObjectName(u"centralWidget")
32
+ self.gridLayout = QGridLayout(self.centralWidget)
33
+ self.gridLayout.setObjectName(u"gridLayout")
34
+ self.notes = QWebEngineView(self.centralWidget)
35
+ self.notes.setObjectName(u"notes")
36
+
37
+ self.gridLayout.addWidget(self.notes, 0, 0, 1, 1)
38
+
39
+ MainWindow.setCentralWidget(self.centralWidget)
40
+ self.menubar = QMenuBar(MainWindow)
41
+ self.menubar.setObjectName(u"menubar")
42
+ self.menubar.setEnabled(True)
43
+ self.menubar.setGeometry(QRect(0, 0, 800, 23))
44
+ self.menubar.setFont(font)
45
+ MainWindow.setMenuBar(self.menubar)
46
+ self.statusbar = QStatusBar(MainWindow)
47
+ self.statusbar.setObjectName(u"statusbar")
48
+ font1 = QFont()
49
+ font1.setPointSize(12)
50
+ self.statusbar.setFont(font1)
51
+ MainWindow.setStatusBar(self.statusbar)
52
+
53
+ self.retranslateUi(MainWindow)
54
+
55
+ QMetaObject.connectSlotsByName(MainWindow)
56
+ # setupUi
57
+
58
+ def retranslateUi(self, MainWindow):
59
+ MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"SplitGuides", None))
60
+ # retranslateUi
61
+