Add a reset button
This commit is contained in:
parent
54e0af1915
commit
1a97bde040
@ -83,6 +83,16 @@ class ConfigureDialog(QtWidgets.QDialog):
|
|||||||
self.render_options_stack = QtWidgets.QStackedWidget(self)
|
self.render_options_stack = QtWidgets.QStackedWidget(self)
|
||||||
self.render_options_stack.setObjectName("render_options_stack")
|
self.render_options_stack.setObjectName("render_options_stack")
|
||||||
self.render_layout.addWidget(self.render_options_stack)
|
self.render_layout.addWidget(self.render_options_stack)
|
||||||
|
self.render_reset_layout = QtWidgets.QHBoxLayout()
|
||||||
|
self.render_reset_layout.setObjectName('render_reset_layout')
|
||||||
|
self.render_reset_layout.setSpacing(0)
|
||||||
|
self.render_reset_layout.setContentsMargins(0, 0, 0, 0)
|
||||||
|
self.render_reset_layout.addStretch()
|
||||||
|
self.render_reset_button = QtWidgets.QPushButton(self.renderer_page)
|
||||||
|
self.render_reset_button.setIcon(QtGui.QIcon.fromTheme('edit-reset'))
|
||||||
|
self.render_reset_button.setObjectName('render_reset_button')
|
||||||
|
self.render_reset_layout.addWidget(self.render_reset_button)
|
||||||
|
self.render_layout.addLayout(self.render_reset_layout)
|
||||||
# Export settings
|
# Export settings
|
||||||
self.export_page = QtWidgets.QWidget()
|
self.export_page = QtWidgets.QWidget()
|
||||||
self.export_page.setObjectName('export_page')
|
self.export_page.setObjectName('export_page')
|
||||||
@ -163,6 +173,7 @@ class ConfigureDialog(QtWidgets.QDialog):
|
|||||||
self.export_margin_bottom_spinbox.valueChanged.connect(on_export_margin_bottom_changed)
|
self.export_margin_bottom_spinbox.valueChanged.connect(on_export_margin_bottom_changed)
|
||||||
on_export_orientation_portait_clicked = partial(self._set_export_value, 'orientation')
|
on_export_orientation_portait_clicked = partial(self._set_export_value, 'orientation')
|
||||||
self.export_orientation_portrait_radio.toggled.connect(on_export_orientation_portait_clicked)
|
self.export_orientation_portrait_radio.toggled.connect(on_export_orientation_portait_clicked)
|
||||||
|
self.render_reset_button.clicked.connect(self.on_reset_button_clicked)
|
||||||
|
|
||||||
def retranslate_ui(self):
|
def retranslate_ui(self):
|
||||||
_translate = QtCore.QCoreApplication.translate
|
_translate = QtCore.QCoreApplication.translate
|
||||||
@ -173,6 +184,9 @@ class ConfigureDialog(QtWidgets.QDialog):
|
|||||||
self.category_list_widget.item(3).setText(_translate('ConfigureDialog', 'PDF'))
|
self.category_list_widget.item(3).setText(_translate('ConfigureDialog', 'PDF'))
|
||||||
self.export_orientation_portrait_radio.setText(_translate('ConfigureDialog', 'Portrait'))
|
self.export_orientation_portrait_radio.setText(_translate('ConfigureDialog', 'Portrait'))
|
||||||
self.export_orientation_landscape_radio.setText(_translate('ConfigureDialog', 'Landscape'))
|
self.export_orientation_landscape_radio.setText(_translate('ConfigureDialog', 'Landscape'))
|
||||||
|
self.render_reset_button.setText(_translate('ConfigureDialog', 'Reset values'))
|
||||||
|
self.render_reset_button.setToolTip(_translate('ConfigureDialog',
|
||||||
|
'Reset the values for this option to the defaults'))
|
||||||
|
|
||||||
def _set_option_value(self, name, value):
|
def _set_option_value(self, name, value):
|
||||||
"""Set an option value"""
|
"""Set an option value"""
|
||||||
@ -192,6 +206,26 @@ class ConfigureDialog(QtWidgets.QDialog):
|
|||||||
value = QtGui.QPageLayout.Portrait if value else QtGui.QPageLayout.Landscape
|
value = QtGui.QPageLayout.Portrait if value else QtGui.QPageLayout.Landscape
|
||||||
self.export_values[name] = value
|
self.export_values[name] = value
|
||||||
|
|
||||||
|
def on_reset_button_clicked(self):
|
||||||
|
"""Reset all the values for the current option group"""
|
||||||
|
current_group = self.render_options_combobox.currentText().replace(' ', '_').lower()
|
||||||
|
self.settings.beginGroup('render')
|
||||||
|
for name, details in get_options(current_group).items():
|
||||||
|
if name in self.option_values:
|
||||||
|
del self.option_values[name]
|
||||||
|
if self.settings.contains(name):
|
||||||
|
self.settings.remove(name)
|
||||||
|
if details['type'] is int:
|
||||||
|
self.option_widgets[name].setValue(details['default'])
|
||||||
|
elif details['type'] is bool:
|
||||||
|
self.option_widgets[name].setChecked(details['default'])
|
||||||
|
elif 'font' in name:
|
||||||
|
value = QtGui.QFont(details['default'])
|
||||||
|
self.option_widgets[name].setCurrentFont(value)
|
||||||
|
else:
|
||||||
|
self.option_widgets[name].setText(details['default'])
|
||||||
|
self.settings.endGroup()
|
||||||
|
|
||||||
def setup_options(self):
|
def setup_options(self):
|
||||||
for group in get_option_groups():
|
for group in get_option_groups():
|
||||||
pretty_group = group.replace('_', ' ').title()
|
pretty_group = group.replace('_', ' ').title()
|
||||||
|
Loading…
Reference in New Issue
Block a user