2009-06-01 09:55:11 +00:00
|
|
|
# Created By: Virgil Dupras
|
|
|
|
# Created On: 2009-04-25
|
2015-01-03 21:30:57 +00:00
|
|
|
# Copyright 2015 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
|
|
|
|
2013-10-20 19:15:09 +00:00
|
|
|
from PyQt5.QtCore import Qt, QRect
|
2014-10-13 19:08:59 +00:00
|
|
|
from PyQt5.QtWidgets import (
|
2020-01-01 02:16:27 +00:00
|
|
|
QMainWindow,
|
|
|
|
QMenu,
|
|
|
|
QLabel,
|
|
|
|
QFileDialog,
|
|
|
|
QMenuBar,
|
|
|
|
QWidget,
|
|
|
|
QVBoxLayout,
|
|
|
|
QAbstractItemView,
|
|
|
|
QStatusBar,
|
|
|
|
QDialog,
|
|
|
|
QPushButton,
|
|
|
|
QCheckBox,
|
|
|
|
QDesktopWidget,
|
2014-10-13 19:08:59 +00:00
|
|
|
)
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2011-11-01 19:44:18 +00:00
|
|
|
from hscommon.trans import trget
|
2012-03-04 16:14:59 +00:00
|
|
|
from qtlib.util import moveToScreenCenter, horizontalWrap, createActions
|
2012-03-04 16:04:47 +00:00
|
|
|
from qtlib.search_edit import SearchEdit
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2016-06-01 01:22:50 +00:00
|
|
|
from core.app import AppMode
|
2011-11-28 15:27:17 +00:00
|
|
|
from .results_model import ResultsView
|
2010-08-11 14:39:06 +00:00
|
|
|
from .stats_label import StatsLabel
|
2011-09-09 16:01:15 +00:00
|
|
|
from .prioritize_dialog import PrioritizeDialog
|
2016-06-01 01:59:31 +00:00
|
|
|
from .se.results_model import ResultsModel as ResultsModelStandard
|
|
|
|
from .me.results_model import ResultsModel as ResultsModelMusic
|
|
|
|
from .pe.results_model import ResultsModel as ResultsModelPicture
|
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 ResultWindow(QMainWindow):
|
2014-02-15 20:05:46 +00:00
|
|
|
def __init__(self, parent, app, **kwargs):
|
|
|
|
super().__init__(parent, **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-06-01 09:55:11 +00:00
|
|
|
self._setupUi()
|
2016-06-01 01:22:50 +00:00
|
|
|
if app.model.app_mode == AppMode.Picture:
|
|
|
|
MODEL_CLASS = ResultsModelPicture
|
|
|
|
elif app.model.app_mode == AppMode.Music:
|
|
|
|
MODEL_CLASS = ResultsModelMusic
|
|
|
|
else:
|
|
|
|
MODEL_CLASS = ResultsModelStandard
|
|
|
|
self.resultsModel = MODEL_CLASS(self.app, self.resultsView)
|
2012-01-16 14:29:57 +00:00
|
|
|
self.stats = StatsLabel(app.model.stats_label, self.statusLabel)
|
2009-06-01 09:55:11 +00:00
|
|
|
self._update_column_actions_status()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2014-03-27 23:09:10 +00:00
|
|
|
self.menuColumns.triggered.connect(self.columnToggled)
|
2012-03-04 14:55:21 +00:00
|
|
|
self.resultsView.doubleClicked.connect(self.resultsDoubleClicked)
|
|
|
|
self.resultsView.spacePressed.connect(self.resultsSpacePressed)
|
2012-03-04 16:04:47 +00:00
|
|
|
self.detailsButton.clicked.connect(self.actionDetails.triggered)
|
|
|
|
self.dupesOnlyCheckBox.stateChanged.connect(self.powerMarkerTriggered)
|
|
|
|
self.deltaValuesCheckBox.stateChanged.connect(self.deltaTriggered)
|
|
|
|
self.searchEdit.searchChanged.connect(self.searchChanged)
|
2010-08-15 10:27:15 +00:00
|
|
|
self.app.willSavePrefs.connect(self.appWillSavePrefs)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2010-10-04 13:29:00 +00:00
|
|
|
def _setupActions(self):
|
|
|
|
# (name, shortcut, icon, desc, func)
|
|
|
|
ACTIONS = [
|
2020-01-01 02:16:27 +00:00
|
|
|
("actionDetails", "Ctrl+I", "", tr("Details"), self.detailsTriggered),
|
|
|
|
("actionActions", "", "", tr("Actions"), self.actionsTriggered),
|
|
|
|
(
|
|
|
|
"actionPowerMarker",
|
|
|
|
"Ctrl+1",
|
|
|
|
"",
|
|
|
|
tr("Show Dupes Only"),
|
|
|
|
self.powerMarkerTriggered,
|
|
|
|
),
|
|
|
|
("actionDelta", "Ctrl+2", "", tr("Show Delta Values"), self.deltaTriggered),
|
|
|
|
(
|
|
|
|
"actionDeleteMarked",
|
|
|
|
"Ctrl+D",
|
|
|
|
"",
|
|
|
|
tr("Send Marked to Recycle Bin..."),
|
|
|
|
self.deleteTriggered,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionMoveMarked",
|
|
|
|
"Ctrl+M",
|
|
|
|
"",
|
|
|
|
tr("Move Marked to..."),
|
|
|
|
self.moveTriggered,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionCopyMarked",
|
|
|
|
"Ctrl+Shift+M",
|
|
|
|
"",
|
|
|
|
tr("Copy Marked to..."),
|
|
|
|
self.copyTriggered,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionRemoveMarked",
|
|
|
|
"Ctrl+R",
|
|
|
|
"",
|
|
|
|
tr("Remove Marked from Results"),
|
|
|
|
self.removeMarkedTriggered,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionReprioritize",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
tr("Re-Prioritize Results..."),
|
|
|
|
self.reprioritizeTriggered,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionRemoveSelected",
|
|
|
|
"Ctrl+Del",
|
|
|
|
"",
|
|
|
|
tr("Remove Selected from Results"),
|
|
|
|
self.removeSelectedTriggered,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionIgnoreSelected",
|
|
|
|
"Ctrl+Shift+Del",
|
|
|
|
"",
|
|
|
|
tr("Add Selected to Ignore List"),
|
|
|
|
self.addToIgnoreListTriggered,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionMakeSelectedReference",
|
|
|
|
"Ctrl+Space",
|
|
|
|
"",
|
|
|
|
tr("Make Selected into Reference"),
|
|
|
|
self.app.model.make_selected_reference,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionOpenSelected",
|
|
|
|
"Ctrl+O",
|
|
|
|
"",
|
|
|
|
tr("Open Selected with Default Application"),
|
|
|
|
self.openTriggered,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionRevealSelected",
|
|
|
|
"Ctrl+Shift+O",
|
|
|
|
"",
|
|
|
|
tr("Open Containing Folder of Selected"),
|
|
|
|
self.revealTriggered,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionRenameSelected",
|
|
|
|
"F2",
|
|
|
|
"",
|
|
|
|
tr("Rename Selected"),
|
|
|
|
self.renameTriggered,
|
|
|
|
),
|
|
|
|
("actionMarkAll", "Ctrl+A", "", tr("Mark All"), self.markAllTriggered),
|
|
|
|
(
|
|
|
|
"actionMarkNone",
|
|
|
|
"Ctrl+Shift+A",
|
|
|
|
"",
|
|
|
|
tr("Mark None"),
|
|
|
|
self.markNoneTriggered,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionInvertMarking",
|
|
|
|
"Ctrl+Alt+A",
|
|
|
|
"",
|
|
|
|
tr("Invert Marking"),
|
|
|
|
self.markInvertTriggered,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"actionMarkSelected",
|
2020-05-07 14:24:07 +00:00
|
|
|
Qt.Key_Space,
|
2020-01-01 02:16:27 +00:00
|
|
|
"",
|
|
|
|
tr("Mark Selected"),
|
|
|
|
self.markSelectedTriggered,
|
|
|
|
),
|
2014-10-13 19:08:59 +00:00
|
|
|
(
|
2020-01-01 02:16:27 +00:00
|
|
|
"actionExportToHTML",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
tr("Export To HTML"),
|
|
|
|
self.app.model.export_to_xhtml,
|
2014-10-13 19:08:59 +00:00
|
|
|
),
|
|
|
|
(
|
2020-01-01 02:16:27 +00:00
|
|
|
"actionExportToCSV",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
tr("Export To CSV"),
|
|
|
|
self.app.model.export_to_csv,
|
2014-10-13 19:08:59 +00:00
|
|
|
),
|
|
|
|
(
|
2020-01-01 02:16:27 +00:00
|
|
|
"actionSaveResults",
|
|
|
|
"Ctrl+S",
|
|
|
|
"",
|
|
|
|
tr("Save Results..."),
|
|
|
|
self.saveResultsTriggered,
|
2014-10-13 19:08:59 +00:00
|
|
|
),
|
|
|
|
(
|
2020-01-01 02:16:27 +00:00
|
|
|
"actionInvokeCustomCommand",
|
|
|
|
"Ctrl+Alt+I",
|
|
|
|
"",
|
|
|
|
tr("Invoke Custom Command"),
|
|
|
|
self.app.invokeCustomCommand,
|
2014-10-13 19:08:59 +00:00
|
|
|
),
|
2010-10-04 13:29:00 +00:00
|
|
|
]
|
2011-01-15 15:29:35 +00:00
|
|
|
createActions(ACTIONS, self)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.actionDelta.setCheckable(True)
|
|
|
|
self.actionPowerMarker.setCheckable(True)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-07-12 14:58:01 +00:00
|
|
|
if self.app.main_window: # We use tab widgets in this case
|
|
|
|
# Keep track of actions which should only be accessible from this class
|
|
|
|
for action, _, _, _, _ in ACTIONS:
|
|
|
|
self.specific_actions.add(getattr(self, action))
|
|
|
|
|
2010-10-04 13:29:00 +00:00
|
|
|
def _setupMenu(self):
|
2020-07-31 14:57: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.menuBar() works as well here
|
|
|
|
self.menubar.setGeometry(QRect(0, 0, 630, 22))
|
|
|
|
self.menuFile = QMenu(self.menubar)
|
|
|
|
self.menuFile.setTitle(tr("File"))
|
|
|
|
self.menuMark = QMenu(self.menubar)
|
|
|
|
self.menuMark.setTitle(tr("Mark"))
|
|
|
|
self.menuActions = QMenu(self.menubar)
|
|
|
|
self.menuActions.setTitle(tr("Actions"))
|
|
|
|
self.menuColumns = QMenu(self.menubar)
|
|
|
|
self.menuColumns.setTitle(tr("Columns"))
|
|
|
|
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.menuMark = self.app.main_window.menuMark
|
|
|
|
self.menuActions = self.app.main_window.menuActions
|
|
|
|
self.menuColumns = self.app.main_window.menuColumns
|
|
|
|
self.menuView = self.app.main_window.menuView
|
|
|
|
self.menuHelp = self.app.main_window.menuHelp
|
|
|
|
menubar = self.app.main_window.menubar
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2010-10-04 13:29:00 +00:00
|
|
|
self.menuActions.addAction(self.actionDeleteMarked)
|
|
|
|
self.menuActions.addAction(self.actionMoveMarked)
|
|
|
|
self.menuActions.addAction(self.actionCopyMarked)
|
|
|
|
self.menuActions.addAction(self.actionRemoveMarked)
|
2011-09-09 16:01:15 +00:00
|
|
|
self.menuActions.addAction(self.actionReprioritize)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.menuActions.addSeparator()
|
|
|
|
self.menuActions.addAction(self.actionRemoveSelected)
|
|
|
|
self.menuActions.addAction(self.actionIgnoreSelected)
|
|
|
|
self.menuActions.addAction(self.actionMakeSelectedReference)
|
|
|
|
self.menuActions.addSeparator()
|
|
|
|
self.menuActions.addAction(self.actionOpenSelected)
|
|
|
|
self.menuActions.addAction(self.actionRevealSelected)
|
|
|
|
self.menuActions.addAction(self.actionInvokeCustomCommand)
|
|
|
|
self.menuActions.addAction(self.actionRenameSelected)
|
|
|
|
self.menuMark.addAction(self.actionMarkAll)
|
|
|
|
self.menuMark.addAction(self.actionMarkNone)
|
|
|
|
self.menuMark.addAction(self.actionInvertMarking)
|
|
|
|
self.menuMark.addAction(self.actionMarkSelected)
|
2020-07-31 14:57:18 +00:00
|
|
|
|
|
|
|
self.menuView.addAction(self.actionDetails)
|
|
|
|
self.menuView.addSeparator()
|
2011-01-15 15:29:35 +00:00
|
|
|
self.menuView.addAction(self.actionPowerMarker)
|
|
|
|
self.menuView.addAction(self.actionDelta)
|
|
|
|
self.menuView.addSeparator()
|
2020-07-31 14:57:18 +00:00
|
|
|
if not self.app.use_tabs:
|
|
|
|
self.menuView.addAction(self.app.actionIgnoreList)
|
|
|
|
# This also pushes back the options entry to the bottom of the menu
|
|
|
|
self.menuView.addSeparator()
|
2011-01-15 15:29:35 +00:00
|
|
|
self.menuView.addAction(self.app.actionPreferences)
|
2020-07-31 14:57:18 +00:00
|
|
|
|
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)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.menuFile.addAction(self.actionSaveResults)
|
2012-07-31 20:46:51 +00:00
|
|
|
self.menuFile.addAction(self.actionExportToHTML)
|
|
|
|
self.menuFile.addAction(self.actionExportToCSV)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.menuFile.addSeparator()
|
2011-01-15 15:29:35 +00:00
|
|
|
self.menuFile.addAction(self.app.actionQuit)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-07-12 14:58:01 +00:00
|
|
|
menubar.addAction(self.menuFile.menuAction())
|
|
|
|
menubar.addAction(self.menuMark.menuAction())
|
|
|
|
menubar.addAction(self.menuActions.menuAction())
|
|
|
|
menubar.addAction(self.menuColumns.menuAction())
|
|
|
|
menubar.addAction(self.menuView.menuAction())
|
|
|
|
menubar.addAction(self.menuHelp.menuAction())
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
# Columns menu
|
|
|
|
menu = self.menuColumns
|
2020-07-12 14:58:01 +00:00
|
|
|
# Avoid adding duplicate actions in tab widget menu in case we recreated
|
|
|
|
# the Result Window instance.
|
|
|
|
if menu.actions():
|
|
|
|
menu.clear()
|
2009-06-01 09:55:11 +00:00
|
|
|
self._column_actions = []
|
2020-01-01 02:16:27 +00:00
|
|
|
for index, (display, visible) in enumerate(
|
|
|
|
self.app.model.result_table.columns.menu_items()
|
|
|
|
):
|
2011-11-28 15:27:17 +00:00
|
|
|
action = menu.addAction(display)
|
2009-06-01 09:55:11 +00:00
|
|
|
action.setCheckable(True)
|
2011-11-28 15:27:17 +00:00
|
|
|
action.setChecked(visible)
|
|
|
|
action.item_index = index
|
2009-06-01 09:55:11 +00:00
|
|
|
self._column_actions.append(action)
|
|
|
|
menu.addSeparator()
|
2011-01-21 12:57:54 +00:00
|
|
|
action = menu.addAction(tr("Reset to Defaults"))
|
2011-11-28 15:27:17 +00:00
|
|
|
action.item_index = -1
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
# Action menu
|
2020-07-12 14:58:01 +00:00
|
|
|
actionMenu = QMenu(tr("Actions"), menubar)
|
2009-06-01 09:55:11 +00:00
|
|
|
actionMenu.addAction(self.actionDeleteMarked)
|
|
|
|
actionMenu.addAction(self.actionMoveMarked)
|
|
|
|
actionMenu.addAction(self.actionCopyMarked)
|
|
|
|
actionMenu.addAction(self.actionRemoveMarked)
|
|
|
|
actionMenu.addSeparator()
|
|
|
|
actionMenu.addAction(self.actionRemoveSelected)
|
|
|
|
actionMenu.addAction(self.actionIgnoreSelected)
|
|
|
|
actionMenu.addAction(self.actionMakeSelectedReference)
|
|
|
|
actionMenu.addSeparator()
|
|
|
|
actionMenu.addAction(self.actionOpenSelected)
|
|
|
|
actionMenu.addAction(self.actionRevealSelected)
|
2010-04-13 08:02:09 +00:00
|
|
|
actionMenu.addAction(self.actionInvokeCustomCommand)
|
2009-06-01 09:55:11 +00:00
|
|
|
actionMenu.addAction(self.actionRenameSelected)
|
|
|
|
self.actionActions.setMenu(actionMenu)
|
2012-03-04 16:04:47 +00:00
|
|
|
self.actionsButton.setMenu(self.actionActions.menu())
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2010-10-04 13:29:00 +00:00
|
|
|
def _setupUi(self):
|
2011-04-22 09:37:53 +00:00
|
|
|
self.setWindowTitle(tr("{} Results").format(self.app.NAME))
|
2010-10-04 13:29:00 +00:00
|
|
|
self.resize(630, 514)
|
|
|
|
self.centralwidget = QWidget(self)
|
2012-03-04 16:04:47 +00:00
|
|
|
self.verticalLayout = QVBoxLayout(self.centralwidget)
|
2013-10-20 19:15:09 +00:00
|
|
|
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
|
2012-03-04 16:04:47 +00:00
|
|
|
self.verticalLayout.setSpacing(0)
|
|
|
|
self.actionsButton = QPushButton(tr("Actions"))
|
|
|
|
self.detailsButton = QPushButton(tr("Details"))
|
|
|
|
self.dupesOnlyCheckBox = QCheckBox(tr("Dupes Only"))
|
|
|
|
self.deltaValuesCheckBox = QCheckBox(tr("Delta Values"))
|
|
|
|
self.searchEdit = SearchEdit()
|
|
|
|
self.searchEdit.setMaximumWidth(300)
|
2020-01-01 02:16:27 +00:00
|
|
|
self.horizontalLayout = horizontalWrap(
|
|
|
|
[
|
|
|
|
self.actionsButton,
|
|
|
|
self.detailsButton,
|
|
|
|
self.dupesOnlyCheckBox,
|
|
|
|
self.deltaValuesCheckBox,
|
|
|
|
None,
|
|
|
|
self.searchEdit,
|
|
|
|
8,
|
|
|
|
]
|
|
|
|
)
|
2012-03-04 16:04:47 +00:00
|
|
|
self.horizontalLayout.setSpacing(8)
|
|
|
|
self.verticalLayout.addLayout(self.horizontalLayout)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.resultsView = ResultsView(self.centralwidget)
|
|
|
|
self.resultsView.setSelectionMode(QAbstractItemView.ExtendedSelection)
|
|
|
|
self.resultsView.setSelectionBehavior(QAbstractItemView.SelectRows)
|
|
|
|
self.resultsView.setSortingEnabled(True)
|
2020-05-02 00:53:49 +00:00
|
|
|
self.resultsView.setWordWrap(False)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.resultsView.verticalHeader().setVisible(False)
|
|
|
|
h = self.resultsView.horizontalHeader()
|
|
|
|
h.setHighlightSections(False)
|
2013-10-20 19:15:09 +00:00
|
|
|
h.setSectionsMovable(True)
|
2010-10-04 13:29:00 +00:00
|
|
|
h.setStretchLastSection(False)
|
|
|
|
h.setDefaultAlignment(Qt.AlignLeft)
|
2012-03-04 16:04:47 +00:00
|
|
|
self.verticalLayout.addWidget(self.resultsView)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.setCentralWidget(self.centralwidget)
|
|
|
|
self._setupActions()
|
|
|
|
self._setupMenu()
|
|
|
|
self.statusbar = QStatusBar(self)
|
|
|
|
self.statusbar.setSizeGripEnabled(True)
|
|
|
|
self.setStatusBar(self.statusbar)
|
2009-06-01 09:55:11 +00:00
|
|
|
self.statusLabel = QLabel(self)
|
|
|
|
self.statusbar.addPermanentWidget(self.statusLabel, 1)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-01-15 15:29:35 +00:00
|
|
|
if self.app.prefs.resultWindowIsMaximized:
|
|
|
|
self.setWindowState(self.windowState() | Qt.WindowMaximized)
|
2011-02-01 10:43:16 +00:00
|
|
|
else:
|
|
|
|
if self.app.prefs.resultWindowRect is not None:
|
|
|
|
self.setGeometry(self.app.prefs.resultWindowRect)
|
2018-10-09 02:20:09 +00:00
|
|
|
# if not on any screen move to center of default screen
|
|
|
|
# moves to center of closest screen if partially off screen
|
|
|
|
frame = self.frameGeometry()
|
|
|
|
if QDesktopWidget().screenNumber(self) == -1:
|
|
|
|
moveToScreenCenter(self)
|
2018-10-11 00:48:32 +00:00
|
|
|
elif QDesktopWidget().availableGeometry(self).contains(frame) is False:
|
2018-10-09 02:20:09 +00:00
|
|
|
frame.moveCenter(QDesktopWidget().availableGeometry(self).center())
|
|
|
|
self.move(frame.topLeft())
|
2011-02-01 10:43:16 +00:00
|
|
|
else:
|
|
|
|
moveToScreenCenter(self)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# --- Private
|
2009-06-01 09:55:11 +00:00
|
|
|
def _update_column_actions_status(self):
|
2011-11-28 15:27:17 +00:00
|
|
|
# Update menu checked state
|
|
|
|
menu_items = self.app.model.result_table.columns.menu_items()
|
|
|
|
for action, (display, visible) in zip(self._column_actions, menu_items):
|
|
|
|
action.setChecked(visible)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# --- Actions
|
2009-06-01 09:55:11 +00:00
|
|
|
def actionsTriggered(self):
|
|
|
|
self.actionsButton.showMenu()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def addToIgnoreListTriggered(self):
|
2011-09-20 19:06:29 +00:00
|
|
|
self.app.model.add_selected_to_ignore_list()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def copyTriggered(self):
|
2012-03-10 19:32:56 +00:00
|
|
|
self.app.model.copy_or_move_marked(True)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def deleteTriggered(self):
|
2012-03-10 19:32:56 +00:00
|
|
|
self.app.model.delete_marked()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2012-03-04 16:04:47 +00:00
|
|
|
def deltaTriggered(self, state=None):
|
|
|
|
# The sender can be either the action or the checkbox, but both have a isChecked() method.
|
|
|
|
self.resultsModel.delta_values = self.sender().isChecked()
|
|
|
|
self.actionDelta.setChecked(self.resultsModel.delta_values)
|
|
|
|
self.deltaValuesCheckBox.setChecked(self.resultsModel.delta_values)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def detailsTriggered(self):
|
|
|
|
self.app.show_details()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def markAllTriggered(self):
|
2011-09-20 19:06:29 +00:00
|
|
|
self.app.model.mark_all()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def markInvertTriggered(self):
|
2011-09-20 19:06:29 +00:00
|
|
|
self.app.model.mark_invert()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def markNoneTriggered(self):
|
2011-09-20 19:06:29 +00:00
|
|
|
self.app.model.mark_none()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def markSelectedTriggered(self):
|
2011-09-20 19:06:29 +00:00
|
|
|
self.app.model.toggle_selected_mark_state()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def moveTriggered(self):
|
2012-03-10 19:32:56 +00:00
|
|
|
self.app.model.copy_or_move_marked(False)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def openTriggered(self):
|
2011-09-20 19:06:29 +00:00
|
|
|
self.app.model.open_selected()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2012-03-04 16:04:47 +00:00
|
|
|
def powerMarkerTriggered(self, state=None):
|
|
|
|
# see deltaTriggered
|
|
|
|
self.resultsModel.power_marker = self.sender().isChecked()
|
|
|
|
self.actionPowerMarker.setChecked(self.resultsModel.power_marker)
|
|
|
|
self.dupesOnlyCheckBox.setChecked(self.resultsModel.power_marker)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def preferencesTriggered(self):
|
|
|
|
self.app.show_preferences()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def removeMarkedTriggered(self):
|
2012-03-10 15:58:08 +00:00
|
|
|
self.app.model.remove_marked()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def removeSelectedTriggered(self):
|
2011-09-20 19:06:29 +00:00
|
|
|
self.app.model.remove_selected()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def renameTriggered(self):
|
2012-03-19 20:20:51 +00:00
|
|
|
index = self.resultsView.selectionModel().currentIndex()
|
|
|
|
# Our index is the current row, with column set to 0. Our filename column is 1 and that's
|
|
|
|
# what we want.
|
|
|
|
index = index.sibling(index.row(), 1)
|
|
|
|
self.resultsView.edit(index)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2011-09-09 16:01:15 +00:00
|
|
|
def reprioritizeTriggered(self):
|
|
|
|
dlg = PrioritizeDialog(self, self.app)
|
|
|
|
result = dlg.exec()
|
|
|
|
if result == QDialog.Accepted:
|
|
|
|
dlg.model.perform_reprioritization()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def revealTriggered(self):
|
2011-09-20 19:06:29 +00:00
|
|
|
self.app.model.reveal_selected()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2010-08-13 11:06:18 +00:00
|
|
|
def saveResultsTriggered(self):
|
2011-11-04 17:10:11 +00:00
|
|
|
title = tr("Select a file to save your results to")
|
2011-01-21 12:57:54 +00:00
|
|
|
files = tr("dupeGuru Results (*.dupeguru)")
|
2020-01-01 02:16:27 +00:00
|
|
|
destination, chosen_filter = QFileDialog.getSaveFileName(self, title, "", files)
|
2010-08-13 11:06:18 +00:00
|
|
|
if destination:
|
2020-01-01 02:16:27 +00:00
|
|
|
if not destination.endswith(".dupeguru"):
|
|
|
|
destination = "{}.dupeguru".format(destination)
|
2011-09-20 19:06:29 +00:00
|
|
|
self.app.model.save_as(destination)
|
2011-01-15 15:29:35 +00:00
|
|
|
self.app.recentResults.insertItem(destination)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
# --- Events
|
2010-08-15 10:27:15 +00:00
|
|
|
def appWillSavePrefs(self):
|
|
|
|
prefs = self.app.prefs
|
2011-01-15 15:29:35 +00:00
|
|
|
prefs.resultWindowIsMaximized = self.isMaximized()
|
|
|
|
prefs.resultWindowRect = self.geometry()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def columnToggled(self, action):
|
2011-11-28 15:27:17 +00:00
|
|
|
index = action.item_index
|
|
|
|
if index == -1:
|
|
|
|
self.app.model.result_table.columns.reset_to_defaults()
|
|
|
|
self._update_column_actions_status()
|
2009-06-01 09:55:11 +00:00
|
|
|
else:
|
2011-11-28 15:27:17 +00:00
|
|
|
visible = self.app.model.result_table.columns.toggle_menu_item(index)
|
|
|
|
action.setChecked(visible)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2009-06-19 11:32:58 +00:00
|
|
|
def contextMenuEvent(self, event):
|
|
|
|
self.actionActions.menu().exec_(event.globalPos())
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2012-03-04 14:55:21 +00:00
|
|
|
def resultsDoubleClicked(self, modelIndex):
|
2011-09-20 19:06:29 +00:00
|
|
|
self.app.model.open_selected()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2010-02-12 14:39:29 +00:00
|
|
|
def resultsSpacePressed(self):
|
2011-09-20 19:06:29 +00:00
|
|
|
self.app.model.toggle_selected_mark_state()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2012-03-04 16:04:47 +00:00
|
|
|
def searchChanged(self):
|
|
|
|
self.app.model.apply_filter(self.searchEdit.text())
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2018-10-09 02:20:09 +00:00
|
|
|
def closeEvent(self, event):
|
|
|
|
# this saves the location of the results window when it is closed
|
|
|
|
self.appWillSavePrefs()
|