2016-05-29 01:54:25 +00:00
|
|
|
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
|
2014-10-13 19:08:59 +00:00
|
|
|
#
|
2015-01-03 21:33:16 +00:00
|
|
|
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
2014-10-13 19:08:59 +00:00
|
|
|
# which should be included with this package. The terms are also available at
|
2015-01-03 21:33:16 +00:00
|
|
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
2011-01-21 12:57:54 +00:00
|
|
|
|
2020-07-22 20:41:22 +00:00
|
|
|
from PyQt5.QtCore import Qt, QSize, pyqtSlot
|
2014-10-13 19:08:59 +00:00
|
|
|
from PyQt5.QtWidgets import (
|
2020-01-01 02:16:27 +00:00
|
|
|
QDialog,
|
|
|
|
QDialogButtonBox,
|
|
|
|
QVBoxLayout,
|
|
|
|
QHBoxLayout,
|
2020-07-22 19:38:03 +00:00
|
|
|
QGridLayout,
|
2020-01-01 02:16:27 +00:00
|
|
|
QLabel,
|
|
|
|
QComboBox,
|
|
|
|
QSlider,
|
|
|
|
QSizePolicy,
|
|
|
|
QSpacerItem,
|
|
|
|
QCheckBox,
|
|
|
|
QLineEdit,
|
|
|
|
QMessageBox,
|
|
|
|
QSpinBox,
|
|
|
|
QLayout,
|
2020-07-20 01:10:06 +00:00
|
|
|
QTabWidget,
|
|
|
|
QWidget,
|
2020-07-22 19:38:03 +00:00
|
|
|
QColorDialog,
|
|
|
|
QPushButton,
|
2020-08-01 14:42:14 +00:00
|
|
|
QGroupBox,
|
2020-08-01 15:40:31 +00:00
|
|
|
QFormLayout,
|
2014-10-13 19:08:59 +00:00
|
|
|
)
|
2020-07-22 20:41:22 +00:00
|
|
|
from PyQt5.QtGui import QPixmap, QIcon
|
2011-01-21 12:57:54 +00:00
|
|
|
|
2011-11-01 19:44:18 +00:00
|
|
|
from hscommon.trans import trget
|
2020-07-21 01:52:15 +00:00
|
|
|
from hscommon.plat import ISLINUX
|
2021-08-28 04:26:19 +00:00
|
|
|
from qtlib.util import horizontal_wrap, move_to_screen_center
|
2016-05-26 01:07:30 +00:00
|
|
|
from qtlib.preferences import get_langnames
|
2020-07-20 03:04:25 +00:00
|
|
|
from enum import Flag, auto
|
2011-01-21 12:57:54 +00:00
|
|
|
|
2016-06-01 01:22:50 +00:00
|
|
|
from .preferences import Preferences
|
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
tr = trget("ui")
|
2011-11-01 19:44:18 +00:00
|
|
|
|
2015-04-13 01:53:45 +00:00
|
|
|
SUPPORTED_LANGUAGES = [
|
2021-08-07 02:39:02 +00:00
|
|
|
"cs",
|
2020-01-01 02:16:27 +00:00
|
|
|
"de",
|
|
|
|
"el",
|
2021-08-07 02:39:02 +00:00
|
|
|
"en",
|
|
|
|
"es",
|
|
|
|
"fr",
|
2020-01-01 02:16:27 +00:00
|
|
|
"hy",
|
2021-08-07 02:39:02 +00:00
|
|
|
"it",
|
|
|
|
"ja",
|
|
|
|
"ko",
|
|
|
|
"nl",
|
|
|
|
"pl_PL",
|
|
|
|
"pt_BR",
|
2020-01-01 02:16:27 +00:00
|
|
|
"ru",
|
2021-08-07 02:39:02 +00:00
|
|
|
"tr",
|
2020-01-01 02:16:27 +00:00
|
|
|
"uk",
|
|
|
|
"vi",
|
2021-08-07 02:39:02 +00:00
|
|
|
"zh_CN",
|
2015-04-13 01:53:45 +00:00
|
|
|
]
|
2011-11-03 14:38:31 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
|
2020-07-20 03:04:25 +00:00
|
|
|
class Sections(Flag):
|
|
|
|
"""Filter blocks of preferences when reset or loaded"""
|
2021-03-18 01:21:29 +00:00
|
|
|
|
2020-07-20 03:04:25 +00:00
|
|
|
GENERAL = auto()
|
|
|
|
DISPLAY = auto()
|
|
|
|
ALL = GENERAL | DISPLAY
|
|
|
|
|
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
class PreferencesDialogBase(QDialog):
|
2013-10-20 19:53:59 +00:00
|
|
|
def __init__(self, parent, app, **kwargs):
|
2011-01-21 12:57:54 +00:00
|
|
|
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
|
2013-10-20 19:53:59 +00:00
|
|
|
super().__init__(parent, flags, **kwargs)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.app = app
|
2016-05-26 01:07:30 +00:00
|
|
|
all_languages = get_langnames()
|
2021-08-15 08:51:27 +00:00
|
|
|
self.supportedLanguages = sorted(SUPPORTED_LANGUAGES, key=lambda lang: all_languages[lang])
|
2011-01-21 12:57:54 +00:00
|
|
|
self._setupUi()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2021-08-15 08:51:27 +00:00
|
|
|
self.filterHardnessSlider.valueChanged["int"].connect(self.filterHardnessLabel.setNum)
|
2014-03-27 23:09:10 +00:00
|
|
|
self.buttonBox.clicked.connect(self.buttonClicked)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.buttonBox.accepted.connect(self.accept)
|
|
|
|
self.buttonBox.rejected.connect(self.reject)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
def _setupFilterHardnessBox(self):
|
|
|
|
self.filterHardnessHLayout = QHBoxLayout()
|
|
|
|
self.filterHardnessLabel = QLabel(self)
|
|
|
|
self.filterHardnessLabel.setText(tr("Filter Hardness:"))
|
|
|
|
self.filterHardnessLabel.setMinimumSize(QSize(0, 0))
|
|
|
|
self.filterHardnessHLayout.addWidget(self.filterHardnessLabel)
|
|
|
|
self.filterHardnessVLayout = QVBoxLayout()
|
|
|
|
self.filterHardnessVLayout.setSpacing(0)
|
|
|
|
self.filterHardnessHLayoutSub1 = QHBoxLayout()
|
|
|
|
self.filterHardnessHLayoutSub1.setSpacing(12)
|
|
|
|
self.filterHardnessSlider = QSlider(self)
|
2021-08-24 05:12:23 +00:00
|
|
|
size_policy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
|
|
|
|
size_policy.setHorizontalStretch(0)
|
|
|
|
size_policy.setVerticalStretch(0)
|
|
|
|
size_policy.setHeightForWidth(self.filterHardnessSlider.sizePolicy().hasHeightForWidth())
|
|
|
|
self.filterHardnessSlider.setSizePolicy(size_policy)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.filterHardnessSlider.setMinimum(1)
|
|
|
|
self.filterHardnessSlider.setMaximum(100)
|
|
|
|
self.filterHardnessSlider.setTracking(True)
|
|
|
|
self.filterHardnessSlider.setOrientation(Qt.Horizontal)
|
|
|
|
self.filterHardnessHLayoutSub1.addWidget(self.filterHardnessSlider)
|
|
|
|
self.filterHardnessLabel = QLabel(self)
|
|
|
|
self.filterHardnessLabel.setText("100")
|
|
|
|
self.filterHardnessLabel.setMinimumSize(QSize(21, 0))
|
|
|
|
self.filterHardnessHLayoutSub1.addWidget(self.filterHardnessLabel)
|
|
|
|
self.filterHardnessVLayout.addLayout(self.filterHardnessHLayoutSub1)
|
|
|
|
self.filterHardnessHLayoutSub2 = QHBoxLayout()
|
|
|
|
self.filterHardnessHLayoutSub2.setContentsMargins(-1, 0, -1, -1)
|
|
|
|
self.moreResultsLabel = QLabel(self)
|
|
|
|
self.moreResultsLabel.setText(tr("More Results"))
|
|
|
|
self.filterHardnessHLayoutSub2.addWidget(self.moreResultsLabel)
|
2021-08-24 05:12:23 +00:00
|
|
|
spacer_item = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
|
|
|
self.filterHardnessHLayoutSub2.addItem(spacer_item)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.fewerResultsLabel = QLabel(self)
|
|
|
|
self.fewerResultsLabel.setText(tr("Fewer Results"))
|
|
|
|
self.filterHardnessHLayoutSub2.addWidget(self.fewerResultsLabel)
|
|
|
|
self.filterHardnessVLayout.addLayout(self.filterHardnessHLayoutSub2)
|
|
|
|
self.filterHardnessHLayout.addLayout(self.filterHardnessVLayout)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
def _setupBottomPart(self):
|
|
|
|
# The bottom part of the pref panel is always the same in all editions.
|
|
|
|
self.copyMoveLabel = QLabel(self)
|
|
|
|
self.copyMoveLabel.setText(tr("Copy and Move:"))
|
|
|
|
self.widgetsVLayout.addWidget(self.copyMoveLabel)
|
|
|
|
self.copyMoveDestinationComboBox = QComboBox(self)
|
|
|
|
self.copyMoveDestinationComboBox.addItem(tr("Right in destination"))
|
|
|
|
self.copyMoveDestinationComboBox.addItem(tr("Recreate relative path"))
|
|
|
|
self.copyMoveDestinationComboBox.addItem(tr("Recreate absolute path"))
|
|
|
|
self.widgetsVLayout.addWidget(self.copyMoveDestinationComboBox)
|
|
|
|
self.customCommandLabel = QLabel(self)
|
2021-08-15 08:51:27 +00:00
|
|
|
self.customCommandLabel.setText(tr("Custom Command (arguments: %d for dupe, %r for ref):"))
|
2011-01-21 12:57:54 +00:00
|
|
|
self.widgetsVLayout.addWidget(self.customCommandLabel)
|
|
|
|
self.customCommandEdit = QLineEdit(self)
|
|
|
|
self.widgetsVLayout.addWidget(self.customCommandEdit)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-07-20 01:10:06 +00:00
|
|
|
def _setupDisplayPage(self):
|
2021-03-18 01:21:29 +00:00
|
|
|
self.ui_groupbox = QGroupBox("&" + tr("General Interface"))
|
2020-08-01 16:50:44 +00:00
|
|
|
layout = QVBoxLayout()
|
2020-07-22 19:38:03 +00:00
|
|
|
self.languageLabel = QLabel(tr("Language:"), self)
|
|
|
|
self.languageComboBox = QComboBox(self)
|
|
|
|
for lang in self.supportedLanguages:
|
|
|
|
self.languageComboBox.addItem(get_langnames()[lang])
|
2021-08-24 05:12:23 +00:00
|
|
|
layout.addLayout(horizontal_wrap([self.languageLabel, self.languageComboBox, None]))
|
2021-03-18 01:21:29 +00:00
|
|
|
self._setupAddCheckbox(
|
|
|
|
"tabs_default_pos",
|
|
|
|
tr("Use default position for tab bar (requires restart)"),
|
|
|
|
)
|
2020-08-01 16:29:22 +00:00
|
|
|
self.tabs_default_pos.setToolTip(
|
2021-03-18 01:21:29 +00:00
|
|
|
tr(
|
|
|
|
"Place the tab bar below the main menu instead of next to it\n\
|
|
|
|
On MacOS, the tab bar will fill up the window's width instead."
|
|
|
|
)
|
|
|
|
)
|
2020-08-01 16:50:44 +00:00
|
|
|
layout.addWidget(self.tabs_default_pos)
|
2021-08-24 08:52:43 +00:00
|
|
|
self._setupAddCheckbox(
|
|
|
|
"use_native_dialogs",
|
|
|
|
tr("Use native OS dialogs"),
|
|
|
|
)
|
|
|
|
self.use_native_dialogs.setToolTip(
|
|
|
|
tr(
|
|
|
|
"For actions such as file/folder selection use the OS native dialogs.\nSome native dialogs have limited functionality."
|
|
|
|
)
|
|
|
|
)
|
|
|
|
layout.addWidget(self.use_native_dialogs)
|
2020-08-01 16:50:44 +00:00
|
|
|
self.ui_groupbox.setLayout(layout)
|
|
|
|
self.displayVLayout.addWidget(self.ui_groupbox)
|
2020-07-22 19:38:03 +00:00
|
|
|
|
2020-09-02 18:26:23 +00:00
|
|
|
gridlayout = QGridLayout()
|
|
|
|
gridlayout.setColumnStretch(2, 2)
|
|
|
|
formlayout = QFormLayout()
|
2021-03-18 01:21:29 +00:00
|
|
|
result_groupbox = QGroupBox("&" + tr("Result Table"))
|
2011-09-23 14:29:25 +00:00
|
|
|
self.fontSizeSpinBox = QSpinBox()
|
|
|
|
self.fontSizeSpinBox.setMinimum(5)
|
2020-09-02 18:26:23 +00:00
|
|
|
formlayout.addRow(tr("Font size:"), self.fontSizeSpinBox)
|
2021-08-15 08:51:27 +00:00
|
|
|
self._setupAddCheckbox("reference_bold_font", tr("Use bold font for references"))
|
2020-09-02 18:26:23 +00:00
|
|
|
formlayout.addRow(self.reference_bold_font)
|
2020-08-01 15:40:31 +00:00
|
|
|
|
2020-07-22 19:38:03 +00:00
|
|
|
self.result_table_ref_foreground_color = ColorPickerButton(self)
|
2021-08-15 08:51:27 +00:00
|
|
|
formlayout.addRow(tr("Reference foreground color:"), self.result_table_ref_foreground_color)
|
2020-08-12 19:37:29 +00:00
|
|
|
self.result_table_ref_background_color = ColorPickerButton(self)
|
2021-08-15 08:51:27 +00:00
|
|
|
formlayout.addRow(tr("Reference background color:"), self.result_table_ref_background_color)
|
2020-07-22 19:38:03 +00:00
|
|
|
self.result_table_delta_foreground_color = ColorPickerButton(self)
|
2021-08-15 08:51:27 +00:00
|
|
|
formlayout.addRow(tr("Delta foreground color:"), self.result_table_delta_foreground_color)
|
2020-09-02 18:26:23 +00:00
|
|
|
formlayout.setLabelAlignment(Qt.AlignLeft)
|
2020-08-01 15:40:31 +00:00
|
|
|
|
2020-08-01 14:42:14 +00:00
|
|
|
# Keep same vertical spacing as parent layout for consistency
|
2020-09-02 18:26:23 +00:00
|
|
|
formlayout.setVerticalSpacing(self.displayVLayout.spacing())
|
|
|
|
gridlayout.addLayout(formlayout, 0, 0)
|
2020-08-01 14:42:14 +00:00
|
|
|
result_groupbox.setLayout(gridlayout)
|
|
|
|
self.displayVLayout.addWidget(result_groupbox)
|
2020-07-22 19:38:03 +00:00
|
|
|
|
2021-03-18 01:21:29 +00:00
|
|
|
details_groupbox = QGroupBox("&" + tr("Details Window"))
|
2020-08-01 14:42:14 +00:00
|
|
|
self.details_groupbox_layout = QVBoxLayout()
|
2021-03-18 01:21:29 +00:00
|
|
|
self._setupAddCheckbox(
|
|
|
|
"details_dialog_titlebar_enabled",
|
|
|
|
tr("Show the title bar and can be docked"),
|
|
|
|
)
|
2020-07-20 01:10:06 +00:00
|
|
|
self.details_dialog_titlebar_enabled.setToolTip(
|
2021-03-18 01:21:29 +00:00
|
|
|
tr(
|
|
|
|
"While the title bar is hidden, \
|
|
|
|
use the modifier key to drag the floating window around"
|
|
|
|
)
|
|
|
|
if ISLINUX
|
|
|
|
else tr("The title bar can only be disabled while the window is docked")
|
|
|
|
)
|
2020-08-01 14:42:14 +00:00
|
|
|
self.details_groupbox_layout.addWidget(self.details_dialog_titlebar_enabled)
|
2021-08-15 08:51:27 +00:00
|
|
|
self._setupAddCheckbox("details_dialog_vertical_titlebar", tr("Vertical title bar"))
|
2020-07-30 01:13:58 +00:00
|
|
|
self.details_dialog_vertical_titlebar.setToolTip(
|
2021-08-15 08:51:27 +00:00
|
|
|
tr("Change the title bar from horizontal on top, to vertical on the left side")
|
2021-03-18 01:21:29 +00:00
|
|
|
)
|
2020-08-01 14:42:14 +00:00
|
|
|
self.details_groupbox_layout.addWidget(self.details_dialog_vertical_titlebar)
|
2021-08-15 08:51:27 +00:00
|
|
|
self.details_dialog_vertical_titlebar.setEnabled(self.details_dialog_titlebar_enabled.isChecked())
|
|
|
|
self.details_dialog_titlebar_enabled.stateChanged.connect(self.details_dialog_vertical_titlebar.setEnabled)
|
2020-07-29 19:42:44 +00:00
|
|
|
gridlayout = QGridLayout()
|
2020-09-02 18:26:23 +00:00
|
|
|
formlayout = QFormLayout()
|
2020-07-29 19:42:44 +00:00
|
|
|
self.details_table_delta_foreground_color = ColorPickerButton(self)
|
2020-09-02 18:26:23 +00:00
|
|
|
# Padding on the right side and space between label and widget to keep it somewhat consistent across themes
|
2020-08-01 14:42:14 +00:00
|
|
|
gridlayout.setColumnStretch(1, 1)
|
2020-09-02 18:26:23 +00:00
|
|
|
formlayout.setHorizontalSpacing(50)
|
2021-08-15 08:51:27 +00:00
|
|
|
formlayout.addRow(tr("Delta foreground color:"), self.details_table_delta_foreground_color)
|
2020-09-02 18:26:23 +00:00
|
|
|
gridlayout.addLayout(formlayout, 0, 0)
|
2020-08-01 14:42:14 +00:00
|
|
|
self.details_groupbox_layout.addLayout(gridlayout)
|
|
|
|
details_groupbox.setLayout(self.details_groupbox_layout)
|
|
|
|
self.displayVLayout.addWidget(details_groupbox)
|
2020-07-14 15:37:48 +00:00
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
def _setupAddCheckbox(self, name, label, parent=None):
|
|
|
|
if parent is None:
|
|
|
|
parent = self
|
|
|
|
cb = QCheckBox(parent)
|
|
|
|
cb.setText(label)
|
|
|
|
setattr(self, name, cb)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
def _setupPreferenceWidgets(self):
|
|
|
|
# Edition-specific
|
|
|
|
pass
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
def _setupUi(self):
|
2016-05-29 01:54:25 +00:00
|
|
|
self.setWindowTitle(tr("Options"))
|
2011-01-21 12:57:54 +00:00
|
|
|
self.setSizeGripEnabled(False)
|
|
|
|
self.setModal(True)
|
|
|
|
self.mainVLayout = QVBoxLayout(self)
|
2020-07-20 01:10:06 +00:00
|
|
|
self.tabwidget = QTabWidget()
|
|
|
|
self.page_general = QWidget()
|
|
|
|
self.page_display = QWidget()
|
2011-01-21 12:57:54 +00:00
|
|
|
self.widgetsVLayout = QVBoxLayout()
|
2020-07-20 01:10:06 +00:00
|
|
|
self.page_general.setLayout(self.widgetsVLayout)
|
|
|
|
self.displayVLayout = QVBoxLayout()
|
2020-08-01 14:42:14 +00:00
|
|
|
self.displayVLayout.setSpacing(5) # arbitrary value, might conflict with style
|
2020-07-20 01:10:06 +00:00
|
|
|
self.page_display.setLayout(self.displayVLayout)
|
2011-01-21 12:57:54 +00:00
|
|
|
self._setupPreferenceWidgets()
|
2020-07-30 01:13:58 +00:00
|
|
|
self._setupDisplayPage()
|
2020-07-20 01:10:06 +00:00
|
|
|
# self.mainVLayout.addLayout(self.widgetsVLayout)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.buttonBox = QDialogButtonBox(self)
|
2020-01-01 02:16:27 +00:00
|
|
|
self.buttonBox.setStandardButtons(
|
2021-08-15 08:51:27 +00:00
|
|
|
QDialogButtonBox.Cancel | QDialogButtonBox.Ok | QDialogButtonBox.RestoreDefaults
|
2020-01-01 02:16:27 +00:00
|
|
|
)
|
2020-07-20 01:10:06 +00:00
|
|
|
self.mainVLayout.addWidget(self.tabwidget)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.mainVLayout.addWidget(self.buttonBox)
|
2018-12-05 03:01:20 +00:00
|
|
|
self.layout().setSizeConstraint(QLayout.SetFixedSize)
|
2021-03-18 01:21:29 +00:00
|
|
|
self.tabwidget.addTab(self.page_general, tr("General"))
|
|
|
|
self.tabwidget.addTab(self.page_display, tr("Display"))
|
2020-07-20 01:10:06 +00:00
|
|
|
self.displayVLayout.addStretch(0)
|
2020-08-01 17:02:04 +00:00
|
|
|
self.widgetsVLayout.addStretch(0)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-07-20 03:04:25 +00:00
|
|
|
def _load(self, prefs, setchecked, section):
|
2011-01-21 12:57:54 +00:00
|
|
|
# Edition-specific
|
|
|
|
pass
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
def _save(self, prefs, ischecked):
|
|
|
|
# Edition-specific
|
|
|
|
pass
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-07-20 03:04:25 +00:00
|
|
|
def load(self, prefs=None, section=Sections.ALL):
|
2011-01-21 12:57:54 +00:00
|
|
|
if prefs is None:
|
|
|
|
prefs = self.app.prefs
|
2021-08-15 08:51:27 +00:00
|
|
|
|
|
|
|
def setchecked(cb, b):
|
|
|
|
cb.setCheckState(Qt.Checked if b else Qt.Unchecked)
|
|
|
|
|
2020-07-20 03:04:25 +00:00
|
|
|
if section & Sections.GENERAL:
|
|
|
|
self.filterHardnessSlider.setValue(prefs.filter_hardness)
|
|
|
|
self.filterHardnessLabel.setNum(prefs.filter_hardness)
|
|
|
|
setchecked(self.mixFileKindBox, prefs.mix_file_kind)
|
|
|
|
setchecked(self.useRegexpBox, prefs.use_regexp)
|
|
|
|
setchecked(self.removeEmptyFoldersBox, prefs.remove_empty_folders)
|
|
|
|
setchecked(self.ignoreHardlinkMatches, prefs.ignore_hardlink_matches)
|
|
|
|
setchecked(self.debugModeBox, prefs.debug_mode)
|
|
|
|
self.copyMoveDestinationComboBox.setCurrentIndex(prefs.destination_type)
|
|
|
|
self.customCommandEdit.setText(prefs.custom_command)
|
|
|
|
if section & Sections.DISPLAY:
|
|
|
|
setchecked(self.reference_bold_font, prefs.reference_bold_font)
|
2020-08-01 16:29:22 +00:00
|
|
|
setchecked(self.tabs_default_pos, prefs.tabs_default_pos)
|
2021-08-24 08:52:43 +00:00
|
|
|
setchecked(self.use_native_dialogs, prefs.use_native_dialogs)
|
2021-03-18 01:21:29 +00:00
|
|
|
setchecked(
|
|
|
|
self.details_dialog_titlebar_enabled,
|
|
|
|
prefs.details_dialog_titlebar_enabled,
|
|
|
|
)
|
|
|
|
setchecked(
|
|
|
|
self.details_dialog_vertical_titlebar,
|
|
|
|
prefs.details_dialog_vertical_titlebar,
|
|
|
|
)
|
2020-07-20 03:04:25 +00:00
|
|
|
self.fontSizeSpinBox.setValue(prefs.tableFontSize)
|
2021-08-15 08:51:27 +00:00
|
|
|
self.details_table_delta_foreground_color.setColor(prefs.details_table_delta_foreground_color)
|
|
|
|
self.result_table_ref_foreground_color.setColor(prefs.result_table_ref_foreground_color)
|
|
|
|
self.result_table_ref_background_color.setColor(prefs.result_table_ref_background_color)
|
|
|
|
self.result_table_delta_foreground_color.setColor(prefs.result_table_delta_foreground_color)
|
2020-07-20 03:04:25 +00:00
|
|
|
try:
|
|
|
|
langindex = self.supportedLanguages.index(self.app.prefs.language)
|
|
|
|
except ValueError:
|
|
|
|
langindex = 0
|
|
|
|
self.languageComboBox.setCurrentIndex(langindex)
|
|
|
|
self._load(prefs, setchecked, section)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
def save(self):
|
|
|
|
prefs = self.app.prefs
|
|
|
|
prefs.filter_hardness = self.filterHardnessSlider.value()
|
2021-08-15 08:51:27 +00:00
|
|
|
|
|
|
|
def ischecked(cb):
|
|
|
|
return cb.checkState() == Qt.Checked
|
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
prefs.mix_file_kind = ischecked(self.mixFileKindBox)
|
|
|
|
prefs.use_regexp = ischecked(self.useRegexpBox)
|
|
|
|
prefs.remove_empty_folders = ischecked(self.removeEmptyFoldersBox)
|
|
|
|
prefs.ignore_hardlink_matches = ischecked(self.ignoreHardlinkMatches)
|
2011-01-26 11:50:44 +00:00
|
|
|
prefs.debug_mode = ischecked(self.debugModeBox)
|
2020-04-26 23:36:27 +00:00
|
|
|
prefs.reference_bold_font = ischecked(self.reference_bold_font)
|
2021-08-15 08:51:27 +00:00
|
|
|
prefs.details_dialog_titlebar_enabled = ischecked(self.details_dialog_titlebar_enabled)
|
|
|
|
prefs.details_dialog_vertical_titlebar = ischecked(self.details_dialog_vertical_titlebar)
|
|
|
|
prefs.details_table_delta_foreground_color = self.details_table_delta_foreground_color.color
|
|
|
|
prefs.result_table_ref_foreground_color = self.result_table_ref_foreground_color.color
|
|
|
|
prefs.result_table_ref_background_color = self.result_table_ref_background_color.color
|
|
|
|
prefs.result_table_delta_foreground_color = self.result_table_delta_foreground_color.color
|
2011-01-21 12:57:54 +00:00
|
|
|
prefs.destination_type = self.copyMoveDestinationComboBox.currentIndex()
|
|
|
|
prefs.custom_command = str(self.customCommandEdit.text())
|
2011-09-23 14:29:25 +00:00
|
|
|
prefs.tableFontSize = self.fontSizeSpinBox.value()
|
2020-07-30 23:32:29 +00:00
|
|
|
prefs.tabs_default_pos = ischecked(self.tabs_default_pos)
|
2021-08-24 08:52:43 +00:00
|
|
|
prefs.use_native_dialogs = ischecked(self.use_native_dialogs)
|
2015-07-20 17:18:14 +00:00
|
|
|
lang = self.supportedLanguages[self.languageComboBox.currentIndex()]
|
2011-01-21 12:57:54 +00:00
|
|
|
oldlang = self.app.prefs.language
|
2015-07-20 17:18:14 +00:00
|
|
|
if oldlang not in self.supportedLanguages:
|
2020-01-01 02:16:27 +00:00
|
|
|
oldlang = "en"
|
2011-01-21 12:57:54 +00:00
|
|
|
if lang != oldlang:
|
2020-01-01 02:16:27 +00:00
|
|
|
QMessageBox.information(
|
|
|
|
self,
|
|
|
|
"",
|
|
|
|
tr("dupeGuru has to restart for language changes to take effect."),
|
|
|
|
)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.app.prefs.language = lang
|
|
|
|
self._save(prefs, ischecked)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-07-20 03:04:25 +00:00
|
|
|
def resetToDefaults(self, section_to_update):
|
|
|
|
self.load(Preferences(), section_to_update)
|
2016-06-01 01:22:50 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# --- Events
|
2011-01-21 12:57:54 +00:00
|
|
|
def buttonClicked(self, button):
|
|
|
|
role = self.buttonBox.buttonRole(button)
|
|
|
|
if role == QDialogButtonBox.ResetRole:
|
2020-07-20 03:04:25 +00:00
|
|
|
current_tab = self.tabwidget.currentWidget()
|
|
|
|
section_to_update = Sections.ALL
|
|
|
|
if current_tab is self.page_general:
|
|
|
|
section_to_update = Sections.GENERAL
|
|
|
|
if current_tab is self.page_display:
|
|
|
|
section_to_update = Sections.DISPLAY
|
|
|
|
self.resetToDefaults(section_to_update)
|
2020-07-22 19:38:03 +00:00
|
|
|
|
2021-08-28 04:26:19 +00:00
|
|
|
def showEvent(self, event):
|
|
|
|
# have to do this here as the frameGeometry is not correct until shown
|
|
|
|
move_to_screen_center(self)
|
|
|
|
super().showEvent(event)
|
|
|
|
|
2020-07-22 19:38:03 +00:00
|
|
|
|
|
|
|
class ColorPickerButton(QPushButton):
|
|
|
|
def __init__(self, parent):
|
|
|
|
super().__init__(parent)
|
|
|
|
self.parent = parent
|
|
|
|
self.color = None
|
|
|
|
self.clicked.connect(self.onClicked)
|
|
|
|
|
|
|
|
@pyqtSlot()
|
|
|
|
def onClicked(self):
|
2021-08-15 08:51:27 +00:00
|
|
|
color = QColorDialog.getColor(self.color if self.color is not None else Qt.white, self.parent)
|
2020-07-22 19:38:03 +00:00
|
|
|
self.setColor(color)
|
|
|
|
|
|
|
|
def setColor(self, color):
|
2020-08-01 00:09:38 +00:00
|
|
|
size = QSize(16, 16)
|
2020-07-22 19:38:03 +00:00
|
|
|
px = QPixmap(size)
|
|
|
|
if color is None:
|
|
|
|
size.width = 0
|
|
|
|
size.height = 0
|
|
|
|
elif not color.isValid():
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
self.color = color
|
|
|
|
px.fill(color)
|
|
|
|
self.setIcon(QIcon(px))
|