Skip to content

Commit 0f57a61

Browse files
committed
Adding "Copy Version Info" context menu to About dialog.
1 parent 3f78655 commit 0f57a61

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

src/themes/cosmic/theme.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ def __init__(self, app):
276276
}
277277
278278
QTabWidget#exportTabs QTabBar::tab,
279-
QTabWidget#tabCategories QTabBar::tab {
279+
QTabWidget#tabCategories QTabBar::tab,
280+
QTabWidget#tabCredits QTabBar::tab{
280281
margin-bottom: 10px;
281282
}
282283

src/windows/about.py

+37-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
from functools import partial
3333

3434
from PyQt5.QtCore import Qt, pyqtSignal
35-
from PyQt5.QtGui import QIcon
3635
from PyQt5.QtWidgets import QDialog
3736

3837
from classes import info, ui_util
@@ -41,6 +40,7 @@
4140
from classes.metrics import track_metric_screen
4241
from windows.views.credits_treeview import CreditsTreeView
4342
from windows.views.changelog_treeview import ChangelogTreeView
43+
from windows.views.menu import StyledContextMenu
4444

4545
import requests
4646
import threading
@@ -132,14 +132,9 @@ def __init__(self):
132132
}
133133
about_html = '''
134134
<div align="center" style="">
135-
<p style="font-size:11pt; font-weight: 300;">
136-
<a href="https://www.openshot.org/%s?r=about-us"
137-
style="text-decoration:none; color: #ffffff;">%s</a>
138-
</p>
135+
<p style="font-size:11pt; font-weight: 300;">%s</p>
139136
</div>
140-
''' % (
141-
info.website_language(),
142-
description_text,)
137+
''' % (description_text,)
143138
company_html = '''
144139
<div style="font-weight:400;" align="right">
145140
%s<br>
@@ -168,6 +163,40 @@ def __init__(self):
168163
# Load release details from HTTP
169164
self.get_current_release()
170165

166+
def contextMenuEvent(self, event):
167+
"""Handle right-click context menu."""
168+
menu = StyledContextMenu(parent=self)
169+
170+
# get translations
171+
self.app = get_app()
172+
_ = self.app._tr
173+
174+
# Add "Copy Version Info" action
175+
copy_action = menu.addAction(_("Copy Version Info"))
176+
action = menu.exec_(event.globalPos())
177+
178+
if action == copy_action:
179+
self.copy_version_info()
180+
181+
def copy_version_info(self):
182+
"""Copy cleaned version info (without HTML <div> and unnecessary links) to clipboard."""
183+
# Get the raw HTML text from txtversion
184+
raw_html = self.txtversion.text()
185+
186+
# Step 1: Strip <div> tags
187+
clean_text = re.sub(r'<div[^>]*>|</div>', '', raw_html).strip()
188+
189+
# Step 2: Replace <br/> with newline characters
190+
clean_text = clean_text.replace("<br/>", "\n")
191+
192+
# Step 3: Remove the HTML link after 'Release Date: x-x-x |'
193+
# Matches "Release Date: YYYY-MM-DD | <a href=...>Release Notes</a>" and keeps only "Release Date: YYYY-MM-DD"
194+
clean_text = re.sub(r'(Release Date: \d{4}-\d{2}-\d{2}) \|.*', r'\1', clean_text)
195+
196+
# Copy the cleaned text to the clipboard
197+
clipboard = get_app().clipboard()
198+
clipboard.setText(clean_text)
199+
171200
def display_release(self, version_text):
172201

173202
version_html = '''

0 commit comments

Comments
 (0)