Skip to content

Commit 6764fa5

Browse files
committed
Adjust position of tutorial message for smaller screens, or when OpenShot is moved past the edge of the screen.
1 parent a45a82d commit 6764fa5

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/windows/views/tutorial.py

+24-6
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ def __init__(self, id, text, arrow, *args):
142142
# Make transparent
143143
self.setAttribute(Qt.WA_NoSystemBackground, True)
144144
self.setAttribute(Qt.WA_TranslucentBackground, True)
145-
# self.setWindowFlags(Qt.FramelessWindowHint)
146-
147145
self.setAttribute(Qt.WA_DeleteOnClose, True)
148146

149147

@@ -289,9 +287,25 @@ def re_position_dialog(self):
289287
""" Reposition a tutorial dialog next to another widget """
290288
if self.current_dialog:
291289
""" Move widget next to its position widget """
292-
x = self.position_widget.mapToGlobal(self.position_widget.pos()).x()
293-
y = self.position_widget.mapToGlobal(self.position_widget.pos()).y()
294-
self.dock.move(QPoint(x + self.x_offset, y + self.y_offset))
290+
x = self.position_widget.mapToGlobal(self.position_widget.pos()).x() + self.x_offset
291+
y = self.position_widget.mapToGlobal(self.position_widget.pos()).y() + self.y_offset
292+
293+
# Position in Screen coordinates
294+
bottom_dialog_pos = self.current_dialog.mapToGlobal(QPoint(self.current_dialog.geometry().right(),
295+
self.current_dialog.geometry().bottom()))
296+
right_edge = bottom_dialog_pos.x()
297+
bottom_edge = bottom_dialog_pos.y()
298+
299+
# If we are exceeding the screen dimensions, adjust back to the visible screen
300+
# This might result in sub-optimal positioning, but at least the tutorial
301+
# buttons won't be hidden off-screen.
302+
if right_edge > self.screen_width:
303+
x = self.screen_width - self.current_dialog.geometry().width()
304+
if bottom_edge > self.screen_height:
305+
y = self.screen_height - self.current_dialog.geometry().height()
306+
307+
# Move tutorial widget to the correct position
308+
self.dock.move(QPoint(x, y))
295309

296310
def __init__(self, win):
297311
""" Constructor """
@@ -308,6 +322,11 @@ def __init__(self, win):
308322
self.tutorial_enabled = s.get("tutorial_enabled")
309323
self.tutorial_ids = s.get("tutorial_ids").split(",")
310324

325+
# get screen geometry
326+
screen = QGuiApplication.primaryScreen()
327+
self.screen_height = screen.geometry().height()
328+
self.screen_width = screen.geometry().width()
329+
311330
# Add all possible tutorials
312331
self.tutorial_objects = [
313332
{"id": "0",
@@ -374,7 +393,6 @@ def __init__(self, win):
374393
self.dock.setWindowFlags(Qt.FramelessWindowHint)
375394
self.dock.setFloating(True)
376395

377-
378396
# Connect to interface dock widgets
379397
self.win.dockFiles.visibilityChanged.connect(functools.partial(self.process, "dockFiles"))
380398
self.win.dockTransitions.visibilityChanged.connect(functools.partial(self.process, "dockTransitions"))

0 commit comments

Comments
 (0)