mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +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:
parent
09d5243648
commit
197acbf5b3
@ -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),
|
||||
|
@ -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_())
|
||||
|
@ -1,6 +1,4 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2009-05-03
|
||||
# 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
|
||||
@ -12,6 +10,8 @@ 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
|
||||
@ -88,3 +88,11 @@ class Preferences(PreferencesBase):
|
||||
|
||||
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)
|
||||
|
@ -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
|
||||
|
@ -1,6 +1,4 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2009-05-17
|
||||
# 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
|
||||
@ -11,9 +9,10 @@ from core.scanner import ScanType
|
||||
from ..base.preferences import Preferences as PreferencesBase
|
||||
|
||||
class Preferences(PreferencesBase):
|
||||
DEFAULT_SCAN_TYPE = ScanType.Tag
|
||||
|
||||
def _load_specific(self, settings):
|
||||
get = self.get_value
|
||||
self.scan_type = get('ScanType', self.scan_type)
|
||||
self.word_weighting = get('WordWeighting', self.word_weighting)
|
||||
self.match_similar = get('MatchSimilar', self.match_similar)
|
||||
self.scan_tag_track = get('ScanTagTrack', self.scan_tag_track)
|
||||
@ -25,7 +24,6 @@ class Preferences(PreferencesBase):
|
||||
|
||||
def _reset_specific(self):
|
||||
self.filter_hardness = 80
|
||||
self.scan_type = ScanType.Tag
|
||||
self.word_weighting = True
|
||||
self.match_similar = False
|
||||
self.scan_tag_track = False
|
||||
@ -37,7 +35,6 @@ class Preferences(PreferencesBase):
|
||||
|
||||
def _save_specific(self, settings):
|
||||
set_ = self.set_value
|
||||
set_('ScanType', self.scan_type)
|
||||
set_('WordWeighting', self.word_weighting)
|
||||
set_('MatchSimilar', self.match_similar)
|
||||
set_('ScanTagTrack', self.scan_tag_track)
|
||||
|
@ -1,5 +1,3 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2009-04-29
|
||||
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
@ -20,13 +18,7 @@ from . import preferences
|
||||
tr = trget('ui')
|
||||
|
||||
class PreferencesDialog(PreferencesDialogBase):
|
||||
def __init__(self, parent, app):
|
||||
PreferencesDialogBase.__init__(self, parent, app)
|
||||
|
||||
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)
|
||||
|
||||
def _setupPreferenceWidgets(self):
|
||||
self._setupScanTypeBox()
|
||||
self._setupFilterHardnessBox()
|
||||
self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
|
||||
self.widget = QWidget(self)
|
||||
@ -72,7 +64,6 @@ class PreferencesDialog(PreferencesDialogBase):
|
||||
self._setupBottomPart()
|
||||
|
||||
def _load(self, prefs, setchecked):
|
||||
self._load_scan_type(prefs)
|
||||
setchecked(self.tagTrackBox, prefs.scan_tag_track)
|
||||
setchecked(self.tagArtistBox, prefs.scan_tag_artist)
|
||||
setchecked(self.tagAlbumBox, prefs.scan_tag_album)
|
||||
@ -82,24 +73,8 @@ class PreferencesDialog(PreferencesDialogBase):
|
||||
setchecked(self.matchSimilarBox, prefs.match_similar)
|
||||
setchecked(self.wordWeightingBox, prefs.word_weighting)
|
||||
|
||||
def _save(self, prefs, ischecked):
|
||||
self._save_scan_type(prefs)
|
||||
prefs.scan_tag_track = ischecked(self.tagTrackBox)
|
||||
prefs.scan_tag_artist = ischecked(self.tagArtistBox)
|
||||
prefs.scan_tag_album = ischecked(self.tagAlbumBox)
|
||||
prefs.scan_tag_title = ischecked(self.tagTitleBox)
|
||||
prefs.scan_tag_genre = ischecked(self.tagGenreBox)
|
||||
prefs.scan_tag_year = ischecked(self.tagYearBox)
|
||||
prefs.match_similar = ischecked(self.matchSimilarBox)
|
||||
prefs.word_weighting = ischecked(self.wordWeightingBox)
|
||||
|
||||
def resetToDefaults(self):
|
||||
self.load(preferences.Preferences())
|
||||
|
||||
#--- Events
|
||||
def scanTypeChanged(self, index):
|
||||
scan_options = self.app.model.scanner.get_scan_options()
|
||||
scan_type = scan_options[self.scanTypeComboBox.currentIndex()].scan_type
|
||||
# Update UI state based on selected scan type
|
||||
scan_type = prefs.scan_type
|
||||
word_based = scan_type in (
|
||||
ScanType.Filename, ScanType.Fields, ScanType.FieldsNoOrder,
|
||||
ScanType.Tag
|
||||
@ -115,3 +90,16 @@ class PreferencesDialog(PreferencesDialogBase):
|
||||
self.tagGenreBox.setEnabled(tag_based)
|
||||
self.tagYearBox.setEnabled(tag_based)
|
||||
|
||||
def _save(self, prefs, ischecked):
|
||||
prefs.scan_tag_track = ischecked(self.tagTrackBox)
|
||||
prefs.scan_tag_artist = ischecked(self.tagArtistBox)
|
||||
prefs.scan_tag_album = ischecked(self.tagAlbumBox)
|
||||
prefs.scan_tag_title = ischecked(self.tagTitleBox)
|
||||
prefs.scan_tag_genre = ischecked(self.tagGenreBox)
|
||||
prefs.scan_tag_year = ischecked(self.tagYearBox)
|
||||
prefs.match_similar = ischecked(self.matchSimilarBox)
|
||||
prefs.word_weighting = ischecked(self.wordWeightingBox)
|
||||
|
||||
def resetToDefaults(self):
|
||||
self.load(preferences.Preferences())
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2009-05-17
|
||||
# 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
|
||||
@ -11,18 +9,17 @@ from core.scanner import ScanType
|
||||
from ..base.preferences import Preferences as PreferencesBase
|
||||
|
||||
class Preferences(PreferencesBase):
|
||||
DEFAULT_SCAN_TYPE = ScanType.FuzzyBlock
|
||||
|
||||
def _load_specific(self, settings):
|
||||
get = self.get_value
|
||||
self.scan_type = get('ScanType', self.scan_type)
|
||||
self.match_scaled = get('MatchScaled', self.match_scaled)
|
||||
|
||||
def _reset_specific(self):
|
||||
self.scan_type = ScanType.FuzzyBlock
|
||||
self.filter_hardness = 95
|
||||
self.match_scaled = False
|
||||
|
||||
def _save_specific(self, settings):
|
||||
set_ = self.set_value
|
||||
set_('ScanType', self.scan_type)
|
||||
set_('MatchScaled', self.match_scaled)
|
||||
|
||||
|
@ -13,13 +13,7 @@ from . import preferences
|
||||
tr = trget('ui')
|
||||
|
||||
class PreferencesDialog(PreferencesDialogBase):
|
||||
def __init__(self, parent, app):
|
||||
PreferencesDialogBase.__init__(self, parent, app)
|
||||
|
||||
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)
|
||||
|
||||
def _setupPreferenceWidgets(self):
|
||||
self._setupScanTypeBox()
|
||||
self._setupFilterHardnessBox()
|
||||
self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
|
||||
self._setupAddCheckbox('matchScaledBox', tr("Match pictures of different dimensions"))
|
||||
@ -37,20 +31,16 @@ class PreferencesDialog(PreferencesDialogBase):
|
||||
self._setupBottomPart()
|
||||
|
||||
def _load(self, prefs, setchecked):
|
||||
self._load_scan_type(prefs)
|
||||
setchecked(self.matchScaledBox, prefs.match_scaled)
|
||||
|
||||
# Update UI state based on selected scan type
|
||||
scan_type = prefs.scan_type
|
||||
fuzzy_scan = scan_type == ScanType.FuzzyBlock
|
||||
self.filterHardnessSlider.setEnabled(fuzzy_scan)
|
||||
|
||||
def _save(self, prefs, ischecked):
|
||||
self._save_scan_type(prefs)
|
||||
prefs.match_scaled = ischecked(self.matchScaledBox)
|
||||
|
||||
def resetToDefaults(self):
|
||||
self.load(preferences.Preferences())
|
||||
|
||||
#--- Events
|
||||
def scanTypeChanged(self, index):
|
||||
scan_options = self.app.model.scanner.get_scan_options()
|
||||
scan_type = scan_options[self.scanTypeComboBox.currentIndex()].scan_type
|
||||
fuzzy_scan = scan_type == ScanType.FuzzyBlock
|
||||
self.filterHardnessSlider.setEnabled(fuzzy_scan)
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2009-05-24
|
||||
# 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
|
||||
@ -11,9 +9,10 @@ from core.scanner import ScanType
|
||||
from ..base.preferences import Preferences as PreferencesBase
|
||||
|
||||
class Preferences(PreferencesBase):
|
||||
DEFAULT_SCAN_TYPE = ScanType.Contents
|
||||
|
||||
def _load_specific(self, settings):
|
||||
get = self.get_value
|
||||
self.scan_type = get('ScanType', self.scan_type)
|
||||
self.word_weighting = get('WordWeighting', self.word_weighting)
|
||||
self.match_similar = get('MatchSimilar', self.match_similar)
|
||||
self.ignore_small_files = get('IgnoreSmallFiles', self.ignore_small_files)
|
||||
@ -21,7 +20,6 @@ class Preferences(PreferencesBase):
|
||||
|
||||
def _reset_specific(self):
|
||||
self.filter_hardness = 80
|
||||
self.scan_type = ScanType.Contents
|
||||
self.word_weighting = True
|
||||
self.match_similar = False
|
||||
self.ignore_small_files = True
|
||||
@ -29,7 +27,6 @@ class Preferences(PreferencesBase):
|
||||
|
||||
def _save_specific(self, settings):
|
||||
set_ = self.set_value
|
||||
set_('ScanType', self.scan_type)
|
||||
set_('WordWeighting', self.word_weighting)
|
||||
set_('MatchSimilar', self.match_similar)
|
||||
set_('IgnoreSmallFiles', self.ignore_small_files)
|
||||
|
@ -21,13 +21,7 @@ from . import preferences
|
||||
tr = trget('ui')
|
||||
|
||||
class PreferencesDialog(PreferencesDialogBase):
|
||||
def __init__(self, parent, app, **kwargs):
|
||||
super().__init__(parent, app, **kwargs)
|
||||
|
||||
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)
|
||||
|
||||
def _setupPreferenceWidgets(self):
|
||||
self._setupScanTypeBox()
|
||||
self._setupFilterHardnessBox()
|
||||
self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
|
||||
self.widget = QWidget(self)
|
||||
@ -81,14 +75,19 @@ class PreferencesDialog(PreferencesDialogBase):
|
||||
self.resize(self.width(), 440)
|
||||
|
||||
def _load(self, prefs, setchecked):
|
||||
self._load_scan_type(prefs)
|
||||
setchecked(self.matchSimilarBox, prefs.match_similar)
|
||||
setchecked(self.wordWeightingBox, prefs.word_weighting)
|
||||
setchecked(self.ignoreSmallFilesBox, prefs.ignore_small_files)
|
||||
self.sizeThresholdEdit.setText(str(prefs.small_file_threshold))
|
||||
|
||||
# Update UI state based on selected scan type
|
||||
scan_type = prefs.scan_type
|
||||
word_based = scan_type == ScanType.Filename
|
||||
self.filterHardnessSlider.setEnabled(word_based)
|
||||
self.matchSimilarBox.setEnabled(word_based)
|
||||
self.wordWeightingBox.setEnabled(word_based)
|
||||
|
||||
def _save(self, prefs, ischecked):
|
||||
self._save_scan_type(prefs)
|
||||
prefs.match_similar = ischecked(self.matchSimilarBox)
|
||||
prefs.word_weighting = ischecked(self.wordWeightingBox)
|
||||
prefs.ignore_small_files = ischecked(self.ignoreSmallFilesBox)
|
||||
@ -97,12 +96,3 @@ class PreferencesDialog(PreferencesDialogBase):
|
||||
def resetToDefaults(self):
|
||||
self.load(preferences.Preferences())
|
||||
|
||||
#--- Events
|
||||
def scanTypeChanged(self, index):
|
||||
scan_options = self.app.model.scanner.get_scan_options()
|
||||
scan_type = scan_options[self.scanTypeComboBox.currentIndex()].scan_type
|
||||
word_based = scan_type == ScanType.Filename
|
||||
self.filterHardnessSlider.setEnabled(word_based)
|
||||
self.matchSimilarBox.setEnabled(word_based)
|
||||
self.wordWeightingBox.setEnabled(word_based)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user