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 icon_pixmap = QPixmap(thumb_path)
113 scaled_pixmap = icon_pixmap.scaled(QSize(93, 62), Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
114 col.setIcon(QIcon(scaled_pixmap))
115 col.setText(self.app._tr(title))
116 col.setToolTip(self.app._tr(title))
117 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
121 col = QStandardItem(
"Name")
122 col.setData(self.app._tr(title), Qt.DisplayRole)
123 col.setText(self.app._tr(title))
124 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
128 col = QStandardItem(
"Path")
129 col.setData(path, Qt.DisplayRole)
131 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
135 col = QStandardItem(
"Service")
136 col.setData(service, Qt.DisplayRole)
138 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
143 self.model.appendRow(row)
154 self.model.setColumnCount(3)
def get_app
Returns the current QApplication instance of OpenShot.