1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-02-03 20:01:38 +00:00

qt: move scan_type preference to main window

It leads to better discoverability of dupeguru's options and will make
more sense after the big merge of all editions.
This commit is contained in:
Virgil Dupras
2016-05-28 21:54:25 -04:00
parent 09d5243648
commit 197acbf5b3
10 changed files with 111 additions and 154 deletions

View File

@@ -80,7 +80,7 @@ class DupeGuru(QObject):
# (name, shortcut, icon, desc, func)
ACTIONS = [
('actionQuit', 'Ctrl+Q', '', tr("Quit"), self.quitTriggered),
('actionPreferences', 'Ctrl+P', '', tr("Preferences"), self.preferencesTriggered),
('actionPreferences', 'Ctrl+P', '', tr("Options"), self.preferencesTriggered),
('actionIgnoreList', '', '', tr("Ignore List"), self.ignoreListTriggered),
('actionShowHelp', 'F1', '', tr("dupeGuru Help"), self.showHelpTriggered),
('actionAbout', '', '', tr("About dupeGuru"), self.showAboutBoxTriggered),

View File

@@ -1,16 +1,14 @@
# Created By: Virgil Dupras
# Created On: 2009-04-25
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html
from PyQt5.QtCore import QRect
from PyQt5.QtCore import QRect, Qt
from PyQt5.QtWidgets import (
QWidget, QFileDialog, QHeaderView, QVBoxLayout, QHBoxLayout, QTreeView,
QAbstractItemView, QSpacerItem, QSizePolicy, QPushButton, QMainWindow, QMenuBar, QMenu, QLabel,
QApplication
QApplication, QComboBox
)
from PyQt5.QtGui import QPixmap, QIcon
@@ -30,6 +28,9 @@ class DirectoriesDialog(QMainWindow):
self.lastAddedFolder = platform.INITIAL_FOLDER_IN_DIALOGS
self.recentFolders = Recent(self.app, 'recentFolders')
self._setupUi()
SCAN_TYPE_ORDER = [so.scan_type for so in self.app.model.scanner.get_scan_options()]
scan_type_index = SCAN_TYPE_ORDER.index(self.app.prefs.scan_type)
self.scanTypeComboBox.setCurrentIndex(scan_type_index)
self.directoriesModel = DirectoriesModel(self.app.model.directory_tree, view=self.treeView)
self.directoriesDelegate = DirectoriesDelegate()
self.treeView.setItemDelegate(self.directoriesDelegate)
@@ -43,6 +44,8 @@ class DirectoriesDialog(QMainWindow):
self._setupBindings()
def _setupBindings(self):
self.showPreferencesButton.clicked.connect(self.app.actionPreferences.trigger)
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)
self.scanButton.clicked.connect(self.scanButtonClicked)
self.loadResultsButton.clicked.connect(self.actionLoadResults.trigger)
self.addFolderButton.clicked.connect(self.actionAddFolder.trigger)
@@ -119,6 +122,21 @@ class DirectoriesDialog(QMainWindow):
self.treeView.setDragDropMode(QAbstractItemView.DropOnly)
self.treeView.setUniformRowHeights(True)
self.verticalLayout.addWidget(self.treeView)
hl = QHBoxLayout()
hl.setAlignment(Qt.AlignLeft)
label = QLabel(tr("Scan Type:"), self)
label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
hl.addWidget(label)
self.scanTypeComboBox = QComboBox(self)
self.scanTypeComboBox.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
self.scanTypeComboBox.setMaximumWidth(400)
for scan_option in self.app.model.scanner.get_scan_options():
self.scanTypeComboBox.addItem(scan_option.label)
hl.addWidget(self.scanTypeComboBox)
self.showPreferencesButton = QPushButton(tr("Options"), self.centralwidget)
self.showPreferencesButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
hl.addWidget(self.showPreferencesButton)
self.verticalLayout.addLayout(hl)
self.horizontalLayout = QHBoxLayout()
self.removeFolderButton = QPushButton(self.centralwidget)
self.removeFolderButton.setIcon(QIcon(QPixmap(":/minus")))
@@ -221,16 +239,11 @@ class DirectoriesDialog(QMainWindow):
return
self.app.model.start_scanning()
def scanTypeChanged(self, index):
scan_options = self.app.model.scanner.get_scan_options()
self.app.prefs.scan_type = scan_options[index].scan_type
self.app._update_options()
def selectionChanged(self, selected, deselected):
self._updateRemoveButton()
if __name__ == '__main__':
import sys
from . import dg_rc # NOQA
from ..testapp import TestApp
app = QApplication([])
dgapp = TestApp()
dialog = DirectoriesDialog(None, dgapp)
dialog.show()
sys.exit(app.exec_())

View File

@@ -1,9 +1,7 @@
# Created By: Virgil Dupras
# Created On: 2009-05-03
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html
from PyQt5.QtWidgets import QApplication
@@ -12,10 +10,12 @@ from hscommon import trans
from qtlib.preferences import Preferences as PreferencesBase
class Preferences(PreferencesBase):
DEFAULT_SCAN_TYPE = None # edition-specific
def _load_specific(self, settings):
# load prefs specific to the dg edition
pass
def _load_values(self, settings):
get = self.get_value
self.filter_hardness = get('FilterHardness', self.filter_hardness)
@@ -29,20 +29,20 @@ class Preferences(PreferencesBase):
self.language = get('Language', self.language)
if not self.language and trans.installed_lang:
self.language = trans.installed_lang
self.tableFontSize = get('TableFontSize', self.tableFontSize)
self.resultWindowIsMaximized = get('ResultWindowIsMaximized', self.resultWindowIsMaximized)
self.resultWindowRect = self.get_rect('ResultWindowRect', self.resultWindowRect)
self.directoriesWindowRect = self.get_rect('DirectoriesWindowRect', self.directoriesWindowRect)
self.recentResults = get('RecentResults', self.recentResults)
self.recentFolders = get('RecentFolders', self.recentFolders)
self._load_specific(settings)
def _reset_specific(self):
# reset prefs specific to the dg edition
pass
def reset(self):
self.filter_hardness = 95
self.mix_file_kind = True
@@ -53,20 +53,20 @@ class Preferences(PreferencesBase):
self.destination_type = 1
self.custom_command = ''
self.language = trans.installed_lang if trans.installed_lang else ''
self.tableFontSize = QApplication.font().pointSize()
self.resultWindowIsMaximized = False
self.resultWindowRect = None
self.directoriesWindowRect = None
self.recentResults = []
self.recentFolders = []
self._reset_specific()
def _save_specific(self, settings):
# save prefs specific to the dg edition
pass
def _save_values(self, settings):
set_ = self.set_value
set_('FilterHardness', self.filter_hardness)
@@ -78,13 +78,21 @@ class Preferences(PreferencesBase):
set_('DestinationType', self.destination_type)
set_('CustomCommand', self.custom_command)
set_('Language', self.language)
set_('TableFontSize', self.tableFontSize)
set_('ResultWindowIsMaximized', self.resultWindowIsMaximized)
self.set_rect('ResultWindowRect', self.resultWindowRect)
self.set_rect('DirectoriesWindowRect', self.directoriesWindowRect)
set_('RecentResults', self.recentResults)
set_('RecentFolders', self.recentFolders)
self._save_specific(settings)
# scan_type is special because we save it immediately when we set it.
@property
def scan_type(self):
return self.get_value('ScanType', self.DEFAULT_SCAN_TYPE)
@scan_type.setter
def scan_type(self, value):
self.set_value('ScanType', value)

View File

@@ -1,6 +1,4 @@
# Created By: Virgil Dupras
# Created On: 2011-01-21
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
@@ -38,18 +36,6 @@ class PreferencesDialogBase(QDialog):
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
def _setupScanTypeBox(self):
hl = QHBoxLayout()
label = QLabel(tr("Scan Type:"), self)
label.setMinimumSize(QSize(100, 0))
label.setMaximumSize(QSize(100, 16777215))
hl.addWidget(label)
self.scanTypeComboBox = QComboBox(self)
for scan_option in self.app.model.scanner.get_scan_options():
self.scanTypeComboBox.addItem(scan_option.label)
hl.addWidget(self.scanTypeComboBox)
self.widgetsVLayout.addLayout(hl)
def _setupFilterHardnessBox(self):
self.filterHardnessHLayout = QHBoxLayout()
self.filterHardnessLabel = QLabel(self)
@@ -126,7 +112,7 @@ class PreferencesDialogBase(QDialog):
pass
def _setupUi(self):
self.setWindowTitle(tr("Preferences"))
self.setWindowTitle(tr("Options"))
self.resize(304, 263)
self.setSizeGripEnabled(False)
self.setModal(True)
@@ -141,19 +127,10 @@ class PreferencesDialogBase(QDialog):
self.mainVLayout.removeWidget(self.ignoreHardlinkMatches)
self.ignoreHardlinkMatches.setHidden(True)
def _load_scan_type(self, prefs):
SCAN_TYPE_ORDER = [so.scan_type for so in self.app.model.scanner.get_scan_options()]
scan_type_index = SCAN_TYPE_ORDER.index(prefs.scan_type)
self.scanTypeComboBox.setCurrentIndex(scan_type_index)
def _load(self, prefs, setchecked):
# Edition-specific
pass
def _save_scan_type(self, prefs):
scan_options = self.app.model.scanner.get_scan_options()
prefs.scan_type = scan_options[self.scanTypeComboBox.currentIndex()].scan_type
def _save(self, prefs, ischecked):
# Edition-specific
pass