OpenShot Video Editor  2.0.0
about.py
Go to the documentation of this file.
1 ##
2 #
3 # @file
4 # @brief This file loads the About dialog (i.e about Openshot Project)
5 # @author Jonathan Thomas <jonathan@openshot.org>
6 # @author Olivier Girard <olivier@openshot.org>
7 #
8 # @section LICENSE
9 #
10 # Copyright (c) 2008-2018 OpenShot Studios, LLC
11 # (http://www.openshotstudios.com). This file is part of
12 # OpenShot Video Editor (http://www.openshot.org), an open-source project
13 # dedicated to delivering high quality video editing and animation solutions
14 # to the world.
15 #
16 # OpenShot Video Editor is free software: you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation, either version 3 of the License, or
19 # (at your option) any later version.
20 #
21 # OpenShot Video Editor is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 #
26 # You should have received a copy of the GNU General Public License
27 # along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
28 #
29 
30 import os
31 import codecs
32 from functools import partial
33 
34 from PyQt5.QtCore import *
35 from PyQt5.QtWidgets import *
36 
37 from classes import info, ui_util
38 from classes.logger import log
39 from classes.app import get_app
40 from classes.metrics import *
41 from windows.views.credits_treeview import CreditsTreeView
42 from windows.views.changelog_treeview import ChangelogTreeView
43 
44 try:
45  import json
46 except ImportError:
47  import simplejson as json
48 
49 import datetime
50 
51 ##
52 # About Dialog
53 class About(QDialog):
54 
55  ui_path = os.path.join(info.PATH, 'windows', 'ui', 'about.ui')
56 
57  def __init__(self):
58  # Create dialog class
59  QDialog.__init__(self)
60 
61  # Load UI from designer
62  ui_util.load_ui(self, self.ui_path)
63 
64  # Init Ui
65  ui_util.init_ui(self)
66 
67  # get translations
68  self.app = get_app()
69  _ = self.app._tr
70 
71  # Hide chnagelog button by default
72  self.btnchangelog.setVisible(False)
73  for project in ['openshot-qt', 'libopenshot', 'libopenshot-audio']:
74  changelog_path = os.path.join(info.PATH, 'settings', '%s.log' % project)
75  if os.path.exists(changelog_path):
76  # Attempt to open changelog with utf-8, and then utf-16-le (for unix / windows support)
77  for encoding_name in ('utf-8', 'utf_16_le'):
78  try:
79  with codecs.open(changelog_path, 'r', encoding=encoding_name) as changelog_file:
80  if changelog_file.read():
81  self.btnchangelog.setVisible(True)
82  break
83  except:
84  # Ignore decoding errors
85  pass
86 
87  create_text = _('Create &amp; Edit Amazing Videos and Movies')
88  description_text = _('OpenShot Video Editor 2.x is the next generation of the award-winning <br/>OpenShot video editing platform.')
89  learnmore_text = _('Learn more')
90  copyright_text = _('Copyright &copy; %(begin_year)s-%(current_year)s') % {'begin_year': '2008', 'current_year': str(datetime.datetime.today().year) }
91  about_html = '<html><head/><body><hr/><p align="center"><span style=" font-size:10pt; font-weight:600;">%s</span></p><p align="center"><span style=" font-size:10pt;">%s </span><a href="https://www.openshot.org/%s?r=about-us"><span style=" font-size:10pt; text-decoration: none; color:#55aaff;">%s</span></a><span style=" font-size:10pt;">.</span></p></body></html>' % (create_text, description_text, info.website_language(), learnmore_text)
92  company_html = '<html><head/><body style="font-size:11pt; font-weight:400; font-style:normal;">\n<hr />\n<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600;">%s </span><a href="http://www.openshotstudios.com?r=about-us"><span style=" font-size:10pt; font-weight:600; text-decoration: none; color:#55aaff;">OpenShot Studios, LLC<br /></span></a></p></body></html>' % (copyright_text)
93 
94  # Set description and company labels
95  self.lblAboutDescription.setText(about_html)
96  self.lblAboutCompany.setText(company_html)
97 
98  # set events handlers
99  self.btncredit.clicked.connect(self.load_credit)
100  self.btnlicense.clicked.connect(self.load_license)
101  self.btnchangelog.clicked.connect(self.load_changelog)
102 
103  # Init some variables
104  self.txtversion.setText(_("Version: %s") % info.VERSION)
105  self.txtversion.setAlignment(Qt.AlignCenter)
106 
107  # Track metrics
108  track_metric_screen("about-screen")
109 
110  ##
111  # Load Credits for everybody who has contributed in several domain for Openshot
112  def load_credit(self):
113  log.info('Credit screen has been opened')
114  windo = Credits()
115  windo.exec_()
116 
117  ##
118  # Load License of the project
119  def load_license(self):
120  log.info('License screen has been opened')
121  windo = License()
122  windo.exec_()
123 
124  ##
125  # Load the changelog window
126  def load_changelog(self):
127  log.info('Changelog screen has been opened')
128  windo = Changelog()
129  windo.exec_()
130 
131 
132 ##
133 # License Dialog
134 class License(QDialog):
135 
136  ui_path = os.path.join(info.PATH, 'windows', 'ui', 'license.ui')
137 
138  def __init__(self):
139  # Create dialog class
140  QDialog.__init__(self)
141 
142  # Load UI from designer
143  ui_util.load_ui(self, self.ui_path)
144 
145  # Init Ui
146  ui_util.init_ui(self)
147 
148  # get translations
149  self.app = get_app()
150  _ = self.app._tr
151 
152  # Init license
153  with open(os.path.join(info.PATH, 'settings', 'license.txt'), 'r') as my_license:
154  text = my_license.read()
155  self.textBrowser.append(text)
156 
157  # Scroll to top
158  cursor = self.textBrowser.textCursor()
159  cursor.setPosition(0)
160  self.textBrowser.setTextCursor(cursor)
161 
162 
163 ##
164 # Credits Dialog
165 class Credits(QDialog):
166 
167  ui_path = os.path.join(info.PATH, 'windows', 'ui', 'credits.ui')
168 
169  ##
170  # Callback for filter being changed
171  def Filter_Triggered(self, textbox, treeview):
172  # Update model for treeview
173  treeview.refresh_view(filter=textbox.text())
174 
175  def __init__(self):
176 
177  # Create dialog class
178  QDialog.__init__(self)
179 
180  # Load UI from designer
181  ui_util.load_ui(self, self.ui_path)
182 
183  # Init Ui
184  ui_util.init_ui(self)
185 
186  # get translations
187  self.app = get_app()
188  _ = self.app._tr
189 
190  # Update supporter button
191  supporter_text = _("Become a Supporter")
192  supporter_html = '<html><head/><body><p align="center"><a href="https://www.openshot.org/%sdonate/?app-about-us"><span style=" text-decoration: underline; color:#55aaff;">%s</span></a></p></body></html>' % (info.website_language(), supporter_text)
193  self.lblBecomeSupporter.setText(supporter_html)
194 
195  # Get list of developers
196  developer_list = []
197  with codecs.open(os.path.join(info.PATH, 'settings', 'contributors.json'), 'r', 'utf-8') as contributors_file:
198  developer_string = contributors_file.read()
199  developer_list = json.loads(developer_string)
200 
201  self.developersListView = CreditsTreeView(credits=developer_list, columns=["email", "website"])
202  self.vboxDevelopers.addWidget(self.developersListView)
203  self.txtDeveloperFilter.textChanged.connect(partial(self.Filter_Triggered, self.txtDeveloperFilter, self.developersListView))
204 
205  # Get string of translators for the current language
206  translator_credits = []
207  translator_credits_string = _("translator-credits").replace("Launchpad Contributions:\n", "").replace("translator-credits","")
208  if translator_credits_string:
209  # Parse string into a list of dictionaries
210  translator_rows = translator_credits_string.split("\n")
211  for row in translator_rows:
212  # Split each row into 2 parts (name and username)
213  translator_parts = row.split("https://launchpad.net/")
214  name = translator_parts[0].strip()
215  username = translator_parts[1].strip()
216  translator_credits.append({"name":name, "website":"https://launchpad.net/%s" % username})
217 
218  # Add translators listview
219  self.translatorsListView = CreditsTreeView(translator_credits, columns=["website"])
220  self.vboxTranslators.addWidget(self.translatorsListView)
221  self.txtTranslatorFilter.textChanged.connect(partial(self.Filter_Triggered, self.txtTranslatorFilter, self.translatorsListView))
222  else:
223  # No translations for this language, hide credits
224  self.tabCredits.removeTab(1)
225 
226  # Get list of supporters
227  supporter_list = []
228  with codecs.open(os.path.join(info.PATH, 'settings', 'supporters.json'), 'r', 'utf-8') as supporter_file:
229  supporter_string = supporter_file.read()
230  supporter_list = json.loads(supporter_string)
231 
232  # Add supporters listview
233  self.supportersListView = CreditsTreeView(supporter_list, columns=["website"])
234  self.vboxSupporters.addWidget(self.supportersListView)
235  self.txtSupporterFilter.textChanged.connect(partial(self.Filter_Triggered, self.txtSupporterFilter, self.supportersListView))
236 
237 
238 ##
239 # Changelog Dialog
240 class Changelog(QDialog):
241 
242  ui_path = os.path.join(info.PATH, 'windows', 'ui', 'changelog.ui')
243 
244  ##
245  # Callback for filter being changed
246  def Filter_Triggered(self, textbox, treeview):
247  # Update model for treeview
248  treeview.refresh_view(filter=textbox.text())
249 
250  def __init__(self):
251 
252  # Create dialog class
253  QDialog.__init__(self)
254 
255  # Load UI from designer
256  ui_util.load_ui(self, self.ui_path)
257 
258  # Init Ui
259  ui_util.init_ui(self)
260 
261  # get translations
262  self.app = get_app()
263  _ = self.app._tr
264 
265  # Update github link button
266  github_text = _("OpenShot on GitHub")
267  github_html = '<html><head/><body><p align="center"><a href="https://github.com/OpenShot/"><span style=" text-decoration: underline; color:#55aaff;">%s</span></a></p></body></html>' % (github_text)
268  self.lblGitHubLink.setText(github_html)
269 
270  # Get changelog for openshot-qt (if any)
271  changelog_list = []
272  changelog_path = os.path.join(info.PATH, 'settings', 'openshot-qt.log')
273  if os.path.exists(changelog_path):
274  # Attempt to open changelog with utf-8, and then utf-16-le (for unix / windows support)
275  for encoding_name in ('utf-8', 'utf_16_le'):
276  try:
277  with codecs.open(changelog_path, 'r', encoding=encoding_name) as changelog_file:
278  for line in changelog_file:
279  changelog_list.append({'hash': line[:9].strip(),
280  'date': line[9:20].strip(),
281  'author': line[20:45].strip(),
282  'subject': line[45:].strip() })
283  except:
284  # Ignore decoding errors
285  pass
286  self.openshot_qt_ListView = ChangelogTreeView(commits=changelog_list, commit_url="https://github.com/OpenShot/openshot-qt/commit/%s/")
287  self.vbox_openshot_qt.addWidget(self.openshot_qt_ListView)
288  self.txtChangeLogFilter_openshot_qt.textChanged.connect(partial(self.Filter_Triggered, self.txtChangeLogFilter_openshot_qt, self.openshot_qt_ListView))
289 
290  # Get changelog for libopenshot (if any)
291  changelog_list = []
292  changelog_path = os.path.join(info.PATH, 'settings', 'libopenshot.log')
293  if os.path.exists(changelog_path):
294  # Attempt to open changelog with utf-8, and then utf-16-le (for unix / windows support)
295  for encoding_name in ('utf-8', 'utf_16_le'):
296  try:
297  with codecs.open(changelog_path, 'r', encoding=encoding_name) as changelog_file:
298  for line in changelog_file:
299  changelog_list.append({'hash': line[:9].strip(),
300  'date': line[9:20].strip(),
301  'author': line[20:45].strip(),
302  'subject': line[45:].strip() })
303  except:
304  # Ignore decoding errors
305  pass
306  self.libopenshot_ListView = ChangelogTreeView(commits=changelog_list, commit_url="https://github.com/OpenShot/libopenshot/commit/%s/")
307  self.vbox_libopenshot.addWidget(self.libopenshot_ListView)
308  self.txtChangeLogFilter_libopenshot.textChanged.connect(partial(self.Filter_Triggered, self.txtChangeLogFilter_libopenshot, self.libopenshot_ListView))
309 
310  # Get changelog for libopenshot-audio (if any)
311  changelog_list = []
312  changelog_path = os.path.join(info.PATH, 'settings', 'libopenshot-audio.log')
313  if os.path.exists(changelog_path):
314  # Attempt to open changelog with utf-8, and then utf-16-le (for unix / windows support)
315  for encoding_name in ('utf-8', 'utf_16_le'):
316  try:
317  with codecs.open(changelog_path, 'r', encoding=encoding_name) as changelog_file:
318  for line in changelog_file:
319  changelog_list.append({'hash': line[:9].strip(),
320  'date': line[9:20].strip(),
321  'author': line[20:45].strip(),
322  'subject': line[45:].strip() })
323  except:
324  # Ignore decoding errors
325  pass
326  self.libopenshot_audio_ListView = ChangelogTreeView(commits=changelog_list, commit_url="https://github.com/OpenShot/libopenshot-audio/commit/%s/")
327  self.vbox_libopenshot_audio.addWidget(self.libopenshot_audio_ListView)
328  self.txtChangeLogFilter_libopenshot_audio.textChanged.connect(partial(self.Filter_Triggered, self.txtChangeLogFilter_libopenshot_audio, self.libopenshot_audio_ListView))
libopenshot_ListView
Definition: about.py:306
tuple ui_path
Definition: about.py:242
Changelog Dialog.
Definition: about.py:240
def track_metric_screen
Track a GUI screen being shown.
Definition: metrics.py:96
libopenshot_audio_ListView
Definition: about.py:326
def load_license
Load License of the project.
Definition: about.py:119
def get_app
Returns the current QApplication instance of OpenShot.
Definition: app.py:55
translatorsListView
Definition: about.py:219
developersListView
Definition: about.py:201
Credits Dialog.
Definition: about.py:165
def __init__
Definition: about.py:57
def __init__
Definition: about.py:138
def Filter_Triggered
Callback for filter being changed.
Definition: about.py:171
tuple ui_path
Definition: about.py:55
openshot_qt_ListView
Definition: about.py:286
def Filter_Triggered
Callback for filter being changed.
Definition: about.py:246
tuple ui_path
Definition: about.py:136
def load_ui
Load a Qt *.ui file, and also load an XML parsed version.
Definition: ui_util.py:66
def load_changelog
Load the changelog window.
Definition: about.py:126
tuple ui_path
Definition: about.py:167
def __init__
Definition: about.py:175
About Dialog.
Definition: about.py:53
def website_language
Get the current website language code for URLs.
Definition: info.py:139
License Dialog.
Definition: about.py:134
supportersListView
Definition: about.py:233
def init_ui
Initialize all child widgets and action of a window or dialog.
Definition: ui_util.py:215
def load_credit
Load Credits for everybody who has contributed in several domain for Openshot.
Definition: about.py:112
def __init__
Definition: about.py:250