OpenShot Video Editor  2.0.0
credits_model.py
Go to the documentation of this file.
1 ##
2 #
3 # @file
4 # @brief This file contains the credits model, used by the about window
5 # @author Jonathan Thomas <jonathan@openshot.org>
6 #
7 # @section LICENSE
8 #
9 # Copyright (c) 2008-2018 OpenShot Studios, LLC
10 # (http://www.openshotstudios.com). This file is part of
11 # OpenShot Video Editor (http://www.openshot.org), an open-source project
12 # dedicated to delivering high quality video editing and animation solutions
13 # to the world.
14 #
15 # OpenShot Video Editor is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation, either version 3 of the License, or
18 # (at your option) any later version.
19 #
20 # OpenShot Video Editor is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
27 #
28 
29 import os
30 
31 from PyQt5.QtCore import Qt
32 from PyQt5.QtGui import *
33 
34 from classes import info
35 from classes.logger import log
36 from classes.app import get_app
37 
38 try:
39  import json
40 except ImportError:
41  import simplejson as json
42 
43 
44 class CreditsStandardItemModel(QStandardItemModel):
45  def __init__(self, parent=None):
46  QStandardItemModel.__init__(self)
47 
48 
49 class CreditsModel():
50  star_icon = QIcon(os.path.join(info.IMAGES_PATH, "star-icon.png"))
51  paypal_icon = QIcon(os.path.join(info.IMAGES_PATH, "paypal-icon.png"))
52  kickstarter_icon = QIcon(os.path.join(info.IMAGES_PATH, "kickstarter-icon.png"))
53  bitcoin_icon = QIcon(os.path.join(info.IMAGES_PATH, "bitcoin-icon.png"))
54  patreon_icon = QIcon(os.path.join(info.IMAGES_PATH, "patreon-icon.png"))
55  developer_icon = QIcon(os.path.join(info.IMAGES_PATH, "python-icon.png"))
56 
57  def update_model(self, filter=None, clear=True):
58  log.info("updating credits model.")
59  app = get_app()
60  _ = app._tr
61 
62  # Get window to check filters
63  win = app.window
64 
65  # Clear all items
66  if clear:
67  log.info('cleared credits model')
68  self.model.clear()
69 
70  # Add Headers
71  self.model.setHorizontalHeaderLabels(["", "", _("Name"), _("Email"), _("Website")])
72 
73  for person in self.credits_list:
74  # Get details of person
75  name = ""
76  if "name" in person.keys():
77  name = person["name"] or ""
78  email = ""
79  if "email" in person.keys():
80  email = person["email"] or ""
81  website = ""
82  if "website" in person.keys():
83  website = person["website"] or ""
84  amount = 0.0
85  if "amount" in person.keys():
86  amount = person["amount"]
87  icons = []
88  if "icons" in person.keys():
89  icons = person["icons"]
90 
91  if filter:
92  if not (filter.lower() in name.lower() or filter.lower() in email.lower() or filter.lower() in website.lower()):
93  continue
94  if len(name) < 2:
95  # Skip blank names
96  continue
97 
98  row = []
99 
100  # Append type icon (PayPal, Kickstarter, Bitcoin, or Patreon)
101  col = QStandardItem()
102  if "p" in icons:
103  col.setIcon(QIcon(self.paypal_icon))
104  col.setToolTip(_("PayPal Supporter!"))
105  elif "k" in icons:
106  col.setIcon(QIcon(self.kickstarter_icon))
107  col.setToolTip(_("Kickstarter Supporter!"))
108  elif "b" in icons:
109  col.setIcon(QIcon(self.bitcoin_icon))
110  col.setToolTip(_("Bitcoin Supporter!"))
111  elif "n" in icons:
112  col.setIcon(QIcon(self.patreon_icon))
113  col.setToolTip(_("Patreon Supporter!"))
114  elif "d" in icons:
115  col.setIcon(QIcon(self.developer_icon))
116  col.setToolTip(_("Developer!"))
117  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
118  row.append(col)
119 
120  # Append Star icon (Multiple donations, big donations, five-timer kickstarter group, etc...)
121  col = QStandardItem()
122  if "s" in icons:
123  col.setIcon(QIcon(self.star_icon))
124  col.setToolTip(_("Multiple Contributions!"))
125  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
126  row.append(col)
127 
128  # Append name
129  col = QStandardItem("Name")
130  col.setText(name)
131  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
132  row.append(col)
133 
134  # Append email
135  col = QStandardItem("Email")
136  col.setText(email)
137  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
138  row.append(col)
139 
140  # Append website
141  col = QStandardItem("Website")
142  col.setText(website)
143  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
144  row.append(col)
145 
146  # Append row to model
147  self.model.appendRow(row)
148 
149  def __init__(self, credits, *args):
150 
151  # Create standard model
152  self.app = get_app()
154  self.model.setColumnCount(6)
155  self.credits_list = credits
def get_app
Returns the current QApplication instance of OpenShot.
Definition: app.py:55