36 from classes
import info
37 from classes.logger
import log
38 from classes.app
import get_app
43 import simplejson
as json
48 QStandardItemModel.__init__(self)
57 selected_row = self.itemFromIndex(item).row()
58 files.append(self.item(selected_row, 4).text())
59 data.setText(json.dumps(files))
60 data.setHtml(
"effect")
68 log.info(
"updating effects model.")
81 self.model.setHorizontalHeaderLabels([_(
"Thumb"), _(
"Name"), _(
"Description")])
84 effects_dir = os.path.join(info.PATH,
"effects")
85 icons_dir = os.path.join(effects_dir,
"icons")
88 raw_effects_list = json.loads(openshot.EffectInfo.Json())
91 for effect_info
in raw_effects_list:
93 effect_name = effect_info[
"class_name"]
94 title = effect_info[
"name"]
95 description = effect_info[
"description"]
96 icon_name =
"%s.png" % effect_name.lower()
97 icon_path = os.path.join(icons_dir, icon_name)
101 if effect_info[
"has_video"]
and effect_info[
"has_audio"]:
102 category =
"Audio & Video"
103 elif not effect_info[
"has_video"]
and effect_info[
"has_audio"]:
105 icon_path = os.path.join(icons_dir,
"audio.png")
106 elif effect_info[
"has_video"]
and not effect_info[
"has_audio"]:
109 log.info(
"category: %s" % category)
112 if win.effectsFilter.text() !=
"":
113 if not win.effectsFilter.text().lower()
in self.app._tr(title).lower()
and not win.effectsFilter.text().lower()
in self.app._tr(description).lower():
117 thumb_path = os.path.join(info.IMAGES_PATH,
"cache", icon_name)
120 if not os.path.exists(thumb_path):
122 thumb_path = os.path.join(info.CACHE_PATH, icon_name)
125 if not os.path.exists(thumb_path):
129 clip = openshot.Clip(icon_path)
130 reader = clip.Reader()
136 reader.GetFrame(0).Thumbnail(thumb_path, 98, 64, os.path.join(info.IMAGES_PATH,
"mask.png"),
"",
143 msg.setText(_(
"{} is not a valid image file.".format(icon_path)))
150 col = QStandardItem()
151 col.setIcon(QIcon(thumb_path))
152 col.setText(self.app._tr(title))
153 col.setToolTip(self.app._tr(title))
154 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
158 col = QStandardItem(
"Name")
159 col.setData(self.app._tr(title), Qt.DisplayRole)
160 col.setText(self.app._tr(title))
161 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
165 col = QStandardItem(
"Description")
166 col.setData(self.app._tr(description), Qt.DisplayRole)
167 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
171 col = QStandardItem(
"Category")
172 col.setData(category, Qt.DisplayRole)
173 col.setText(category)
174 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
178 col = QStandardItem(
"Effect")
179 col.setData(effect_name, Qt.DisplayRole)
180 col.setText(effect_name)
181 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
186 self.model.appendRow(row)
194 self.model.setColumnCount(5)
def get_app
Returns the current QApplication instance of OpenShot.