1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-23 07:01:39 +00:00

Merge branch 'qt5' into develop

Conflicts:
	README.md
	qtlib/about_box.py
	qtlib/reg.py
	qtlib/reg_demo_dialog.py
	qtlib/reg_submit_dialog.py
This commit is contained in:
Virgil Dupras
2013-12-07 19:49:27 -05:00
42 changed files with 182 additions and 168 deletions

View File

@@ -9,8 +9,9 @@
import sys
import os.path as op
from PyQt4.QtCore import QTimer, QObject, QCoreApplication, QUrl, QProcess, SIGNAL, pyqtSignal
from PyQt4.QtGui import QDesktopServices, QFileDialog, QDialog, QMessageBox, QApplication
from PyQt5.QtCore import QTimer, QObject, QCoreApplication, QUrl, QProcess, pyqtSignal
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QApplication, QFileDialog, QDialog, QMessageBox
from hscommon.trans import trget
from hscommon.plat import ISLINUX
@@ -41,8 +42,8 @@ class DupeGuru(QObject):
PREFERENCES_CLASS = None
PREFERENCES_DIALOG_CLASS = None
def __init__(self):
QObject.__init__(self)
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.prefs = self.PREFERENCES_CLASS()
self.prefs.load()
self.model = self.MODELCLASS(view=self)
@@ -73,7 +74,7 @@ class DupeGuru(QObject):
# In some circumstances, the nag is hidden by other window, which may make the user think
# that the application haven't launched.
QTimer.singleShot(0, self.finishedLaunching)
self.connect(QCoreApplication.instance(), SIGNAL('aboutToQuit()'), self.application_will_terminate)
QCoreApplication.instance().aboutToQuit.connect(self.application_will_terminate)
def _setupActions(self):
# Setup actions that are common to both the directory dialog and the results window.

View File

@@ -6,8 +6,8 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QDialog, QVBoxLayout, QLabel, QCheckBox, QDialogButtonBox
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel, QCheckBox, QDialogButtonBox
from hscommon.trans import trget
from qtlib.radio_box import RadioBox
@@ -15,9 +15,9 @@ from qtlib.radio_box import RadioBox
tr = trget('ui')
class DeletionOptions(QDialog):
def __init__(self, parent, model):
def __init__(self, parent, model, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
QDialog.__init__(self, parent, flags)
super().__init__(parent, flags, **kwargs)
self.model = model
self._setupUi()
self.model.view = self

View File

@@ -6,14 +6,14 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QDialog
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDialog
from .details_table import DetailsModel
class DetailsDialog(QDialog):
def __init__(self, parent, app):
QDialog.__init__(self, parent, Qt.Tool)
def __init__(self, parent, app, **kwargs):
super().__init__(parent, Qt.Tool, **kwargs)
self.app = app
self.model = app.model.details_panel
self._setupUi()
@@ -33,7 +33,7 @@ class DetailsDialog(QDialog):
def show(self):
self._shown_once = True
QDialog.show(self)
super().show()
#--- Events
def appWillSavePrefs(self):
@@ -42,5 +42,6 @@ class DetailsDialog(QDialog):
#--- model --> view
def refresh(self):
self.tableModel.reset()
self.tableModel.beginResetModel()
self.tableModel.endResetModel()

View File

@@ -6,8 +6,8 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt, SIGNAL, QAbstractTableModel
from PyQt4.QtGui import QHeaderView, QTableView
from PyQt5.QtCore import Qt, QAbstractTableModel
from PyQt5.QtWidgets import QHeaderView, QTableView
from hscommon.trans import trget
@@ -16,8 +16,8 @@ tr = trget('ui')
HEADER = [tr("Attribute"), tr("Selected"), tr("Reference")]
class DetailsModel(QAbstractTableModel):
def __init__(self, model):
QAbstractTableModel.__init__(self)
def __init__(self, model, **kwargs):
super().__init__(**kwargs)
self.model = model
def columnCount(self, parent):
@@ -55,9 +55,9 @@ class DetailsTable(QTableView):
hheader.setHighlightSections(False)
hheader.setStretchLastSection(False)
hheader.resizeSection(0, 100)
hheader.setResizeMode(0, QHeaderView.Fixed)
hheader.setResizeMode(1, QHeaderView.Stretch)
hheader.setResizeMode(2, QHeaderView.Stretch)
hheader.setSectionResizeMode(0, QHeaderView.Fixed)
hheader.setSectionResizeMode(1, QHeaderView.Stretch)
hheader.setSectionResizeMode(2, QHeaderView.Stretch)
vheader = self.verticalHeader()
vheader.setVisible(False)
vheader.setDefaultSectionSize(18)

View File

@@ -6,10 +6,11 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import QRect
from PyQt4.QtGui import (QWidget, QFileDialog, QHeaderView, QVBoxLayout, QHBoxLayout, QTreeView,
QAbstractItemView, QSpacerItem, QSizePolicy, QPushButton, QApplication, QMainWindow, QMenuBar,
QMenu, QIcon, QPixmap, QLabel)
from PyQt5.QtCore import QRect
from PyQt5.QtWidgets import (QWidget, QFileDialog, QHeaderView, QVBoxLayout, QHBoxLayout, QTreeView,
QAbstractItemView, QSpacerItem, QSizePolicy, QPushButton, QMainWindow, QMenuBar, QMenu, QLabel,
QApplication)
from PyQt5.QtGui import QPixmap, QIcon
from hscommon.trans import trget
from qtlib.recent import Recent
@@ -21,8 +22,8 @@ from .directories_model import DirectoriesModel, DirectoriesDelegate
tr = trget('ui')
class DirectoriesDialog(QMainWindow):
def __init__(self, parent, app):
QMainWindow.__init__(self, None)
def __init__(self, parent, app, **kwargs):
super().__init__(None, **kwargs)
self.app = app
self.lastAddedFolder = platform.INITIAL_FOLDER_IN_DIALOGS
self.recentFolders = Recent(self.app, 'recentFolders')
@@ -148,8 +149,8 @@ class DirectoriesDialog(QMainWindow):
def _setupColumns(self):
header = self.treeView.header()
header.setStretchLastSection(False)
header.setResizeMode(0, QHeaderView.Stretch)
header.setResizeMode(1, QHeaderView.Fixed)
header.setSectionResizeMode(0, QHeaderView.Stretch)
header.setSectionResizeMode(1, QHeaderView.Fixed)
header.resizeSection(1, 100)
def _updateAddButton(self):

View File

@@ -8,9 +8,10 @@
import urllib.parse
from PyQt4.QtCore import pyqtSignal, Qt, QRect, QUrl, QModelIndex
from PyQt4.QtGui import (QComboBox, QStyledItemDelegate, QApplication, QBrush, QStyle,
QStyleOptionComboBox, QStyleOptionViewItemV4, QItemSelection)
from PyQt5.QtCore import pyqtSignal, Qt, QRect, QUrl, QModelIndex, QItemSelection
from PyQt5.QtWidgets import (QComboBox, QStyledItemDelegate, QStyle, QStyleOptionComboBox,
QStyleOptionViewItem, QApplication)
from PyQt5.QtGui import QBrush
from hscommon.trans import trget
from qtlib.tree_model import RefNode, TreeModel
@@ -29,7 +30,7 @@ class DirectoriesDelegate(QStyledItemDelegate):
def paint(self, painter, option, index):
self.initStyleOption(option, index)
# No idea why, but this cast is required if we want to have access to the V4 valuess
option = QStyleOptionViewItemV4(option)
option = QStyleOptionViewItem(option)
if (index.column() == 1) and (option.state & QStyle.State_Selected):
cboption = QStyleOptionComboBox()
cboption.rect = option.rect
@@ -42,7 +43,7 @@ class DirectoriesDelegate(QStyledItemDelegate):
rect.setLeft(rect.left()+4)
painter.drawText(rect, Qt.AlignLeft, option.text)
else:
QStyledItemDelegate.paint(self, painter, option, index)
super().paint(painter, option, index)
def setEditorData(self, editor, index):
value = index.model().data(index, Qt.EditRole)
@@ -58,8 +59,8 @@ class DirectoriesDelegate(QStyledItemDelegate):
class DirectoriesModel(TreeModel):
def __init__(self, model, view):
TreeModel.__init__(self)
def __init__(self, model, view, **kwargs):
super().__init__(**kwargs)
self.model = model
self.model.view = self
self.view = view

View File

@@ -6,8 +6,8 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt
from PyQt4.QtGui import QDialog, QVBoxLayout, QPushButton, QTableView, QAbstractItemView
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QPushButton, QTableView, QAbstractItemView
from hscommon.trans import trget
from qtlib.util import horizontalWrap
@@ -16,9 +16,9 @@ from .ignore_list_table import IgnoreListTable
tr = trget('ui')
class IgnoreListDialog(QDialog):
def __init__(self, parent, model):
def __init__(self, parent, model, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
QDialog.__init__(self, parent, flags)
super().__init__(parent, flags, **kwargs)
self._setupUi()
self.model = model
self.model.view = self
@@ -50,5 +50,5 @@ class IgnoreListDialog(QDialog):
#--- model --> view
def show(self):
QDialog.show(self)
super().show()

View File

@@ -6,7 +6,7 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtGui import QApplication
from PyQt5.QtWidgets import QApplication
from hscommon import trans
from qtlib.preferences import Preferences as PreferencesBase

View File

@@ -6,8 +6,8 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import SIGNAL, Qt, QSize
from PyQt4.QtGui import (QDialog, QDialogButtonBox, QVBoxLayout, QHBoxLayout, QLabel, QComboBox,
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtWidgets import (QDialog, QDialogButtonBox, QVBoxLayout, QHBoxLayout, QLabel, QComboBox,
QSlider, QSizePolicy, QSpacerItem, QCheckBox, QLineEdit, QMessageBox, QSpinBox)
from hscommon.plat import ISOSX, ISLINUX
@@ -20,14 +20,14 @@ tr = trget('ui')
SUPPORTED_LANGUAGES = ['en', 'fr', 'de', 'zh_CN', 'cs', 'it', 'hy', 'ru', 'uk', 'pt_BR', 'vi']
class PreferencesDialogBase(QDialog):
def __init__(self, parent, app):
def __init__(self, parent, app, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
QDialog.__init__(self, parent, flags)
super().__init__(parent, flags, **kwargs)
self.app = app
self._setupUi()
self.connect(self.filterHardnessSlider, SIGNAL("valueChanged(int)"), self.filterHardnessLabel.setNum)
self.connect(self.buttonBox, SIGNAL('clicked(QAbstractButton*)'), self.buttonClicked)
self.filterHardnessSlider.valueChanged['int'].connect(self.filterHardnessLabel.setNum)
self.buttonBox.clicked['QAbstractButton*'].connect(self.buttonClicked)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)

View File

@@ -6,8 +6,8 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt, QMimeData, QByteArray
from PyQt4.QtGui import (QDialog, QVBoxLayout, QHBoxLayout, QPushButton, QComboBox, QListView,
from PyQt5.QtCore import Qt, QMimeData, QByteArray
from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QPushButton, QComboBox, QListView,
QDialogButtonBox, QAbstractItemView, QLabel, QStyle, QSplitter, QWidget, QSizePolicy)
from hscommon.trans import trget
@@ -52,9 +52,9 @@ class PrioritizationList(ListviewModel):
return Qt.MoveAction
class PrioritizeDialog(QDialog):
def __init__(self, parent, app):
def __init__(self, parent, app, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
QDialog.__init__(self, parent, flags)
super().__init__(parent, flags, **kwargs)
self._setupUi()
self.model = PrioritizeDialogModel(app=app.model)
self.categoryList = ComboboxModel(model=self.model.category_list, view=self.categoryCombobox)

View File

@@ -6,8 +6,8 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt
from PyQt4.QtGui import (QDialog, QVBoxLayout, QHBoxLayout, QPushButton, QSpacerItem, QSizePolicy,
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QPushButton, QSpacerItem, QSizePolicy,
QLabel, QTableView, QAbstractItemView, QApplication)
from hscommon.trans import trget
@@ -16,9 +16,9 @@ from .problem_table import ProblemTable
tr = trget('ui')
class ProblemDialog(QDialog):
def __init__(self, parent, model):
def __init__(self, parent, model, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
QDialog.__init__(self, parent, flags)
super().__init__(parent, flags, **kwargs)
self._setupUi()
self.model = model
self.model.view = self

View File

@@ -15,8 +15,8 @@ class ProblemTable(Table):
Column('msg', defaultWidth=150),
]
def __init__(self, model, view):
Table.__init__(self, model, view)
def __init__(self, model, view, **kwargs):
super().__init__(model, view, **kwargs)
# we have to prevent Return from initiating editing.
# self.view.editSelected = lambda: None

View File

@@ -6,9 +6,9 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt, QUrl, QRect
from PyQt4.QtGui import (QMainWindow, QMenu, QLabel, QDesktopServices, QFileDialog, QMenuBar,
QWidget, QVBoxLayout, QAbstractItemView, QStatusBar, QDialog, QAction, QPushButton, QCheckBox)
from PyQt5.QtCore import Qt, QRect
from PyQt5.QtWidgets import (QMainWindow, QMenu, QLabel, QFileDialog, QMenuBar, QWidget,
QVBoxLayout, QAbstractItemView, QStatusBar, QDialog, QAction, QPushButton, QCheckBox)
from hscommon.trans import trget
from qtlib.util import moveToScreenCenter, horizontalWrap, createActions
@@ -21,8 +21,8 @@ from .prioritize_dialog import PrioritizeDialog
tr = trget('ui')
class ResultWindow(QMainWindow):
def __init__(self, app):
QMainWindow.__init__(self, None)
def __init__(self, app, **kwargs):
super().__init__(None, **kwargs)
self.app = app
self._setupUi()
self.resultsModel = app.RESULT_MODEL_CLASS(self.app, self.resultsView)
@@ -163,7 +163,7 @@ class ResultWindow(QMainWindow):
self.resize(630, 514)
self.centralwidget = QWidget(self)
self.verticalLayout = QVBoxLayout(self.centralwidget)
self.verticalLayout.setMargin(0)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setSpacing(0)
self.actionsButton = QPushButton(tr("Actions"))
self.detailsButton = QPushButton(tr("Details"))
@@ -182,7 +182,7 @@ class ResultWindow(QMainWindow):
self.resultsView.verticalHeader().setVisible(False)
h = self.resultsView.horizontalHeader()
h.setHighlightSections(False)
h.setMovable(True)
h.setSectionsMovable(True)
h.setStretchLastSection(False)
h.setDefaultAlignment(Qt.AlignLeft)
self.verticalLayout.addWidget(self.resultsView)

View File

@@ -6,15 +6,16 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt, pyqtSignal
from PyQt4.QtGui import QBrush, QFont, QFontMetrics, QTableView, QColor
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtGui import QBrush, QFont, QFontMetrics, QColor
from PyQt5.QtWidgets import QTableView
from qtlib.table import Table
class ResultsModel(Table):
def __init__(self, app, view):
def __init__(self, app, view, **kwargs):
model = app.model.result_table
Table.__init__(self, model, view)
super().__init__(model, view, **kwargs)
view.horizontalHeader().setSortIndicator(1, Qt.AscendingOrder)
app.prefsChanged.connect(self.appPrefsChanged)
@@ -108,7 +109,7 @@ class ResultsView(QTableView):
if event.text() == ' ':
self.spacePressed.emit()
return
QTableView.keyPressEvent(self, event)
super().keyPressEvent(event)
def mouseDoubleClickEvent(self, event):
self.doubleClicked.emit(None)