mirror of
https://github.com/arsenetar/dupeguru.git
synced 2024-12-21 10:59:03 +00:00
Fix ME/SE details dialogs, add preferences
* Fix ME and SE versions of details dialog not displaying their content properly after change to QDockWidget * Add option to toggle titlebar and orientation of titlebar in preferences dialog * Fix setting layout on PE details dialog window while layout already set, by removing the self (parent) reference in constructing the QSplitter
This commit is contained in:
parent
56912a7108
commit
3eddeb6aeb
@ -54,11 +54,11 @@ class DupeGuru(QObject):
|
||||
def _setup(self):
|
||||
core.pe.photo.PLAT_SPECIFIC_PHOTO_CLASS = PlatSpecificPhoto
|
||||
self._setupActions()
|
||||
self.details_dialog = None
|
||||
self._update_options()
|
||||
self.recentResults = Recent(self, "recentResults")
|
||||
self.recentResults.mustOpenItem.connect(self.model.load_from)
|
||||
self.resultWindow = None
|
||||
self.details_dialog = None
|
||||
self.directories_dialog = DirectoriesDialog(self)
|
||||
self.progress_window = ProgressWindow(
|
||||
self.directories_dialog, self.model.progress_window
|
||||
@ -152,6 +152,9 @@ class DupeGuru(QObject):
|
||||
self.model.options["match_scaled"] = self.prefs.match_scaled
|
||||
self.model.options["picture_cache_type"] = self.prefs.picture_cache_type
|
||||
|
||||
if self.details_dialog:
|
||||
self.details_dialog.update_options()
|
||||
|
||||
# --- Private
|
||||
def _get_details_dialog_class(self):
|
||||
if self.model.app_mode == AppMode.Picture:
|
||||
|
@ -7,7 +7,7 @@
|
||||
# http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QDockWidget
|
||||
from PyQt5.QtWidgets import QDockWidget, QWidget
|
||||
|
||||
from .details_table import DetailsModel
|
||||
|
||||
@ -17,7 +17,9 @@ class DetailsDialog(QDockWidget):
|
||||
super().__init__(parent, Qt.Tool, **kwargs)
|
||||
self.app = app
|
||||
self.model = app.model.details_panel
|
||||
self.setAllowedAreas(Qt.AllDockWidgetAreas)
|
||||
self._setupUi()
|
||||
self.update_options()
|
||||
# To avoid saving uninitialized geometry on appWillSavePrefs, we track whether our dialog
|
||||
# has been shown. If it has, we know that our geometry should be saved.
|
||||
self._shown_once = False
|
||||
@ -36,6 +38,22 @@ class DetailsDialog(QDockWidget):
|
||||
self._shown_once = True
|
||||
super().show()
|
||||
|
||||
def update_options(self):
|
||||
# This disables the title bar (if we had not set one before already)
|
||||
# essentially making it a simple floating window, not dockable anymore
|
||||
if not self.app.prefs.details_dialog_titlebar_enabled \
|
||||
and not self.titleBarWidget():
|
||||
self.setTitleBarWidget(QWidget())
|
||||
elif self.titleBarWidget() is not None:
|
||||
# resets to the default title bar
|
||||
self.setTitleBarWidget(None)
|
||||
|
||||
features = self.features()
|
||||
if self.app.prefs.details_dialog_vertical_titlebar:
|
||||
self.setFeatures(features | QDockWidget.DockWidgetVerticalTitleBar)
|
||||
elif features & QDockWidget.DockWidgetVerticalTitleBar:
|
||||
self.setFeatures(features ^ QDockWidget.DockWidgetVerticalTitleBar)
|
||||
|
||||
# --- Events
|
||||
def appWillSavePrefs(self):
|
||||
if self._shown_once:
|
||||
|
@ -5,7 +5,7 @@
|
||||
# http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from PyQt5.QtCore import QSize
|
||||
from PyQt5.QtWidgets import QVBoxLayout, QAbstractItemView
|
||||
from PyQt5.QtWidgets import QVBoxLayout, QAbstractItemView, QWidget
|
||||
|
||||
from hscommon.trans import trget
|
||||
from ..details_dialog import DetailsDialog as DetailsDialogBase
|
||||
@ -27,3 +27,6 @@ class DetailsDialog(DetailsDialogBase):
|
||||
self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
self.tableView.setShowGrid(False)
|
||||
self.verticalLayout.addWidget(self.tableView)
|
||||
self.centralWidget = QWidget()
|
||||
self.centralWidget.setLayout(self.verticalLayout)
|
||||
self.setWidget(self.centralWidget)
|
||||
|
@ -25,8 +25,7 @@ class DetailsDialog(DetailsDialogBase):
|
||||
self.setWindowTitle(tr("Details"))
|
||||
self.resize(502, 502)
|
||||
self.setMinimumSize(QSize(250, 250))
|
||||
self.setAllowedAreas(Qt.AllDockWidgetAreas)
|
||||
self.splitter = QSplitter(Qt.Vertical, self)
|
||||
self.splitter = QSplitter(Qt.Vertical)
|
||||
self.topFrame = QFrame()
|
||||
self.topFrame.setFrameShape(QFrame.StyledPanel)
|
||||
self.horizontalLayout = QGridLayout()
|
||||
@ -96,7 +95,8 @@ class DetailsDialog(DetailsDialogBase):
|
||||
# due to the toolbar in the middle keeping the same width,
|
||||
# so resizing in the GridLayout's engine leads to not enough space
|
||||
# left for the panel on the right.
|
||||
# This doesn't work as a QDockWidget however!
|
||||
# This work as a QMainWindow, but doesn't work as a QDockWidget:
|
||||
# resize can only grow. Might need some custom sizeHint somewhere...
|
||||
# self.horizontalLayout.setColumnMinimumWidth(
|
||||
# 0, self.selectedImageViewer.size().width())
|
||||
# self.horizontalLayout.setColumnMinimumWidth(
|
||||
|
@ -31,6 +31,8 @@ class Preferences(PreferencesBase):
|
||||
|
||||
self.tableFontSize = get("TableFontSize", self.tableFontSize)
|
||||
self.reference_bold_font = get('ReferenceBoldFont', self.reference_bold_font)
|
||||
self.details_dialog_titlebar_enabled = get('DetailsDialogTitleBarEnabled', self.details_dialog_titlebar_enabled)
|
||||
self.details_dialog_vertical_titlebar = get('DetailsDialogVerticalTitleBar', self.details_dialog_vertical_titlebar)
|
||||
self.resultWindowIsMaximized = get(
|
||||
"ResultWindowIsMaximized", self.resultWindowIsMaximized
|
||||
)
|
||||
@ -67,6 +69,8 @@ class Preferences(PreferencesBase):
|
||||
|
||||
self.tableFontSize = QApplication.font().pointSize()
|
||||
self.reference_bold_font = True
|
||||
self.details_dialog_titlebar_enabled = True
|
||||
self.details_dialog_vertical_titlebar = True
|
||||
self.resultWindowIsMaximized = False
|
||||
self.resultWindowRect = None
|
||||
self.directoriesWindowRect = None
|
||||
@ -100,6 +104,8 @@ class Preferences(PreferencesBase):
|
||||
|
||||
set_("TableFontSize", self.tableFontSize)
|
||||
set_('ReferenceBoldFont', self.reference_bold_font)
|
||||
set_('DetailsDialogTitleBarEnabled', self.details_dialog_titlebar_enabled)
|
||||
set_('DetailsDialogVerticalTitleBar', self.details_dialog_vertical_titlebar)
|
||||
set_("ResultWindowIsMaximized", self.resultWindowIsMaximized)
|
||||
self.set_rect("ResultWindowRect", self.resultWindowRect)
|
||||
self.set_rect("DirectoriesWindowRect", self.directoriesWindowRect)
|
||||
|
@ -117,8 +117,21 @@ class PreferencesDialogBase(QDialog):
|
||||
self.widgetsVLayout.addLayout(
|
||||
horizontalWrap([self.fontSizeLabel, self.fontSizeSpinBox, None])
|
||||
)
|
||||
self._setupAddCheckbox("reference_bold_font", tr("Bold font for reference."))
|
||||
self._setupAddCheckbox("reference_bold_font",
|
||||
tr("Bold font for reference."))
|
||||
self.widgetsVLayout.addWidget(self.reference_bold_font)
|
||||
|
||||
self._setupAddCheckbox("details_dialog_titlebar_enabled",
|
||||
tr("Details dialog displays a title bar and is dockable"))
|
||||
self.widgetsVLayout.addWidget(self.details_dialog_titlebar_enabled)
|
||||
self._setupAddCheckbox("details_dialog_vertical_titlebar",
|
||||
tr("Details dialog displays a vertical title bar."))
|
||||
self.widgetsVLayout.addWidget(self.details_dialog_vertical_titlebar)
|
||||
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)
|
||||
|
||||
self.languageLabel = QLabel(tr("Language:"), self)
|
||||
self.languageComboBox = QComboBox(self)
|
||||
for lang in self.supportedLanguages:
|
||||
@ -190,6 +203,8 @@ class PreferencesDialogBase(QDialog):
|
||||
setchecked(self.ignoreHardlinkMatches, prefs.ignore_hardlink_matches)
|
||||
setchecked(self.debugModeBox, prefs.debug_mode)
|
||||
setchecked(self.reference_bold_font, prefs.reference_bold_font)
|
||||
setchecked(self.details_dialog_titlebar_enabled , prefs.details_dialog_titlebar_enabled)
|
||||
setchecked(self.details_dialog_vertical_titlebar, prefs.details_dialog_vertical_titlebar)
|
||||
self.copyMoveDestinationComboBox.setCurrentIndex(prefs.destination_type)
|
||||
self.customCommandEdit.setText(prefs.custom_command)
|
||||
self.fontSizeSpinBox.setValue(prefs.tableFontSize)
|
||||
@ -210,6 +225,8 @@ class PreferencesDialogBase(QDialog):
|
||||
prefs.ignore_hardlink_matches = ischecked(self.ignoreHardlinkMatches)
|
||||
prefs.debug_mode = ischecked(self.debugModeBox)
|
||||
prefs.reference_bold_font = ischecked(self.reference_bold_font)
|
||||
prefs.details_dialog_titlebar_enabled = ischecked(self.details_dialog_titlebar_enabled)
|
||||
prefs.details_dialog_vertical_titlebar = ischecked(self.details_dialog_vertical_titlebar)
|
||||
prefs.destination_type = self.copyMoveDestinationComboBox.currentIndex()
|
||||
prefs.custom_command = str(self.customCommandEdit.text())
|
||||
prefs.tableFontSize = self.fontSizeSpinBox.value()
|
||||
|
@ -5,7 +5,7 @@
|
||||
# http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from PyQt5.QtCore import QSize
|
||||
from PyQt5.QtWidgets import QVBoxLayout, QAbstractItemView
|
||||
from PyQt5.QtWidgets import QVBoxLayout, QAbstractItemView, QWidget
|
||||
|
||||
from hscommon.trans import trget
|
||||
from ..details_dialog import DetailsDialog as DetailsDialogBase
|
||||
@ -27,3 +27,6 @@ class DetailsDialog(DetailsDialogBase):
|
||||
self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
self.tableView.setShowGrid(False)
|
||||
self.verticalLayout.addWidget(self.tableView)
|
||||
self.centralWidget = QWidget()
|
||||
self.centralWidget.setLayout(self.verticalLayout)
|
||||
self.setWidget(self.centralWidget)
|
||||
|
Loading…
Reference in New Issue
Block a user