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 
43 try:
44  import json
45 except ImportError:
46  import simplejson as json
47 
48 import datetime
49 
50 ##
51 # About Dialog
52 class About(QDialog):
53 
54  ui_path = os.path.join(info.PATH, 'windows', 'ui', 'about.ui')
55 
56  def __init__(self):
57  # Create dialog class
58  QDialog.__init__(self)
59 
60  # Load UI from designer
61  ui_util.load_ui(self, self.ui_path)
62 
63  # Init Ui
64  ui_util.init_ui(self)
65 
66  # get translations
67  self.app = get_app()
68  _ = self.app._tr
69 
70  create_text = _('Create &amp; Edit Amazing Videos and Movies')
71  description_text = _('OpenShot Video Editor 2.x is the next generation of the award-winning <br/>OpenShot video editing platform.')
72  learnmore_text = _('Learn more')
73  copyright_text = _('Copyright &copy; %(begin_year)s-%(current_year)s') % {'begin_year': '2008', 'current_year': str(datetime.datetime.today().year) }
74  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="http://%s.openshot.org?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)
75  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://%s.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, info.website_language())
76 
77  # Set description and company labels
78  self.lblAboutDescription.setText(about_html)
79  self.lblAboutCompany.setText(company_html)
80 
81  # set events handlers
82  self.btncredit.clicked.connect(self.load_credit)
83  self.btnlicense.clicked.connect(self.load_license)
84 
85  # Init some variables
86  self.txtversion.setText(_("Version: %s") % info.VERSION)
87  self.txtversion.setAlignment(Qt.AlignCenter)
88 
89  # Track metrics
90  track_metric_screen("about-screen")
91 
92  ##
93  # Load Credits for everybody who has contributed in several domain for Openshot
94  def load_credit(self):
95  log.info('Credit screen has been opened')
96  windo = Credits()
97  windo.exec_()
98 
99  ##
100  # Load License of the project
101  def load_license(self):
102  log.info('License screen has been opened')
103  windo = License()
104  windo.exec_()
105 
106 
107 ##
108 # License Dialog
109 class License(QDialog):
110 
111  ui_path = os.path.join(info.PATH, 'windows', 'ui', 'license.ui')
112 
113  def __init__(self):
114  # Create dialog class
115  QDialog.__init__(self)
116 
117  # Load UI from designer
118  ui_util.load_ui(self, self.ui_path)
119 
120  # Init Ui
121  ui_util.init_ui(self)
122 
123  # get translations
124  self.app = get_app()
125  _ = self.app._tr
126 
127  # Init license
128  with open(os.path.join(info.PATH, 'settings', 'license.txt'), 'r') as my_license:
129  text = my_license.read()
130  self.textBrowser.append(text)
131 
132  # Scroll to top
133  cursor = self.textBrowser.textCursor()
134  cursor.setPosition(0)
135  self.textBrowser.setTextCursor(cursor)
136 
137 
138 ##
139 # Credits Dialog
140 class Credits(QDialog):
141 
142  ui_path = os.path.join(info.PATH, 'windows', 'ui', 'credits.ui')
143 
144  ##
145  # Callback for filter being changed
146  def Filter_Triggered(self, textbox, treeview):
147  # Update model for treeview
148  treeview.refresh_view(filter=textbox.text())
149 
150  def __init__(self):
151 
152  # Create dialog class
153  QDialog.__init__(self)
154 
155  # Load UI from designer
156  ui_util.load_ui(self, self.ui_path)
157 
158  # Init Ui
159  ui_util.init_ui(self)
160 
161  # get translations
162  self.app = get_app()
163  _ = self.app._tr
164 
165  # Update supporter button
166  supporter_text = _("Become a Supporter")
167  supporter_html = '<html><head/><body><p align="center"><a href="http://%s.openshot.org/donate/?app-about-us"><span style=" text-decoration: underline; color:#55aaff;">%s</span></a></p></body></html>' % (info.website_language(), supporter_text)
168  self.lblBecomeSupporter.setText(supporter_html)
169 
170  # Get list of developers
171  developer_list = []
172  with codecs.open(os.path.join(info.PATH, 'settings', 'contributors.json'), 'r', 'utf-8') as contributors_file:
173  developer_string = contributors_file.read()
174  developer_list = json.loads(developer_string)
175 
176  self.developersListView = CreditsTreeView(credits=developer_list, columns=["email", "website"])
177  self.vboxDevelopers.addWidget(self.developersListView)
178  self.txtDeveloperFilter.textChanged.connect(partial(self.Filter_Triggered, self.txtDeveloperFilter, self.developersListView))
179 
180  # Get string of translators for the current language
181  translator_credits = []
182  translator_credits_string = _("translator-credits").replace("Launchpad Contributions:\n", "").replace("translator-credits","")
183  if translator_credits_string:
184  # Parse string into a list of dictionaries
185  translator_rows = translator_credits_string.split("\n")
186  for row in translator_rows:
187  # Split each row into 2 parts (name and username)
188  translator_parts = row.split("https://launchpad.net/")
189  name = translator_parts[0].strip()
190  username = translator_parts[1].strip()
191  translator_credits.append({"name":name, "website":"https://launchpad.net/%s" % username})
192 
193  # Add translators listview
194  self.translatorsListView = CreditsTreeView(translator_credits, columns=["website"])
195  self.vboxTranslators.addWidget(self.translatorsListView)
196  self.txtTranslatorFilter.textChanged.connect(partial(self.Filter_Triggered, self.txtTranslatorFilter, self.translatorsListView))
197  else:
198  # No translations for this language, hide credits
199  self.tabCredits.removeTab(1)
200 
201  # Get list of supporters
202  supporter_list = []
203  with codecs.open(os.path.join(info.PATH, 'settings', 'supporters.json'), 'r', 'utf-8') as supporter_file:
204  supporter_string = supporter_file.read()
205  supporter_list = json.loads(supporter_string)
206 
207  # Add supporters listview
208  self.supportersListView = CreditsTreeView(supporter_list, columns=["website"])
209  self.vboxSupporters.addWidget(self.supportersListView)
210  self.txtSupporterFilter.textChanged.connect(partial(self.Filter_Triggered, self.txtSupporterFilter, self.supportersListView))
211 
def track_metric_screen
Track a GUI screen being shown.
Definition: metrics.py:96
def load_license
Load License of the project.
Definition: about.py:101
def get_app
Returns the current QApplication instance of OpenShot.
Definition: app.py:55
translatorsListView
Definition: about.py:194
developersListView
Definition: about.py:176
Credits Dialog.
Definition: about.py:140
def __init__
Definition: about.py:56
def __init__
Definition: about.py:113
def Filter_Triggered
Callback for filter being changed.
Definition: about.py:146
tuple ui_path
Definition: about.py:54
tuple ui_path
Definition: about.py:111
def load_ui
Load a Qt *.ui file, and also load an XML parsed version.
Definition: ui_util.py:66
tuple ui_path
Definition: about.py:142
def __init__
Definition: about.py:150
About Dialog.
Definition: about.py:52
def website_language
Get the current website language code for URLs.
Definition: info.py:138
License Dialog.
Definition: about.py:109
supportersListView
Definition: about.py:208
def init_ui
Initialize all child widgets and action of a window or dialog.
Definition: ui_util.py:220
def load_credit
Load Credits for everybody who has contributed in several domain for Openshot.
Definition: about.py:94