1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 06:37:17 +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

@@ -6,18 +6,19 @@
# 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, QCoreApplication
from PyQt4.QtGui import (QDialog, QDialogButtonBox, QPixmap, QSizePolicy, QHBoxLayout, QVBoxLayout,
QLabel, QFont, QApplication)
from PyQt5.QtCore import Qt, QCoreApplication
from PyQt5.QtGui import QPixmap, QFont
from PyQt5.QtWidgets import (QDialog, QDialogButtonBox, QSizePolicy, QHBoxLayout, QVBoxLayout,
QLabel, QApplication)
from hscommon.trans import trget
tr = trget('qtlib')
class AboutBox(QDialog):
def __init__(self, parent, app):
def __init__(self, parent, app, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.MSWindowsFixedSizeDialogHint
QDialog.__init__(self, parent, flags)
super().__init__(parent, flags, **kwargs)
self.app = app
self._setupUi()

View File

@@ -7,7 +7,7 @@
# 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, QTimer, QObject
from PyQt5.QtCore import SIGNAL, QTimer, QObject
class Application(QObject):
def __init__(self):

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.QtCore import Qt
from PyQt5.QtCore import Qt
class Column:
def __init__(self, attrname, defaultWidth, editor=None, alignment=Qt.AlignLeft, cantTruncate=False):

View File

@@ -10,9 +10,10 @@ import traceback
import sys
import os
from PyQt4.QtCore import Qt, QUrl, QCoreApplication, QSize
from PyQt4.QtGui import (QDialog, QDesktopServices, QVBoxLayout, QHBoxLayout, QLabel,
QPlainTextEdit, QPushButton, QApplication)
from PyQt5.QtCore import Qt, QUrl, QCoreApplication, QSize
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QLabel, QPlainTextEdit, QPushButton,
QApplication)
from hscommon.trans import trget
from .util import horizontalSpacer
@@ -20,9 +21,9 @@ from .util import horizontalSpacer
tr = trget('qtlib')
class ErrorReportDialog(QDialog):
def __init__(self, parent, error):
def __init__(self, parent, error, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
QDialog.__init__(self, parent, flags)
super().__init__(parent, flags, **kwargs)
self._setupUi()
name = QCoreApplication.applicationName()
version = QCoreApplication.applicationVersion()
@@ -67,7 +68,7 @@ class ErrorReportDialog(QDialog):
text = self.errorTextEdit.toPlainText()
url = QUrl("mailto:support@hardcoded.net?SUBJECT=Error Report&BODY=%s" % text)
QDesktopServices.openUrl(url)
QDialog.accept(self)
super().accept()
def install_excepthook():

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.QtCore import Qt, QSettings, QRect, QPyNullVariant
from PyQt5.QtCore import Qt, QSettings, QRect
from hscommon.trans import trget
from hscommon.util import tryint
@@ -52,8 +52,6 @@ def adjust_after_deserialization(v):
return False
else:
return tryint(v, v)
if isinstance(v, QPyNullVariant):
return None
return v
# About QRect conversion:

View File

@@ -6,13 +6,13 @@
# 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, QTimer
from PyQt4.QtGui import QProgressDialog
from PyQt5.QtCore import Qt, QTimer
from PyQt5.QtWidgets import QProgressDialog
class ProgressWindow(QProgressDialog):
def __init__(self, parent, model):
def __init__(self, parent, model, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
QProgressDialog.__init__(self, '', "Cancel", 0, 100, parent, flags)
super().__init__('', "Cancel", 0, 100, parent, flags, **kwargs)
self.model = model
model.view = self
# We don't have access to QProgressDialog's labels directly, so we se the model label's view
@@ -35,7 +35,7 @@ class ProgressWindow(QProgressDialog):
def show(self):
self.reset()
QProgressDialog.show(self)
super().show()
self.canceled.connect(self.model.cancel)
self._timer.start(500)
@@ -44,5 +44,5 @@ class ProgressWindow(QProgressDialog):
# For some weird reason, canceled() signal is sent upon close, whether the user canceled
# or not. If we don't want a false cancellation, we have to disconnect it.
self.canceled.disconnect()
QProgressDialog.close(self)
super().close()

View File

@@ -5,18 +5,18 @@
# which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import pyqtSignal
from PyQt4.QtGui import QWidget, QHBoxLayout, QRadioButton
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QRadioButton
from .util import horizontalSpacer
class RadioBox(QWidget):
def __init__(self, parent=None, items=None, spread=True):
def __init__(self, parent=None, items=None, spread=True, **kwargs):
# If spread is False, insert a spacer in the layout so that the items don't use all the
# space they're given but rather align left.
if items is None:
items = []
QWidget.__init__(self, parent)
super().__init__(parent, **kwargs)
self._buttons = []
self._labels = items
self._selected_index = 0

View File

@@ -8,8 +8,8 @@
from collections import namedtuple
from PyQt4.QtCore import pyqtSignal, QObject
from PyQt4.QtGui import QAction
from PyQt5.QtCore import pyqtSignal, QObject
from PyQt5.QtWidgets import QAction
from hscommon.trans import trget
from hscommon.util import dedupe
@@ -19,8 +19,8 @@ tr = trget('qtlib')
MenuEntry = namedtuple('MenuEntry', 'menu fixedItemCount')
class Recent(QObject):
def __init__(self, app, prefName, maxItemCount=10):
QObject.__init__(self)
def __init__(self, app, prefName, maxItemCount=10, **kwargs):
super().__init__(**kwargs)
self._app = app
self._menuEntries = []
self._prefName = prefName

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 pyqtSignal, Qt
from PyQt4.QtGui import (QToolButton, QLineEdit, QIcon, QPixmap, QStyle, QStyleOptionFrameV2,
QPainter, QPalette)
from PyQt5.QtCore import pyqtSignal, Qt
from PyQt5.QtGui import QIcon, QPixmap, QPainter, QPalette
from PyQt5.QtWidgets import QToolButton, QLineEdit, QStyle, QStyleOptionFrame
from hscommon.trans import trget
@@ -18,8 +18,8 @@ tr = trget('qtlib')
# "images" folder in your resources.
class LineEditButton(QToolButton):
def __init__(self, parent):
QToolButton.__init__(self, parent)
def __init__(self, parent, **kwargs):
super().__init__(parent, **kwargs)
pixmap = QPixmap(':/search_clear_13')
self.setIcon(QIcon(pixmap))
self.setIconSize(pixmap.size())
@@ -30,9 +30,9 @@ class LineEditButton(QToolButton):
class SearchEdit(QLineEdit):
def __init__(self, parent=None, immediate=False):
def __init__(self, parent=None, immediate=False, **kwargs):
# immediate: send searchChanged signals at each keystroke.
QLineEdit.__init__(self, parent)
super().__init__(parent, **kwargs)
self._clearButton = LineEditButton(self)
frameWidth = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth)
paddingRight = self._clearButton.sizeHint().width() + frameWidth + 1
@@ -66,7 +66,7 @@ class SearchEdit(QLineEdit):
def paintEvent(self, event):
QLineEdit.paintEvent(self, event)
if not bool(self.text()) and self.inactiveText and not self.hasFocus():
panel = QStyleOptionFrameV2()
panel = QStyleOptionFrame()
self.initStyleOption(panel)
textRect = self.style().subElementRect(QStyle.SE_LineEditContents, panel, self)
leftMargin = 2

View File

@@ -6,12 +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 Qt, QAbstractListModel
from PyQt4.QtGui import QItemSelection, QItemSelectionModel
from PyQt5.QtCore import Qt, QAbstractListModel, QItemSelection, QItemSelectionModel
class SelectableList(QAbstractListModel):
def __init__(self, model, view):
QAbstractListModel.__init__(self)
def __init__(self, model, view, **kwargs):
super().__init__(**kwargs)
self._updating = False
self.view = view
self.model = model
@@ -50,8 +49,8 @@ class SelectableList(QAbstractListModel):
self._restoreSelection()
class ComboboxModel(SelectableList):
def __init__(self, model, view):
SelectableList.__init__(self, model, view)
def __init__(self, model, view, **kwargs):
super().__init__(model, view, **kwargs)
self.view.currentIndexChanged[int].connect(self.selectionChanged)
#--- Override
@@ -71,8 +70,8 @@ class ComboboxModel(SelectableList):
self._updateSelection()
class ListviewModel(SelectableList):
def __init__(self, model, view):
SelectableList.__init__(self, model, view)
def __init__(self, model, view, **kwargs):
super().__init__(model, view, **kwargs)
self.view.selectionModel().selectionChanged[(QItemSelection, QItemSelection)].connect(
self.selectionChanged)

View File

@@ -6,8 +6,7 @@
# 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, QAbstractTableModel, QModelIndex
from PyQt4.QtGui import QItemSelectionModel, QItemSelection
from PyQt5.QtCore import Qt, QAbstractTableModel, QModelIndex, QItemSelectionModel, QItemSelection
from .column import Columns
@@ -16,8 +15,8 @@ class Table(QAbstractTableModel):
INVALID_INDEX_FLAGS = Qt.ItemIsEnabled
COLUMNS = []
def __init__(self, model, view):
QAbstractTableModel.__init__(self)
def __init__(self, model, view, **kwargs):
super().__init__(**kwargs)
self.model = model
self.view = view
self.view.setModel(self)
@@ -135,7 +134,8 @@ class Table(QAbstractTableModel):
#--- model --> view
def refresh(self):
self.reset()
self.beginResetModel()
self.endResetModel()
self._updateViewSelection()
def show_selected_row(self):

View File

@@ -8,7 +8,7 @@
import logging
from PyQt4.QtCore import QAbstractItemModel, QModelIndex
from PyQt5.QtCore import QAbstractItemModel, QModelIndex
class NodeContainer:
def __init__(self):
@@ -79,9 +79,8 @@ class DummyNode(TreeNode):
pass
class TreeModel(QAbstractItemModel, NodeContainer):
def __init__(self):
QAbstractItemModel.__init__(self)
NodeContainer.__init__(self)
def __init__(self, **kwargs):
super().__init__(**kwargs)
self._dummyNodes = set() # dummy nodes' reference have to be kept to avoid segfault
#--- Private
@@ -128,10 +127,11 @@ class TreeModel(QAbstractItemModel, NodeContainer):
return self.createIndex(node.parent.row, 0, node.parent)
def reset(self):
super().beginResetModel()
self.invalidate()
self._ref2node = {}
self._dummyNodes = set()
QAbstractItemModel.reset(self)
super().endResetModel()
def rowCount(self, parent=QModelIndex()):
node = parent.internalPointer() if parent.isValid() else self

View File

@@ -14,8 +14,9 @@ import logging
from hscommon.util import first
from PyQt4.QtGui import (QDesktopWidget, QSpacerItem, QSizePolicy, QPixmap, QIcon, QAction,
QHBoxLayout, QDesktopServices)
from PyQt5.QtCore import QStandardPaths
from PyQt5.QtGui import QPixmap, QIcon
from PyQt5.QtWidgets import QDesktopWidget, QSpacerItem, QSizePolicy, QAction, QHBoxLayout
def moveToScreenCenter(widget):
frame = widget.frameGeometry()
@@ -75,7 +76,7 @@ def setAccelKeys(menu):
action.setText(newtext)
def getAppData():
return str(QDesktopServices.storageLocation(QDesktopServices.DataLocation))
return QStandardPaths.standardLocations(QStandardPaths.DataLocation)[0]
class SysWrapper(io.IOBase):
def write(self, s):