39 from classes
import info, ui_util, settings, qt_types, updates
40 from classes.app
import get_app
41 from classes.language
import get_all_languages
42 from classes.logger
import log
52 ui_path = os.path.join(info.PATH,
'windows',
'ui',
'preferences.ui')
57 QDialog.__init__(self)
81 if "setting" in item
and "value" in item:
82 self.
params[item[
"setting"]] = item
91 category = item.get(
"category")
92 setting_type = item.get(
"type")
93 sort_category = item.get(
"sort")
99 if not setting_type ==
"hidden":
105 scroll_area = QScrollArea(self)
106 scroll_area.setWidgetResizable(
True)
107 scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
108 scroll_area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
111 layout = QVBoxLayout()
112 tabWidget = QWidget(self)
113 tabWidget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
114 tabWidget.setLayout(layout)
115 scroll_area.setWidget(tabWidget)
118 self.tabCategories.addTab(scroll_area, _(category))
122 item[
"title_tr"] = _(item.get(
"title"))
128 for category
in self.category_tabs.keys():
133 if self.category_sort.get(category):
135 params.sort(key=operator.itemgetter(
"title_tr"))
144 label.setText(_(param[
"title"]))
145 label.setToolTip(_(param[
"title"]))
147 if param[
"type"] ==
"spinner":
149 widget = QDoubleSpinBox()
150 widget.setMinimum(float(param[
"min"]))
151 widget.setMaximum(float(param[
"max"]))
152 widget.setValue(float(param[
"value"]))
153 widget.setSingleStep(1.0)
154 widget.setToolTip(param[
"title"])
157 if param[
"type"] ==
"spinner-int":
160 widget.setMinimum(int(param[
"min"]))
161 widget.setMaximum(int(param[
"max"]))
162 widget.setValue(int(param[
"value"]))
163 widget.setSingleStep(1.0)
164 widget.setToolTip(param[
"title"])
167 elif param[
"type"] ==
"text":
170 widget.setText(_(param[
"value"]))
173 elif param[
"type"] ==
"browse":
176 widget.setText(_(param[
"value"]))
178 extraWidget = QPushButton(_(
"Browse..."))
179 extraWidget.clicked.connect(functools.partial(self.
selectExecutable, widget, param))
181 elif param[
"type"] ==
"bool":
184 if param[
"value"] ==
True:
185 widget.setCheckState(Qt.Checked)
187 widget.setCheckState(Qt.Unchecked)
188 widget.stateChanged.connect(functools.partial(self.
bool_value_changed, widget, param))
190 elif param[
"type"] ==
"dropdown":
196 value_list = param[
"values"]
198 if param[
"setting"] ==
"default-profile":
201 for profile_folder
in [info.USER_PROFILES_PATH, info.PROFILES_PATH]:
202 for file
in os.listdir(profile_folder):
204 profile_path = os.path.join(profile_folder, file)
205 profile = openshot.Profile(profile_path)
206 value_list.append({
"name":profile.info.description,
"value":profile.info.description})
208 value_list.sort(key=operator.itemgetter(
"name"))
211 if param[
"setting"] ==
"default-language":
217 lang_name =
"%s (%s)" % (language, locale)
218 value_list.append({
"name":lang_name,
"value":locale})
220 value_list.sort(key=operator.itemgetter(
"name"))
222 value_list.insert(0, {
"name":_(
"Default"),
"value":
"Default"})
227 for value_item
in value_list:
228 k = value_item[
"name"]
229 v = value_item[
"value"]
231 widget.addItem(_(k), v)
234 if v == param[
"value"]:
235 widget.setCurrentIndex(box_index)
236 box_index = box_index + 1
242 if (widget
and label):
244 label.setMinimumWidth(180);
245 label.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
246 widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
249 layout_hbox = QHBoxLayout()
250 layout_hbox.addWidget(label)
251 layout_hbox.addWidget(widget)
254 layout_hbox.addWidget(extraWidget)
257 tabWidget.layout().addLayout(layout_hbox)
260 tabWidget.layout().addWidget(label)
263 tabWidget.layout().addStretch()
268 fileName, fileType = QFileDialog.getOpenFileName(self, _(
"Select executable file"), QDir.rootPath(), _(
"All Files (*)"))
270 self.s.set(param[
"setting"], fileName)
271 widget.setText(fileName)
276 if "restart" in param
and param[
"restart"]:
281 if state == Qt.Checked:
282 self.s.set(param[
"setting"],
True)
284 self.s.set(param[
"setting"],
False)
287 if param[
"setting"] ==
"debug-mode":
289 log.info(
"Setting debug-mode to %s" % (state == Qt.Checked))
290 debug_enabled = (state == Qt.Checked)
293 openshot.ZmqLogger.Instance().Enable(debug_enabled)
295 elif param[
"setting"] ==
"enable-auto-save":
297 if (state == Qt.Checked):
299 get_app().window.auto_save_timer.start()
302 get_app().window.auto_save_timer.stop()
304 elif param[
"setting"] ==
"hardware_decode":
305 if (state == Qt.Checked):
307 openshot.Settings.Instance().HARDWARE_DECODE =
True
310 openshot.Settings.Instance().HARDWARE_DECODE =
False
312 elif param[
"setting"] ==
"hardware_encode":
313 if (state == Qt.Checked):
315 openshot.Settings.Instance().HARDWARE_ENCODE =
True
318 openshot.Settings.Instance().HARDWARE_ENCODE =
False
320 elif param[
"setting"] ==
"omp_threads_enabled":
321 if (state == Qt.Checked):
323 openshot.Settings.Instance().WAIT_FOR_VIDEO_PROCESSING_TASK =
False
326 openshot.Settings.Instance().WAIT_FOR_VIDEO_PROCESSING_TASK =
True
333 self.s.set(param[
"setting"], value)
336 if param[
"setting"] ==
"autosave-interval":
338 get_app().window.auto_save_timer.setInterval(value * 1000 * 60)
341 if param[
"setting"]
in [
"cache-limit-mb",
"cache-scale",
"cache-quality"]:
342 get_app().window.InitCacheSettings()
351 value = widget.toPlainText()
356 if param.get(
"category") ==
"Keyboard":
357 previous_value = value
358 value = QKeySequence(value).toString()
359 log.info(
"Parsing keyboard mapping via QKeySequence from %s to %s" % (previous_value, value))
362 self.s.set(param[
"setting"], value)
370 value = widget.itemData(index)
371 self.s.set(param[
"setting"], value)
375 if param[
"setting"]
in [
"cache-mode",
"cache-image-format"]:
376 get_app().window.InitCacheSettings()
392 msg.setWindowTitle(_(
"Restart Required"))
393 msg.setText(_(
"Please restart OpenShot for all preferences to take effect."))
397 super(Preferences, self).
reject()
def track_metric_screen
Track a GUI screen being shown.
def get_app
Returns the current QApplication instance of OpenShot.
def dropdown_index_changed
def check_for_restart
Check if the app needs to restart.
def load_ui
Load a Qt *.ui file, and also load an XML parsed version.
def spinner_value_changed
def closeEvent
Signal for closing Preferences window.
def init_ui
Initialize all child widgets and action of a window or dialog.
def get_all_languages
Get all language names and countries packaged with OpenShot.
def get_settings
Get the current QApplication's settings instance.