Skip to content

Commit 0a2be85

Browse files
committed
Fixing a regression which caused a window border around the tutorial. Also improving tutorial style for all themes (i.e. new arrow, larger font)
1 parent 9f7e0ee commit 0a2be85

File tree

2 files changed

+68
-27
lines changed

2 files changed

+68
-27
lines changed

src/themes/cosmic/theme.py

+17
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ def __init__(self, app):
5555
padding: 20px;
5656
}
5757
58+
QLabel#lblTutorialText {
59+
font-size: 14px;
60+
}
61+
62+
QCheckBox#checkboxMetrics {
63+
font-size: 14px;
64+
}
65+
66+
QWidget#tutorial QPushButton#NextTip {
67+
background-color: #283241;
68+
font-size: 12px;
69+
}
70+
71+
QWidget#tutorial QPushButton#HideTutorial {
72+
font-size: 12px;
73+
}
74+
5875
5976
QDialog {
6077
background-color: #192332;

src/windows/views/tutorial.py

+51-27
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,51 @@
4444
class TutorialDialog(QWidget):
4545
""" A customized QWidget used to instruct a user how to use a certain feature """
4646

47-
def paintEvent(self, event, *args):
47+
def paintEvent(self, event):
4848
""" Custom paint event """
49-
# Paint custom frame image on QWidget
5049
painter = QPainter(self)
5150
painter.setRenderHint(QPainter.Antialiasing)
52-
frameColor = QColor("#53a0ed")
5351

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))
5564
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
6471
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)
6680
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
7392

7493
def checkbox_metrics_callback(self, state):
7594
""" Callback for error and anonymous usage checkbox"""
@@ -96,8 +115,13 @@ def mouseReleaseEvent(self, event):
96115
self.manager.next_tip(self.widget_id)
97116

98117
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)
101125

102126
# get translations
103127
app = get_app()
@@ -114,6 +138,7 @@ def __init__(self, widget_id, text, arrow, manager, *args):
114138

115139
# Add label
116140
self.label = QLabel(self)
141+
self.label.setObjectName("lblTutorialText")
117142
self.label.setText(text)
118143
self.label.setTextFormat(Qt.RichText)
119144
self.label.setWordWrap(True)
@@ -130,6 +155,7 @@ def __init__(self, widget_id, text, arrow, manager, *args):
130155

131156
# create spinner
132157
checkbox_metrics = QCheckBox()
158+
checkbox_metrics.setObjectName("checkboxMetrics")
133159
checkbox_metrics.setText(_("Yes, I would like to improve OpenShot!"))
134160
checkbox_metrics.setStyleSheet("margin-left: 25px; margin-bottom: 5px;")
135161
if s.get("send_metrics"):
@@ -151,9 +177,11 @@ def __init__(self, widget_id, text, arrow, manager, *args):
151177
# Create buttons
152178
self.btn_close_tips = QPushButton(self)
153179
self.btn_close_tips.setText(_("Hide Tutorial"))
180+
self.btn_close_tips.setObjectName("HideTutorial")
154181
self.btn_close_tips.addAction(self.close_action)
155182

156183
self.btn_next_tip = QPushButton(self)
184+
self.btn_next_tip.setObjectName("NextTip")
157185
self.btn_next_tip.setText(_("Next"))
158186
self.btn_next_tip.setStyleSheet("font-weight:bold;")
159187

@@ -168,11 +196,6 @@ def __init__(self, widget_id, text, arrow, manager, *args):
168196
self.setMinimumHeight(100)
169197
self.setFocusPolicy(Qt.ClickFocus)
170198

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-
176199
# Connect close action signal
177200
self.close_action.triggered.connect(
178201
functools.partial(self.manager.hide_tips, self.widget_id, True))
@@ -361,6 +384,7 @@ def __init__(self, win, *args):
361384
self.win = win
362385
self.dock = win.dockTutorial
363386
self.current_dialog = None
387+
self.dock.setParent(None)
364388

365389
# get translations
366390
app = get_app()
@@ -441,7 +465,7 @@ def __init__(self, win, *args):
441465
self.dock.setTitleBarWidget(QWidget()) # Prevents window decoration
442466
self.dock.setAttribute(Qt.WA_NoSystemBackground, True)
443467
self.dock.setAttribute(Qt.WA_TranslucentBackground, True)
444-
self.dock.setWindowFlags(Qt.FramelessWindowHint)
468+
self.dock.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool | Qt.WindowStaysOnTopHint)
445469
self.dock.setFloating(True)
446470

447471
# Timer for processing new tutorials

0 commit comments

Comments
 (0)