44
44
class TutorialDialog (QWidget ):
45
45
""" A customized QWidget used to instruct a user how to use a certain feature """
46
46
47
- def paintEvent (self , event , * args ):
47
+ def paintEvent (self , event ):
48
48
""" Custom paint event """
49
- # Paint custom frame image on QWidget
50
49
painter = QPainter (self )
51
50
painter .setRenderHint (QPainter .Antialiasing )
52
- frameColor = QColor ("#53a0ed" )
53
51
54
- painter .setPen (QPen (frameColor , 2 ))
52
+ # Define rounded rectangle geometry
53
+ rounded_rect = QRectF (31 , 0 , self .width () - 31 , self .height ())
54
+ corner_radius = 10
55
+
56
+ # Clip to the rounded rectangle
57
+ path = QPainterPath ()
58
+ path .addRoundedRect (rounded_rect , corner_radius , corner_radius )
59
+ painter .setClipPath (path )
60
+
61
+ # Fill background
62
+ frameColor = QColor ("#53a0ed" )
63
+ painter .setPen (QPen (frameColor , 1.2 ))
55
64
painter .setBrush (self .palette ().color (QPalette .Window ))
56
- painter .drawRoundedRect (
57
- QRectF (31 , 0 ,
58
- self .width () - 31 ,
59
- self .height ()
60
- ),
61
- 10 , 10 )
62
-
63
- # Paint blue triangle (if needed)
65
+ painter .drawRoundedRect (rounded_rect , corner_radius , corner_radius )
66
+
67
+ # Disable clipping temporarily for the arrow
68
+ painter .setClipping (False )
69
+
70
+ # Draw arrow if needed
64
71
if self .arrow :
65
- arrow_height = 20
72
+ arrow_height = 15
73
+ arrow_top = 35 - arrow_height
74
+ arrow_bottom = 35 + arrow_height
75
+ arrow_point = rounded_rect .topLeft ().toPoint () + QPoint (- 15 , 35 )
76
+ arrow_top_corner = rounded_rect .topLeft ().toPoint () + QPoint (1 , arrow_top )
77
+ arrow_bottom_corner = rounded_rect .topLeft ().toPoint () + QPoint (1 , arrow_bottom )
78
+
79
+ # Draw triangle (filled with the same background color as the window)
66
80
path = QPainterPath ()
67
- path .moveTo (0 , 35 )
68
- path .lineTo (31 , 35 - arrow_height )
69
- path .lineTo (
70
- 31 , int ((35 - arrow_height ) + (arrow_height * 2 )))
71
- path .lineTo (0 , 35 )
72
- painter .fillPath (path , frameColor )
81
+ path .moveTo (arrow_point ) # Starting point of the arrow
82
+ path .lineTo (arrow_top_corner ) # Top corner of the triangle
83
+ path .lineTo (arrow_bottom_corner ) # Bottom corner of the triangle
84
+ path .closeSubpath ()
85
+ painter .fillPath (path , self .palette ().color (QPalette .Window ))
86
+
87
+ # Draw the triangle's borders
88
+ border_pen = QPen (frameColor , 1 )
89
+ painter .setPen (border_pen )
90
+ painter .drawLine (arrow_point , arrow_top_corner ) # Top triangle border
91
+ painter .drawLine (arrow_point , arrow_bottom_corner ) # Bottom triangle border
73
92
74
93
def checkbox_metrics_callback (self , state ):
75
94
""" Callback for error and anonymous usage checkbox"""
@@ -96,8 +115,13 @@ def mouseReleaseEvent(self, event):
96
115
self .manager .next_tip (self .widget_id )
97
116
98
117
def __init__ (self , widget_id , text , arrow , manager , * args ):
99
- # Invoke parent init
100
- QWidget .__init__ (self , * args )
118
+ super ().__init__ (* args )
119
+
120
+ # Ensure frameless, floating behavior
121
+ self .setWindowFlags (Qt .FramelessWindowHint | Qt .Tool | Qt .WindowStaysOnTopHint )
122
+ self .setAttribute (Qt .WA_NoSystemBackground , True )
123
+ self .setAttribute (Qt .WA_TranslucentBackground , True )
124
+ self .setAttribute (Qt .WA_DeleteOnClose , True )
101
125
102
126
# get translations
103
127
app = get_app ()
@@ -114,6 +138,7 @@ def __init__(self, widget_id, text, arrow, manager, *args):
114
138
115
139
# Add label
116
140
self .label = QLabel (self )
141
+ self .label .setObjectName ("lblTutorialText" )
117
142
self .label .setText (text )
118
143
self .label .setTextFormat (Qt .RichText )
119
144
self .label .setWordWrap (True )
@@ -130,6 +155,7 @@ def __init__(self, widget_id, text, arrow, manager, *args):
130
155
131
156
# create spinner
132
157
checkbox_metrics = QCheckBox ()
158
+ checkbox_metrics .setObjectName ("checkboxMetrics" )
133
159
checkbox_metrics .setText (_ ("Yes, I would like to improve OpenShot!" ))
134
160
checkbox_metrics .setStyleSheet ("margin-left: 25px; margin-bottom: 5px;" )
135
161
if s .get ("send_metrics" ):
@@ -151,9 +177,11 @@ def __init__(self, widget_id, text, arrow, manager, *args):
151
177
# Create buttons
152
178
self .btn_close_tips = QPushButton (self )
153
179
self .btn_close_tips .setText (_ ("Hide Tutorial" ))
180
+ self .btn_close_tips .setObjectName ("HideTutorial" )
154
181
self .btn_close_tips .addAction (self .close_action )
155
182
156
183
self .btn_next_tip = QPushButton (self )
184
+ self .btn_next_tip .setObjectName ("NextTip" )
157
185
self .btn_next_tip .setText (_ ("Next" ))
158
186
self .btn_next_tip .setStyleSheet ("font-weight:bold;" )
159
187
@@ -168,11 +196,6 @@ def __init__(self, widget_id, text, arrow, manager, *args):
168
196
self .setMinimumHeight (100 )
169
197
self .setFocusPolicy (Qt .ClickFocus )
170
198
171
- # Make transparent
172
- self .setAttribute (Qt .WA_NoSystemBackground , True )
173
- self .setAttribute (Qt .WA_TranslucentBackground , True )
174
- self .setAttribute (Qt .WA_DeleteOnClose , True )
175
-
176
199
# Connect close action signal
177
200
self .close_action .triggered .connect (
178
201
functools .partial (self .manager .hide_tips , self .widget_id , True ))
@@ -361,6 +384,7 @@ def __init__(self, win, *args):
361
384
self .win = win
362
385
self .dock = win .dockTutorial
363
386
self .current_dialog = None
387
+ self .dock .setParent (None )
364
388
365
389
# get translations
366
390
app = get_app ()
@@ -441,7 +465,7 @@ def __init__(self, win, *args):
441
465
self .dock .setTitleBarWidget (QWidget ()) # Prevents window decoration
442
466
self .dock .setAttribute (Qt .WA_NoSystemBackground , True )
443
467
self .dock .setAttribute (Qt .WA_TranslucentBackground , True )
444
- self .dock .setWindowFlags (Qt .FramelessWindowHint )
468
+ self .dock .setWindowFlags (Qt .FramelessWindowHint | Qt . Tool | Qt . WindowStaysOnTopHint )
445
469
self .dock .setFloating (True )
446
470
447
471
# Timer for processing new tutorials
0 commit comments