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
commit 46f8984bdc
42 changed files with 182 additions and 168 deletions

View File

@ -48,12 +48,16 @@ to be installed manually.
* All systems: [Python 3.3+][python] and [setuptools][setuptools] * All systems: [Python 3.3+][python] and [setuptools][setuptools]
* Mac OS X: The last XCode to have the 10.6 SDK included. * Mac OS X: The last XCode to have the 10.6 SDK included.
* Windows: Visual Studio 2008, [PyQt 4.7+][pyqt], [cx_Freeze][cxfreeze] and * Windows: Visual Studio 2010, [PyQt 5.0+][pyqt], [cx_Freeze][cxfreeze] and
[Advanced Installer][advinst] (you only need the last two if you want to create an installer) [Advanced Installer][advinst] (you only need the last two if you want to create an installer)
On Ubuntu, the apt-get command to install all pre-requisites is: On Ubuntu (13.10+), the apt-get command to install all pre-requisites is:
$ apt-get install python3-dev python3-pyqt4 pyqt4-dev-tools python3-setuptools $ apt-get install python3-dev python3-pyqt5 pyqt5-dev-tools
On Arch, it's:
$ pacman -S python-pyqt5
## Setting up the virtual environment ## Setting up the virtual environment

View File

@ -18,7 +18,7 @@ echo "Installing pip requirements"
if [ "$(uname)" == "Darwin" ]; then if [ "$(uname)" == "Darwin" ]; then
pip install -r requirements-osx.txt pip install -r requirements-osx.txt
else else
python3 -c "import PyQt4" >/dev/null 2>&1 || { echo >&2 "PyQt 4.8+ required. Install it and try again. Aborting"; exit 1; } python3 -c "import PyQt5" >/dev/null 2>&1 || { echo >&2 "PyQt 5.1+ required. Install it and try again. Aborting"; exit 1; }
pip install -r requirements.txt pip install -r requirements.txt
fi fi

View File

@ -149,7 +149,7 @@ def build_qt(edition, dev, conf):
print("Building localizations") print("Building localizations")
build_localizations('qt', edition) build_localizations('qt', edition)
print("Building Qt stuff") print("Building Qt stuff")
print_and_do("pyrcc4 -py3 {0} > {1}".format(op.join('qt', 'base', 'dg.qrc'), op.join('qt', 'base', 'dg_rc.py'))) print_and_do("pyrcc5 {0} > {1}".format(op.join('qt', 'base', 'dg.qrc'), op.join('qt', 'base', 'dg_rc.py')))
fix_qt_resource_file(op.join('qt', 'base', 'dg_rc.py')) fix_qt_resource_file(op.join('qt', 'base', 'dg_rc.py'))
build_help(edition) build_help(edition)
print("Creating the run.py file") print("Creating the run.py file")
@ -187,7 +187,7 @@ def build_localizations(ui, edition):
shutil.copytree('locale', locale_dest, ignore=shutil.ignore_patterns('*.po', '*.pot')) shutil.copytree('locale', locale_dest, ignore=shutil.ignore_patterns('*.po', '*.pot'))
if ui == 'qt' and not ISLINUX: if ui == 'qt' and not ISLINUX:
print("Copying qt_*.qm files into the 'locale' folder") print("Copying qt_*.qm files into the 'locale' folder")
from PyQt4.QtCore import QLibraryInfo from PyQt5.QtCore import QLibraryInfo
trfolder = QLibraryInfo.location(QLibraryInfo.TranslationsPath) trfolder = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
for lang in loc.get_langs('locale'): for lang in loc.get_langs('locale'):
qmname = 'qt_%s.qm' % lang qmname = 'qt_%s.qm' % lang

View File

@ -211,7 +211,7 @@ def copy_packages(packages_names, dest, create_links=False, extra_ignores=None):
shutil.copy(source_path, dest_path) shutil.copy(source_path, dest_path)
def copy_qt_plugins(folder_names, dest): # This is only for Windows def copy_qt_plugins(folder_names, dest): # This is only for Windows
from PyQt4.QtCore import QLibraryInfo from PyQt5.QtCore import QLibraryInfo
qt_plugin_dir = QLibraryInfo.location(QLibraryInfo.PluginsPath) qt_plugin_dir = QLibraryInfo.location(QLibraryInfo.PluginsPath)
def ignore(path, names): def ignore(path, names):
if path == qt_plugin_dir: if path == qt_plugin_dir:
@ -450,7 +450,7 @@ def collect_stdlib_dependencies(script, dest_folder, extra_deps=None):
delete_files_with_pattern(op.join(dest_folder, 'distutils'), '*.exe') delete_files_with_pattern(op.join(dest_folder, 'distutils'), '*.exe')
def fix_qt_resource_file(path): def fix_qt_resource_file(path):
# pyrcc4 under Windows, if the locale is non-english, can produce a source file with a date # pyrcc5 under Windows, if the locale is non-english, can produce a source file with a date
# containing accented characters. If it does, the encoding is wrong and it prevents the file # containing accented characters. If it does, the encoding is wrong and it prevents the file
# from being correctly frozen by cx_freeze. To work around that, we open the file, strip all # from being correctly frozen by cx_freeze. To work around that, we open the file, strip all
# comments, and save. # comments, and save.

View File

@ -61,8 +61,8 @@ try:
except ImportError: except ImportError:
try: try:
from PyQt4.QtCore import QUrl from PyQt5.QtCore import QUrl, QStandardPaths
from PyQt4.QtGui import QDesktopServices from PyQt5.QtGui import QDesktopServices
def _open_path(path): def _open_path(path):
url = QUrl.fromLocalFile(str(path)) url = QUrl.fromLocalFile(str(path))
QDesktopServices.openUrl(url) QDesktopServices.openUrl(url)
@ -72,10 +72,10 @@ except ImportError:
def _special_folder_path(special_folder, appname=None): def _special_folder_path(special_folder, appname=None):
if special_folder == SpecialFolder.Cache: if special_folder == SpecialFolder.Cache:
qtfolder = QDesktopServices.CacheLocation qtfolder = QStandardPaths.CacheLocation
else: else:
qtfolder = QDesktopServices.DataLocation qtfolder = QStandardPaths.DataLocation
return str(QDesktopServices.storageLocation(qtfolder)) return QStandardPaths.standardLocations(qtfolder)[0]
except ImportError: except ImportError:
# We're either running tests, and these functions don't matter much or we're in a really # We're either running tests, and these functions don't matter much or we're in a really

View File

@ -59,7 +59,7 @@ def get_locale_name(lang):
#--- Qt #--- Qt
def install_qt_trans(lang=None): def install_qt_trans(lang=None):
from PyQt4.QtCore import QCoreApplication, QTranslator, QLocale from PyQt5.QtCore import QCoreApplication, QTranslator, QLocale
if not lang: if not lang:
lang = str(QLocale.system().name())[:2] lang = str(QLocale.system().name())[:2]
localename = get_locale_name(lang) localename = get_locale_name(lang)
@ -116,7 +116,7 @@ def install_gettext_trans_under_qt(base_folder, lang=None):
# So, we install the gettext locale, great, but we also should try to install qt_*.qm if # So, we install the gettext locale, great, but we also should try to install qt_*.qm if
# available so that strings that are inside Qt itself over which I have no control are in the # available so that strings that are inside Qt itself over which I have no control are in the
# right language. # right language.
from PyQt4.QtCore import QCoreApplication, QTranslator, QLocale, QLibraryInfo from PyQt5.QtCore import QCoreApplication, QTranslator, QLocale, QLibraryInfo
if not lang: if not lang:
lang = str(QLocale.system().name())[:2] lang = str(QLocale.system().name())[:2]
localename = get_locale_name(lang) localename = get_locale_name(lang)

View File

@ -9,8 +9,9 @@
import sys import sys
import os.path as op import os.path as op
from PyQt4.QtCore import QTimer, QObject, QCoreApplication, QUrl, QProcess, SIGNAL, pyqtSignal from PyQt5.QtCore import QTimer, QObject, QCoreApplication, QUrl, QProcess, pyqtSignal
from PyQt4.QtGui import QDesktopServices, QFileDialog, QDialog, QMessageBox, QApplication from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QApplication, QFileDialog, QDialog, QMessageBox
from hscommon.trans import trget from hscommon.trans import trget
from hscommon.plat import ISLINUX from hscommon.plat import ISLINUX
@ -41,8 +42,8 @@ class DupeGuru(QObject):
PREFERENCES_CLASS = None PREFERENCES_CLASS = None
PREFERENCES_DIALOG_CLASS = None PREFERENCES_DIALOG_CLASS = None
def __init__(self): def __init__(self, **kwargs):
QObject.__init__(self) super().__init__(**kwargs)
self.prefs = self.PREFERENCES_CLASS() self.prefs = self.PREFERENCES_CLASS()
self.prefs.load() self.prefs.load()
self.model = self.MODELCLASS(view=self) 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 # In some circumstances, the nag is hidden by other window, which may make the user think
# that the application haven't launched. # that the application haven't launched.
QTimer.singleShot(0, self.finishedLaunching) 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): def _setupActions(self):
# Setup actions that are common to both the directory dialog and the results window. # 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 # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt4.QtGui import QDialog, QVBoxLayout, QLabel, QCheckBox, QDialogButtonBox from PyQt5.QtWidgets import QDialog, QVBoxLayout, QLabel, QCheckBox, QDialogButtonBox
from hscommon.trans import trget from hscommon.trans import trget
from qtlib.radio_box import RadioBox from qtlib.radio_box import RadioBox
@ -15,9 +15,9 @@ from qtlib.radio_box import RadioBox
tr = trget('ui') tr = trget('ui')
class DeletionOptions(QDialog): class DeletionOptions(QDialog):
def __init__(self, parent, model): def __init__(self, parent, model, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
QDialog.__init__(self, parent, flags) super().__init__(parent, flags, **kwargs)
self.model = model self.model = model
self._setupUi() self._setupUi()
self.model.view = self self.model.view = self

View File

@ -6,14 +6,14 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt4.QtGui import QDialog from PyQt5.QtWidgets import QDialog
from .details_table import DetailsModel from .details_table import DetailsModel
class DetailsDialog(QDialog): class DetailsDialog(QDialog):
def __init__(self, parent, app): def __init__(self, parent, app, **kwargs):
QDialog.__init__(self, parent, Qt.Tool) super().__init__(parent, Qt.Tool, **kwargs)
self.app = app self.app = app
self.model = app.model.details_panel self.model = app.model.details_panel
self._setupUi() self._setupUi()
@ -33,7 +33,7 @@ class DetailsDialog(QDialog):
def show(self): def show(self):
self._shown_once = True self._shown_once = True
QDialog.show(self) super().show()
#--- Events #--- Events
def appWillSavePrefs(self): def appWillSavePrefs(self):
@ -42,5 +42,6 @@ class DetailsDialog(QDialog):
#--- model --> view #--- model --> view
def refresh(self): 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 # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt, SIGNAL, QAbstractTableModel from PyQt5.QtCore import Qt, QAbstractTableModel
from PyQt4.QtGui import QHeaderView, QTableView from PyQt5.QtWidgets import QHeaderView, QTableView
from hscommon.trans import trget from hscommon.trans import trget
@ -16,8 +16,8 @@ tr = trget('ui')
HEADER = [tr("Attribute"), tr("Selected"), tr("Reference")] HEADER = [tr("Attribute"), tr("Selected"), tr("Reference")]
class DetailsModel(QAbstractTableModel): class DetailsModel(QAbstractTableModel):
def __init__(self, model): def __init__(self, model, **kwargs):
QAbstractTableModel.__init__(self) super().__init__(**kwargs)
self.model = model self.model = model
def columnCount(self, parent): def columnCount(self, parent):
@ -55,9 +55,9 @@ class DetailsTable(QTableView):
hheader.setHighlightSections(False) hheader.setHighlightSections(False)
hheader.setStretchLastSection(False) hheader.setStretchLastSection(False)
hheader.resizeSection(0, 100) hheader.resizeSection(0, 100)
hheader.setResizeMode(0, QHeaderView.Fixed) hheader.setSectionResizeMode(0, QHeaderView.Fixed)
hheader.setResizeMode(1, QHeaderView.Stretch) hheader.setSectionResizeMode(1, QHeaderView.Stretch)
hheader.setResizeMode(2, QHeaderView.Stretch) hheader.setSectionResizeMode(2, QHeaderView.Stretch)
vheader = self.verticalHeader() vheader = self.verticalHeader()
vheader.setVisible(False) vheader.setVisible(False)
vheader.setDefaultSectionSize(18) vheader.setDefaultSectionSize(18)

View File

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

View File

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

View File

@ -6,8 +6,8 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt4.QtGui import QDialog, QVBoxLayout, QPushButton, QTableView, QAbstractItemView from PyQt5.QtWidgets import QDialog, QVBoxLayout, QPushButton, QTableView, QAbstractItemView
from hscommon.trans import trget from hscommon.trans import trget
from qtlib.util import horizontalWrap from qtlib.util import horizontalWrap
@ -16,9 +16,9 @@ from .ignore_list_table import IgnoreListTable
tr = trget('ui') tr = trget('ui')
class IgnoreListDialog(QDialog): class IgnoreListDialog(QDialog):
def __init__(self, parent, model): def __init__(self, parent, model, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
QDialog.__init__(self, parent, flags) super().__init__(parent, flags, **kwargs)
self._setupUi() self._setupUi()
self.model = model self.model = model
self.model.view = self self.model.view = self
@ -50,5 +50,5 @@ class IgnoreListDialog(QDialog):
#--- model --> view #--- model --> view
def show(self): 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 # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtGui import QApplication from PyQt5.QtWidgets import QApplication
from hscommon import trans from hscommon import trans
from qtlib.preferences import Preferences as PreferencesBase 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 # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import SIGNAL, Qt, QSize from PyQt5.QtCore import Qt, QSize
from PyQt4.QtGui import (QDialog, QDialogButtonBox, QVBoxLayout, QHBoxLayout, QLabel, QComboBox, from PyQt5.QtWidgets import (QDialog, QDialogButtonBox, QVBoxLayout, QHBoxLayout, QLabel, QComboBox,
QSlider, QSizePolicy, QSpacerItem, QCheckBox, QLineEdit, QMessageBox, QSpinBox) QSlider, QSizePolicy, QSpacerItem, QCheckBox, QLineEdit, QMessageBox, QSpinBox)
from hscommon.plat import ISOSX, ISLINUX 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'] SUPPORTED_LANGUAGES = ['en', 'fr', 'de', 'zh_CN', 'cs', 'it', 'hy', 'ru', 'uk', 'pt_BR', 'vi']
class PreferencesDialogBase(QDialog): class PreferencesDialogBase(QDialog):
def __init__(self, parent, app): def __init__(self, parent, app, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
QDialog.__init__(self, parent, flags) super().__init__(parent, flags, **kwargs)
self.app = app self.app = app
self._setupUi() self._setupUi()
self.connect(self.filterHardnessSlider, SIGNAL("valueChanged(int)"), self.filterHardnessLabel.setNum) self.filterHardnessSlider.valueChanged['int'].connect(self.filterHardnessLabel.setNum)
self.connect(self.buttonBox, SIGNAL('clicked(QAbstractButton*)'), self.buttonClicked) self.buttonBox.clicked['QAbstractButton*'].connect(self.buttonClicked)
self.buttonBox.accepted.connect(self.accept) self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject) 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 # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt, QMimeData, QByteArray from PyQt5.QtCore import Qt, QMimeData, QByteArray
from PyQt4.QtGui import (QDialog, QVBoxLayout, QHBoxLayout, QPushButton, QComboBox, QListView, from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QPushButton, QComboBox, QListView,
QDialogButtonBox, QAbstractItemView, QLabel, QStyle, QSplitter, QWidget, QSizePolicy) QDialogButtonBox, QAbstractItemView, QLabel, QStyle, QSplitter, QWidget, QSizePolicy)
from hscommon.trans import trget from hscommon.trans import trget
@ -52,9 +52,9 @@ class PrioritizationList(ListviewModel):
return Qt.MoveAction return Qt.MoveAction
class PrioritizeDialog(QDialog): class PrioritizeDialog(QDialog):
def __init__(self, parent, app): def __init__(self, parent, app, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
QDialog.__init__(self, parent, flags) super().__init__(parent, flags, **kwargs)
self._setupUi() self._setupUi()
self.model = PrioritizeDialogModel(app=app.model) self.model = PrioritizeDialogModel(app=app.model)
self.categoryList = ComboboxModel(model=self.model.category_list, view=self.categoryCombobox) 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 # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt4.QtGui import (QDialog, QVBoxLayout, QHBoxLayout, QPushButton, QSpacerItem, QSizePolicy, from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QHBoxLayout, QPushButton, QSpacerItem, QSizePolicy,
QLabel, QTableView, QAbstractItemView, QApplication) QLabel, QTableView, QAbstractItemView, QApplication)
from hscommon.trans import trget from hscommon.trans import trget
@ -16,9 +16,9 @@ from .problem_table import ProblemTable
tr = trget('ui') tr = trget('ui')
class ProblemDialog(QDialog): class ProblemDialog(QDialog):
def __init__(self, parent, model): def __init__(self, parent, model, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
QDialog.__init__(self, parent, flags) super().__init__(parent, flags, **kwargs)
self._setupUi() self._setupUi()
self.model = model self.model = model
self.model.view = self self.model.view = self

View File

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

View File

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

View File

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

View File

@ -6,8 +6,8 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import QSize from PyQt5.QtCore import QSize
from PyQt4.QtGui import QVBoxLayout, QAbstractItemView from PyQt5.QtWidgets import QVBoxLayout, QAbstractItemView
from hscommon.trans import trget from hscommon.trans import trget
from ..base.details_dialog import DetailsDialog as DetailsDialogBase from ..base.details_dialog import DetailsDialog as DetailsDialogBase
@ -22,7 +22,7 @@ class DetailsDialog(DetailsDialogBase):
self.setMinimumSize(QSize(250, 250)) self.setMinimumSize(QSize(250, 250))
self.verticalLayout = QVBoxLayout(self) self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setSpacing(0) self.verticalLayout.setSpacing(0)
self.verticalLayout.setMargin(0) self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.tableView = DetailsTable(self) self.tableView = DetailsTable(self)
self.tableView.setAlternatingRowColors(True) self.tableView.setAlternatingRowColors(True)
self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows) self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)

View File

@ -7,8 +7,8 @@
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
import sys import sys
from PyQt4.QtCore import QSize from PyQt5.QtCore import QSize
from PyQt4.QtGui import (QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QSpacerItem, QWidget, from PyQt5.QtWidgets import (QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QSpacerItem, QWidget,
QApplication) QApplication)
from hscommon.trans import trget from hscommon.trans import trget
@ -50,7 +50,7 @@ class PreferencesDialog(PreferencesDialogBase):
self.widget.setMinimumSize(QSize(0, 40)) self.widget.setMinimumSize(QSize(0, 40))
self.verticalLayout_4 = QVBoxLayout(self.widget) self.verticalLayout_4 = QVBoxLayout(self.widget)
self.verticalLayout_4.setSpacing(0) self.verticalLayout_4.setSpacing(0)
self.verticalLayout_4.setMargin(0) self.verticalLayout_4.setContentsMargins(0, 0, 0, 0)
self.label_6 = QLabel(self.widget) self.label_6 = QLabel(self.widget)
self.label_6.setText(tr("Tags to scan:")) self.label_6.setText(tr("Tags to scan:"))
self.verticalLayout_4.addWidget(self.label_6) self.verticalLayout_4.addWidget(self.label_6)

View File

@ -8,7 +8,7 @@
import logging import logging
from PyQt4.QtGui import QImage, QImageReader, QTransform from PyQt5.QtGui import QImage, QImageReader, QTransform
from core_pe import __appname__ from core_pe import __appname__
from core_pe.photo import Photo as PhotoBase from core_pe.photo import Photo as PhotoBase

View File

@ -6,8 +6,9 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt, QSize from PyQt5.QtCore import Qt, QSize
from PyQt4.QtGui import QVBoxLayout, QAbstractItemView, QHBoxLayout, QLabel, QSizePolicy, QPixmap from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QVBoxLayout, QAbstractItemView, QHBoxLayout, QLabel, QSizePolicy
from hscommon.trans import trget from hscommon.trans import trget
from ..base.details_dialog import DetailsDialog as DetailsDialogBase from ..base.details_dialog import DetailsDialog as DetailsDialogBase
@ -27,7 +28,7 @@ class DetailsDialog(DetailsDialogBase):
self.setMinimumSize(QSize(250, 250)) self.setMinimumSize(QSize(250, 250))
self.verticalLayout = QVBoxLayout(self) self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setSpacing(0) self.verticalLayout.setSpacing(0)
self.verticalLayout.setMargin(0) self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout = QHBoxLayout() self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setSpacing(4) self.horizontalLayout.setSpacing(4)
self.selectedImage = QLabel(self) self.selectedImage = QLabel(self)

View File

@ -7,7 +7,7 @@
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
import sys import sys
from PyQt4.QtGui import QApplication from PyQt5.QtWidgets import QApplication
from hscommon.trans import trget from hscommon.trans import trget
from core.scanner import ScanType from core.scanner import ScanType

View File

@ -6,7 +6,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtGui import QMessageBox, QAction from PyQt5.QtWidgets import QMessageBox, QAction
from hscommon.trans import trget from hscommon.trans import trget
from ..base.result_window import ResultWindow as ResultWindowBase from ..base.result_window import ResultWindow as ResultWindowBase

View File

@ -8,8 +8,9 @@
import sys import sys
import os.path as op import os.path as op
from PyQt4.QtCore import QCoreApplication, QSettings from PyQt5.QtCore import QCoreApplication, QSettings
from PyQt4.QtGui import QApplication, QIcon, QPixmap from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtWidgets import QApplication
from hscommon.plat import ISWINDOWS from hscommon.plat import ISWINDOWS
from hscommon.trans import install_gettext_trans_under_qt from hscommon.trans import install_gettext_trans_under_qt
@ -22,7 +23,7 @@ from core_{edition} import __version__, __appname__
if ISWINDOWS: if ISWINDOWS:
import qt.base.cxfreeze_fix import qt.base.cxfreeze_fix
if __name__ == "__main__": def main():
app = QApplication(sys.argv) app = QApplication(sys.argv)
QCoreApplication.setOrganizationName('Hardcoded Software') QCoreApplication.setOrganizationName('Hardcoded Software')
QCoreApplication.setApplicationName(__appname__) QCoreApplication.setApplicationName(__appname__)
@ -38,4 +39,7 @@ if __name__ == "__main__":
app.setWindowIcon(QIcon(QPixmap(":/{0}".format(DupeGuru.LOGO_NAME)))) app.setWindowIcon(QIcon(QPixmap(":/{0}".format(DupeGuru.LOGO_NAME))))
dgapp = DupeGuru() dgapp = DupeGuru()
install_excepthook() install_excepthook()
sys.exit(app.exec_()) return app.exec()
if __name__ == "__main__":
sys.exit(main())

View File

@ -6,8 +6,8 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import QSize from PyQt5.QtCore import QSize
from PyQt4.QtGui import QVBoxLayout, QAbstractItemView from PyQt5.QtWidgets import QVBoxLayout, QAbstractItemView
from hscommon.trans import trget from hscommon.trans import trget
from ..base.details_dialog import DetailsDialog as DetailsDialogBase from ..base.details_dialog import DetailsDialog as DetailsDialogBase
@ -22,7 +22,7 @@ class DetailsDialog(DetailsDialogBase):
self.setMinimumSize(QSize(200, 0)) self.setMinimumSize(QSize(200, 0))
self.verticalLayout = QVBoxLayout(self) self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setSpacing(0) self.verticalLayout.setSpacing(0)
self.verticalLayout.setMargin(0) self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.tableView = DetailsTable(self) self.tableView = DetailsTable(self)
self.tableView.setAlternatingRowColors(True) self.tableView.setAlternatingRowColors(True)
self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows) self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)

View File

@ -7,8 +7,8 @@
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
import sys import sys
from PyQt4.QtCore import QSize from PyQt5.QtCore import QSize
from PyQt4.QtGui import (QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QSpacerItem, QWidget, from PyQt5.QtWidgets import (QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QSpacerItem, QWidget,
QLineEdit, QApplication) QLineEdit, QApplication)
from hscommon.plat import ISWINDOWS, ISLINUX from hscommon.plat import ISWINDOWS, ISLINUX
@ -29,8 +29,8 @@ SCAN_TYPE_ORDER = [
] ]
class PreferencesDialog(PreferencesDialogBase): class PreferencesDialog(PreferencesDialogBase):
def __init__(self, parent, app): def __init__(self, parent, app, **kwargs):
PreferencesDialogBase.__init__(self, parent, app) super().__init__(parent, app, **kwargs)
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged) self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)

View File

@ -6,18 +6,19 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt, QCoreApplication from PyQt5.QtCore import Qt, QCoreApplication
from PyQt4.QtGui import (QDialog, QDialogButtonBox, QPixmap, QSizePolicy, QHBoxLayout, QVBoxLayout, from PyQt5.QtGui import QPixmap, QFont
QLabel, QFont, QApplication) from PyQt5.QtWidgets import (QDialog, QDialogButtonBox, QSizePolicy, QHBoxLayout, QVBoxLayout,
QLabel, QApplication)
from hscommon.trans import trget from hscommon.trans import trget
tr = trget('qtlib') tr = trget('qtlib')
class AboutBox(QDialog): class AboutBox(QDialog):
def __init__(self, parent, app): def __init__(self, parent, app, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.MSWindowsFixedSizeDialogHint flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.MSWindowsFixedSizeDialogHint
QDialog.__init__(self, parent, flags) super().__init__(parent, flags, **kwargs)
self.app = app self.app = app
self._setupUi() self._setupUi()

View File

@ -7,7 +7,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import SIGNAL, QTimer, QObject from PyQt5.QtCore import SIGNAL, QTimer, QObject
class Application(QObject): class Application(QObject):
def __init__(self): def __init__(self):

View File

@ -6,7 +6,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt from PyQt5.QtCore import Qt
class Column: class Column:
def __init__(self, attrname, defaultWidth, editor=None, alignment=Qt.AlignLeft, cantTruncate=False): def __init__(self, attrname, defaultWidth, editor=None, alignment=Qt.AlignLeft, cantTruncate=False):

View File

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

View File

@ -6,7 +6,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # 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.trans import trget
from hscommon.util import tryint from hscommon.util import tryint
@ -52,8 +52,6 @@ def adjust_after_deserialization(v):
return False return False
else: else:
return tryint(v, v) return tryint(v, v)
if isinstance(v, QPyNullVariant):
return None
return v return v
# About QRect conversion: # About QRect conversion:

View File

@ -6,13 +6,13 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt, QTimer from PyQt5.QtCore import Qt, QTimer
from PyQt4.QtGui import QProgressDialog from PyQt5.QtWidgets import QProgressDialog
class ProgressWindow(QProgressDialog): class ProgressWindow(QProgressDialog):
def __init__(self, parent, model): def __init__(self, parent, model, **kwargs):
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint 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 self.model = model
model.view = self model.view = self
# We don't have access to QProgressDialog's labels directly, so we se the model label's view # 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): def show(self):
self.reset() self.reset()
QProgressDialog.show(self) super().show()
self.canceled.connect(self.model.cancel) self.canceled.connect(self.model.cancel)
self._timer.start(500) 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 # 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. # or not. If we don't want a false cancellation, we have to disconnect it.
self.canceled.disconnect() 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 # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import pyqtSignal from PyQt5.QtCore import pyqtSignal
from PyQt4.QtGui import QWidget, QHBoxLayout, QRadioButton from PyQt5.QtWidgets import QWidget, QHBoxLayout, QRadioButton
from .util import horizontalSpacer from .util import horizontalSpacer
class RadioBox(QWidget): 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 # 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. # space they're given but rather align left.
if items is None: if items is None:
items = [] items = []
QWidget.__init__(self, parent) super().__init__(parent, **kwargs)
self._buttons = [] self._buttons = []
self._labels = items self._labels = items
self._selected_index = 0 self._selected_index = 0

View File

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

View File

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

View File

@ -6,12 +6,11 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt, QAbstractListModel from PyQt5.QtCore import Qt, QAbstractListModel, QItemSelection, QItemSelectionModel
from PyQt4.QtGui import QItemSelection, QItemSelectionModel
class SelectableList(QAbstractListModel): class SelectableList(QAbstractListModel):
def __init__(self, model, view): def __init__(self, model, view, **kwargs):
QAbstractListModel.__init__(self) super().__init__(**kwargs)
self._updating = False self._updating = False
self.view = view self.view = view
self.model = model self.model = model
@ -50,8 +49,8 @@ class SelectableList(QAbstractListModel):
self._restoreSelection() self._restoreSelection()
class ComboboxModel(SelectableList): class ComboboxModel(SelectableList):
def __init__(self, model, view): def __init__(self, model, view, **kwargs):
SelectableList.__init__(self, model, view) super().__init__(model, view, **kwargs)
self.view.currentIndexChanged[int].connect(self.selectionChanged) self.view.currentIndexChanged[int].connect(self.selectionChanged)
#--- Override #--- Override
@ -71,8 +70,8 @@ class ComboboxModel(SelectableList):
self._updateSelection() self._updateSelection()
class ListviewModel(SelectableList): class ListviewModel(SelectableList):
def __init__(self, model, view): def __init__(self, model, view, **kwargs):
SelectableList.__init__(self, model, view) super().__init__(model, view, **kwargs)
self.view.selectionModel().selectionChanged[(QItemSelection, QItemSelection)].connect( self.view.selectionModel().selectionChanged[(QItemSelection, QItemSelection)].connect(
self.selectionChanged) self.selectionChanged)

View File

@ -6,8 +6,7 @@
# which should be included with this package. The terms are also available at # which should be included with this package. The terms are also available at
# http://www.hardcoded.net/licenses/bsd_license # http://www.hardcoded.net/licenses/bsd_license
from PyQt4.QtCore import Qt, QAbstractTableModel, QModelIndex from PyQt5.QtCore import Qt, QAbstractTableModel, QModelIndex, QItemSelectionModel, QItemSelection
from PyQt4.QtGui import QItemSelectionModel, QItemSelection
from .column import Columns from .column import Columns
@ -16,8 +15,8 @@ class Table(QAbstractTableModel):
INVALID_INDEX_FLAGS = Qt.ItemIsEnabled INVALID_INDEX_FLAGS = Qt.ItemIsEnabled
COLUMNS = [] COLUMNS = []
def __init__(self, model, view): def __init__(self, model, view, **kwargs):
QAbstractTableModel.__init__(self) super().__init__(**kwargs)
self.model = model self.model = model
self.view = view self.view = view
self.view.setModel(self) self.view.setModel(self)
@ -135,7 +134,8 @@ class Table(QAbstractTableModel):
#--- model --> view #--- model --> view
def refresh(self): def refresh(self):
self.reset() self.beginResetModel()
self.endResetModel()
self._updateViewSelection() self._updateViewSelection()
def show_selected_row(self): def show_selected_row(self):

View File

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

View File

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