Skip to content

Commit

Permalink
fix README bug and OSX bug
Browse files Browse the repository at this point in the history
  • Loading branch information
HDembinski committed May 31, 2021
1 parent a09b9d6 commit f5e2f00
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion monolens/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def main():
for key in settings.allKeys():
value = settings.value(key)
print(f" {key}: {value}")
if settings.value("show_intro", "True") == "True":
if DEBUG == 2 or settings.value("show_intro", "True") == "True":
intro = Intro()
intro.show()
intro.closed.connect(lens.show)
Expand Down
24 changes: 14 additions & 10 deletions monolens/intro.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from PySide6 import QtWidgets, QtCore, QtGui
from pathlib import Path
import re


class Intro(QtWidgets.QWidget):
Expand All @@ -14,19 +12,25 @@ def __init__(self):
self.setWindowFlag(QtCore.Qt.WindowStaysOnTopHint)
self.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False)

with open(Path(__file__).parent / ".." / "README.md") as f:
tx = f.read()
m = re.search("<!-- usage begin -->\n(.+?)\n<!--", tx, re.DOTALL)
usage = m.group(1).split("\n-")
usage = "".join(f"<li>{x}</li>" for x in usage if x and not x.isspace())

tx = f"""<h1 align="center">Welcome to Monolens</h1>
# TODO would be great to read this list from README
tx = """<h1 align="center">Welcome to Monolens</h1>
<p>Monolens allows you to view part of your screen in grayscale.</p>
<h2>Usage</h2>
<ul>
{usage}
<li>Drag the lens around by holding a Mouse button down inside the window</li>
<li>To quit, press Escape, Q, or double click on the lens</li>
<li>Resize the lens by pressing up, down, left, right</li>
<li>Press Tab to switch between monochrome view and simulated protanopia,
deuteranopia, tritanopia</li>
<li>To move the lens to another screen, press M</li>
</ul>
<br>
<p>
On OSX, you need to give Monolens permission to make screenshots, which is
safe.
</p>
"""

font = QtGui.QFont()
Expand Down
5 changes: 4 additions & 1 deletion monolens/lens.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ def _updateScreenshot(self, screen):
):
self._screenshot = pix.toImage()
self._converted = QtGui.QImage(
pix.width(), pix.height(), QtGui.QImage.Format_RGB32
self._screenshot.width(),
self._screenshot.height(),
QtGui.QImage.Format_RGB32,
)
self._converted.setDevicePixelRatio(self._screenshot.devicePixelRatio())
else:
# override lens with old pixels from previous screenshot
p = QtGui.QPainter(self._screenshot)
Expand Down

0 comments on commit f5e2f00

Please sign in to comment.