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
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2016-05-29 01:54:25 +00:00
|
|
|
from PyQt5.QtCore import QRect, Qt
|
2014-10-13 19:08:59 +00:00
|
|
|
from PyQt5.QtWidgets import (
|
2021-08-24 08:52:43 +00:00
|
|
|
QListView,
|
2020-01-01 02:16:27 +00:00
|
|
|
QWidget,
|
|
|
|
QFileDialog,
|
|
|
|
QHeaderView,
|
|
|
|
QVBoxLayout,
|
|
|
|
QHBoxLayout,
|
|
|
|
QTreeView,
|
|
|
|
QAbstractItemView,
|
|
|
|
QSpacerItem,
|
|
|
|
QSizePolicy,
|
|
|
|
QPushButton,
|
|
|
|
QMainWindow,
|
|
|
|
QMenuBar,
|
|
|
|
QMenu,
|
|
|
|
QLabel,
|
|
|
|
QComboBox,
|
2014-10-13 19:08:59 +00:00
|
|
|
)
|
2013-10-20 19:15:09 +00:00
|
|
|
from PyQt5.QtGui import QPixmap, QIcon
|
2011-01-15 15:29:35 +00:00
|
|
|
|
2011-11-01 19:44:18 +00:00
|
|
|
from hscommon.trans import trget
|
2016-05-30 02:37:38 +00:00
|
|
|
from core.app import AppMode
|
2022-05-09 00:22:08 +00:00
|
|
|
from qt.radio_box import RadioBox
|
|
|
|
from qt.recent import Recent
|
|
|
|
from qt.util import move_to_screen_center, create_actions
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2009-10-14 13:29:46 +00:00
|
|
|
from . import platform
|
|
|
|
from .directories_model import DirectoriesModel, DirectoriesDelegate
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
tr = trget("ui")
|
|
|
|
|
2011-11-01 19:44:18 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
class DirectoriesDialog(QMainWindow):
|
2014-02-15 20:05:46 +00:00
|
|
|
def __init__(self, app, **kwargs):
|
2013-10-20 19:53:59 +00:00
|
|
|
super().__init__(None, **kwargs)
|
2009-06-01 09:55:11 +00:00
|
|
|
self.app = app
|
2020-07-12 14:58:01 +00:00
|
|
|
self.specific_actions = set()
|
2009-10-14 13:29:46 +00:00
|
|
|
self.lastAddedFolder = platform.INITIAL_FOLDER_IN_DIALOGS
|
2020-01-01 02:16:27 +00:00
|
|
|
self.recentFolders = Recent(self.app, "recentFolders")
|
2009-06-01 09:55:11 +00:00
|
|
|
self._setupUi()
|
2016-05-30 02:37:38 +00:00
|
|
|
self._updateScanTypeList()
|
2021-08-15 09:10:18 +00:00
|
|
|
self.directoriesModel = DirectoriesModel(self.app.model.directory_tree, view=self.treeView)
|
2011-11-28 19:21:10 +00:00
|
|
|
self.directoriesDelegate = DirectoriesDelegate()
|
|
|
|
self.treeView.setItemDelegate(self.directoriesDelegate)
|
|
|
|
self._setupColumns()
|
2011-01-17 16:15:16 +00:00
|
|
|
self.app.recentResults.addMenu(self.menuLoadRecent)
|
|
|
|
self.app.recentResults.addMenu(self.menuRecentResults)
|
|
|
|
self.recentFolders.addMenu(self.menuRecentFolders)
|
|
|
|
self._updateAddButton()
|
2009-06-01 09:55:11 +00:00
|
|
|
self._updateRemoveButton()
|
2011-01-17 16:15:16 +00:00
|
|
|
self._updateLoadResultsButton()
|
2016-05-30 02:37:38 +00:00
|
|
|
self._updateActionsState()
|
2011-01-17 16:15:16 +00:00
|
|
|
self._setupBindings()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-17 16:15:16 +00:00
|
|
|
def _setupBindings(self):
|
2016-05-30 02:37:38 +00:00
|
|
|
self.appModeRadioBox.itemSelected.connect(self.appModeButtonSelected)
|
2016-05-29 01:54:25 +00:00
|
|
|
self.showPreferencesButton.clicked.connect(self.app.actionPreferences.trigger)
|
2011-01-15 15:29:35 +00:00
|
|
|
self.scanButton.clicked.connect(self.scanButtonClicked)
|
2011-01-17 16:15:16 +00:00
|
|
|
self.loadResultsButton.clicked.connect(self.actionLoadResults.trigger)
|
|
|
|
self.addFolderButton.clicked.connect(self.actionAddFolder.trigger)
|
|
|
|
self.removeFolderButton.clicked.connect(self.removeFolderButtonClicked)
|
2011-01-15 15:29:35 +00:00
|
|
|
self.treeView.selectionModel().selectionChanged.connect(self.selectionChanged)
|
2011-01-17 16:15:16 +00:00
|
|
|
self.app.recentResults.itemsChanged.connect(self._updateLoadResultsButton)
|
|
|
|
self.recentFolders.itemsChanged.connect(self._updateAddButton)
|
2011-09-20 19:06:29 +00:00
|
|
|
self.recentFolders.mustOpenItem.connect(self.app.model.add_directory)
|
2011-01-27 09:27:17 +00:00
|
|
|
self.directoriesModel.foldersAdded.connect(self.directoriesModelAddedFolders)
|
2010-08-15 10:27:15 +00:00
|
|
|
self.app.willSavePrefs.connect(self.appWillSavePrefs)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
def _setupActions(self):
|
|
|
|
# (name, shortcut, icon, desc, func)
|
|
|
|
ACTIONS = [
|
2020-01-01 02:16:27 +00:00
|
|
|
(
|
|
|
|
"actionLoadResults",
|
|
|
|
"Ctrl+L",
|
|
|
|
"",
|
|
|
|
tr("Load Results..."),
|
|
|
|
self.loadResultsTriggered,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionShowResultsWindow",
|
|
|
|
"",
|
|
|
|
"",
|
2020-07-31 03:08:08 +00:00
|
|
|
tr("Scan Results"),
|
2020-01-01 02:16:27 +00:00
|
|
|
self.app.showResultsWindow,
|
|
|
|
),
|
|
|
|
("actionAddFolder", "", "", tr("Add Folder..."), self.addFolderTriggered),
|
2020-09-04 16:56:25 +00:00
|
|
|
("actionLoadDirectories", "", "", tr("Load Directories..."), self.loadDirectoriesTriggered),
|
|
|
|
("actionSaveDirectories", "", "", tr("Save Directories..."), self.saveDirectoriesTriggered),
|
2011-01-15 15:29:35 +00:00
|
|
|
]
|
2021-08-24 05:12:23 +00:00
|
|
|
create_actions(ACTIONS, self)
|
2020-09-04 16:56:25 +00:00
|
|
|
if self.app.use_tabs:
|
|
|
|
# Keep track of actions which should only be accessible from this window
|
|
|
|
self.specific_actions.add(self.actionLoadDirectories)
|
|
|
|
self.specific_actions.add(self.actionSaveDirectories)
|
2020-07-12 14:58:01 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
def _setupMenu(self):
|
2020-07-31 20:27:18 +00:00
|
|
|
if not self.app.use_tabs:
|
2020-07-12 14:58:01 +00:00
|
|
|
# we are our own QMainWindow, we need our own menu bar
|
|
|
|
self.menubar = QMenuBar(self)
|
|
|
|
self.menubar.setGeometry(QRect(0, 0, 42, 22))
|
|
|
|
self.menuFile = QMenu(self.menubar)
|
|
|
|
self.menuFile.setTitle(tr("File"))
|
|
|
|
self.menuView = QMenu(self.menubar)
|
|
|
|
self.menuView.setTitle(tr("View"))
|
|
|
|
self.menuHelp = QMenu(self.menubar)
|
|
|
|
self.menuHelp.setTitle(tr("Help"))
|
|
|
|
self.setMenuBar(self.menubar)
|
|
|
|
menubar = self.menubar
|
|
|
|
else:
|
|
|
|
# we are part of a tab widget, we populate its window's menubar instead
|
|
|
|
self.menuFile = self.app.main_window.menuFile
|
|
|
|
self.menuView = self.app.main_window.menuView
|
|
|
|
self.menuHelp = self.app.main_window.menuHelp
|
|
|
|
menubar = self.app.main_window.menubar
|
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
self.menuLoadRecent = QMenu(self.menuFile)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.menuLoadRecent.setTitle(tr("Load Recent Results"))
|
2020-07-31 14:57:18 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
self.menuFile.addAction(self.actionLoadResults)
|
|
|
|
self.menuFile.addAction(self.menuLoadRecent.menuAction())
|
|
|
|
self.menuFile.addSeparator()
|
2021-10-29 04:22:12 +00:00
|
|
|
self.menuFile.addAction(self.app.actionClearCache)
|
2016-06-01 00:55:32 +00:00
|
|
|
self.menuFile.addSeparator()
|
2020-09-04 16:56:25 +00:00
|
|
|
self.menuFile.addAction(self.actionLoadDirectories)
|
|
|
|
self.menuFile.addAction(self.actionSaveDirectories)
|
|
|
|
self.menuFile.addSeparator()
|
2011-01-15 15:29:35 +00:00
|
|
|
self.menuFile.addAction(self.app.actionQuit)
|
2020-07-31 14:57:18 +00:00
|
|
|
|
|
|
|
self.menuView.addAction(self.app.actionDirectoriesWindow)
|
2011-01-15 15:29:35 +00:00
|
|
|
self.menuView.addAction(self.actionShowResultsWindow)
|
2012-03-14 16:47:21 +00:00
|
|
|
self.menuView.addAction(self.app.actionIgnoreList)
|
2020-07-28 14:33:28 +00:00
|
|
|
self.menuView.addAction(self.app.actionExcludeList)
|
2020-07-31 14:57:18 +00:00
|
|
|
self.menuView.addSeparator()
|
|
|
|
self.menuView.addAction(self.app.actionPreferences)
|
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
self.menuHelp.addAction(self.app.actionShowHelp)
|
|
|
|
self.menuHelp.addAction(self.app.actionOpenDebugLog)
|
|
|
|
self.menuHelp.addAction(self.app.actionAbout)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-07-12 14:58:01 +00:00
|
|
|
menubar.addAction(self.menuFile.menuAction())
|
|
|
|
menubar.addAction(self.menuView.menuAction())
|
|
|
|
menubar.addAction(self.menuHelp.menuAction())
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-17 16:15:16 +00:00
|
|
|
# Recent folders menu
|
|
|
|
self.menuRecentFolders = QMenu()
|
|
|
|
self.menuRecentFolders.addAction(self.actionAddFolder)
|
|
|
|
self.menuRecentFolders.addSeparator()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-17 16:15:16 +00:00
|
|
|
# Recent results menu
|
|
|
|
self.menuRecentResults = QMenu()
|
|
|
|
self.menuRecentResults.addAction(self.actionLoadResults)
|
|
|
|
self.menuRecentResults.addSeparator()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def _setupUi(self):
|
2011-01-15 15:29:35 +00:00
|
|
|
self.setWindowTitle(self.app.NAME)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.resize(420, 338)
|
2011-01-15 15:29:35 +00:00
|
|
|
self.centralwidget = QWidget(self)
|
|
|
|
self.verticalLayout = QVBoxLayout(self.centralwidget)
|
2020-07-12 14:58:01 +00:00
|
|
|
self.verticalLayout.setContentsMargins(4, 0, 4, 0)
|
|
|
|
self.verticalLayout.setSpacing(0)
|
2016-05-29 01:54:25 +00:00
|
|
|
hl = QHBoxLayout()
|
2016-05-30 02:37:38 +00:00
|
|
|
label = QLabel(tr("Application Mode:"), self)
|
|
|
|
label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
|
|
|
hl.addWidget(label)
|
2021-08-15 09:10:18 +00:00
|
|
|
self.appModeRadioBox = RadioBox(self, items=[tr("Standard"), tr("Music"), tr("Picture")], spread=False)
|
2016-05-30 02:37:38 +00:00
|
|
|
hl.addWidget(self.appModeRadioBox)
|
|
|
|
self.verticalLayout.addLayout(hl)
|
|
|
|
hl = QHBoxLayout()
|
2016-05-29 01:54:25 +00:00
|
|
|
hl.setAlignment(Qt.AlignLeft)
|
|
|
|
label = QLabel(tr("Scan Type:"), self)
|
|
|
|
label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
|
|
|
hl.addWidget(label)
|
|
|
|
self.scanTypeComboBox = QComboBox(self)
|
2021-08-15 09:10:18 +00:00
|
|
|
self.scanTypeComboBox.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
|
2016-05-29 01:54:25 +00:00
|
|
|
self.scanTypeComboBox.setMaximumWidth(400)
|
|
|
|
hl.addWidget(self.scanTypeComboBox)
|
2016-05-30 02:37:38 +00:00
|
|
|
self.showPreferencesButton = QPushButton(tr("More Options"), self.centralwidget)
|
2016-05-29 01:54:25 +00:00
|
|
|
self.showPreferencesButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
|
|
|
|
hl.addWidget(self.showPreferencesButton)
|
|
|
|
self.verticalLayout.addLayout(hl)
|
2021-08-15 09:10:18 +00:00
|
|
|
self.promptLabel = QLabel(tr('Select folders to scan and press "Scan".'), self.centralwidget)
|
2016-06-06 14:29:02 +00:00
|
|
|
self.verticalLayout.addWidget(self.promptLabel)
|
|
|
|
self.treeView = QTreeView(self.centralwidget)
|
|
|
|
self.treeView.setSelectionMode(QAbstractItemView.ExtendedSelection)
|
|
|
|
self.treeView.setSelectionBehavior(QAbstractItemView.SelectRows)
|
|
|
|
self.treeView.setAcceptDrops(True)
|
2020-01-01 02:16:27 +00:00
|
|
|
triggers = (
|
2021-08-15 09:10:18 +00:00
|
|
|
QAbstractItemView.DoubleClicked | QAbstractItemView.EditKeyPressed | QAbstractItemView.SelectedClicked
|
2020-01-01 02:16:27 +00:00
|
|
|
)
|
2016-06-06 14:29:02 +00:00
|
|
|
self.treeView.setEditTriggers(triggers)
|
|
|
|
self.treeView.setDragDropOverwriteMode(True)
|
|
|
|
self.treeView.setDragDropMode(QAbstractItemView.DropOnly)
|
|
|
|
self.treeView.setUniformRowHeights(True)
|
|
|
|
self.verticalLayout.addWidget(self.treeView)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.horizontalLayout = QHBoxLayout()
|
2011-01-18 10:07:56 +00:00
|
|
|
self.removeFolderButton = QPushButton(self.centralwidget)
|
|
|
|
self.removeFolderButton.setIcon(QIcon(QPixmap(":/minus")))
|
2011-01-17 16:15:16 +00:00
|
|
|
self.removeFolderButton.setShortcut("Del")
|
|
|
|
self.horizontalLayout.addWidget(self.removeFolderButton)
|
2011-01-18 10:07:56 +00:00
|
|
|
self.addFolderButton = QPushButton(self.centralwidget)
|
|
|
|
self.addFolderButton.setIcon(QIcon(QPixmap(":/plus")))
|
2011-01-17 16:15:16 +00:00
|
|
|
self.horizontalLayout.addWidget(self.addFolderButton)
|
2021-08-24 05:12:23 +00:00
|
|
|
spacer_item = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
|
|
|
self.horizontalLayout.addItem(spacer_item)
|
2011-01-17 16:15:16 +00:00
|
|
|
self.loadResultsButton = QPushButton(self.centralwidget)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.loadResultsButton.setText(tr("Load Results"))
|
2011-01-17 16:15:16 +00:00
|
|
|
self.horizontalLayout.addWidget(self.loadResultsButton)
|
2011-01-15 15:29:35 +00:00
|
|
|
self.scanButton = QPushButton(self.centralwidget)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.scanButton.setText(tr("Scan"))
|
2011-01-15 15:29:35 +00:00
|
|
|
self.scanButton.setDefault(True)
|
|
|
|
self.horizontalLayout.addWidget(self.scanButton)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.verticalLayout.addLayout(self.horizontalLayout)
|
2011-01-15 15:29:35 +00:00
|
|
|
self.setCentralWidget(self.centralwidget)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
self._setupActions()
|
|
|
|
self._setupMenu()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2010-08-15 10:27:15 +00:00
|
|
|
if self.app.prefs.directoriesWindowRect is not None:
|
|
|
|
self.setGeometry(self.app.prefs.directoriesWindowRect)
|
2011-02-01 10:43:16 +00:00
|
|
|
else:
|
2021-08-24 05:12:23 +00:00
|
|
|
move_to_screen_center(self)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-11-28 19:21:10 +00:00
|
|
|
def _setupColumns(self):
|
|
|
|
header = self.treeView.header()
|
|
|
|
header.setStretchLastSection(False)
|
2013-10-20 19:15:09 +00:00
|
|
|
header.setSectionResizeMode(0, QHeaderView.Stretch)
|
|
|
|
header.setSectionResizeMode(1, QHeaderView.Fixed)
|
2011-11-28 19:21:10 +00:00
|
|
|
header.resizeSection(1, 100)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2016-05-30 02:37:38 +00:00
|
|
|
def _updateActionsState(self):
|
|
|
|
self.actionShowResultsWindow.setEnabled(self.app.resultWindow is not None)
|
|
|
|
|
2011-01-17 16:15:16 +00:00
|
|
|
def _updateAddButton(self):
|
|
|
|
if self.recentFolders.isEmpty():
|
|
|
|
self.addFolderButton.setMenu(None)
|
|
|
|
else:
|
|
|
|
self.addFolderButton.setMenu(self.menuRecentFolders)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def _updateRemoveButton(self):
|
|
|
|
indexes = self.treeView.selectedIndexes()
|
|
|
|
if not indexes:
|
2011-01-17 16:15:16 +00:00
|
|
|
self.removeFolderButton.setEnabled(False)
|
2009-06-01 09:55:11 +00:00
|
|
|
return
|
2011-01-17 16:15:16 +00:00
|
|
|
self.removeFolderButton.setEnabled(True)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-17 16:15:16 +00:00
|
|
|
def _updateLoadResultsButton(self):
|
|
|
|
if self.app.recentResults.isEmpty():
|
|
|
|
self.loadResultsButton.setMenu(None)
|
|
|
|
else:
|
|
|
|
self.loadResultsButton.setMenu(self.menuRecentResults)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2016-05-30 02:37:38 +00:00
|
|
|
def _updateScanTypeList(self):
|
|
|
|
try:
|
2021-08-15 09:10:18 +00:00
|
|
|
self.scanTypeComboBox.currentIndexChanged[int].disconnect(self.scanTypeChanged)
|
2016-05-30 02:37:38 +00:00
|
|
|
except TypeError:
|
|
|
|
# Not connected, ignore
|
|
|
|
pass
|
|
|
|
self.scanTypeComboBox.clear()
|
|
|
|
scan_options = self.app.model.SCANNER_CLASS.get_scan_options()
|
|
|
|
for scan_option in scan_options:
|
|
|
|
self.scanTypeComboBox.addItem(scan_option.label)
|
|
|
|
SCAN_TYPE_ORDER = [so.scan_type for so in scan_options]
|
|
|
|
selected_scan_type = self.app.prefs.get_scan_type(self.app.model.app_mode)
|
|
|
|
scan_type_index = SCAN_TYPE_ORDER.index(selected_scan_type)
|
|
|
|
self.scanTypeComboBox.setCurrentIndex(scan_type_index)
|
|
|
|
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)
|
|
|
|
self.app._update_options()
|
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# --- QWidget overrides
|
2011-01-15 15:29:35 +00:00
|
|
|
def closeEvent(self, event):
|
|
|
|
event.accept()
|
2011-09-20 19:06:29 +00:00
|
|
|
if self.app.model.results.is_modified:
|
2011-01-21 12:57:54 +00:00
|
|
|
title = tr("Unsaved results")
|
2011-11-04 17:10:11 +00:00
|
|
|
msg = tr("You have unsaved results, do you really want to quit?")
|
2011-01-15 15:29:35 +00:00
|
|
|
if not self.app.confirm(title, msg):
|
|
|
|
event.ignore()
|
|
|
|
if event.isAccepted():
|
2016-08-15 01:11:24 +00:00
|
|
|
self.app.shutdown()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# --- Events
|
2011-01-17 16:15:16 +00:00
|
|
|
def addFolderTriggered(self):
|
2021-08-24 08:52:43 +00:00
|
|
|
no_native = not self.app.prefs.use_native_dialogs
|
2011-11-04 17:10:11 +00:00
|
|
|
title = tr("Select a folder to add to the scanning list")
|
2021-08-24 08:52:43 +00:00
|
|
|
file_dialog = QFileDialog(self, title, self.lastAddedFolder)
|
|
|
|
file_dialog.setFileMode(QFileDialog.DirectoryOnly)
|
|
|
|
file_dialog.setOption(QFileDialog.DontUseNativeDialog, no_native)
|
|
|
|
if no_native:
|
|
|
|
file_view = file_dialog.findChild(QListView, "listView")
|
|
|
|
if file_view:
|
|
|
|
file_view.setSelectionMode(QAbstractItemView.MultiSelection)
|
|
|
|
f_tree_view = file_dialog.findChild(QTreeView)
|
|
|
|
if f_tree_view:
|
|
|
|
f_tree_view.setSelectionMode(QAbstractItemView.MultiSelection)
|
|
|
|
if not file_dialog.exec():
|
2009-06-01 09:55:11 +00:00
|
|
|
return
|
2021-08-24 08:52:43 +00:00
|
|
|
|
|
|
|
paths = file_dialog.selectedFiles()
|
|
|
|
self.lastAddedFolder = paths[-1]
|
|
|
|
[self.app.model.add_directory(path) for path in paths]
|
|
|
|
[self.recentFolders.insertItem(path) for path in paths]
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2016-05-30 02:37:38 +00:00
|
|
|
def appModeButtonSelected(self, index):
|
2016-05-31 02:27:59 +00:00
|
|
|
if index == 2:
|
2021-08-21 23:02:02 +00:00
|
|
|
mode = AppMode.PICTURE
|
2016-05-31 02:27:59 +00:00
|
|
|
elif index == 1:
|
2021-08-21 23:02:02 +00:00
|
|
|
mode = AppMode.MUSIC
|
2016-05-30 02:37:38 +00:00
|
|
|
else:
|
2021-08-21 23:02:02 +00:00
|
|
|
mode = AppMode.STANDARD
|
2016-05-30 02:37:38 +00:00
|
|
|
self.app.model.app_mode = mode
|
|
|
|
self._updateScanTypeList()
|
|
|
|
|
2010-08-15 10:27:15 +00:00
|
|
|
def appWillSavePrefs(self):
|
|
|
|
self.app.prefs.directoriesWindowRect = self.geometry()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-27 09:27:17 +00:00
|
|
|
def directoriesModelAddedFolders(self, folders):
|
|
|
|
for folder in folders:
|
|
|
|
self.recentFolders.insertItem(folder)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
def loadResultsTriggered(self):
|
2011-11-04 17:10:11 +00:00
|
|
|
title = tr("Select a results file to load")
|
2020-01-01 02:16:27 +00:00
|
|
|
files = ";;".join([tr("dupeGuru Results (*.dupeguru)"), tr("All Files (*.*)")])
|
|
|
|
destination = QFileDialog.getOpenFileName(self, title, "", files)[0]
|
2011-01-15 15:29:35 +00:00
|
|
|
if destination:
|
2011-09-20 19:06:29 +00:00
|
|
|
self.app.model.load_from(destination)
|
2011-01-15 15:29:35 +00:00
|
|
|
self.app.recentResults.insertItem(destination)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-09-04 16:56:25 +00:00
|
|
|
def loadDirectoriesTriggered(self):
|
|
|
|
title = tr("Select a directories file to load")
|
2021-01-30 03:20:22 +00:00
|
|
|
files = ";;".join([tr("dupeGuru Directories (*.dupegurudirs)"), tr("All Files (*.*)")])
|
2020-09-04 16:56:25 +00:00
|
|
|
destination = QFileDialog.getOpenFileName(self, title, "", files)[0]
|
|
|
|
if destination:
|
|
|
|
self.app.model.load_directories(destination)
|
|
|
|
|
2011-01-17 16:15:16 +00:00
|
|
|
def removeFolderButtonClicked(self):
|
2011-11-28 19:52:48 +00:00
|
|
|
self.directoriesModel.model.remove_selected()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-09-04 16:56:25 +00:00
|
|
|
def saveDirectoriesTriggered(self):
|
|
|
|
title = tr("Select a file to save your directories to")
|
|
|
|
files = tr("dupeGuru Directories (*.dupegurudirs)")
|
|
|
|
destination, chosen_filter = QFileDialog.getSaveFileName(self, title, "", files)
|
|
|
|
if destination:
|
|
|
|
if not destination.endswith(".dupegurudirs"):
|
2022-04-28 01:53:12 +00:00
|
|
|
destination = f"{destination}.dupegurudirs"
|
2020-09-04 16:56:25 +00:00
|
|
|
self.app.model.save_directories_as(destination)
|
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
def scanButtonClicked(self):
|
2011-09-20 19:06:29 +00:00
|
|
|
if self.app.model.results.is_modified:
|
2011-09-22 14:35:17 +00:00
|
|
|
title = tr("Start a new scan")
|
2011-11-04 17:10:11 +00:00
|
|
|
msg = tr("You have unsaved results, do you really want to continue?")
|
2011-01-15 15:29:35 +00:00
|
|
|
if not self.app.confirm(title, msg):
|
|
|
|
return
|
2022-03-31 05:16:37 +00:00
|
|
|
self.app.model.start_scanning(self.app.prefs.profile_scan)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2016-05-29 01:54:25 +00:00
|
|
|
def scanTypeChanged(self, index):
|
2016-05-29 20:52:07 +00:00
|
|
|
scan_options = self.app.model.SCANNER_CLASS.get_scan_options()
|
2021-08-15 09:10:18 +00:00
|
|
|
self.app.prefs.set_scan_type(self.app.model.app_mode, scan_options[index].scan_type)
|
2016-05-29 01:54:25 +00:00
|
|
|
self.app._update_options()
|
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def selectionChanged(self, selected, deselected):
|
|
|
|
self._updateRemoveButton()
|