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"]:
110 if win.effectsFilter.text() !=
"":
111 if not win.effectsFilter.text().lower()
in self.app._tr(title).lower()
and not win.effectsFilter.text().lower()
in self.app._tr(description).lower():
115 thumb_path = os.path.join(info.IMAGES_PATH,
"cache", icon_name)
118 if not os.path.exists(thumb_path):
120 thumb_path = os.path.join(info.CACHE_PATH, icon_name)
123 if not os.path.exists(thumb_path):
127 clip = openshot.Clip(icon_path)
128 reader = clip.Reader()
134 reader.GetFrame(0).Thumbnail(thumb_path, 98, 64, os.path.join(info.IMAGES_PATH,
"mask.png"),
"",
141 msg.setText(_(
"{} is not a valid image file.".format(icon_path)))
148 col = QStandardItem()
149 col.setIcon(QIcon(thumb_path))
150 col.setText(self.app._tr(title))
151 col.setToolTip(self.app._tr(title))
152 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
156 col = QStandardItem(
"Name")
157 col.setData(self.app._tr(title), Qt.DisplayRole)
158 col.setText(self.app._tr(title))
159 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
163 col = QStandardItem(
"Description")
164 col.setData(self.app._tr(description), Qt.DisplayRole)
165 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
169 col = QStandardItem(
"Category")
170 col.setData(category, Qt.DisplayRole)
171 col.setText(category)
172 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
176 col = QStandardItem(
"Effect")
177 col.setData(effect_name, Qt.DisplayRole)
178 col.setText(effect_name)
179 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
184 self.model.appendRow(row)
192 self.model.setColumnCount(5)
def get_app
Returns the current QApplication instance of OpenShot.