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-2016 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 
55  def update_model(self, filter=None, clear=True):
56  log.info("updating credits model.")
57  app = get_app()
58  _ = app._tr
59 
60  # Get window to check filters
61  win = app.window
62 
63  # Clear all items
64  if clear:
65  log.info('cleared credits model')
66  self.model.clear()
67 
68  # Add Headers
69  self.model.setHorizontalHeaderLabels(["", "", _("Name"), _("Email"), _("Website")])
70 
71  for person in self.credits_list:
72  # Get details of person
73  name = ""
74  if "name" in person.keys():
75  name = person["name"] or ""
76  email = ""
77  if "email" in person.keys():
78  email = person["email"] or ""
79  website = ""
80  if "website" in person.keys():
81  website = person["website"] or ""
82  amount = 0.0
83  if "amount" in person.keys():
84  amount = person["amount"]
85  icons = []
86  if "icons" in person.keys():
87  icons = person["icons"]
88 
89  if filter:
90  if not (filter.lower() in name.lower() or filter.lower() in email.lower() or filter.lower() in website.lower()):
91  continue
92  if len(name) < 2:
93  # Skip blank names
94  continue
95 
96  row = []
97 
98  # Append type icon (PayPal, Kickstarter, or Bitcoin)
99  col = QStandardItem()
100  if "p" in icons:
101  col.setIcon(QIcon(self.paypal_icon))
102  col.setToolTip(_("PayPal Supporter!"))
103  elif "k" in icons:
104  col.setIcon(QIcon(self.kickstarter_icon))
105  col.setToolTip(_("Kickstarter Supporter!"))
106  elif "b" in icons:
107  col.setIcon(QIcon(self.bitcoin_icon))
108  col.setToolTip(_("Bitcoin Supporter!"))
109  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
110  row.append(col)
111 
112  # Append Star icon (Multiple donations, big donations, five-timer kickstarter group, etc...)
113  col = QStandardItem()
114  if "s" in icons:
115  col.setIcon(QIcon(self.star_icon))
116  col.setToolTip(_("Multiple Contributions!"))
117  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
118  row.append(col)
119 
120  # Append name
121  col = QStandardItem("Name")
122  col.setText(name)
123  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
124  row.append(col)
125 
126  # Append email
127  col = QStandardItem("Email")
128  col.setText(email)
129  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
130  row.append(col)
131 
132  # Append website
133  col = QStandardItem("Website")
134  col.setText(website)
135  col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
136  row.append(col)
137 
138  # Append row to model
139  self.model.appendRow(row)
140 
141  def __init__(self, credits, *args):
142 
143  # Create standard model
144  self.app = get_app()
146  self.model.setColumnCount(6)
147  self.credits_list = credits
def get_app()
Returns the current QApplication instance of OpenShot.
Definition: app.py:54
def update_model(self, filter=None, clear=True)
def __init__(self, credits, args)