30 import xml.dom.minidom
as xml
37 from classes
import info
38 from classes.logger
import log
39 from classes.app
import get_app
44 log.info(
"updating effects model.")
57 self.
model.setHorizontalHeaderLabels([_(
"Thumb"), _(
"Name")])
60 effects_dir = os.path.join(info.PATH,
"blender")
61 icons_dir = os.path.join(effects_dir,
"icons")
63 for file
in os.listdir(effects_dir):
64 if os.path.isfile(os.path.join(effects_dir, file))
and ".xml" in file:
66 path = os.path.join(effects_dir, file)
67 (fileBaseName, fileExtension) = os.path.splitext(path)
70 xmldoc = xml.parse(path)
73 title = xmldoc.getElementsByTagName(
"title")[0].childNodes[0].data
74 description = xmldoc.getElementsByTagName(
"description")[0].childNodes[0].data
75 icon_name = xmldoc.getElementsByTagName(
"icon")[0].childNodes[0].data
76 icon_path = os.path.join(icons_dir, icon_name)
77 category = xmldoc.getElementsByTagName(
"category")[0].childNodes[0].data
78 service = xmldoc.getElementsByTagName(
"service")[0].childNodes[0].data
80 if not win.actionEffectsShowAll.isChecked():
81 if win.actionEffectsShowVideo.isChecked():
82 if not category ==
"Video":
84 elif win.actionEffectsShowAudio.isChecked():
85 if not category ==
"Audio":
88 if win.effectsFilter.text() !=
"":
89 if not win.effectsFilter.text().lower()
in self.
app._tr(
90 title).lower()
and not win.effectsFilter.text().lower()
in self.
app._tr(
95 thumb_path = os.path.join(info.CACHE_PATH, icon_name)
98 if not os.path.exists(thumb_path):
102 clip = openshot.Clip(icon_path)
103 reader = clip.Reader()
109 scale = 95.0 / reader.info.width
112 reader.GetFrame(0).Save(thumb_path, scale)
118 msg.setText(_(
"{} is not a valid image file.".format(icon_path)))
125 col = QStandardItem()
126 col.setIcon(QIcon(thumb_path))
127 col.setText(self.
app._tr(title))
128 col.setToolTip(self.
app._tr(title))
129 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
133 col = QStandardItem(
"Name")
134 col.setData(self.
app._tr(title), Qt.DisplayRole)
135 col.setText(self.
app._tr(title))
136 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
140 col = QStandardItem(
"Path")
141 col.setData(path, Qt.DisplayRole)
143 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
147 col = QStandardItem(
"Service")
148 col.setData(service, Qt.DisplayRole)
150 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
155 self.
model.appendRow(row)
166 self.
model.setColumnCount(4)
def get_app()
Returns the current QApplication instance of OpenShot.
def update_model(self, clear=True)