|
1 |
| -""" |
| 1 | +""" |
2 | 2 | @file
|
3 | 3 | @brief This file contains the credits treeview, used by the about window
|
4 | 4 | @author Noah Figg <[email protected]>
|
5 | 5 | @author Jonathan Thomas <[email protected]>
|
6 |
| - |
| 6 | +
|
7 | 7 | @section LICENSE
|
8 |
| - |
| 8 | +
|
9 | 9 | Copyright (c) 2008-2018 OpenShot Studios, LLC
|
10 | 10 | (http://www.openshotstudios.com). This file is part of
|
11 | 11 | OpenShot Video Editor (http://www.openshot.org), an open-source project
|
12 | 12 | dedicated to delivering high quality video editing and animation solutions
|
13 | 13 | to the world.
|
14 |
| - |
| 14 | +
|
15 | 15 | OpenShot Video Editor is free software: you can redistribute it and/or modify
|
16 | 16 | it under the terms of the GNU General Public License as published by
|
17 | 17 | the Free Software Foundation, either version 3 of the License, or
|
18 | 18 | (at your option) any later version.
|
19 |
| - |
| 19 | +
|
20 | 20 | OpenShot Video Editor is distributed in the hope that it will be useful,
|
21 | 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 | 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 | 23 | GNU General Public License for more details.
|
24 |
| - |
| 24 | +
|
25 | 25 | You should have received a copy of the GNU General Public License
|
26 | 26 | along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
27 | 27 | """
|
28 | 28 |
|
29 | 29 | import os
|
30 | 30 | from urllib.parse import urlparse
|
31 | 31 |
|
| 32 | +import webbrowser |
32 | 33 | from PyQt5.QtCore import QSize, Qt, QPoint
|
33 |
| -from PyQt5.QtWidgets import QListView, QTreeView, QMessageBox, QAbstractItemView, QMenu, QSizePolicy, QHeaderView |
| 34 | +from PyQt5.QtWidgets import QListView, QTreeView, QMessageBox, QAbstractItemView, QMenu, QSizePolicy, QHeaderView, QApplication |
| 35 | +from PyQt5.QtGui import QCursor |
| 36 | +from functools import partial |
34 | 37 |
|
35 | 38 | from classes.logger import log
|
36 | 39 | from classes.app import get_app
|
@@ -61,6 +64,38 @@ def refresh_view(self, filter=None):
|
61 | 64 | if "website" not in self.columns:
|
62 | 65 | self.setColumnHidden(4, True)
|
63 | 66 |
|
| 67 | + def contextMenuEvent(self, event): |
| 68 | + log.info('contextMenuEvent') |
| 69 | + _ = get_app()._tr |
| 70 | + |
| 71 | + # Get data model and selection |
| 72 | + model = self.credits_model.model |
| 73 | + row = self.indexAt(event.pos()).row() |
| 74 | + if row != -1: |
| 75 | + email = model.item(row, 3).text() |
| 76 | + website = model.item(row, 4).text() |
| 77 | + |
| 78 | + menu = QMenu(self) |
| 79 | + if email: |
| 80 | + copy_action = menu.addAction(_("Copy E-mail")) |
| 81 | + copy_action.triggered.connect(partial(self.CopyEmailTriggered, email)) |
| 82 | + if website: |
| 83 | + github_action = menu.addAction(_("View Website")) |
| 84 | + github_action.triggered.connect(partial(self.ViewWebsite, website)) |
| 85 | + menu.popup(QCursor.pos()) |
| 86 | + |
| 87 | + def CopyEmailTriggered(self, email=""): |
| 88 | + log.info("CopyEmailTriggered") |
| 89 | + clipboard = QApplication.clipboard() |
| 90 | + clipboard.setText(email) |
| 91 | + |
| 92 | + def ViewWebsite(self, website=""): |
| 93 | + log.info("ViewWebsite") |
| 94 | + try: |
| 95 | + webbrowser.open(website) |
| 96 | + except: |
| 97 | + log.warning('Failed to launch web browser to %s' % website) |
| 98 | + |
64 | 99 | def __init__(self, credits, columns, *args):
|
65 | 100 | # Invoke parent init
|
66 | 101 | QListView.__init__(self, *args)
|
|
0 commit comments