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
81 thumb_path = os.path.join(info.CACHE_PATH, icon_name)
84 if not os.path.exists(thumb_path):
88 clip = openshot.Clip(icon_path)
89 reader = clip.Reader()
95 scale = 95.0 / reader.info.width
98 reader.GetFrame(0).Save(thumb_path, scale)
104 msg.setText(_(
"{} is not a valid image file.".format(icon_path)))
111 col = QStandardItem()
112 col.setIcon(QIcon(thumb_path))
113 col.setText(self.app._tr(title))
114 col.setToolTip(self.app._tr(title))
115 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
119 col = QStandardItem(
"Name")
120 col.setData(self.app._tr(title), Qt.DisplayRole)
121 col.setText(self.app._tr(title))
122 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
126 col = QStandardItem(
"Path")
127 col.setData(path, Qt.DisplayRole)
129 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
133 col = QStandardItem(
"Service")
134 col.setData(service, Qt.DisplayRole)
136 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
141 self.model.appendRow(row)
152 self.model.setColumnCount(4)
def get_app
Returns the current QApplication instance of OpenShot.