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 not win.actionEffectsShowAll.isChecked():
113 if win.actionEffectsShowVideo.isChecked():
114 if not category ==
"Video":
116 elif win.actionEffectsShowAudio.isChecked():
117 if not category ==
"Audio":
120 if win.effectsFilter.text() !=
"":
121 if not win.effectsFilter.text().lower()
in self.app._tr(title).lower()
and not win.effectsFilter.text().lower()
in self.app._tr(description).lower():
125 thumb_path = os.path.join(info.IMAGES_PATH,
"cache", icon_name)
128 if not os.path.exists(thumb_path):
130 thumb_path = os.path.join(info.CACHE_PATH, icon_name)
133 if not os.path.exists(thumb_path):
137 clip = openshot.Clip(icon_path)
138 reader = clip.Reader()
144 reader.GetFrame(0).Thumbnail(thumb_path, 98, 64, os.path.join(info.IMAGES_PATH,
"mask.png"),
"",
151 msg.setText(_(
"{} is not a valid image file.".
format(icon_path)))
158 col = QStandardItem()
159 col.setIcon(QIcon(thumb_path))
160 col.setText(self.app._tr(title))
161 col.setToolTip(self.app._tr(title))
162 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
166 col = QStandardItem(
"Name")
167 col.setData(self.app._tr(title), Qt.DisplayRole)
168 col.setText(self.app._tr(title))
169 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
173 col = QStandardItem(
"Description")
174 col.setData(self.app._tr(description), Qt.DisplayRole)
175 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
179 col = QStandardItem(
"Category")
180 col.setData(category, Qt.DisplayRole)
181 col.setText(category)
182 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
186 col = QStandardItem(
"Effect")
187 col.setData(effect_name, Qt.DisplayRole)
188 col.setText(effect_name)
189 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
194 self.model.appendRow(row)
205 self.model.setColumnCount(5)
def get_app()
Returns the current QApplication instance of OpenShot.
def mimeData(self, indexes)
def __init__(self, parent=None)
def update_model(self, clear=True)