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-2016 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 from functools import partial
32 
33 from PyQt5.QtCore import *
34 from PyQt5.QtWidgets import *
35 
36 from classes import info, ui_util
37 from classes.logger import log
38 from classes.app import get_app
39 from classes.metrics import *
40 from windows.views.credits_treeview import CreditsTreeView
41 
42 try:
43  import json
44 except ImportError:
45  import simplejson as json
46 
47 
48 ##
49 # About Dialog
50 class About(QDialog):
51 
52  ui_path = os.path.join(info.PATH, 'windows', 'ui', 'about.ui')
53 
54  def __init__(self):
55  # Create dialog class
56  QDialog.__init__(self)
57 
58  # Load UI from designer
59  ui_util.load_ui(self, self.ui_path)
60 
61  # Init Ui
62  ui_util.init_ui(self)
63 
64  # get translations
65  self.app = get_app()
66  _ = self.app._tr
67 
68  # set events handlers
69  self.btncredit.clicked.connect(self.load_credit)
70  self.btnlicense.clicked.connect(self.load_license)
71 
72  # Init some variables
73  self.txtversion.setText(_("Version: %s") % info.VERSION)
74  self.txtversion.setAlignment(Qt.AlignCenter)
75 
76  # Track metrics
77  track_metric_screen("about-screen")
78 
79  ##
80  # Load Credits for everybody who has contribuated in several domain for Openshot
81  def load_credit(self):
82  log.info('Credit screen has been opened')
83  windo = Credits()
84  windo.exec_()
85 
86  ##
87  # Load License of the project
88  def load_license(self):
89  log.info('License screen has been opened')
90  windo = License()
91  windo.exec_()
92 
93 
94 ##
95 # License Dialog
96 class License(QDialog):
97 
98  ui_path = os.path.join(info.PATH, 'windows', 'ui', 'license.ui')
99 
100  def __init__(self):
101  # Create dialog class
102  QDialog.__init__(self)
103 
104  # Load UI from designer
105  ui_util.load_ui(self, self.ui_path)
106 
107  # Init Ui
108  ui_util.init_ui(self)
109 
110  # get translations
111  self.app = get_app()
112  _ = self.app._tr
113 
114  # Init license
115  with open(os.path.join(info.PATH, 'settings', 'license.txt'), 'r') as my_license:
116  text = my_license.read()
117  self.textBrowser.append(text)
118 
119  # Scroll to top
120  cursor = self.textBrowser.textCursor()
121  cursor.setPosition(0)
122  self.textBrowser.setTextCursor(cursor)
123 
124 
125 ##
126 # Credits Dialog
127 class Credits(QDialog):
128 
129  ui_path = os.path.join(info.PATH, 'windows', 'ui', 'credits.ui')
130 
131  ##
132  # Callback for filter being changed
133  def Filter_Triggered(self, textbox, treeview):
134  # Update model for treeview
135  treeview.refresh_view(filter=textbox.text())
136 
137  def __init__(self):
138 
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  # Add credits listview
153  self.developersListView = CreditsTreeView(credits=info.CREDITS['code'], columns=["email", "website"])
154  self.vboxDevelopers.addWidget(self.developersListView)
155  self.txtDeveloperFilter.textChanged.connect(partial(self.Filter_Triggered, self.txtDeveloperFilter, self.developersListView))
156 
157  # Get string of translators for the current language
158  translator_credits = []
159  translator_credits_string = _("translator-credits").replace("Launchpad Contributions:\n", "").replace("translator-credits","")
160  if translator_credits_string:
161  # Parse string into a list of dictionaries
162  translator_rows = translator_credits_string.split("\n")
163  for row in translator_rows:
164  # Split each row into 2 parts (name and username)
165  translator_parts = row.split("https://launchpad.net/")
166  name = translator_parts[0].strip()
167  username = translator_parts[1].strip()
168  translator_credits.append({"name":name, "website":"https://launchpad.net/%s" % username})
169 
170  # Add translators listview
171  self.translatorsListView = CreditsTreeView(translator_credits, columns=["website"])
172  self.vboxTranslators.addWidget(self.translatorsListView)
173  self.txtTranslatorFilter.textChanged.connect(partial(self.Filter_Triggered, self.txtTranslatorFilter, self.translatorsListView))
174  else:
175  # No translations for this langauge, hide credits
176  self.tabCredits.removeTab(1)
177 
178  # Get list of supporters
179  supporter_list = []
180  import codecs
181  with codecs.open(os.path.join(info.PATH, 'settings', 'supporters.json'), 'r', 'utf-8') as supporter_file:
182  supporter_string = supporter_file.read()
183  supporter_list = json.loads(supporter_string)
184 
185  # Add supporters listview
186  self.supportersListView = CreditsTreeView(supporter_list, columns=["website"])
187  self.vboxSupporters.addWidget(self.supportersListView)
188  self.txtSupporterFilter.textChanged.connect(partial(self.Filter_Triggered, self.txtSupporterFilter, self.supportersListView))
189 
def get_app()
Returns the current QApplication instance of OpenShot.
Definition: app.py:54
def load_credit(self)
Load Credits for everybody who has contribuated in several domain for Openshot.
Definition: about.py:81
def __init__(self)
Definition: about.py:100
translatorsListView
Definition: about.py:171
developersListView
Definition: about.py:153
Credits Dialog.
Definition: about.py:127
def __init__(self)
Definition: about.py:137
About Dialog.
Definition: about.py:50
License Dialog.
Definition: about.py:96
supportersListView
Definition: about.py:186
def Filter_Triggered(self, textbox, treeview)
Callback for filter being changed.
Definition: about.py:133
def load_license(self)
Load License of the project.
Definition: about.py:88
def __init__(self)
Definition: about.py:54
def init_ui(window)
Initialize all child widgets and action of a window or dialog.
Definition: ui_util.py:200
def track_metric_screen(screen_name)
Track a GUI screen being shown.
Definition: metrics.py:94
def load_ui(window, path)
Load a Qt *.ui file, and also load an XML parsed version.
Definition: ui_util.py:65