@@ -142,8 +142,6 @@ def __init__(self, id, text, arrow, *args):
142
142
# Make transparent
143
143
self .setAttribute (Qt .WA_NoSystemBackground , True )
144
144
self .setAttribute (Qt .WA_TranslucentBackground , True )
145
- # self.setWindowFlags(Qt.FramelessWindowHint)
146
-
147
145
self .setAttribute (Qt .WA_DeleteOnClose , True )
148
146
149
147
@@ -289,9 +287,25 @@ def re_position_dialog(self):
289
287
""" Reposition a tutorial dialog next to another widget """
290
288
if self .current_dialog :
291
289
""" 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 ))
295
309
296
310
def __init__ (self , win ):
297
311
""" Constructor """
@@ -308,6 +322,11 @@ def __init__(self, win):
308
322
self .tutorial_enabled = s .get ("tutorial_enabled" )
309
323
self .tutorial_ids = s .get ("tutorial_ids" ).split ("," )
310
324
325
+ # get screen geometry
326
+ screen = QGuiApplication .primaryScreen ()
327
+ self .screen_height = screen .geometry ().height ()
328
+ self .screen_width = screen .geometry ().width ()
329
+
311
330
# Add all possible tutorials
312
331
self .tutorial_objects = [
313
332
{"id" : "0" ,
@@ -374,7 +393,6 @@ def __init__(self, win):
374
393
self .dock .setWindowFlags (Qt .FramelessWindowHint )
375
394
self .dock .setFloating (True )
376
395
377
-
378
396
# Connect to interface dock widgets
379
397
self .win .dockFiles .visibilityChanged .connect (functools .partial (self .process , "dockFiles" ))
380
398
self .win .dockTransitions .visibilityChanged .connect (functools .partial (self .process , "dockTransitions" ))
0 commit comments