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, 3).text())
59 data.setText(json.dumps(files))
60 data.setHtml(
"transition")
68 log.info(
"updating transitions model.")
81 self.
model.setHorizontalHeaderLabels([_(
"Thumb"), _(
"Name")])
84 transitions_dir = os.path.join(info.PATH,
"transitions")
85 common_dir = os.path.join(transitions_dir,
"common")
86 extra_dir = os.path.join(transitions_dir,
"extra")
87 transition_groups = [{
"type":
"common",
"dir": common_dir,
"files": os.listdir(common_dir)},
88 {
"type":
"extra",
"dir": extra_dir,
"files": os.listdir(extra_dir)}]
91 if (os.path.exists(info.TRANSITIONS_PATH)
and os.listdir(info.TRANSITIONS_PATH)):
92 transition_groups.append({
"type":
"user",
"dir": info.TRANSITIONS_PATH,
"files": os.listdir(info.TRANSITIONS_PATH)})
94 for group
in transition_groups:
97 files = group[
"files"]
99 for filename
in sorted(files):
100 path = os.path.join(dir, filename)
101 (fileBaseName, fileExtension) = os.path.splitext(filename)
104 if filename[0] ==
"." or "thumbs.db" in filename.lower():
109 name_parts = fileBaseName.split(
"_")
110 if name_parts[-1].isdigit():
111 suffix_number = name_parts[-1]
114 trans_name = fileBaseName.replace(
"_",
" ").capitalize()
118 trans_name = trans_name.replace(suffix_number,
"%s")
119 trans_name = self.
app._tr(trans_name) % suffix_number
121 trans_name = self.
app._tr(trans_name)
123 if not win.actionTransitionsShowAll.isChecked():
124 if win.actionTransitionsShowCommon.isChecked():
125 if not type ==
"common":
128 if win.transitionsFilter.text() !=
"":
129 if not win.transitionsFilter.text().lower()
in trans_name.lower():
133 thumb_path = os.path.join(info.IMAGES_PATH,
"cache",
"{}.png".format(fileBaseName))
136 if not os.path.exists(thumb_path):
138 thumb_path = os.path.join(info.CACHE_PATH,
"{}.png".format(fileBaseName))
141 if not os.path.exists(thumb_path):
145 clip = openshot.Clip(path)
146 reader = clip.Reader()
152 reader.GetFrame(0).Thumbnail(thumb_path, 98, 64, os.path.join(info.IMAGES_PATH,
"mask.png"),
"",
"#000",
True)
159 msg.setText(_(
"{} is not a valid image file.".format(filename)))
166 col = QStandardItem()
167 col.setIcon(QIcon(thumb_path))
168 col.setText(trans_name)
169 col.setToolTip(trans_name)
170 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
174 col = QStandardItem(
"Name")
175 col.setData(trans_name, Qt.DisplayRole)
176 col.setText(trans_name)
177 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
181 col = QStandardItem(
"Type")
182 col.setData(type, Qt.DisplayRole)
184 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
188 col = QStandardItem(
"Path")
189 col.setData(path, Qt.DisplayRole)
191 col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled)
196 self.
model.appendRow(row)
204 self.
model.setColumnCount(4)
def mimeData(self, indexes)
def get_app()
Returns the current QApplication instance of OpenShot.
def __init__(self, parent=None)
def update_model(self, clear=True)