[PATCH] qtcompat: replace most enum references with fully qualified names for PyQt6

695 views
Skip to first unread message

Matt Harbison

unread,
Apr 4, 2022, 8:02:44 PM4/4/22
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1649086340 14400
# Mon Apr 04 11:32:20 2022 -0400
# Node ID abcb33e2ccdc60bc7e279f6d5378a7bd263e43ea
# Parent f1e47bf79221fb84cc22b058f33ec74f41cca211
# EXP-Topic pyqt6
qtcompat: replace most enum references with fully qualified names for PyQt6

Unfortunately this isn't everything because the replacement is done via pattern,
matching, and there are cases where the subclass is used as the prefix and
others where the class was assigned to a local variable and then used (to
shorten the line?). There are 102 enum classes affected, so I don't see a good
way to split this up for review, but enabling word diff helps a lot.

The other thing to note here is that I saved off all of the fully qualified
names that were changed, to a file, and scripted importing and printing them all
with PyQt 5.13.2/Qt 5.9.9 (which is used for both Windows and macOS builds).
Everything imported fine except `QLibraryInfo.LibraryPath.PluginsPath`, so that
is conditionalized in `qtapp.py` (and commented in `setup.py` for when it gets
modified to support PyQt6).

The changes were made by running this script on the PyQt6 *.pyi files...

```
import sys
import pathlib
from typed_ast import ast3


def add_parents(tree):
for node in ast3.walk(tree):
for child in ast.iter_child_nodes(node):
child.parent = node


def find_enums(tree):
for node in ast3.walk(tree):
if not isinstance(node, ast3.Assign):
continue
if node.type_comment is None:
continue
if '.' not in node.type_comment:
continue
#if not node.type_comment.startswith("'"):
if node.type_comment.startswith("typing."):
continue
comment = node.type_comment.strip("'")
mod, cls = comment.rsplit(".", maxsplit=1)
assert len(node.targets) == 1
name = node.targets[0].id
yield (mod, cls, name)


def main():
for filename in sys.argv[1:]:
tree = ast3.parse(pathlib.Path(filename).read_text())
for mod, cls, name in find_enums(tree):
old = f"{mod}.{name}"
new = f"{mod}.{cls}.{name}"
print(f"{old} {new}")


if __name__ == '__main__':
main()
```

... and then running this on `hg files 'set:**.py or grep(r"^#!.*?python")'` ...

```
import pathlib
import sys
import re

script_path = pathlib.Path(__file__).parent

replacements = []
with (script_path / 'enums.txt').open() as f:
for line in f:
orig, replacement = line.split()
orig_re = re.compile(re.escape(orig) + r'(?=\W)')
replacements.append((orig_re, replacement))


for filename in sys.argv[1:]:
path = pathlib.Path(filename)
content = path.read_text()
print(filename)
for orig_re, replacement in replacements:
content = orig_re.sub(replacement, content)
path.write_text(content)
```

diff --git a/contrib/thgdebugtools/dbgutil.py b/contrib/thgdebugtools/dbgutil.py
--- a/contrib/thgdebugtools/dbgutil.py
+++ b/contrib/thgdebugtools/dbgutil.py
@@ -79,7 +79,7 @@

def _getText(self, title, label, text=None):
newtext, ok = QInputDialog.getText(self._parentWidget(), title, label,
- QLineEdit.Normal, text or '')
+ QLineEdit.EchoMode.Normal, text or '')
if ok:
return pycompat.unicode(newtext)

diff --git a/contrib/thgdebugtools/widgets.py b/contrib/thgdebugtools/widgets.py
--- a/contrib/thgdebugtools/widgets.py
+++ b/contrib/thgdebugtools/widgets.py
@@ -160,9 +160,9 @@

self._buttonBox = bbox = QDialogButtonBox(self)
self.layout().addWidget(bbox)
- b = bbox.addButton('&Show Widget', QDialogButtonBox.ActionRole)
+ b = bbox.addButton('&Show Widget', QDialogButtonBox.ButtonRole.ActionRole)
b.clicked.connect(self.showWidget)
- b = bbox.addButton('&Destroy', QDialogButtonBox.ResetRole)
+ b = bbox.addButton('&Destroy', QDialogButtonBox.ButtonRole.ResetRole)
b.clicked.connect(self.deleteWidget)
b.setAutoDefault(False)

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -413,6 +413,7 @@
os.path.dirname(PyQt4.__file__), 'translations')
else:
from PyQt4.QtCore import QLibraryInfo
+ # TODO: use QLibraryInfo.LibraryPath.TranslationsPath with PyQt6
trpath = unicode(
QLibraryInfo.location(QLibraryInfo.TranslationsPath))
else:
@@ -422,6 +423,8 @@
os.path.dirname(PyQt5.__file__), 'translations')
else:
from PyQt5.QtCore import QLibraryInfo
+ # QLibraryInfo.LibraryPath.PluginsPath is not available with
+ # PyQt 5.13.2/Qt 5.9.9
trpath = unicode(
QLibraryInfo.location(QLibraryInfo.TranslationsPath))
builddir = os.path.join(self.get_finalized_command('build').build_base,
@@ -576,6 +579,8 @@

def qt5_plugins(subdir, *dlls):
from PyQt5.QtCore import QLibraryInfo
+ # QLibraryInfo.LibraryPath.PluginsPath is not available with
+ # PyQt 5.13.2/Qt 5.9.9
pluginsdir = QLibraryInfo.location(QLibraryInfo.PluginsPath)
# py2 somehow mangles the path generated here in the form of
# C:/Qt/Qt5.9.9/5.9.9/msvc2017_64/plugins\\platforms\\qwindows.dll
@@ -661,6 +666,8 @@

def qt5_plugins(subdir, *dlls):
from PyQt5.QtCore import QLibraryInfo
+ # QLibraryInfo.LibraryPath.PluginsPath is not available with
+ # PyQt 5.13.2/Qt 5.9.9
pluginsdir = QLibraryInfo.location(QLibraryInfo.PluginsPath)
return subdir, [os.path.join(pluginsdir, subdir, e) for e in dlls]

diff --git a/tests/pytesthgenv.py b/tests/pytesthgenv.py
--- a/tests/pytesthgenv.py
+++ b/tests/pytesthgenv.py
@@ -120,8 +120,8 @@
# settings will be saved at $HGTMP/.config/TortoiseHg/TortoiseHgQt.ini
self._qapp.setApplicationName('TortoiseHgQt')
self._qapp.setOrganizationName('TortoiseHg')
- QSettings.setDefaultFormat(QSettings.IniFormat)
- QSettings.setPath(QSettings.IniFormat, QSettings.UserScope,
+ QSettings.setDefaultFormat(QSettings.Format.IniFormat)
+ QSettings.setPath(QSettings.Format.IniFormat, QSettings.Scope.UserScope,
self.configdir)

def pytest_sessionfinish(self):
diff --git a/tests/qt_manifestmodel_test.py b/tests/qt_manifestmodel_test.py
--- a/tests/qt_manifestmodel_test.py
+++ b/tests/qt_manifestmodel_test.py
@@ -159,8 +159,8 @@
def test_drag_flag(self):
m = self.new_model(0)
# only files are drag enabled
- self.assertTrue(m.flags(m.indexFromPath('foo')) & Qt.ItemIsDragEnabled)
- self.assertFalse(m.flags(m.indexFromPath('baz')) & Qt.ItemIsDragEnabled)
+ self.assertTrue(m.flags(m.indexFromPath('foo')) & Qt.ItemFlag.ItemIsDragEnabled)
+ self.assertFalse(m.flags(m.indexFromPath('baz')) & Qt.ItemFlag.ItemIsDragEnabled)

def test_isdir(self):
m = self.new_model(3)
@@ -455,7 +455,7 @@
m.setRawContext(repo[1])
self.assertEqual(1, m.rev())
# should not fall back to patch handler
- self.assertTrue(m.flags(m.indexFromPath('foo')) & Qt.ItemIsDragEnabled)
+ self.assertTrue(m.flags(m.indexFromPath('foo')) & Qt.ItemFlag.ItemIsDragEnabled)

def test_change_base_rev(self):
m = self.new_model(10)
@@ -535,7 +535,7 @@

def test_no_drag_flag(self):
m = self.new_model(b'patch0.diff')
- self.assertFalse(m.flags(m.indexFromPath('foo')) & Qt.ItemIsDragEnabled)
+ self.assertFalse(m.flags(m.indexFromPath('foo')) & Qt.ItemFlag.ItemIsDragEnabled)

def test_status(self):
m = self.new_model(b'patch0.diff')
diff --git a/tests/qt_patchqueuemodel_test.py b/tests/qt_patchqueuemodel_test.py
--- a/tests/qt_patchqueuemodel_test.py
+++ b/tests/qt_patchqueuemodel_test.py
@@ -53,7 +53,7 @@

def indexForPatch(self, patch):
m = self.model
- indexes = m.match(m.index(0, 0), Qt.EditRole, patch)
+ indexes = m.match(m.index(0, 0), Qt.ItemDataRole.EditRole, patch)
return indexes[0]

def wait(self, timeout=5000):
@@ -81,9 +81,9 @@
def test_tooltip(self):
m = self.model
self.assertEqual('foo.diff: no guards\nfoo patch',
- m.data(self.indexForPatch('foo.diff'), Qt.ToolTipRole))
+ m.data(self.indexForPatch('foo.diff'), Qt.ItemDataRole.ToolTipRole))
self.assertEqual('bar.diff: +debug, -release\n',
- m.data(self.indexForPatch('bar.diff'), Qt.ToolTipRole))
+ m.data(self.indexForPatch('bar.diff'), Qt.ItemDataRole.ToolTipRole))

def test_patchguards(self):
m = self.model
@@ -95,7 +95,7 @@
m = self.model
s = QItemSelectionModel(m)
s.setCurrentIndex(self.indexForPatch('bar.diff'),
- QItemSelectionModel.SelectCurrent)
+ QItemSelectionModel.SelectionFlag.SelectCurrent)
time.sleep(self.mtimedelay) # qdelete does not obtain lock
self.hg.qdelete(b'baz.diff') # delete first row
self.repoagent.pollStatus()
@@ -106,7 +106,7 @@
m = self.model
s = QItemSelectionModel(m)
s.setCurrentIndex(self.indexForPatch('bar.diff'),
- QItemSelectionModel.SelectCurrent)
+ QItemSelectionModel.SelectionFlag.SelectCurrent)
time.sleep(self.mtimedelay) # qdelete does not obtain lock
self.hg.qdelete(b'bar.diff')
self.repoagent.pollStatus()
@@ -117,7 +117,7 @@
m = self.model
s = QItemSelectionModel(m)
s.setCurrentIndex(self.indexForPatch('bar.diff'),
- QItemSelectionModel.SelectCurrent)
+ QItemSelectionModel.SelectionFlag.SelectCurrent)
time.sleep(self.mtimedelay) # qrename does not obtain lock
self.hg.qrename(b'bar.diff', b'bar2.diff')
self.repoagent.pollStatus()
@@ -128,7 +128,7 @@
m = self.model
s = QItemSelectionModel(m)
s.setCurrentIndex(self.indexForPatch('baz.diff'),
- QItemSelectionModel.SelectCurrent)
+ QItemSelectionModel.SelectionFlag.SelectCurrent)
time.sleep(self.mtimedelay) # qdelete/qrename does not obtain lock
self.hg.qdelete(b'bar.diff')
self.hg.qrename(b'baz.diff', b'baz1.diff')
@@ -139,7 +139,7 @@
def test_dnd_into_top(self):
m = self.model
data = m.mimeData([self.indexForPatch('foo.diff')])
- r = m.dropMimeData(data, Qt.MoveAction, 0, 0, QModelIndex())
+ r = m.dropMimeData(data, Qt.DropAction.MoveAction, 0, 0, QModelIndex())
self.assertTrue(r)
self.wait()
self.assertEqual('foo.diff', m.patchName(m.index(0, 0)))
@@ -147,7 +147,7 @@
def test_dnd_into_bottom(self):
m = self.model
data = m.mimeData([self.indexForPatch('baz.diff')])
- r = m.dropMimeData(data, Qt.MoveAction, m.rowCount(), 0, QModelIndex())
+ r = m.dropMimeData(data, Qt.DropAction.MoveAction, m.rowCount(), 0, QModelIndex())
self.assertTrue(r)
self.wait()
self.assertEqual('baz.diff', m.patchName(m.index(m.rowCount() - 1, 0)))
@@ -157,5 +157,5 @@
self.repoagent.pollStatus()
m = self.model
data = m.mimeData([self.indexForPatch('baz.diff')])
- r = m.dropMimeData(data, Qt.MoveAction, m.rowCount(), 0, QModelIndex())
+ r = m.dropMimeData(data, Qt.DropAction.MoveAction, m.rowCount(), 0, QModelIndex())
self.assertFalse(r)
diff --git a/tortoisehg/hgqt/about.py b/tortoisehg/hgqt/about.py
--- a/tortoisehg/hgqt/about.py
+++ b/tortoisehg/hgqt/about.py
@@ -54,7 +54,7 @@

self.setWindowIcon(qtlib.geticon('thg'))
self.setWindowTitle(_('About'))
- self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
+ self.setWindowFlags(self.windowFlags() & ~Qt.WindowType.WindowContextHelpButtonHint)

self.vbox = QVBoxLayout()
self.vbox.setSpacing(8)
@@ -62,33 +62,33 @@
self.logo_lbl = QLabel()
self.logo_lbl.setMinimumSize(QSize(92, 50))
self.logo_lbl.setScaledContents(False)
- self.logo_lbl.setAlignment(Qt.AlignCenter)
+ self.logo_lbl.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.logo_lbl.setPixmap(QPixmap(qtlib.iconpath('thg_logo_92x50.png')))
self.vbox.addWidget(self.logo_lbl)

self.name_version_libs_lbl = QLabel()
self.name_version_libs_lbl.setText(' ')
- self.name_version_libs_lbl.setAlignment(Qt.AlignCenter)
+ self.name_version_libs_lbl.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.name_version_libs_lbl.setTextInteractionFlags(
- Qt.TextSelectableByMouse)
+ Qt.TextInteractionFlag.TextSelectableByMouse)
self.vbox.addWidget(self.name_version_libs_lbl)
self.getVersionInfo()

self.copyright_lbl = QLabel()
- self.copyright_lbl.setAlignment(Qt.AlignCenter)
+ self.copyright_lbl.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.copyright_lbl.setText('\n'
+ _('Copyright 2008-2021 Steve Borho and others'))
self.vbox.addWidget(self.copyright_lbl)
self.courtesy_lbl = QLabel()
- self.courtesy_lbl.setAlignment(Qt.AlignCenter)
+ self.courtesy_lbl.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.courtesy_lbl.setText(
_('Several icons are courtesy of the TortoiseSVN and Tango projects') + '\n')
self.vbox.addWidget(self.courtesy_lbl)

self.download_url_lbl = QLabel()
self.download_url_lbl.setMouseTracking(True)
- self.download_url_lbl.setAlignment(Qt.AlignCenter)
- self.download_url_lbl.setTextInteractionFlags(Qt.LinksAccessibleByMouse)
+ self.download_url_lbl.setAlignment(Qt.AlignmentFlag.AlignCenter)
+ self.download_url_lbl.setTextInteractionFlags(Qt.TextInteractionFlag.LinksAccessibleByMouse)
self.download_url_lbl.setOpenExternalLinks(True)
self.download_url_lbl.setText('<a href=%s>%s</a>' %
('https://tortoisehg.bitbucket.io',
@@ -99,7 +99,7 @@
self.vbox.addWidget(QLabel())

self.hosting_lbl = QLabel()
- self.hosting_lbl.setAlignment(Qt.AlignCenter)
+ self.hosting_lbl.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.hosting_lbl.setText(
_('Hosting donated by %s and %s') % (
'<a href=https://clever-cloud.com>Clever Cloud</a>',
@@ -108,7 +108,7 @@
)
self.hosting_lbl.setMouseTracking(True)
self.hosting_lbl.setTextInteractionFlags(
- Qt.LinksAccessibleByMouse
+ Qt.TextInteractionFlag.LinksAccessibleByMouse
)
self.hosting_lbl.setOpenExternalLinks(True)
self.vbox.addWidget(self.hosting_lbl)
@@ -119,16 +119,16 @@

bbox = QDialogButtonBox(self)
self.license_btn = bbox.addButton(_('&License'),
- QDialogButtonBox.ResetRole)
+ QDialogButtonBox.ButtonRole.ResetRole)
self.license_btn.setAutoDefault(False)
self.license_btn.clicked.connect(self.showLicense)
- self.close_btn = bbox.addButton(QDialogButtonBox.Close)
+ self.close_btn = bbox.addButton(QDialogButtonBox.StandardButton.Close)
self.close_btn.setDefault(True)
self.close_btn.clicked.connect(self.close)
self.vbox.addWidget(bbox)

self.setLayout(self.vbox)
- self.layout().setSizeConstraint(QLayout.SetFixedSize)
+ self.layout().setSizeConstraint(QLayout.SizeConstraint.SetFixedSize)
self._readsettings()

# Spawn it later, so that the dialog gets visible quickly.
@@ -184,13 +184,13 @@

self.setWindowIcon(qtlib.geticon('thg'))
self.setWindowTitle(_('License'))
- self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
+ self.setWindowFlags(self.windowFlags() & ~Qt.WindowType.WindowContextHelpButtonHint)
self.resize(700, 400)

self.lic_txt = QPlainTextEdit()
self.lic_txt.setFont(QFont('Monospace'))
self.lic_txt.setTextInteractionFlags(
- Qt.TextSelectableByKeyboard|Qt.TextSelectableByMouse)
+ Qt.TextInteractionFlag.TextSelectableByKeyboard|Qt.TextInteractionFlag.TextSelectableByMouse)
try:
with open(paths.get_license_path(), 'r') as fp:
lic = fp.read()
@@ -199,7 +199,7 @@
pass

bbox = QDialogButtonBox(self)
- self.close_btn = bbox.addButton(QDialogButtonBox.Close)
+ self.close_btn = bbox.addButton(QDialogButtonBox.StandardButton.Close)
self.close_btn.clicked.connect(self.close)

self.vbox = QVBoxLayout()
diff --git a/tortoisehg/hgqt/archive.py b/tortoisehg/hgqt/archive.py
--- a/tortoisehg/hgqt/archive.py
+++ b/tortoisehg/hgqt/archive.py
@@ -82,7 +82,7 @@
def __init__(self, repoagent, rev, parent=None, minrev=None):
# type: (thgrepo.RepoAgent, Optional[Text], Optional[QWidget], Optional[Text]) -> None
super(ArchiveWidget, self).__init__(parent)
- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self._repoagent = repoagent
if not minrev:
minrev = rev
@@ -108,7 +108,7 @@
## revision selection
self.rev_combo = QComboBox()
self.rev_combo.setEditable(True)
- self.rev_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
+ self.rev_combo.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToContents)
form.addRow(_('Revision:'), self.rev_combo)

### content type
@@ -127,7 +127,7 @@
sincebox = QHBoxLayout()
self.rootrev_combo = QComboBox(self)
self.rootrev_combo.setEditable(True)
- self.rootrev_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
+ self.rootrev_combo.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToContents)
if minrev:
for text in possibleroots:
self.rootrev_combo.addItem(text)
diff --git a/tortoisehg/hgqt/backout.py b/tortoisehg/hgqt/backout.py
--- a/tortoisehg/hgqt/backout.py
+++ b/tortoisehg/hgqt/backout.py
@@ -85,16 +85,16 @@
super(BackoutDialog, self).__init__(parent)
self._repoagent = repoagent
f = self.windowFlags()
- self.setWindowFlags(f & ~Qt.WindowContextHelpButtonHint)
+ self.setWindowFlags(f & ~Qt.WindowType.WindowContextHelpButtonHint)

repo = repoagent.rawRepo()
parentbackout = repo[rev] == repo[b'.']

self.setWindowTitle(_('Backout - %s') % repoagent.displayName())
self.setWindowIcon(qtlib.geticon('hg-revert'))
- self.setOption(QWizard.NoBackButtonOnStartPage, True)
- self.setOption(QWizard.NoBackButtonOnLastPage, True)
- self.setOption(QWizard.IndependentPages, True)
+ self.setOption(QWizard.WizardOption.NoBackButtonOnStartPage, True)
+ self.setOption(QWizard.WizardOption.NoBackButtonOnLastPage, True)
+ self.setOption(QWizard.WizardOption.IndependentPages, True)

self.addPage(SummaryPage(repoagent, rev, parentbackout, self))
self.addPage(BackoutPage(repoagent, rev, parentbackout, self))
@@ -511,7 +511,7 @@
if self.isComplete():
self.wizard().next()
actionEnter = QAction('alt-enter', self)
- actionEnter.setShortcuts([Qt.CTRL+Qt.Key_Return, Qt.CTRL+Qt.Key_Enter])
+ actionEnter.setShortcuts([Qt.Modifier.CTRL+Qt.Key.Key_Return, Qt.Modifier.CTRL+Qt.Key.Key_Enter])
actionEnter.triggered.connect(tryperform)
self.addAction(actionEnter)

@@ -637,4 +637,4 @@
def currentPage(self):
# type: () -> None
self.bkCsInfo.update(self.repo[b'tip'])
- self.wizard().setOption(QWizard.NoCancelButton, True)
+ self.wizard().setOption(QWizard.WizardOption.NoCancelButton, True)
diff --git a/tortoisehg/hgqt/bisect.py b/tortoisehg/hgqt/bisect.py
--- a/tortoisehg/hgqt/bisect.py
+++ b/tortoisehg/hgqt/bisect.py
@@ -46,7 +46,7 @@
self.setWindowTitle(_('Bisect - %s') % repoagent.displayName())
self.setWindowIcon(qtlib.geticon('hg-bisect'))
self.setWindowFlags(self.windowFlags()
- & ~Qt.WindowContextHelpButtonHint)
+ & ~Qt.WindowType.WindowContextHelpButtonHint)

self._repoagent = repoagent
self._cmdsession = cmdcore.nullCmdSession()
@@ -91,7 +91,7 @@
for state, text in [('good', _('Revision is &Good')),
('bad', _('Revision is &Bad')),
('skip', _('&Skip this Revision'))]:
- btn = buttons.addButton(text, QDialogButtonBox.ActionRole)
+ btn = buttons.addButton(text, QDialogButtonBox.ButtonRole.ActionRole)
btn.setObjectName(state)

hbox = QHBoxLayout()
diff --git a/tortoisehg/hgqt/blockmatcher.py b/tortoisehg/hgqt/blockmatcher.py
--- a/tortoisehg/hgqt/blockmatcher.py
+++ b/tortoisehg/hgqt/blockmatcher.py
@@ -65,7 +65,7 @@
self._pagestep = 10
self._vrectcolor = QColor(0x00, 0x00, 0x55, 0x25)
self._vrectbordercolor = self._vrectcolor.darker()
- self.sizePolicy().setControlType(QSizePolicy.Slider)
+ self.sizePolicy().setControlType(QSizePolicy.ControlType.Slider)
self.setMinimumWidth(20)

def clear(self):
@@ -186,7 +186,7 @@
self._pagestep = {'left': 10, 'right': 10}
self._vrectcolor = QColor(0x00, 0x00, 0x55, 0x25)
self._vrectbordercolor = self._vrectcolor.darker()
- self.sizePolicy().setControlType(QSizePolicy.Slider)
+ self.sizePolicy().setControlType(QSizePolicy.ControlType.Slider)
self.setMinimumWidth(20)

def nDiffs(self):
@@ -260,7 +260,7 @@
mr = v_r
Mr = v_r + ps_r

- p.setPen(Qt.NoPen)
+ p.setPen(Qt.PenStyle.NoPen)
for typ, alo, ahi, blo, bhi in self._blocks:
if not (ml<=alo<=Ml or ml<=ahi<=Ml or mr<=blo<=Mr or mr<=bhi<=Mr):
continue
diff --git a/tortoisehg/hgqt/bookmark.py b/tortoisehg/hgqt/bookmark.py
--- a/tortoisehg/hgqt/bookmark.py
+++ b/tortoisehg/hgqt/bookmark.py
@@ -50,7 +50,7 @@
def __init__(self, repoagent, rev, parent=None):
super(BookmarkDialog, self).__init__(parent)
self.setWindowFlags(self.windowFlags() & \
- ~Qt.WindowContextHelpButtonHint)
+ ~Qt.WindowType.WindowContextHelpButtonHint)
self._repoagent = repoagent
repo = repoagent.rawRepo()
self._cmdsession = cmdcore.nullCmdSession()
@@ -61,13 +61,13 @@
base = QVBoxLayout()
base.setSpacing(0)
base.setContentsMargins(*(0,)*4)
- base.setSizeConstraint(QLayout.SetMinAndMaxSize)
+ base.setSizeConstraint(QLayout.SizeConstraint.SetMinAndMaxSize)
self.setLayout(base)

## main layout grid
formwidget = QWidget(self)
- formwidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
- form = QFormLayout(fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow)
+ formwidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
+ form = QFormLayout(fieldGrowthPolicy=QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow)
formwidget.setLayout(form)
base.addWidget(formwidget)

@@ -114,8 +114,8 @@

## horizontal separator
self.sep = QFrame()
- self.sep.setFrameShadow(QFrame.Sunken)
- self.sep.setFrameShape(QFrame.HLine)
+ self.sep.setFrameShadow(QFrame.Shadow.Sunken)
+ self.sep.setFrameShape(QFrame.Shape.HLine)
self.layout().addWidget(self.sep)

## status line
@@ -287,7 +287,7 @@

# horizontal splitter
self.splitter = QSplitter(self)
- self.splitter.setOrientation(Qt.Horizontal)
+ self.splitter.setOrientation(Qt.Orientation.Horizontal)
self.splitter.setChildrenCollapsible(False)
self.splitter.setObjectName('splitter')
self.layout().addWidget(self.splitter)
@@ -301,7 +301,7 @@
outgoingLabel = QLabel(_('Outgoing Bookmarks'))
outgoingLayout.addWidget(outgoingLabel)
self.outgoingList = QListWidget(self)
- self.outgoingList.setContextMenuPolicy(Qt.CustomContextMenu)
+ self.outgoingList.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.outgoingList.setSelectionMode(QListWidget.ExtendedSelection)
self.outgoingList.customContextMenuRequested.connect(
self._onOutgoingMenuRequested)
@@ -332,7 +332,7 @@
incomingLabel = QLabel(_('Incoming Bookmarks'))
incomingLayout.addWidget(incomingLabel)
self.incomingList = QListWidget(self)
- self.incomingList.setContextMenuPolicy(Qt.CustomContextMenu)
+ self.incomingList.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.incomingList.setSelectionMode(QListWidget.ExtendedSelection)
self.incomingList.customContextMenuRequested.connect(
self._onIncomingMenuRequested)
@@ -457,7 +457,7 @@
bookmarks = [hglib.tounicode(x.strip()) for x in bookmarks]
worklist.addItems(bookmarks)
for select in selected:
- items = worklist.findItems(select, Qt.MatchExactly)
+ items = worklist.findItems(select, Qt.MatchFlag.MatchExactly)
for item in items:
item.setSelected(True)

@@ -472,7 +472,7 @@
def _popupMenuFor(self, actions, worklist, pos):
menu = QMenu(self)
menu.addActions(actions)
- menu.setAttribute(Qt.WA_DeleteOnClose)
+ menu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
menu.popup(worklist.viewport().mapToGlobal(pos))

@pyqtSlot()
diff --git a/tortoisehg/hgqt/bugreport.py b/tortoisehg/hgqt/bugreport.py
--- a/tortoisehg/hgqt/bugreport.py
+++ b/tortoisehg/hgqt/bugreport.py
@@ -86,12 +86,12 @@
tb = QTextBrowser()
self.text = self.gettext(opts)
tb.setHtml('<pre>' + qtlib.htmlescape(self.text, False) + '</pre>')
- tb.setWordWrapMode(QTextOption.NoWrap)
+ tb.setWordWrapMode(QTextOption.WrapMode.NoWrap)
layout.addWidget(tb)

self.download_url_lbl = QLabel(_('Checking for updates...'))
self.download_url_lbl.setMouseTracking(True)
- self.download_url_lbl.setTextInteractionFlags(Qt.LinksAccessibleByMouse)
+ self.download_url_lbl.setTextInteractionFlags(Qt.TextInteractionFlag.LinksAccessibleByMouse)
self.download_url_lbl.setOpenExternalLinks(True)
layout.addWidget(self.download_url_lbl)

@@ -107,7 +107,7 @@

self.setWindowTitle(_('TortoiseHg Bug Report'))
self.setWindowFlags(self.windowFlags() & \
- ~Qt.WindowContextHelpButtonHint)
+ ~Qt.WindowType.WindowContextHelpButtonHint)
self.resize(650, 400)
self._readsettings()

@@ -212,12 +212,12 @@
"""Message box for recoverable exception"""
def __init__(self, main, text, opts, parent=None):
super(ExceptionMsgBox, self).__init__(parent)
- self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
+ self.setWindowFlags(self.windowFlags() & ~Qt.WindowType.WindowContextHelpButtonHint)
self.setWindowTitle(_('TortoiseHg Error'))

self._opts = opts

- labelflags = Qt.TextSelectableByMouse | Qt.LinksAccessibleByMouse
+ labelflags = Qt.TextInteractionFlag.TextSelectableByMouse | Qt.TextInteractionFlag.LinksAccessibleByMouse

self.setLayout(QVBoxLayout())

@@ -245,7 +245,7 @@
self._textlabel.setWordWrap(False)
self.layout().addWidget(self._textlabel)

- bb = QDialogButtonBox(QDialogButtonBox.Close, centerButtons=True)
+ bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Close, centerButtons=True)
bb.rejected.connect(self.reject)
self.layout().addWidget(bb)
desktopgeom = qApp.desktop().availableGeometry()
diff --git a/tortoisehg/hgqt/chunks.py b/tortoisehg/hgqt/chunks.py
--- a/tortoisehg/hgqt/chunks.py
+++ b/tortoisehg/hgqt/chunks.py
@@ -89,7 +89,7 @@
self.setLayout(layout)

self.splitter = QSplitter(self)
- self.splitter.setOrientation(Qt.Vertical)
+ self.splitter.setOrientation(Qt.Orientation.Vertical)
self.splitter.setChildrenCollapsible(False)
self.layout().addWidget(self.splitter)

@@ -98,12 +98,12 @@
model = manifestmodel.ManifestModel(
repoagent, self, statusfilter='MAR', flat=True)
self.filelist.setModel(model)
- self.filelist.setContextMenuPolicy(Qt.CustomContextMenu)
+ self.filelist.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.filelist.customContextMenuRequested.connect(self.menuRequest)
self.filelist.doubleClicked.connect(self.vdiff)

self.fileListFrame = QFrame(self.splitter)
- self.fileListFrame.setFrameShape(QFrame.NoFrame)
+ self.fileListFrame.setFrameShape(QFrame.Shape.NoFrame)
vbox = QVBoxLayout()
vbox.setSpacing(0)
vbox.setContentsMargins(0, 0, 0, 0)
@@ -240,7 +240,7 @@
parent=self):
dlg = rejects.RejectsDialog(repo.ui, repo.wjoin(wfile),
self)
- if dlg.exec_() == QDialog.Accepted:
+ if dlg.exec_() == QDialog.DialogCode.Accepted:
ok = True
break
return ok
@@ -531,10 +531,10 @@
p = QPainter()
fm = QFontMetrics(self.font())
if fm.width(self.text()): # > self.contentsRect().width():
- elided = fm.elidedText(self.text(), Qt.ElideLeft,
+ elided = fm.elidedText(self.text(), Qt.TextElideMode.ElideLeft,
self.rect().width(), 0)
- p.drawText(self.rect(), Qt.AlignTop | Qt.AlignRight |
- Qt.TextSingleLine, elided)
+ p.drawText(self.rect(), Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignRight |
+ Qt.TextFlag.TextSingleLine, elided)
else:
super(ElideLabel, self).paintEvent(event)

@@ -568,7 +568,7 @@
hbox.addWidget(w)
w.setWordWrap(True)
f = w.textInteractionFlags()
- w.setTextInteractionFlags(f | Qt.TextSelectableByMouse)
+ w.setTextInteractionFlags(f | Qt.TextInteractionFlag.TextSelectableByMouse)
w.linkActivated.connect(self.linkActivated)

self.searchbar = qscilib.SearchToolBar()
@@ -580,16 +580,16 @@
self.sumlabel = QLabel()
self.allbutton = QToolButton()
self.allbutton.setText(_('All', 'files'))
- self.allbutton.setShortcut(QKeySequence.SelectAll)
+ self.allbutton.setShortcut(QKeySequence.StandardKey.SelectAll)
self.allbutton.clicked.connect(self.selectAll)
self.nonebutton = QToolButton()
self.nonebutton.setText(_('None', 'files'))
- self.nonebutton.setShortcut(QKeySequence.New)
+ self.nonebutton.setShortcut(QKeySequence.StandardKey.New)
self.nonebutton.clicked.connect(self.selectNone)
self.actionFind = self.searchbar.toggleViewAction()
self.actionFind.setIcon(qtlib.geticon('edit-find'))
self.actionFind.setToolTip(_('Toggle display of text search bar'))
- qtlib.newshortcutsforstdkey(QKeySequence.Find, self, self.searchbar.show)
+ qtlib.newshortcutsforstdkey(QKeySequence.StandardKey.Find, self, self.searchbar.show)
self.diffToolbar = QToolBar(_('Diff Toolbar'))
self.diffToolbar.setIconSize(qtlib.smallIconSize())
self.diffToolbar.setStyleSheet(qtlib.tbstylesheet)
@@ -621,12 +621,12 @@
self.sci.setMarginSensitivity(1, True)
self.sci.marginClicked.connect(self.marginClicked)

- self._checkedpix = qtlib.getcheckboxpixmap(QStyle.State_On,
- Qt.gray, self)
+ self._checkedpix = qtlib.getcheckboxpixmap(QStyle.StateFlag.State_On,
+ Qt.GlobalColor.gray, self)
self.selected = self.sci.markerDefine(self._checkedpix, -1)

- self._uncheckedpix = qtlib.getcheckboxpixmap(QStyle.State_Off,
- Qt.gray, self)
+ self._uncheckedpix = qtlib.getcheckboxpixmap(QStyle.StateFlag.State_Off,
+ Qt.GlobalColor.gray, self)
self.unselected = self.sci.markerDefine(self._uncheckedpix, -1)

self.vertical = self.sci.markerDefine(qsci.VerticalLine, -1)
@@ -735,7 +735,7 @@
QColor('blue'), self._forceviewindicator)
# delay until next event-loop in order to complete mouse release
self.sci.SCN_INDICATORRELEASE.connect(self.forceDisplayFile,
- Qt.QueuedConnection)
+ Qt.ConnectionType.QueuedConnection)

def forceDisplayFile(self):
if self.curchunks:
diff --git a/tortoisehg/hgqt/clone.py b/tortoisehg/hgqt/clone.py
--- a/tortoisehg/hgqt/clone.py
+++ b/tortoisehg/hgqt/clone.py
@@ -95,7 +95,7 @@
def __init__(self, config, cmdagent, parent=None):
# type: (HgConfig, cmdcore.CmdAgent, Optional[QWidget]) -> None
super(CloneWidget, self).__init__(parent)
- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self._config = config
self._cmdagent = cmdagent

@@ -378,7 +378,7 @@
FD = QFileDialog
caption = _("Select source repository")
path = FD.getExistingDirectory(self, caption,
- self.src_combo.currentText(), QFileDialog.ShowDirsOnly)
+ self.src_combo.currentText(), QFileDialog.Option.ShowDirsOnly)
if path:
self.src_combo.setEditText(QDir.toNativeSeparators(path))
self._suggestDestination()
@@ -390,7 +390,7 @@
FD = QFileDialog
caption = _("Select destination repository")
path = FD.getExistingDirectory(self, caption,
- self.dest_combo.currentText(), QFileDialog.ShowDirsOnly)
+ self.dest_combo.currentText(), QFileDialog.Option.ShowDirsOnly)
if path:
self.dest_combo.setEditText(QDir.toNativeSeparators(path))
self._suggestDestination() # in case existing dir is selected
@@ -403,7 +403,7 @@
caption = _("Select patch folder")
upatchroot = os.path.join(self.src_combo.currentText(), '.hg')
upath = FD.getExistingDirectory(self, caption, upatchroot,
- QFileDialog.ShowDirsOnly)
+ QFileDialog.Option.ShowDirsOnly)
if upath:
self.qclone_txt.setText(QDir.toNativeSeparators(upath))
self.qclone_txt.setFocus()
diff --git a/tortoisehg/hgqt/close_branch.py b/tortoisehg/hgqt/close_branch.py
--- a/tortoisehg/hgqt/close_branch.py
+++ b/tortoisehg/hgqt/close_branch.py
@@ -55,7 +55,7 @@
form.setContentsMargins(0, 0, 0, 0)
# simple widget with only an editable commit message textbox
self.setLayout(form)
- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
# add revision information about selected revision
form.addRow(_('Revision:'), QLabel('%d (%s)' % (rev, self._repo[rev])))
# commit message
diff --git a/tortoisehg/hgqt/cmdcore.py b/tortoisehg/hgqt/cmdcore.py
--- a/tortoisehg/hgqt/cmdcore.py
+++ b/tortoisehg/hgqt/cmdcore.py
@@ -297,7 +297,7 @@

def isCommandRunning(self):
# type: () -> bool
- return self._proc.state() != QProcess.NotRunning
+ return self._proc.state() != QProcess.ProcessState.NotRunning

@pyqtSlot(int)
def _finish(self, ret):
@@ -306,11 +306,11 @@

@pyqtSlot(QProcess.ProcessError)
def _handleerror(self, error):
- if error == QProcess.FailedToStart:
+ if error == QProcess.ProcessError.FailedToStart:
self.outputReceived.emit(_('failed to start command\n'),
'ui.error')
self._finish(-1)
- elif error != QProcess.Crashed:
+ elif error != QProcess.ProcessError.Crashed:
self.outputReceived.emit(_('error while running command\n'),
'ui.error')

@@ -363,7 +363,7 @@
proc.setWorkingDirectory(cwd)
proc.error.connect(self._onServiceError)
proc.finished.connect(self._onServiceFinished)
- proc.setReadChannel(QProcess.StandardOutput)
+ proc.setReadChannel(QProcess.ProcessChannel.StandardOutput)
proc.readyRead.connect(self._onReadyRead)
proc.readyReadStandardError.connect(self._onReadyReadError)
return proc
@@ -420,7 +420,7 @@
@pyqtSlot(QProcess.ProcessError)
def _onServiceError(self, error):
self._emitError(self._proc.errorString())
- if error == QProcess.FailedToStart:
+ if error == QProcess.ProcessError.FailedToStart:
self._onServiceFinished()

@pyqtSlot()
diff --git a/tortoisehg/hgqt/cmdui.py b/tortoisehg/hgqt/cmdui.py
--- a/tortoisehg/hgqt/cmdui.py
+++ b/tortoisehg/hgqt/cmdui.py
@@ -228,7 +228,7 @@
self.setReadOnly(True)
self.setUtf8(True)
self.setMarginWidth(1, 0)
- self.setWrapMode(QsciScintilla.WrapCharacter)
+ self.setWrapMode(QsciScintilla.WrapMode.WrapCharacter)
self._initfont()
self._initmarkers()
qscilib.unbindConflictedKeys(self)
@@ -245,7 +245,7 @@
def _initmarkers(self):
self._markers = {}
for l in ('ui.error', 'ui.warning', 'control'):
- self._markers[l] = m = self.markerDefine(QsciScintilla.Background)
+ self._markers[l] = m = self.markerDefine(QsciScintilla.MarkerSymbol.Background)
c = QColor(qtlib.getbgcoloreffect(l))
if c.isValid():
self.setMarkerBackgroundColor(c, m)
@@ -285,7 +285,7 @@

def keyPressEvent(self, event):
# propagate key events important for dialog
- if event.key() == Qt.Key_Escape:
+ if event.key() == Qt.Key.Key_Escape:
event.ignore()
return
super(LogWidget, self).keyPressEvent(event)
@@ -313,9 +313,9 @@
def getLineInput(self):
mode = self._promptmode
if mode == cmdcore.UiHandler.TextInput:
- return self._getTextInput(QLineEdit.Normal)
+ return self._getTextInput(QLineEdit.EchoMode.Normal)
elif mode == cmdcore.UiHandler.PasswordInput:
- return self._getTextInput(QLineEdit.Password)
+ return self._getTextInput(QLineEdit.EchoMode.Password)
elif mode == cmdcore.UiHandler.ChoiceInput:
return self._getChoiceInput()
else:
@@ -330,12 +330,12 @@

def _getChoiceInput(self):
msg, choicepairs = hglib.extractchoices(self._prompttext)
- dlg = QMessageBox(QMessageBox.Question, _('TortoiseHg Prompt'), msg,
+ dlg = QMessageBox(QMessageBox.Icon.Question, _('TortoiseHg Prompt'), msg,
QMessageBox.StandardButton.NoButton, self._parentWidget())
- dlg.setWindowFlags(Qt.Sheet)
- dlg.setWindowModality(Qt.WindowModal)
+ dlg.setWindowFlags(Qt.WindowType.Sheet)
+ dlg.setWindowModality(Qt.WindowModality.WindowModal)
for r, t in choicepairs:
- button = dlg.addButton(t, QMessageBox.ActionRole)
+ button = dlg.addButton(t, QMessageBox.ButtonRole.ActionRole)
button.response = r
if r == self._promptdefault:
dlg.setDefaultButton(button)
@@ -343,7 +343,7 @@
dlg.addButton(QMessageBox.StandardButton.Cancel).hide()
dlg.exec_()
button = dlg.clickedButton()
- if button and dlg.buttonRole(button) == QMessageBox.ActionRole:
+ if button and dlg.buttonRole(button) == QMessageBox.ButtonRole.ActionRole:
return button.response

def _parentWidget(self):
@@ -359,7 +359,7 @@
def getLineInput(self):
mode = self._promptmode
if mode == cmdcore.UiHandler.PasswordInput:
- return self._getTextInput(QLineEdit.Password)
+ return self._getTextInput(QLineEdit.EchoMode.Password)
else:
return ''

@@ -400,14 +400,14 @@

# bottom buttons
self._buttonbox = buttons = QDialogButtonBox()
- self._cancelBtn = buttons.addButton(QDialogButtonBox.Cancel)
+ self._cancelBtn = buttons.addButton(QDialogButtonBox.StandardButton.Cancel)
self._cancelBtn.clicked.connect(self.abortCommand)

- self._closeBtn = buttons.addButton(QDialogButtonBox.Close)
+ self._closeBtn = buttons.addButton(QDialogButtonBox.StandardButton.Close)
self._closeBtn.clicked.connect(self.reject)

self._detailBtn = buttons.addButton(_detailbtntextmap[logVisible],
- QDialogButtonBox.ResetRole)
+ QDialogButtonBox.ButtonRole.ResetRole)
self._detailBtn.setAutoDefault(False)
self._detailBtn.setCheckable(True)
self._detailBtn.setChecked(logVisible)
@@ -490,13 +490,13 @@
self.finished.emit(self._session.exitCode())

def _updateSizePolicy(self):
- if self.testAttribute(Qt.WA_WState_OwnSizePolicy):
+ if self.testAttribute(Qt.WidgetAttribute.WA_WState_OwnSizePolicy):
return
if self.isLogVisible():
- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
else:
- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
- self.setAttribute(Qt.WA_WState_OwnSizePolicy, False)
+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
+ self.setAttribute(Qt.WidgetAttribute.WA_WState_OwnSizePolicy, False)

def _updateStatus(self):
self._stbar.show()
@@ -547,10 +547,10 @@
def __init__(self, parent=None):
super(CmdControlDialog, self).__init__(parent)
self.setWindowFlags(self.windowFlags()
- & ~Qt.WindowContextHelpButtonHint)
+ & ~Qt.WindowType.WindowContextHelpButtonHint)

vbox = QVBoxLayout()
- vbox.setSizeConstraint(QLayout.SetMinAndMaxSize)
+ vbox.setSizeConstraint(QLayout.SizeConstraint.SetMinAndMaxSize)
self.setLayout(vbox)

self.__cmdwidget = None
@@ -558,7 +558,7 @@
self.__cmdcontrol = cmd = CmdSessionControlWidget(self)
cmd.finished.connect(self.done)
vbox.addWidget(cmd)
- self.__runbutton = cmd.addButton(_('&Run'), QDialogButtonBox.AcceptRole)
+ self.__runbutton = cmd.addButton(_('&Run'), QDialogButtonBox.ButtonRole.AcceptRole)
self.__runbutton.clicked.connect(self.runCommand)

self.__updateUi()
@@ -612,7 +612,7 @@

# set focus to the first item of the command widget
fw = self.__cmdwidget
- while fw.focusPolicy() == Qt.NoFocus or not fw.isVisibleTo(self):
+ while fw.focusPolicy() == Qt.FocusPolicy.NoFocus or not fw.isVisibleTo(self):
fw = fw.nextInFocusChain()
if fw is self.__cmdwidget or fw is self.__cmdcontrol:
# no candidate available
@@ -702,14 +702,14 @@
def __init__(self, parent=None):
super(CmdSessionDialog, self).__init__(parent)
self.setWindowFlags(self.windowFlags()
- & ~Qt.WindowContextHelpButtonHint)
+ & ~Qt.WindowType.WindowContextHelpButtonHint)
self.setWindowTitle(_('TortoiseHg Command Dialog'))
self.resize(540, 420)

vbox = QVBoxLayout()
self.setLayout(vbox)
vbox.setContentsMargins(5, 5, 5, 5)
- vbox.setSizeConstraint(QLayout.SetMinAndMaxSize)
+ vbox.setSizeConstraint(QLayout.SizeConstraint.SetMinAndMaxSize)

self._cmdcontrol = cmd = CmdSessionControlWidget(self, logVisible=True)
cmd.finished.connect(self.done)
diff --git a/tortoisehg/hgqt/commit.py b/tortoisehg/hgqt/commit.py
--- a/tortoisehg/hgqt/commit.py
+++ b/tortoisehg/hgqt/commit.py
@@ -300,7 +300,7 @@

self.recentMessagesButton = QToolButton(
text=_('Copy message'),
- popupMode=QToolButton.InstantPopup,
+ popupMode=QToolButton.ToolButtonPopupMode.InstantPopup,
toolTip=_('Copy one of the recent commit messages'))
m = QMenu(self.recentMessagesButton)
m.triggered.connect(self.msgSelected)
@@ -367,8 +367,8 @@
self.hasmqbutton = False

self.optionslabel = QLabel()
- self.optionslabel.setSizePolicy(QSizePolicy.Ignored,
- QSizePolicy.Preferred)
+ self.optionslabel.setSizePolicy(QSizePolicy.Policy.Ignored,
+ QSizePolicy.Policy.Preferred)
vbox.addWidget(self.optionslabel, 0)

self.wdirinfo = revpanel.WDirInfoWidget(repo)
@@ -385,7 +385,7 @@
upperframe.setSizePolicy(sp)
upperframe.setLayout(vbox)

- self.split = QSplitter(Qt.Vertical)
+ self.split = QSplitter(Qt.Orientation.Vertical)
if os.name == 'nt':
self.split.setStyle(QStyleFactory.create('Plastique'))
sp = SP(SP.Expanding, SP.Expanding)
@@ -485,13 +485,13 @@
def menuButtonWidth(self):
style = self.style()
opt = self.styleOption()
- opt.features = QStyleOptionToolButton.MenuButtonPopup
- rect = style.subControlRect(QStyle.CC_ToolButton, opt,
- QStyle.SC_ToolButtonMenu, self)
+ opt.features = QStyleOptionToolButton.ToolButtonFeature.MenuButtonPopup
+ rect = style.subControlRect(QStyle.ComplexControl.CC_ToolButton, opt,
+ QStyle.SubControl.SC_ToolButtonMenu, self)
return rect.width()
def setBold(self):
f = self.font()
- f.setWeight(QFont.Bold)
+ f.setWeight(QFont.Weight.Bold)
self.setFont(f)
def sizeHint(self):
# Set the desired width to keep the button from resizing
@@ -499,7 +499,7 @@

self.committb = committb = CommitToolButton(self)
committb.setBold()
- committb.setPopupMode(QToolButton.MenuButtonPopup)
+ committb.setPopupMode(QToolButton.ToolButtonPopupMode.MenuButtonPopup)
fmk = lambda s: committb.fontMetrics().width(hglib.tounicode(s[2]))
committb._width = (max(pycompat.maplist(fmk, acts))
+ 4*committb.menuButtonWidth())
@@ -532,9 +532,9 @@
self.commitButtonEnable.connect(committb.setEnabled)
self.commitSetAction(actionName=self._getPreferredActionName())
sc = QShortcut(QKeySequence('Ctrl+Return'), self, self.mqPerformAction)
- sc.setContext(Qt.WidgetWithChildrenShortcut)
+ sc.setContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
sc = QShortcut(QKeySequence('Ctrl+Enter'), self, self.mqPerformAction)
- sc.setContext(Qt.WidgetWithChildrenShortcut)
+ sc.setContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
return committb

@pyqtSlot(bool)
@@ -774,9 +774,9 @@
dlg = DetailsDialog(self._repoagent, self.opts, self.userhist, self,
mode=mode)
dlg.finished.connect(dlg.deleteLater)
- dlg.setWindowFlags(Qt.Sheet)
- dlg.setWindowModality(Qt.WindowModal)
- if dlg.exec_() == QDialog.Accepted:
+ dlg.setWindowFlags(Qt.WindowType.Sheet)
+ dlg.setWindowModality(Qt.WindowModality.WindowModal)
+ if dlg.exec_() == QDialog.DialogCode.Accepted:
self.opts.update(dlg.outopts)
self.refresh()

@@ -885,9 +885,9 @@
def branchOp(self):
# type: () -> None
d = branchop.BranchOpDialog(self._repoagent, self.branchop, self)
- d.setWindowFlags(Qt.Sheet)
- d.setWindowModality(Qt.WindowModal)
- if d.exec_() == QDialog.Accepted:
+ d.setWindowFlags(Qt.WindowType.Sheet)
+ d.setWindowModality(Qt.WindowModality.WindowModal)
+ if d.exec_() == QDialog.DialogCode.Accepted:
self.branchop = d.branchop
if self.branchop is False:
if not self.getMessage(True).strip():
@@ -903,8 +903,8 @@
def topicOp(self):
# type: () -> None
d = topic.TopicDialog(self._repoagent, self.branchop, self)
- d.setWindowFlags(Qt.Sheet)
- d.setWindowModality(Qt.WindowModal)
+ d.setWindowFlags(Qt.WindowType.Sheet)
+ d.setWindowModality(Qt.WindowModality.WindowModal)
d.exec_()
self.msgte.setFocus()
self.refresh()
@@ -1597,7 +1597,7 @@
def __init__(self, repoagent, pats, opts, parent=None):
# type: (RepoAgent, List[bytes], Dict[Text, bytes], Optional[QObject]) -> None
QDialog.__init__(self, parent)
- self.setWindowFlags(Qt.Window)
+ self.setWindowFlags(Qt.WindowType.Window)
self.setWindowIcon(qtlib.geticon('hg-commit'))
self._repoagent = repoagent
self.pats = pats
@@ -1648,7 +1648,7 @@
self.commit.reload()
self.updateUndo()
self.commit.msgte.setFocus()
- qtlib.newshortcutsforstdkey(QKeySequence.Refresh, self, self.refresh)
+ qtlib.newshortcutsforstdkey(QKeySequence.StandardKey.Refresh, self, self.refresh)

def linkActivated(self, link):
# type: (Text) -> None
diff --git a/tortoisehg/hgqt/compress.py b/tortoisehg/hgqt/compress.py
--- a/tortoisehg/hgqt/compress.py
+++ b/tortoisehg/hgqt/compress.py
@@ -36,20 +36,20 @@
def __init__(self, repoagent, revs, parent):
super(CompressDialog, self).__init__(parent)
f = self.windowFlags()
- self.setWindowFlags(f & ~Qt.WindowContextHelpButtonHint)
+ self.setWindowFlags(f & ~Qt.WindowType.WindowContextHelpButtonHint)
self._repoagent = repoagent
self.revs = revs

box = QVBoxLayout()
box.setSpacing(8)
box.setContentsMargins(*(6,)*4)
- box.setSizeConstraint(QLayout.SetMinAndMaxSize)
+ box.setSizeConstraint(QLayout.SizeConstraint.SetMinAndMaxSize)
self.setLayout(box)

style = csinfo.panelstyle(selectable=True)

srcb = QGroupBox(_('Compress changesets up to and including'))
- srcb.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
+ srcb.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed)
srcb.setLayout(QVBoxLayout())
srcb.layout().setContentsMargins(*(2,)*4)
source = csinfo.create(self.repo, revs[0], style, withupdate=True)
@@ -57,7 +57,7 @@
self.layout().addWidget(srcb)

destb = QGroupBox(_('Onto destination'))
- destb.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
+ destb.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed)
destb.setLayout(QVBoxLayout())
destb.layout().setContentsMargins(*(2,)*4)
dest = csinfo.create(self.repo, revs[1], style, withupdate=True)
@@ -69,7 +69,7 @@
cmd.finished.connect(self.done)
cmd.setLogVisible(True)
self.compressbtn = cmd.addButton(_('Compress'),
- QDialogButtonBox.AcceptRole)
+ QDialogButtonBox.ButtonRole.AcceptRole)
self.compressbtn.setEnabled(False)
self.compressbtn.clicked.connect(self.compress)
self.layout().addWidget(cmd)
diff --git a/tortoisehg/hgqt/csinfo.py b/tortoisehg/hgqt/csinfo.py
--- a/tortoisehg/hgqt/csinfo.py
+++ b/tortoisehg/hgqt/csinfo.py
@@ -448,23 +448,23 @@
if self.revlabel is None:
self.revlabel = QLabel()
self.revlabel.linkActivated.connect(self.linkActivated)
- layout.addWidget(self.revlabel, 0, Qt.AlignTop)
+ layout.addWidget(self.revlabel, 0, Qt.AlignmentFlag.AlignTop)

if 'expandable' in self.csstyle and self.csstyle['expandable']:
if self.expand_btn.parentWidget() is None:
self.expand_btn.clicked.connect(lambda: self.update())
margin = QHBoxLayout()
margin.setContentsMargins(3, 3, 3, 3)
- margin.addWidget(self.expand_btn, 0, Qt.AlignTop)
+ margin.addWidget(self.expand_btn, 0, Qt.AlignmentFlag.AlignTop)
layout.insertLayout(0, margin)
self.expand_btn.setVisible(True)
elif self.expand_btn.parentWidget() is not None:
self.expand_btn.setHidden(True)

- interact = Qt.LinksAccessibleByMouse
+ interact = Qt.TextInteractionFlag.LinksAccessibleByMouse

if 'selectable' in self.csstyle and self.csstyle['selectable']:
- interact |= Qt.TextBrowserInteraction
+ interact |= Qt.TextInteractionFlag.TextBrowserInteraction

self.revlabel.setTextInteractionFlags(interact)

@@ -525,7 +525,7 @@

if 'selectable' in self.csstyle:
sel = self.csstyle['selectable']
- val = sel and Qt.TextSelectableByMouse or Qt.TextBrowserInteraction
+ val = sel and Qt.TextInteractionFlag.TextSelectableByMouse or Qt.TextInteractionFlag.TextBrowserInteraction
self.setTextInteractionFlags(val)

if 'width' in self.csstyle:
diff --git a/tortoisehg/hgqt/cslist.py b/tortoisehg/hgqt/cslist.py
--- a/tortoisehg/hgqt/cslist.py
+++ b/tortoisehg/hgqt/cslist.py
@@ -54,10 +54,10 @@
selectable=True)

# main layout
- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
self.mainvbox = QVBoxLayout()
self.mainvbox.setSpacing(_SPACING)
- self.mainvbox.setSizeConstraint(QLayout.SetMinAndMaxSize)
+ self.mainvbox.setSizeConstraint(QLayout.SizeConstraint.SetMinAndMaxSize)
self.setLayout(self.mainvbox)

## status box
@@ -71,7 +71,7 @@
## scroll area
self.scrollarea = QScrollArea()
self.scrollarea.setMinimumSize(400, 200)
- self.scrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
+ self.scrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
self.scrollarea.setWidgetResizable(True)
self.mainvbox.addWidget(self.scrollarea)

@@ -79,7 +79,7 @@
self.scrollbox = QWidget()
self.csvbox = QVBoxLayout()
self.csvbox.setSpacing(_SPACING)
- self.csvbox.setSizeConstraint(QLayout.SetMaximumSize)
+ self.csvbox.setSizeConstraint(QLayout.SizeConstraint.SetMaximumSize)
self.scrollbox.setLayout(self.csvbox)
self.scrollarea.setWidget(self.scrollbox)

@@ -136,11 +136,11 @@
style = self.compactchk.isChecked() and self.lstyle or self.pstyle
info = self.curfactory(item, style=style)
info.update(item)
- sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
+ sizePolicy = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
info.setSizePolicy(sizePolicy)
- self.csvbox.addWidget(info, Qt.AlignTop)
+ self.csvbox.addWidget(info, Qt.AlignmentFlag.AlignTop)

def updatestatus(self):
if not self.curitems:
diff --git a/tortoisehg/hgqt/customtools.py b/tortoisehg/hgqt/customtools.py
--- a/tortoisehg/hgqt/customtools.py
+++ b/tortoisehg/hgqt/customtools.py
@@ -333,7 +333,7 @@
self.setLayout(topbox)
self.hooktable = QTableWidget(0, 3, parent)
self.hooktable.setHorizontalHeaderLabels((_('Type'), _('Name'), _('Command')))
- self.hooktable.sortByColumn(0, Qt.AscendingOrder)
+ self.hooktable.sortByColumn(0, Qt.SortOrder.AscendingOrder)
self.hooktable.setSelectionBehavior(self.hooktable.SelectRows)
self.hooktable.setSelectionMode(self.hooktable.SingleSelection)
self.hooktable.cellDoubleClicked.connect(self.editHook)
@@ -384,7 +384,7 @@
self.hooktable.setItem(row, c, QTableWidgetItem(text))
# Make the hook column not editable (a dialog is used to edit it)
itemhook = self.hooktable.item(row, 0)
- itemhook.setFlags(itemhook.flags() & ~Qt.ItemIsEditable)
+ itemhook.setFlags(itemhook.flags() & ~Qt.ItemFlag.ItemIsEditable)
self.hooktable.setSortingEnabled(True)
self.hooktable.resizeColumnsToContents()
self.updatebuttons()
@@ -530,7 +530,7 @@
itemhook = QTableWidgetItem(hglib.tounicode(hooktype))
# Make the hook column not editable
# (a dialog is used to edit it)
- itemhook.setFlags(itemhook.flags() & ~Qt.ItemIsEditable)
+ itemhook.setFlags(itemhook.flags() & ~Qt.ItemFlag.ItemIsEditable)
itemname = QTableWidgetItem(hglib.tounicode(name))
itemtool = QTableWidgetItem(
hglib.tounicode(hooks[hooktype][name]))
@@ -562,7 +562,7 @@
# Enable drag and drop to reorder the tools
self.setDragEnabled(True)
self.setDragDropMode(self.InternalMove)
- self.setDefaultDropAction(Qt.MoveAction)
+ self.setDefaultDropAction(Qt.DropAction.MoveAction)

def _guidef2toollist(self, guidef):
toollist = []
@@ -660,7 +660,7 @@
def __init__(self, parent=None, dialogname='', **kwargs):
QDialog.__init__(self, parent, **kwargs)
self.dialogname = dialogname
- self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
+ self.setWindowFlags(self.windowFlags() & ~Qt.WindowType.WindowContextHelpButtonHint)

self.hbox = QHBoxLayout()
self.formvbox = QFormLayout()
@@ -695,7 +695,7 @@
combo.setCurrentIndex(index)
if tooltips:
for idx, tooltip in enumerate(tooltips):
- combo.setItemData(idx, tooltip, Qt.ToolTipRole)
+ combo.setItemData(idx, tooltip, Qt.ItemDataRole.ToolTipRole)
return combo

def _addConfigItem(self, parent, label, configwidget, tooltip=None):
diff --git a/tortoisehg/hgqt/docklog.py b/tortoisehg/hgqt/docklog.py
--- a/tortoisehg/hgqt/docklog.py
+++ b/tortoisehg/hgqt/docklog.py
@@ -53,7 +53,7 @@

def __init__(self, parent=None):
super(_LogWidgetForConsole, self).__init__(parent)
- self._prompt_marker = self.markerDefine(QsciScintilla.Background)
+ self._prompt_marker = self.markerDefine(QsciScintilla.MarkerSymbol.Background)
self.setMarkerBackgroundColor(QColor('#e8f3fe'), self._prompt_marker)
self.cursorPositionChanged.connect(self._updatePrompt)
# ensure not moving prompt line even if completion list get shorter,
@@ -70,16 +70,16 @@
def keyPressEvent(self, event):
cursoronprompt = not self.isReadOnly()
if cursoronprompt:
- if event.key() == Qt.Key_Up:
+ if event.key() == Qt.Key.Key_Up:
return self.historyRequested.emit(self.commandText(), -1)
- elif event.key() == Qt.Key_Down:
+ elif event.key() == Qt.Key.Key_Down:
return self.historyRequested.emit(self.commandText(), +1)
del self._savedcommands[:] # settle candidate by user input
- if event.key() in (Qt.Key_Return, Qt.Key_Enter):
+ if event.key() in (Qt.Key.Key_Return, Qt.Key.Key_Enter):
return self.returnPressed.emit(self.commandText())
- if event.key() == Qt.Key_Tab:
+ if event.key() == Qt.Key.Key_Tab:
return self.completeRequested.emit(self.commandText())
- if event.key() == Qt.Key_Escape:
+ if event.key() == Qt.Key.Key_Escape:
# When ESC is pressed, if the cursor is on the prompt,
# this clears it, if not, this moves the cursor to the prompt
self.setCommandText('')
@@ -423,11 +423,11 @@

@pyqtSlot()
def _handleExtprocError(self):
- if self._extproc.state() == QProcess.NotRunning:
+ if self._extproc.state() == QProcess.ProcessState.NotRunning:
self._logwidget.closePrompt()
msg = self._extproc.errorString()
self._logwidget.appendLog(msg + '\n', 'ui.error')
- if self._extproc.state() == QProcess.NotRunning:
+ if self._extproc.state() == QProcess.ProcessState.NotRunning:
self._logwidget.openPrompt()

@pyqtSlot()
@@ -533,12 +533,12 @@
def __init__(self, repomanager, cmdagent, parent=None):
super(LogDockWidget, self).__init__(parent)

- self.setFeatures(QDockWidget.DockWidgetClosable |
- QDockWidget.DockWidgetMovable |
- QDockWidget.DockWidgetFloatable)
+ self.setFeatures(QDockWidget.DockWidgetFeature.DockWidgetClosable |
+ QDockWidget.DockWidgetFeature.DockWidgetMovable |
+ QDockWidget.DockWidgetFeature.DockWidgetFloatable)
self.setWindowTitle(_('Console'))
# Not enabled until we have a way to make it configurable
- #self.setWindowFlags(Qt.Drawer)
+ #self.setWindowFlags(Qt.WindowType.Drawer)
self.dockLocationChanged.connect(self._updateTitleBarStyle)

self._repomanager = repomanager
@@ -591,8 +591,8 @@
@pyqtSlot(Qt.DockWidgetArea)
def _updateTitleBarStyle(self, area):
f = self.features()
- if area & (Qt.TopDockWidgetArea | Qt.BottomDockWidgetArea):
- f |= QDockWidget.DockWidgetVerticalTitleBar # saves vertical space
+ if area & (Qt.DockWidgetArea.TopDockWidgetArea | Qt.DockWidgetArea.BottomDockWidgetArea):
+ f |= QDockWidget.DockWidgetFeature.DockWidgetVerticalTitleBar # saves vertical space
else:
- f &= ~QDockWidget.DockWidgetVerticalTitleBar
+ f &= ~QDockWidget.DockWidgetFeature.DockWidgetVerticalTitleBar
self.setFeatures(f)
diff --git a/tortoisehg/hgqt/filectxactions.py b/tortoisehg/hgqt/filectxactions.py
--- a/tortoisehg/hgqt/filectxactions.py
+++ b/tortoisehg/hgqt/filectxactions.py
@@ -154,7 +154,7 @@
act.setIcon(qtlib.geticon(icon))
if key:
qtlib.setContextMenuShortcut(act, key)
- act.setShortcutContext(Qt.WidgetWithChildrenShortcut)
+ act.setShortcutContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
if tip:
act.setStatusTip(tip)
act.triggered.connect(getattr(self, name))
@@ -509,7 +509,7 @@
# the same shortcut as editFile that is disabled for working rev
a = self.action('editLocalFile')
qtlib.setContextMenuShortcut(a, 'Ctrl+Shift+E')
- a.setShortcutContext(Qt.WidgetWithChildrenShortcut)
+ a.setShortcutContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
a = self.action('addLargefile')
a.setVisible(b'largefiles' in repo.extensions())
self._addAction('renameFileMenu', *self._createRenameFileMenu())
diff --git a/tortoisehg/hgqt/filedialogs.py b/tortoisehg/hgqt/filedialogs.py
--- a/tortoisehg/hgqt/filedialogs.py
+++ b/tortoisehg/hgqt/filedialogs.py
@@ -134,7 +134,7 @@
lines.append((i + 1, _colormap['-'], ))

p = QPainter(viewport)
- p.setRenderHint(QPainter.Antialiasing)
+ p.setRenderHint(QPainter.RenderHint.Antialiasing)
for (line, color) in lines:
p.setPen(QPen(color, 3.0))
y = line * scale
@@ -245,16 +245,16 @@

def setupUi(self):
self.editToolbar = QToolBar(self)
- self.editToolbar.setContextMenuPolicy(Qt.PreventContextMenu)
- self.addToolBar(Qt.ToolBarArea(Qt.TopToolBarArea), self.editToolbar)
+ self.editToolbar.setContextMenuPolicy(Qt.ContextMenuPolicy.PreventContextMenu)
+ self.addToolBar(Qt.ToolBarArea(Qt.ToolBarArea.TopToolBarArea), self.editToolbar)
self.actionClose = QAction(self)
- self.actionClose.setShortcuts(QKeySequence.Close)
+ self.actionClose.setShortcuts(QKeySequence.StandardKey.Close)
self.actionReload = QAction(self)
- self.actionReload.setShortcuts(QKeySequence.Refresh)
+ self.actionReload.setShortcuts(QKeySequence.StandardKey.Refresh)
self.editToolbar.addAction(self.actionReload)
self.addAction(self.actionClose)

- self.splitter = QSplitter(Qt.Vertical)
+ self.splitter = QSplitter(Qt.Orientation.Vertical)
self.setCentralWidget(self.splitter)
cs = ('fileLogDialog', _('File History Log Columns'))
self.repoview = repoview.HgRepoView(self._repoagent, cs[0], cs,
@@ -301,10 +301,10 @@
self.actionReload.setIcon(qtlib.geticon('view-refresh'))

self.actionBack = QAction(_('Back'), self, enabled=False,
- shortcut=QKeySequence.Back,
+ shortcut=QKeySequence.StandardKey.Back,
icon=qtlib.geticon('go-previous'))
self.actionForward = QAction(_('Forward'), self, enabled=False,
- shortcut=QKeySequence.Forward,
+ shortcut=QKeySequence.StandardKey.Forward,
icon=qtlib.geticon('go-next'))
self.repoview.revisionSelected.connect(self._updateHistoryActions)
self.actionBack.triggered.connect(self.repoview.back)
@@ -358,7 +358,7 @@
a = menu.addAction(_('Show Revision &Details'))
a.setIcon(qtlib.geticon('hg-log'))
a.triggered.connect(self.onShowRevisionDetails)
- menu.setAttribute(Qt.WA_DeleteOnClose)
+ menu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
menu.popup(point)

def onShowRevisionDetails(self):
@@ -460,12 +460,12 @@

def setupUi(self):
self.editToolbar = QToolBar(self)
- self.editToolbar.setContextMenuPolicy(Qt.PreventContextMenu)
- self.addToolBar(Qt.ToolBarArea(Qt.TopToolBarArea), self.editToolbar)
+ self.editToolbar.setContextMenuPolicy(Qt.ContextMenuPolicy.PreventContextMenu)
+ self.addToolBar(Qt.ToolBarArea(Qt.ToolBarArea.TopToolBarArea), self.editToolbar)
self.actionClose = QAction(self)
- self.actionClose.setShortcuts(QKeySequence.Close)
+ self.actionClose.setShortcuts(QKeySequence.StandardKey.Close)
self.actionReload = QAction(self)
- self.actionReload.setShortcuts(QKeySequence.Refresh)
+ self.actionReload.setShortcuts(QKeySequence.StandardKey.Refresh)
self.editToolbar.addAction(self.actionReload)
self.addAction(self.actionClose)

@@ -474,14 +474,14 @@
w.setLayout(layout)
return w

- self.splitter = QSplitter(Qt.Vertical)
+ self.splitter = QSplitter(Qt.Orientation.Vertical)
self.setCentralWidget(self.splitter)
self.horizontalLayout = QHBoxLayout()
self._repoViews = []
cs = ('fileDiffDialogLeft', _('File Differences Log Columns'))
for cfgname in [cs[0], 'fileDiffDialogRight']:
w = repoview.HgRepoView(self._repoagent, cfgname, cs, self)
- w.setSelectionMode(QAbstractItemView.SingleSelection)
+ w.setSelectionMode(QAbstractItemView.SelectionMode.SingleSelection)
self.horizontalLayout.addWidget(w)
self._repoViews.append(w)
self.frame = QFrame()
@@ -510,11 +510,11 @@
for side, idx in (('left', 0), ('right', 3)):
sci = _FileDiffScintilla(self.frame)
sci.installEventFilter(self)
- sci.verticalScrollBar().setFocusPolicy(Qt.StrongFocus)
+ sci.verticalScrollBar().setFocusPolicy(Qt.FocusPolicy.StrongFocus)
sci.setFocusProxy(sci.verticalScrollBar())
sci.verticalScrollBar().installEventFilter(self)

- sci.setFrameShape(QFrame.NoFrame)
+ sci.setFrameShape(QFrame.Shape.NoFrame)
sci.setMarginLineNumbers(1, True)
sci.SendScintilla(sci.SCI_SETSELEOLFILLED, True)

@@ -535,20 +535,20 @@
sci.SendScintilla(sci.SCI_SETMARGINMASKN, 1, 0)

# define markers for colorize zones of diff
- self.markerplus = sci.markerDefine(QsciScintilla.Background)
+ self.markerplus = sci.markerDefine(QsciScintilla.MarkerSymbol.Background)
sci.setMarkerBackgroundColor(_colormap['+'], self.markerplus)
- self.markerminus = sci.markerDefine(QsciScintilla.Background)
+ self.markerminus = sci.markerDefine(QsciScintilla.MarkerSymbol.Background)
sci.setMarkerBackgroundColor(_colormap['-'], self.markerminus)
- self.markertriangle = sci.markerDefine(QsciScintilla.Background)
+ self.markertriangle = sci.markerDefine(QsciScintilla.MarkerSymbol.Background)
sci.setMarkerBackgroundColor(_colormap['x'], self.markertriangle)

- self.markerplusline = sci.markerDefine(QsciScintilla.Invisible,
+ self.markerplusline = sci.markerDefine(QsciScintilla.MarkerSymbol.Invisible,
_MARKERPLUSLINE)
- self.markerminusline = sci.markerDefine(QsciScintilla.Invisible,
+ self.markerminusline = sci.markerDefine(QsciScintilla.MarkerSymbol.Invisible,
_MARKERMINUSLINE)
- self.markerplusunderline = sci.markerDefine(QsciScintilla.Invisible,
+ self.markerplusunderline = sci.markerDefine(QsciScintilla.MarkerSymbol.Invisible,
_MARKERPLUSUNDERLINE)
- self.markerminusunderline = sci.markerDefine(QsciScintilla.Invisible,
+ self.markerminusunderline = sci.markerDefine(QsciScintilla.MarkerSymbol.Invisible,
_MARKERMINUSUNDERLINE)

self.viewers[side] = sci
@@ -644,11 +644,11 @@
if watched in self.viewers.values():
# copy page steps to diffblock _after_ viewers are resized; resize
# events will be posted in arbitrary order.
- if event.type() == QEvent.Resize:
+ if event.type() == QEvent.Type.Resize:
self._delayedSyncPageStep.start()
return False
elif watched in self._repoViews:
- if event.type() == QEvent.FocusIn:
+ if event.type() == QEvent.Type.FocusIn:
self._updateFileActionsForSelection(watched.selectionModel())
return False
else:
@@ -855,5 +855,5 @@
return
menu = QMenu(self)
_setupFileMenu(menu, self._fileactions)
- menu.setAttribute(Qt.WA_DeleteOnClose)
+ menu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
menu.popup(point)
diff --git a/tortoisehg/hgqt/filelistview.py b/tortoisehg/hgqt/filelistview.py
--- a/tortoisehg/hgqt/filelistview.py
+++ b/tortoisehg/hgqt/filelistview.py
@@ -53,10 +53,10 @@
# type: (Optional[QWidget]) -> None
QTreeView.__init__(self, parent)
self.setHeaderHidden(True)
- self.setDragDropMode(QAbstractItemView.DragOnly)
- self.setSelectionMode(QAbstractItemView.ExtendedSelection)
+ self.setDragDropMode(QAbstractItemView.DragDropMode.DragOnly)
+ self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
self.setRootIsDecorated(False)
- self.setTextElideMode(Qt.ElideLeft)
+ self.setTextElideMode(Qt.TextElideMode.ElideLeft)

# give consistent height and enable optimization
self.setIconSize(qtlib.smallIconSize())
diff --git a/tortoisehg/hgqt/fileview.py b/tortoisehg/hgqt/fileview.py
--- a/tortoisehg/hgqt/fileview.py
+++ b/tortoisehg/hgqt/fileview.py
@@ -135,7 +135,7 @@
self.filenamelabel = w = QLabel()
w.setWordWrap(True)
f = w.textInteractionFlags()
- w.setTextInteractionFlags(f | Qt.TextSelectableByMouse)
+ w.setTextInteractionFlags(f | Qt.TextInteractionFlag.TextSelectableByMouse)
w.linkActivated.connect(self.linkActivated)
hbox.addWidget(w, 1)

@@ -161,7 +161,7 @@
hbox.addWidget(self.blksearch)

self.sci.cursorPositionChanged.connect(self._updateDiffActions)
- self.sci.setContextMenuPolicy(Qt.CustomContextMenu)
+ self.sci.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.sci.customContextMenuRequested.connect(self._onMenuRequested)
self.sci.SCN_ZOOM.connect(self._updateScrollBar)

@@ -259,7 +259,7 @@
self.actionFind.setIcon(qtlib.geticon('edit-find'))
self.actionFind.setToolTip(_('Toggle display of text search bar'))
self.actionFind.triggered.connect(self._onSearchbarTriggered)
- qtlib.newshortcutsforstdkey(QKeySequence.Find, self,
+ qtlib.newshortcutsforstdkey(QKeySequence.StandardKey.Find, self,
self._showSearchbar)

self.actionShelf = QAction('Shelve', self)
@@ -951,7 +951,7 @@
QColor('blue'), self._forceviewindicator)
# delay until next event-loop in order to complete mouse release
self._sci.SCN_INDICATORRELEASE.connect(self._requestForceDisplay,
- Qt.QueuedConnection)
+ Qt.ConnectionType.QueuedConnection)

@pyqtSlot()
def _requestForceDisplay(self):
@@ -1010,7 +1010,7 @@
except RuntimeError:
sciviewport = None
if watched is sciviewport:
- if event.type() == QEvent.MouseMove:
+ if event.type() == QEvent.Type.MouseMove:
line = self._sci.lineNearPoint(event.pos())
self._emitRevisionHintAtLine(line)
return False
@@ -1192,7 +1192,7 @@
def _margin_style(self):
"""Style for margin area"""
s = Qsci.QsciStyle(qscilib.STYLE_FILEVIEW_MARGIN)
- s.setPaper(QApplication.palette().color(QPalette.Window))
+ s.setPaper(QApplication.palette().color(QPalette.ColorRole.Window))
s.setFont(self._sci.font())
return s

@@ -1269,7 +1269,7 @@
return

lastclick = self._lastmarginclick
- if (state == Qt.ControlModifier
+ if (state == Qt.KeyboardModifier.ControlModifier
or lastclick.elapsed() < QApplication.doubleClickInterval()):
if line >= len(self._links):
# empty line next to the last line
@@ -1282,7 +1282,7 @@

# mimic the default "border selection" behavior,
# which is disabled when you use setMarginSensitivity()
- if state == Qt.ShiftModifier:
+ if state == Qt.KeyboardModifier.ShiftModifier:
r = self._sci.getSelection()
sellinetop, selchartop, sellinebottom, selcharbottom = r
if sellinetop <= line:
@@ -1307,9 +1307,9 @@
def __init__(self, sci, fd, parent=None):
super(_ChunkSelectionViewControl, self).__init__(parent)
self._sci = sci
- p = qtlib.getcheckboxpixmap(QStyle.State_On, QColor('#B0FFA0'), sci)
+ p = qtlib.getcheckboxpixmap(QStyle.StateFlag.State_On, QColor('#B0FFA0'), sci)
self._sci.markerDefine(p, _IncludedChunkStartMarker)
- p = qtlib.getcheckboxpixmap(QStyle.State_Off, QColor('#B0FFA0'), sci)
+ p = qtlib.getcheckboxpixmap(QStyle.StateFlag.State_Off, QColor('#B0FFA0'), sci)
self._sci.markerDefine(p, _ExcludedChunkStartMarker)

self._sci.markerDefine(qsci.Background, _ExcludedLineMarker)
@@ -1335,8 +1335,8 @@
self._sci.setIndicatorForegroundColor(QColor('gray'),
self._excludeindicator)

- self._toggleshortcut = a = QShortcut(Qt.Key_Space, sci)
- a.setContext(Qt.WidgetShortcut)
+ self._toggleshortcut = a = QShortcut(Qt.Key.Key_Space, sci)
+ a.setContext(Qt.ShortcutContext.WidgetShortcut)
a.setEnabled(False)
a.activated.connect(self._toggleCurrentChunk)

@@ -1408,7 +1408,7 @@
return
if line not in self._chunkatline:
return
- if state & Qt.ShiftModifier:
+ if state & Qt.KeyboardModifier.ShiftModifier:
excluded = self._getChunkAtLine(line)
cl = self._currentChunkLine()
end = max(line, cl)
diff --git a/tortoisehg/hgqt/graft.py b/tortoisehg/hgqt/graft.py
--- a/tortoisehg/hgqt/graft.py
+++ b/tortoisehg/hgqt/graft.py
@@ -59,7 +59,7 @@
super(GraftDialog, self).__init__(parent)
self.setWindowIcon(qtlib.geticon('hg-transplant'))
self.setWindowFlags(self.windowFlags()
- & ~Qt.WindowContextHelpButtonHint)
+ & ~Qt.WindowType.WindowContextHelpButtonHint)

self._repoagent = repoagent
self._cmdsession = cmdcore.nullCmdSession()
@@ -136,11 +136,11 @@
box.addWidget(self._stbar)

bbox = QDialogButtonBox()
- self.cancelbtn = bbox.addButton(QDialogButtonBox.Cancel)
+ self.cancelbtn = bbox.addButton(QDialogButtonBox.StandardButton.Cancel)
self.cancelbtn.clicked.connect(self.reject)
- self.graftbtn = bbox.addButton(_('Graft'), QDialogButtonBox.ActionRole)
+ self.graftbtn = bbox.addButton(_('Graft'), QDialogButtonBox.ButtonRole.ActionRole)
self.graftbtn.clicked.connect(self.graft)
- self.abortbtn = bbox.addButton(_('Abort'), QDialogButtonBox.ActionRole)
+ self.abortbtn = bbox.addButton(_('Abort'), QDialogButtonBox.ButtonRole.ActionRole)
self.abortbtn.clicked.connect(self.abort)
box.addWidget(bbox)
self.bbox = bbox
diff --git a/tortoisehg/hgqt/grep.py b/tortoisehg/hgqt/grep.py
--- a/tortoisehg/hgqt/grep.py
+++ b/tortoisehg/hgqt/grep.py
@@ -100,7 +100,7 @@
bt = QPushButton(_('Search'))
bt.setDefault(True)
f = bt.font()
- f.setWeight(QFont.Bold)
+ f.setWeight(QFont.Weight.Bold)
bt.setFont(f)
cbt = QPushButton(_('Stop'))
cbt.setEnabled(False)
@@ -146,7 +146,7 @@
grid.setColumnStretch(3, 1)
grid.setColumnStretch(1, 0)
frame = QFrame()
- frame.setFrameStyle(QFrame.StyledPanel)
+ frame.setFrameStyle(QFrame.Shape.StyledPanel)
revision.toggled.connect(self._onRevisionToggled)
history.toggled.connect(singlematch.setDisabled)
revle.setEnabled(False)
@@ -297,7 +297,7 @@
self.thread.wait(2000)

def keyPressEvent(self, event):
- if (event.key() == Qt.Key_Escape
+ if (event.key() == Qt.Key.Key_Escape
and self.thread and self.thread.isRunning()):
self.stopClicked()
else:
@@ -603,8 +603,8 @@
self.setDragDropMode(QTableView.DragOnly)
self.setItemDelegateForColumn(COL_TEXT, self.delegate)
self.setSelectionMode(QTableView.ExtendedSelection)
- self.setSelectionBehavior(QAbstractItemView.SelectRows)
- self.setContextMenuPolicy(Qt.CustomContextMenu)
+ self.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
+ self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.setShowGrid(False)
vh = self.verticalHeader()
vh.hide()
@@ -770,21 +770,21 @@
def columnCount(self, parent=QModelIndex()):
return len(self.headers)

- def data(self, index, role=Qt.DisplayRole):
+ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
if not index.isValid():
return None
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
return self.rows[index.row()][index.column()]
return None

- def headerData(self, col, orientation, role=Qt.DisplayRole):
- if role != Qt.DisplayRole or orientation != Qt.Horizontal:
+ def headerData(self, col, orientation, role=Qt.ItemDataRole.DisplayRole):
+ if role != Qt.ItemDataRole.DisplayRole or orientation != Qt.Orientation.Horizontal:
return None
else:
return self.headers[col]

def flags(self, index):
- flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled
+ flags = Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsDragEnabled
return flags

def mimeTypes(self):
@@ -818,7 +818,7 @@
def sort(self, col, order):
self.layoutAboutToBeChanged.emit()
self.rows.sort(key=lambda x: x[col],
- reverse=(order == Qt.DescendingOrder))
+ reverse=(order == Qt.SortOrder.DescendingOrder))
self.layoutChanged.emit()

## Custom methods
@@ -843,7 +843,7 @@
class SearchDialog(QDialog):
def __init__(self, repoagent, upats, parent=None, **opts):
super(SearchDialog, self).__init__(parent)
- self.setWindowFlags(Qt.Window)
+ self.setWindowFlags(Qt.WindowType.Window)
self.setWindowIcon(qtlib.geticon('view-filter'))
self.setWindowTitle(_('TortoiseHg Search'))

diff --git a/tortoisehg/hgqt/guess.py b/tortoisehg/hgqt/guess.py
--- a/tortoisehg/hgqt/guess.py
+++ b/tortoisehg/hgqt/guess.py
@@ -78,14 +78,14 @@
self.setWindowTitle(_('Detect Copies/Renames in %s')
% repoagent.displayName())
self.setWindowIcon(qtlib.geticon('thg-guess'))
- self.setWindowFlags(Qt.Window)
+ self.setWindowFlags(Qt.WindowType.Window)

layout = QVBoxLayout()
layout.setContentsMargins(*(2,)*4)
self.setLayout(layout)

# vsplit for top & diff
- vsplit = QSplitter(Qt.Horizontal)
+ vsplit = QSplitter(Qt.Orientation.Horizontal)
utframe = QFrame(vsplit)
matchframe = QFrame(vsplit)

@@ -96,7 +96,7 @@
matchvbox.setContentsMargins(*(2,)*4)
matchframe.setLayout(matchvbox)

- hsplit = QSplitter(Qt.Vertical)
+ hsplit = QSplitter(Qt.Orientation.Vertical)
layout.addWidget(hsplit)
hsplit.addWidget(vsplit)
utheader = QHBoxLayout()
@@ -112,18 +112,18 @@
utheader.addWidget(tb)

self.unrevlist = QListWidget()
- self.unrevlist.setSelectionMode(QAbstractItemView.ExtendedSelection)
+ self.unrevlist.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
self.unrevlist.doubleClicked.connect(self.onUnrevDoubleClicked)
utvbox.addWidget(self.unrevlist)

simhbox = QHBoxLayout()
utvbox.addLayout(simhbox)
lbl = QLabel()
- slider = QSlider(Qt.Horizontal)
+ slider = QSlider(Qt.Orientation.Horizontal)
slider.setRange(0, 100)
slider.setTickInterval(10)
slider.setPageStep(10)
- slider.setTickPosition(QSlider.TicksBelow)
+ slider.setTickPosition(QSlider.TickPosition.TicksBelow)
slider.changefunc = lambda v: lbl.setText(
_('Min Similarity: %d%%') % v)
slider.valueChanged.connect(slider.changefunc)
@@ -174,7 +174,7 @@
selmodel = matchtv.selectionModel()
selmodel.selectionChanged.connect(matchselect)

- sp = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+ sp = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
sp.setHorizontalStretch(1)
matchframe.setSizePolicy(sp)

@@ -384,7 +384,7 @@
def data(self, index, role):
if not index.isValid():
return None
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
s = self.rows[index.row()][index.column()]
f = self.displayformats[index.column()]
return f(s)
@@ -395,19 +395,19 @@
return QColor('green')
else:
return QColor('black')
- elif role == Qt.ToolTipRole:
+ elif role == Qt.ItemDataRole.ToolTipRole:
# explain what row means?
'''
return None

def headerData(self, col, orientation, role):
- if role != Qt.DisplayRole or orientation != Qt.Horizontal:
+ if role != Qt.ItemDataRole.DisplayRole or orientation != Qt.Orientation.Horizontal:
return None
else:
return self.headers[col]

def flags(self, index):
- return Qt.ItemIsSelectable | Qt.ItemIsEnabled
+ return Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsEnabled

# Custom methods

@@ -442,7 +442,7 @@
self.beginResetModel()
self.layoutAboutToBeChanged.emit()
self.rows.sort(key=lambda x: x[col],
- reverse=(order == Qt.DescendingOrder))
+ reverse=(order == Qt.SortOrder.DescendingOrder))
self.layoutChanged.emit()
self.endResetModel()

diff --git a/tortoisehg/hgqt/hgemail.py b/tortoisehg/hgqt/hgemail.py
--- a/tortoisehg/hgqt/hgemail.py
+++ b/tortoisehg/hgqt/hgemail.py
@@ -58,7 +58,7 @@
(Passed as `hg email --bundle --rev {rev}`)
"""
super(EmailDialog, self).__init__(parent)
- self.setWindowFlags(Qt.Window)
+ self.setWindowFlags(Qt.WindowType.Window)
self._repoagent = repoagent
self._cmdsession = cmdcore.nullCmdSession()
self._outgoing = outgoing
@@ -409,22 +409,22 @@
return None

rev = self._revs[index.row()]
- if index.column() == 0 and role == Qt.CheckStateRole:
- return rev in self._selectedrevs and Qt.Checked or Qt.Unchecked
- if role == Qt.DisplayRole:
+ if index.column() == 0 and role == Qt.ItemDataRole.CheckStateRole:
+ return rev in self._selectedrevs and Qt.CheckState.Checked or Qt.CheckState.Unchecked
+ if role == Qt.ItemDataRole.DisplayRole:
coldata = self._COLUMNS[index.column()][1]
return hglib.tounicode(coldata(self._repo[rev]))

return None

- def setData(self, index, value, role=Qt.EditRole):
+ def setData(self, index, value, role=Qt.ItemDataRole.EditRole):
if not index.isValid() or self._readonly:
return False

rev = self._revs[index.row()]
- if index.column() == 0 and role == Qt.CheckStateRole:
+ if index.column() == 0 and role == Qt.ItemDataRole.CheckStateRole:
origvalue = rev in self._selectedrevs
- if value == Qt.Checked:
+ if value == Qt.CheckState.Checked:
self._selectedrevs.add(rev)
else:
self._selectedrevs.remove(rev)
@@ -442,7 +442,7 @@
def flags(self, index):
v = super(_ChangesetsModel, self).flags(index)
if index.column() == 0 and not self._readonly:
- return Qt.ItemIsUserCheckable | v
+ return Qt.ItemFlag.ItemIsUserCheckable | v
else:
return v

@@ -457,7 +457,7 @@
return len(self._COLUMNS)

def headerData(self, section, orientation, role):
- if role != Qt.DisplayRole or orientation != Qt.Horizontal:
+ if role != Qt.ItemDataRole.DisplayRole or orientation != Qt.Orientation.Horizontal:
return None

return self._COLUMNS[section][0].capitalize()
diff --git a/tortoisehg/hgqt/hgignore.py b/tortoisehg/hgqt/hgignore.py
--- a/tortoisehg/hgqt/hgignore.py
+++ b/tortoisehg/hgqt/hgignore.py
@@ -65,8 +65,8 @@
'Initialize the Dialog'
QDialog.__init__(self, parent)
self.setWindowFlags(self.windowFlags()
- & ~Qt.WindowContextHelpButtonHint
- | Qt.WindowMaximizeButtonHint)
+ & ~Qt.WindowType.WindowContextHelpButtonHint
+ | Qt.WindowType.WindowMaximizeButtonHint)

self._repoagent = repoagent
self.pats = pats
@@ -134,12 +134,12 @@

ignorelist = QListWidget()
ivbox.addWidget(ignorelist)
- ignorelist.setSelectionMode(QAbstractItemView.ExtendedSelection)
+ ignorelist.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
unknownlist = QListWidget()
uvbox.addWidget(unknownlist)
- unknownlist.setSelectionMode(QAbstractItemView.ExtendedSelection)
+ unknownlist.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
unknownlist.currentTextChanged.connect(self.setGlobFilter)
- unknownlist.setContextMenuPolicy(Qt.CustomContextMenu)
+ unknownlist.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
unknownlist.customContextMenuRequested.connect(self.menuRequest)
unknownlist.itemDoubleClicked.connect(self.unknownDoubleClicked)
lbl = QLabel(_('Backspace or Del to remove row(s)'))
@@ -170,9 +170,9 @@
def eventFilter(self, obj, event):
if obj != self.ignorelist:
return False
- if event.type() != QEvent.KeyPress:
+ if event.type() != QEvent.Type.KeyPress:
return False
- elif event.key() not in (Qt.Key_Backspace, Qt.Key_Delete):
+ elif event.key() not in (Qt.Key.Key_Backspace, Qt.Key.Key_Delete):
return False
if obj.currentRow() < 0:
return False
@@ -250,7 +250,7 @@

def editClicked(self):
ignfile = hglib.tounicode(self.ignorefile)
- if qscilib.fileEditor(ignfile) == QDialog.Accepted:
+ if qscilib.fileEditor(ignfile) == QDialog.DialogCode.Accepted:
self.refresh()

def addEntry(self):
diff --git a/tortoisehg/hgqt/hginit.py b/tortoisehg/hgqt/hginit.py
--- a/tortoisehg/hgqt/hginit.py
+++ b/tortoisehg/hgqt/hginit.py
@@ -56,7 +56,7 @@
def __init__(self, ui, cmdagent, destdir='.', parent=None):
# type: (uimod.ui, cmdcore.CmdAgent, Text, Optional[QWidget]) -> None
super(InitWidget, self).__init__(parent)
- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self._cmdagent = cmdagent

form = QFormLayout()
diff --git a/tortoisehg/hgqt/htmldelegate.py b/tortoisehg/hgqt/htmldelegate.py
--- a/tortoisehg/hgqt/htmldelegate.py
+++ b/tortoisehg/hgqt/htmldelegate.py
@@ -25,7 +25,7 @@
def paint(self, painter, option, index):
# draw selection
option = QStyleOptionViewItemV4(option)
- self.parent().style().drawControl(QStyle.CE_ItemViewItem, option, painter)
+ self.parent().style().drawControl(QStyle.ControlElement.CE_ItemViewItem, option, painter)

# draw text
doc = self._builddoc(option, index)
@@ -36,14 +36,14 @@
option.rect.top() + (option.rect.height() - doc.size().height()) / 2))
ctx = QAbstractTextDocumentLayout.PaintContext()
ctx.palette = option.palette
- if option.state & QStyle.State_Selected:
- if option.state & QStyle.State_Active:
- ctx.palette.setCurrentColorGroup(QPalette.Active)
+ if option.state & QStyle.StateFlag.State_Selected:
+ if option.state & QStyle.StateFlag.State_Active:
+ ctx.palette.setCurrentColorGroup(QPalette.ColorGroup.Active)
else:
- ctx.palette.setCurrentColorGroup(QPalette.Inactive)
- ctx.palette.setBrush(QPalette.Text, ctx.palette.highlightedText())
- elif not option.state & QStyle.State_Enabled:
- ctx.palette.setCurrentColorGroup(QPalette.Disabled)
+ ctx.palette.setCurrentColorGroup(QPalette.ColorGroup.Inactive)
+ ctx.palette.setBrush(QPalette.ColorRole.Text, ctx.palette.highlightedText())
+ elif not option.state & QStyle.StateFlag.State_Enabled:
+ ctx.palette.setCurrentColorGroup(QPalette.ColorGroup.Disabled)

doc.documentLayout().draw(painter, ctx)
painter.restore()
diff --git a/tortoisehg/hgqt/infobar.py b/tortoisehg/hgqt/infobar.py
--- a/tortoisehg/hgqt/infobar.py
+++ b/tortoisehg/hgqt/infobar.py
@@ -120,12 +120,12 @@
}

def __init__(self, parent=None):
- super(InfoBar, self).__init__(parent, frameShape=QFrame.StyledPanel,
- frameShadow=QFrame.Plain)
+ super(InfoBar, self).__init__(parent, frameShape=QFrame.Shape.StyledPanel,
+ frameShadow=QFrame.Shadow.Plain)
self.setAutoFillBackground(True)
p = self.palette()
- p.setColor(QPalette.Window, QColor(self._colormap[self.infobartype]))
- p.setColor(QPalette.WindowText, QColor("black"))
+ p.setColor(QPalette.ColorRole.Window, QColor(self._colormap[self.infobartype]))
+ p.setColor(QPalette.ColorRole.WindowText, QColor("black"))
self.setPalette(p)

self.setLayout(QHBoxLayout())
@@ -133,7 +133,7 @@

self.layout().addStretch()
self._closebutton = QPushButton(self, flat=True, autoDefault=False,
- icon=self.style().standardIcon(QStyle.SP_TitleBarCloseButton))
+ icon=self.style().standardIcon(QStyle.StandardPixmap.SP_TitleBarCloseButton))
if qtlib.IS_RETINA:
self._closebutton.setIconSize(qtlib.barRetinaIconSize())
self._closebutton.clicked.connect(self.close)
@@ -151,7 +151,7 @@
super(InfoBar, self).closeEvent(event)

def keyPressEvent(self, event):
- if event.key() == Qt.Key_Escape:
+ if event.key() == Qt.Key.Key_Escape:
self.close()
super(InfoBar, self).keyPressEvent(event)

@@ -170,8 +170,8 @@
super(StatusInfoBar, self).__init__(parent)
self._msglabel = QLabel(message, self,
wordWrap=True,
- textInteractionFlags=Qt.TextSelectableByMouse \
- | Qt.LinksAccessibleByMouse)
+ textInteractionFlags=Qt.TextInteractionFlag.TextSelectableByMouse \
+ | Qt.TextInteractionFlag.LinksAccessibleByMouse)
self._msglabel.linkActivated.connect(self.linkActivated)
self.addWidget(self._msglabel, stretch=1)

@@ -186,8 +186,8 @@

self._msglabel = QLabel(message, self,
wordWrap=True,
- textInteractionFlags=Qt.TextSelectableByMouse \
- | Qt.LinksAccessibleByMouse)
+ textInteractionFlags=Qt.TextInteractionFlag.TextSelectableByMouse \
+ | Qt.TextInteractionFlag.LinksAccessibleByMouse)
self._msglabel.linkActivated.connect(self.linkActivated)
self.addWidget(self._msglabel, stretch=1)

@@ -209,15 +209,15 @@
# no wordWrap=True and stretch=1, which inserts unwanted space
# between _msglabel and _buttons.
self._msglabel = QLabel(message, self,
- textInteractionFlags=Qt.TextSelectableByMouse \
- | Qt.LinksAccessibleByMouse)
+ textInteractionFlags=Qt.TextInteractionFlag.TextSelectableByMouse \
+ | Qt.TextInteractionFlag.LinksAccessibleByMouse)
self._msglabel.linkActivated.connect(self.linkActivated)
self.addWidget(self._msglabel)

self._buttons = QDialogButtonBox(self)
- self._buttons.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
- self.acceptButton = self._buttons.addButton(QDialogButtonBox.Ok)
- self.rejectButton = self._buttons.addButton(QDialogButtonBox.Cancel)
+ self._buttons.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
+ self.acceptButton = self._buttons.addButton(QDialogButtonBox.StandardButton.Ok)
+ self.rejectButton = self._buttons.addButton(QDialogButtonBox.StandardButton.Cancel)
self._buttons.accepted.connect(self._accept)
self._buttons.rejected.connect(self._reject)
self.addWidget(self._buttons)
diff --git a/tortoisehg/hgqt/locktool.py b/tortoisehg/hgqt/locktool.py
--- a/tortoisehg/hgqt/locktool.py
+++ b/tortoisehg/hgqt/locktool.py
@@ -269,9 +269,9 @@

def keyPressEvent(self, event):
sess = self._cmdsession
- if event.matches(QKeySequence.Refresh):
+ if event.matches(QKeySequence.StandardKey.Refresh):
self.reload()
- elif event.key() == Qt.Key_Escape and not sess.isFinished():
+ elif event.key() == Qt.Key.Key_Escape and not sess.isFinished():
sess.abort()
else:
return super(LockDialog, self).keyPressEvent(event)
diff --git a/tortoisehg/hgqt/manifestmodel.py b/tortoisehg/hgqt/manifestmodel.py
--- a/tortoisehg/hgqt/manifestmodel.py
+++ b/tortoisehg/hgqt/manifestmodel.py
@@ -90,7 +90,7 @@
# emitted when all files of the revision has been loaded successfully
revLoaded = pyqtSignal(object)

- StatusRole = Qt.UserRole + 1
+ StatusRole = Qt.ItemDataRole.UserRole + 1
"""Role for file change status"""

# -1 and None are valid revision number
@@ -116,18 +116,18 @@
self._populate = _populaterepo
self._rootpopulated = False

- def data(self, index, role=Qt.DisplayRole):
+ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
# type: (QModelIndex, Qt.ItemDataRole) -> Optional[Any]
if not index.isValid():
return

- if role == Qt.DecorationRole:
+ if role == Qt.ItemDataRole.DecorationRole:
return self.fileIcon(index)
if role == self.StatusRole:
return self.fileStatus(index)

e = index.internalPointer() # type: "_Entry"
- if role in (Qt.DisplayRole, Qt.EditRole):
+ if role in (Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.EditRole):
return e.name

def filePath(self, index):
@@ -262,7 +262,7 @@
return f
if not (self.isDir(index) or self.fileStatus(index) == 'R'
or self._populate is _populatepatch):
- f |= Qt.ItemIsDragEnabled
+ f |= Qt.ItemFlag.ItemIsDragEnabled
return f

def index(self, row, column, parent=QModelIndex()):
diff --git a/tortoisehg/hgqt/matching.py b/tortoisehg/hgqt/matching.py
--- a/tortoisehg/hgqt/matching.py
+++ b/tortoisehg/hgqt/matching.py
@@ -42,7 +42,7 @@
def __init__(self, repoagent, rev=None, parent=None):
super(MatchDialog, self).__init__(parent)
self.setWindowFlags(self.windowFlags() & \
- ~Qt.WindowContextHelpButtonHint)
+ ~Qt.WindowType.WindowContextHelpButtonHint)

self.revsetexpression = ''
self._repoagent = repoagent
@@ -88,11 +88,11 @@
expandable=True)
factory = csinfo.factory(self.repo, style=style)
self.rev_to_match_info = factory()
- self.rev_to_match_info.setSizePolicy(QSizePolicy.Preferred,
- QSizePolicy.Fixed)
+ self.rev_to_match_info.setSizePolicy(QSizePolicy.Policy.Preferred,
+ QSizePolicy.Policy.Fixed)
self.rev_to_match_info_lbl = QLabel(_('Revision to Match:'))
self.grid.addWidget(self.rev_to_match_info_lbl, 1, 0,
- Qt.AlignLeft | Qt.AlignTop)
+ Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)
self.grid.addWidget(self.rev_to_match_info, 1, 1)
self.grid.addWidget(self.rev_to_match_info_text, 1, 1)

@@ -102,7 +102,7 @@
expander = qtlib.ExpanderLabel(_('Fields to match:'), False)
expander.expanded.connect(self.show_options)
row = self.grid.rowCount()
- self.grid.addWidget(expander, row, 0, Qt.AlignLeft | Qt.AlignTop)
+ self.grid.addWidget(expander, row, 0, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)
self.grid.addLayout(self.optbox, row, 1)

self.summary_chk = QCheckBox(_('Summary (first description line)'))
@@ -156,11 +156,11 @@

## bottom buttons
buttons = QDialogButtonBox()
- self.close_btn = buttons.addButton(QDialogButtonBox.Close)
+ self.close_btn = buttons.addButton(QDialogButtonBox.StandardButton.Close)
self.close_btn.clicked.connect(self.reject)
self.close_btn.setAutoDefault(False)
self.match_btn = buttons.addButton(_('&Match'),
- QDialogButtonBox.ActionRole)
+ QDialogButtonBox.ButtonRole.ActionRole)
self.match_btn.clicked.connect(self.match)
box.addWidget(buttons)

@@ -169,7 +169,7 @@

# dialog setting
self.setLayout(box)
- self.layout().setSizeConstraint(QLayout.SetMinAndMaxSize)
+ self.layout().setSizeConstraint(QLayout.SizeConstraint.SetMinAndMaxSize)
self.setWindowTitle(_('Find matches - %s') % repoagent.displayName())
self.setWindowIcon(qtlib.geticon('hg-update'))

diff --git a/tortoisehg/hgqt/merge.py b/tortoisehg/hgqt/merge.py
--- a/tortoisehg/hgqt/merge.py
+++ b/tortoisehg/hgqt/merge.py
@@ -58,12 +58,12 @@
assert isinstance(otherrev, int), repr(otherrev)
self._repoagent = repoagent
f = self.windowFlags()
- self.setWindowFlags(f & ~Qt.WindowContextHelpButtonHint)
+ self.setWindowFlags(f & ~Qt.WindowType.WindowContextHelpButtonHint)
self.setWindowTitle(_('Merge - %s') % repoagent.displayName())
self.setWindowIcon(qtlib.geticon('hg-merge'))
- self.setOption(QWizard.NoBackButtonOnStartPage, True)
- self.setOption(QWizard.NoBackButtonOnLastPage, True)
- self.setOption(QWizard.IndependentPages, True)
+ self.setOption(QWizard.WizardOption.NoBackButtonOnStartPage, True)
+ self.setOption(QWizard.WizardOption.NoBackButtonOnLastPage, True)
+ self.setOption(QWizard.WizardOption.IndependentPages, True)

# set pages
summarypage = SummaryPage(repoagent, otherrev, self)
@@ -75,7 +75,7 @@

# move focus to "Next" button so that "Cancel" doesn't eat Enter key
summarypage.refreshFinished.connect(
- self.button(QWizard.NextButton).setFocus)
+ self.button(QWizard.WizardButton.NextButton).setFocus)

self.resize(QSize(700, 489).expandedTo(self.minimumSizeHint()))

@@ -152,7 +152,7 @@
pass

def currentPage(self):
- self.wizard().setOption(QWizard.NoDefaultButton, False)
+ self.wizard().setOption(QWizard.WizardOption.NoDefaultButton, False)

def canExit(self):
if len(self.repo[None].parents()) == 2:
@@ -539,7 +539,7 @@
if self.isComplete():
self.wizard().next()
actionEnter = QAction('alt-enter', self)
- actionEnter.setShortcuts([Qt.CTRL+Qt.Key_Return, Qt.CTRL+Qt.Key_Enter])
+ actionEnter.setShortcuts([Qt.Modifier.CTRL+Qt.Key.Key_Return, Qt.Modifier.CTRL+Qt.Key.Key_Enter])
actionEnter.triggered.connect(tryperform)
self.addAction(actionEnter)

@@ -559,9 +559,9 @@
hblayout.addStretch()
self.layout().addLayout(hblayout)

- self.setButtonText(QWizard.CommitButton, _('Commit Now'))
+ self.setButtonText(QWizard.WizardButton.CommitButton, _('Commit Now'))
# The cancel button does not really "cancel" the merge
- self.setButtonText(QWizard.CancelButton, _('Commit Later'))
+ self.setButtonText(QWizard.WizardButton.CancelButton, _('Commit Later'))

# Update the options label
self.refresh()
@@ -578,7 +578,7 @@

def currentPage(self):
super(CommitPage, self).currentPage()
- self.wizard().setOption(QWizard.NoDefaultButton, True)
+ self.wizard().setOption(QWizard.WizardOption.NoDefaultButton, True)
self.mergeCsInfo.update() # show post-merge state

self.msgEntry.setText(commit.mergecommitmessage(self.repo))
@@ -661,9 +661,9 @@
dlg = commit.DetailsDialog(self._repoagent, self.opts, self.userhist,
self, mode='merge')
dlg.finished.connect(dlg.deleteLater)
- dlg.setWindowFlags(Qt.Sheet)
- dlg.setWindowModality(Qt.WindowModal)
- if dlg.exec_() == QDialog.Accepted:
+ dlg.setWindowFlags(Qt.WindowType.Sheet)
+ dlg.setWindowModality(Qt.WindowModality.WindowModal)
+ if dlg.exec_() == QDialog.DialogCode.Accepted:
self.opts.update(dlg.outopts)
self.refresh()

@@ -685,4 +685,4 @@
def currentPage(self):
super(ResultPage, self).currentPage()
self.mergeCsInfo.update(self.repo[b'tip'])
- self.wizard().setOption(QWizard.NoCancelButton, True)
+ self.wizard().setOption(QWizard.WizardOption.NoCancelButton, True)
diff --git a/tortoisehg/hgqt/messageentry.py b/tortoisehg/hgqt/messageentry.py
--- a/tortoisehg/hgqt/messageentry.py
+++ b/tortoisehg/hgqt/messageentry.py
@@ -39,7 +39,7 @@
def __init__(self, parent, getCheckedFunc=None):
super(MessageEntry, self).__init__(parent)
self.setEdgeColor(QColor('LightSalmon'))
- self.setEdgeMode(QsciScintilla.EdgeLine)
+ self.setEdgeMode(QsciScintilla.EdgeMode.EdgeLine)
self.setReadOnly(False)
self.setMarginWidth(1, 0)
self.setFont(qtlib.getfont('fontcomment').font())
@@ -47,19 +47,19 @@
self.setCaretLineBackgroundColor(QColor("#e6fff0"))
self.setCaretLineVisible(True)
self.setAutoIndent(True)
- self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
+ self.setAutoCompletionSource(QsciScintilla.AutoCompletionSource.AcsAPIs)
self.setAutoCompletionFillupsEnabled(True)
- self.setMatchedBraceBackgroundColor(Qt.yellow)
+ self.setMatchedBraceBackgroundColor(Qt.GlobalColor.yellow)
self.setIndentationsUseTabs(False)
- self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
+ self.setBraceMatching(QsciScintilla.BraceMatch.SloppyBraceMatch)
# https://www.riverbankcomputing.com/pipermail/qscintilla/2009-February/000461.html
- self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
- self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
+ self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
+ self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
# default message entry widgets to word wrap, user may override
- self.setWrapMode(QsciScintilla.WrapWord)
+ self.setWrapMode(QsciScintilla.WrapMode.WrapWord)

self.getChecked = getCheckedFunc
- self.setContextMenuPolicy(Qt.CustomContextMenu)
+ self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.customContextMenuRequested.connect(self.menuRequested)
self.applylexer()

@@ -75,7 +75,7 @@
self.fontHeight = QFontMetrics(font).height()
if qtlib.readBool(QSettings(), 'msgentry/lexer', True):
self.setLexer(QsciLexerMakefile(self))
- self.lexer().setColor(QColor(Qt.red), QsciLexerMakefile.Error)
+ self.lexer().setColor(QColor(Qt.GlobalColor.red), QsciLexerMakefile.Error)
self.lexer().setFont(font)
else:
self.setLexer(None)
@@ -262,7 +262,7 @@
self.horizontalScrollBar().setSliderPosition(0)

def keyPressEvent(self, event):
- if event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_E:
+ if event.modifiers() == Qt.KeyboardModifier.ControlModifier and event.key() == Qt.Key.Key_E:
line, col = self.getCursorPosition()
self.reflowBlock(line)
else:
diff --git a/tortoisehg/hgqt/mq.py b/tortoisehg/hgqt/mq.py
--- a/tortoisehg/hgqt/mq.py
+++ b/tortoisehg/hgqt/mq.py
@@ -81,7 +81,7 @@
parent=parent):
dlg = rejects.RejectsDialog(repo.ui, repo.wjoin(wfile), parent)
r = dlg.exec_()
- rejfiles[ufile] = (r == QDialog.Accepted)
+ rejfiles[ufile] = (r == QDialog.DialogCode.Accepted)

# empty rejfiles means we failed to parse output message
return bool(rejfiles) and all(rejfiles.values())
@@ -402,9 +402,9 @@
def launchOptionsDialog(self):
dlg = OptionsDialog(self._opts, self._parentWidget())
dlg.finished.connect(dlg.deleteLater)
- dlg.setWindowFlags(Qt.Sheet)
- dlg.setWindowModality(Qt.WindowModal)
- if dlg.exec_() == QDialog.Accepted:
+ dlg.setWindowFlags(Qt.WindowType.Sheet)
+ dlg.setWindowModality(Qt.WindowModality.WindowModal)
+ if dlg.exec_() == QDialog.DialogCode.Accepted:
self._opts.update(dlg.outopts)


@@ -474,25 +474,25 @@
elif why is not None:
self._statusmap[patch] = 'unguarded'

- def data(self, index, role=Qt.DisplayRole):
+ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
if not index.isValid():
return
- if role in (Qt.DisplayRole, Qt.EditRole):
+ if role in (Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.EditRole):
return self.patchName(index)
- if role == Qt.DecorationRole:
+ if role == Qt.ItemDataRole.DecorationRole:
return self._statusIcon(index)
- if role == Qt.FontRole:
+ if role == Qt.ItemDataRole.FontRole:
return self._statusFont(index)
- if role == Qt.ToolTipRole:
+ if role == Qt.ItemDataRole.ToolTipRole:
return self._toolTip(index)

def flags(self, index):
flags = super(PatchQueueModel, self).flags(index)
if not index.isValid():
- return flags | Qt.ItemIsDropEnabled # insertion point
+ return flags | Qt.ItemFlag.ItemIsDropEnabled # insertion point
patch = self._series[index.row()]
if self._statusmap.get(patch) != 'applied':
- flags |= Qt.ItemIsDragEnabled
+ flags |= Qt.ItemFlag.ItemIsDragEnabled
return flags

def rowCount(self, parent=QModelIndex()):
@@ -579,7 +579,7 @@
return data

def dropMimeData(self, data, action, row, column, parent):
- if (action != Qt.MoveAction
+ if (action != Qt.DropAction.MoveAction
or not data.hasFormat('application/vnd.thg.mq.series')
or row < 0 or parent.isValid()):
return False
@@ -599,7 +599,7 @@
return True

def supportedDropActions(self):
- return Qt.MoveAction
+ return Qt.DropAction.MoveAction


class MQPatchesWidget(QDockWidget):
@@ -610,9 +610,9 @@
self._actionregistry = actionregistry
self._repoagent = None

- self.setFeatures(QDockWidget.DockWidgetClosable |
- QDockWidget.DockWidgetMovable |
- QDockWidget.DockWidgetFloatable)
+ self.setFeatures(QDockWidget.DockWidgetFeature.DockWidgetClosable |
+ QDockWidget.DockWidgetFeature.DockWidgetMovable |
+ QDockWidget.DockWidgetFeature.DockWidgetFloatable)
self.setWindowTitle(_('Patch Queue'))

w = QWidget()
@@ -665,7 +665,7 @@
}
for n, a in namedActions.items():
self.addAction(a)
- a.setShortcutContext(Qt.WidgetWithChildrenShortcut)
+ a.setShortcutContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
self._actionregistry.registerAction(n, a)

tbar = QToolBar(_('Patch Queue Actions Toolbar'), self)
@@ -700,19 +700,19 @@
qqueuehbox.addWidget(self._qqueueComboWidget, 1)
self._qqueueConfigBtn = QToolButton(self)
self._qqueueConfigBtn.setText('...')
- self._qqueueConfigBtn.setPopupMode(QToolButton.InstantPopup)
+ self._qqueueConfigBtn.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
qqueuehbox.addWidget(self._qqueueConfigBtn)

self._qqueueActions = QueueManagementActions(self)
self._qqueueConfigBtn.setMenu(self._qqueueActions.createMenu(self))

self._queueListWidget = QListView(self)
- self._queueListWidget.setDragDropMode(QAbstractItemView.InternalMove)
- self._queueListWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
+ self._queueListWidget.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove)
+ self._queueListWidget.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
self._queueListWidget.setIconSize(qtlib.smallIconSize() * 0.75)
self._queueListWidget.setSelectionMode(
- QAbstractItemView.ExtendedSelection)
- self._queueListWidget.setContextMenuPolicy(Qt.CustomContextMenu)
+ QAbstractItemView.SelectionMode.ExtendedSelection)
+ self._queueListWidget.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self._queueListWidget.customContextMenuRequested.connect(
self._onMenuRequested)
layout.addWidget(self._queueListWidget, 1)
@@ -795,7 +795,7 @@
menu.addAction(self._qdeleteAct)
menu.addAction(self._qrenameAct)
menu.addAction(self._setGuardsAct)
- menu.setAttribute(Qt.WA_DeleteOnClose)
+ menu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
menu.popup(self._queueListWidget.viewport().mapToGlobal(pos))

def _currentPatchName(self):
@@ -949,7 +949,7 @@
newguards))

def keyPressEvent(self, event):
- if event.key() == Qt.Key_Escape:
+ if event.key() == Qt.Key.Key_Escape:
self._patchActions.abort()
self._qqueueActions.abort()
else:
diff --git a/tortoisehg/hgqt/p4pending.py b/tortoisehg/hgqt/p4pending.py
--- a/tortoisehg/hgqt/p4pending.py
+++ b/tortoisehg/hgqt/p4pending.py
@@ -73,7 +73,7 @@
self.setWindowTitle(_('Pending Perforce Changelists - %s') %
repoagent.displayName())
self.setWindowFlags(self.windowFlags() &
- ~Qt.WindowContextHelpButtonHint)
+ ~Qt.WindowType.WindowContextHelpButtonHint)

@pyqtSlot(str)
def p4clActivated(self, curcl):
@@ -88,8 +88,8 @@
self.cslist.clear()
self.cslist.update(revs)
sensitive = not curcl.endswith(b'(submitted)')
- self.bb.button(QDialogButtonBox.Ok).setEnabled(sensitive)
- self.bb.button(QDialogButtonBox.Discard).setEnabled(sensitive)
+ self.bb.button(QDialogButtonBox.StandardButton.Ok).setEnabled(sensitive)
+ self.bb.button(QDialogButtonBox.StandardButton.Discard).setEnabled(sensitive)
self.curcl = curcl

def submit(self):
@@ -98,8 +98,8 @@
'--config', 'extensions.perfarce=',
'--repository', hglib.tounicode(self.url),
hglib.tounicode(self.curcl[:-10])]
- self.bb.button(QDialogButtonBox.Ok).setEnabled(False)
- self.bb.button(QDialogButtonBox.Discard).setEnabled(False)
+ self.bb.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
+ self.bb.button(QDialogButtonBox.StandardButton.Discard).setEnabled(False)
self.showMessage.emit(_('Submitting p4 changelist...'))
self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
sess.commandFinished.connect(self.commandFinished)
@@ -110,8 +110,8 @@
'--config', 'extensions.perfarce=',
'--repository', hglib.tounicode(self.url),
hglib.tounicode(self.curcl[:-10])]
- self.bb.button(QDialogButtonBox.Ok).setEnabled(False)
- self.bb.button(QDialogButtonBox.Discard).setEnabled(False)
+ self.bb.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
+ self.bb.button(QDialogButtonBox.StandardButton.Discard).setEnabled(False)
self.showMessage.emit(_('Reverting p4 changelist...'))
self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
sess.commandFinished.connect(self.commandFinished)
@@ -119,15 +119,15 @@
@pyqtSlot(int)
def commandFinished(self, ret):
self.showMessage.emit('')
- self.bb.button(QDialogButtonBox.Ok).setEnabled(True)
- self.bb.button(QDialogButtonBox.Discard).setEnabled(True)
+ self.bb.button(QDialogButtonBox.StandardButton.Ok).setEnabled(True)
+ self.bb.button(QDialogButtonBox.StandardButton.Discard).setEnabled(True)
if ret == 0:
self.reject()
else:
cmdui.errorMessageBox(self._cmdsession, self)

def keyPressEvent(self, event):
- if event.key() == Qt.Key_Escape:
+ if event.key() == Qt.Key.Key_Escape:
if not self._cmdsession.isFinished():
self._cmdsession.abort()
else:
diff --git a/tortoisehg/hgqt/phabreview.py b/tortoisehg/hgqt/phabreview.py
--- a/tortoisehg/hgqt/phabreview.py
+++ b/tortoisehg/hgqt/phabreview.py
@@ -103,7 +103,7 @@
:revs: List of revisions to be sent.
"""
super(PhabReviewDialog, self).__init__(parent)
- self.setWindowFlags(Qt.Window)
+ self.setWindowFlags(Qt.WindowType.Window)
self._repoagent = repoagent
self._cmdsession = cmdcore.nullCmdSession()
self._rescansession = cmdcore.nullCmdSession()
@@ -116,7 +116,7 @@
proxymodel = QSortFilterProxyModel(self._qui.available_reviewer_list)
proxymodel.setDynamicSortFilter(True)
proxymodel.setSourceModel(QStandardItemModel())
- proxymodel.setFilterCaseSensitivity(Qt.CaseInsensitive)
+ proxymodel.setFilterCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive)
proxymodel.sort(0)
self.availablereviewersmodel = proxymodel

@@ -251,7 +251,7 @@
reviewer = history.get(username)
if reviewer:
witem = QListWidgetItem(pycompat.unicode(reviewer))
- witem.setData(Qt.UserRole + 1, reviewer)
+ witem.setData(Qt.ItemDataRole.UserRole + 1, reviewer)
reviewers.addItem(witem)
s.endArray()

@@ -274,7 +274,7 @@
selectedreviewers = self._qui.selected_reviewers_list

for i in pycompat.xrange(selectedreviewers.count()):
- reviewer = selectedreviewers.item(i).data(Qt.UserRole + 1)
+ reviewer = selectedreviewers.item(i).data(Qt.ItemDataRole.UserRole + 1)
reviewers[reviewer.username] = reviewer

s = QSettings()
@@ -297,7 +297,7 @@
for i in pycompat.xrange(reviewers.count()):
s.setArrayIndex(i)
s.setValue("username",
- reviewers.item(i).data(Qt.UserRole + 1).username)
+ reviewers.item(i).data(Qt.ItemDataRole.UserRole + 1).username)
s.endArray()

def _initchangesets(self, revs):
@@ -336,7 +336,7 @@
opts['rev'] = hglib.compactrevs(self._revs)

reviewerlist = self._qui.selected_reviewers_list
- opts['reviewer'] = [reviewerlist.item(i).data(Qt.UserRole + 1).username
+ opts['reviewer'] = [reviewerlist.item(i).data(Qt.ItemDataRole.UserRole + 1).username
for i in pycompat.xrange(reviewerlist.count())]

return opts
@@ -419,7 +419,7 @@
url = b'Not Configured!'

reviewerlist = self._qui.selected_reviewers_list
- role = Qt.UserRole + 1
+ role = Qt.ItemDataRole.UserRole + 1

reviewers = [reviewerlist.item(i).data(role).username
for i in pycompat.xrange(reviewerlist.count())]
@@ -621,9 +621,9 @@

for i in self._qui.available_reviewer_list.selectedIndexes():
item = model.item(proxymodel.mapToSource(i).row())
- if not reviewers.findItems(item.text(), Qt.MatchExactly):
+ if not reviewers.findItems(item.text(), Qt.MatchFlag.MatchExactly):
witem = QListWidgetItem(item.text())
- witem.setData(Qt.UserRole + 1, item.data())
+ witem.setData(Qt.ItemDataRole.UserRole + 1, item.data())
reviewers.addItem(witem)

@pyqtSlot()
diff --git a/tortoisehg/hgqt/pick.py b/tortoisehg/hgqt/pick.py
--- a/tortoisehg/hgqt/pick.py
+++ b/tortoisehg/hgqt/pick.py
@@ -57,7 +57,7 @@

# TODO: self.setWindowIcon(qtlib.geticon('hg-pick'))
self.setWindowFlags(self.windowFlags()
- & ~Qt.WindowContextHelpButtonHint)
+ & ~Qt.WindowType.WindowContextHelpButtonHint)
self._repoagent = repoagent
self._cmdsession = cmdcore.nullCmdSession()
self.opts = opts
@@ -93,15 +93,15 @@
box.addWidget(self._stbar)

bbox = QDialogButtonBox()
- self.cancelbtn = bbox.addButton(QDialogButtonBox.Cancel)
+ self.cancelbtn = bbox.addButton(QDialogButtonBox.StandardButton.Cancel)
self.cancelbtn.clicked.connect(self.reject)

self.runbtn = bbox.addButton(_('Pick'),
- QDialogButtonBox.ActionRole)
+ QDialogButtonBox.ButtonRole.ActionRole)
self.runbtn.clicked.connect(self.runCommand)

self.abortbtn = bbox.addButton(_('Abort'),
- QDialogButtonBox.ActionRole)
+ QDialogButtonBox.ButtonRole.ActionRole)
self.abortbtn.clicked.connect(self.abort)
box.addWidget(bbox)

diff --git a/tortoisehg/hgqt/postreview.py b/tortoisehg/hgqt/postreview.py
--- a/tortoisehg/hgqt/postreview.py
+++ b/tortoisehg/hgqt/postreview.py
@@ -137,7 +137,7 @@
def __init__(self, ui, repoagent, revs, parent=None):
# type: (uimod.ui, RepoAgent, Sequence[Union[bytes, int]], Optional[QWidget]) -> None
super(PostReviewDialog, self).__init__(parent)
- self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
+ self.setWindowFlags(self.windowFlags() & ~Qt.WindowType.WindowContextHelpButtonHint)
self.ui = ui
self._repoagent = repoagent
self._cmdsession = cmdcore.nullCmdSession()
@@ -166,7 +166,7 @@
pwd, ok = qtlib.getTextInput(self,
_('Review Board'),
_('Password:'),
- mode=QLineEdit.Password)
+ mode=QLineEdit.EchoMode.Password)
if ok and pwd:
self.password = hglib.fromunicode(pwd)
return True
diff --git a/tortoisehg/hgqt/prune.py b/tortoisehg/hgqt/prune.py
--- a/tortoisehg/hgqt/prune.py
+++ b/tortoisehg/hgqt/prune.py
@@ -52,7 +52,7 @@
super(PruneWidget, self).__init__(parent)
self._repoagent = repoagent

- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
vbox = QVBoxLayout(self)
form = QFormLayout()
vbox.addLayout(form)
diff --git a/tortoisehg/hgqt/purge.py b/tortoisehg/hgqt/purge.py
--- a/tortoisehg/hgqt/purge.py
+++ b/tortoisehg/hgqt/purge.py
@@ -51,7 +51,7 @@
def __init__(self, repoagent, parent=None):
QDialog.__init__(self, parent)
f = self.windowFlags()
- self.setWindowFlags(f & ~Qt.WindowContextHelpButtonHint)
+ self.setWindowFlags(f & ~Qt.WindowType.WindowContextHelpButtonHint)

self._repoagent = repoagent

diff --git a/tortoisehg/hgqt/qdelete.py b/tortoisehg/hgqt/qdelete.py
--- a/tortoisehg/hgqt/qdelete.py
+++ b/tortoisehg/hgqt/qdelete.py
@@ -29,7 +29,7 @@
self.setWindowTitle(_('Delete Patches'))
self.setWindowIcon(qtlib.geticon('hg-qdelete'))
self.setWindowFlags(self.windowFlags()
- & ~Qt.WindowContextHelpButtonHint)
+ & ~Qt.WindowType.WindowContextHelpButtonHint)

self.setLayout(QVBoxLayout())

diff --git a/tortoisehg/hgqt/qfold.py b/tortoisehg/hgqt/qfold.py
--- a/tortoisehg/hgqt/qfold.py
+++ b/tortoisehg/hgqt/qfold.py
@@ -50,8 +50,8 @@
self.setWindowIcon(qtlib.geticon('hg-qfold'))

f = self.windowFlags()
- self.setWindowFlags(f & ~Qt.WindowContextHelpButtonHint
- | Qt.WindowMaximizeButtonHint)
+ self.setWindowFlags(f & ~Qt.WindowType.WindowContextHelpButtonHint
+ | Qt.WindowType.WindowMaximizeButtonHint)

self.setLayout(QVBoxLayout())

@@ -98,9 +98,9 @@

for p in patches:
item = QListWidgetItem(hglib.tounicode(p))
- item.setFlags(Qt.ItemIsSelectable |
- Qt.ItemIsEnabled |
- Qt.ItemIsDragEnabled)
+ item.setFlags(Qt.ItemFlag.ItemIsSelectable |
+ Qt.ItemFlag.ItemIsEnabled |
+ Qt.ItemFlag.ItemIsDragEnabled)
self.ulw.addItem(item)

slbl = QLabel(_('Summary:'))
@@ -109,7 +109,7 @@
self.summ.setFont(qtlib.getfont('fontcomment').font())
self.summ.setMaximumHeight(80)
self.summ.setReadOnly(True)
- self.summ.setFocusPolicy(Qt.NoFocus)
+ self.summ.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.layout().addWidget(self.summ)

BB = QDialogButtonBox
diff --git a/tortoisehg/hgqt/qscilib.py b/tortoisehg/hgqt/qscilib.py
--- a/tortoisehg/hgqt/qscilib.py
+++ b/tortoisehg/hgqt/qscilib.py
@@ -189,7 +189,7 @@
event.commitString())
self._imsupport.insertpreedit(event.preeditString())
for a in event.attributes():
- if a.type == QInputMethodEvent.Cursor:
+ if a.type == QInputMethodEvent.AttributeType.Cursor:
self._imsupport.movepreeditcursor(a.start)
# TextFormat is not supported

@@ -198,8 +198,8 @@
# QScintilla 2.5 can translate Backtab to Shift+SCK_TAB (issue #82)
if QSCINTILLA_VERSION < 0x20500:
def keyPressEvent(self, event):
- if event.key() == Qt.Key_Backtab:
- event = QKeyEvent(event.type(), Qt.Key_Tab, Qt.ShiftModifier)
+ if event.key() == Qt.Key.Key_Backtab:
+ event = QKeyEvent(event.type(), Qt.Key.Key_Tab, Qt.KeyboardModifier.ShiftModifier)
super(ScintillaCompat, self).keyPressEvent(event)

if not hasattr(QsciScintilla, 'createStandardContextMenu'):
@@ -209,27 +209,27 @@
menu = QMenu(self)
if not self.isReadOnly():
a = menu.addAction(_('&Undo'), self.undo)
- a.setShortcuts(QKeySequence.Undo)
+ a.setShortcuts(QKeySequence.StandardKey.Undo)
a.setEnabled(self.isUndoAvailable())
a = menu.addAction(_('&Redo'), self.redo)
- a.setShortcuts(QKeySequence.Redo)
+ a.setShortcuts(QKeySequence.StandardKey.Redo)
a.setEnabled(self.isRedoAvailable())
menu.addSeparator()
a = menu.addAction(_('Cu&t'), self.cut)
- a.setShortcuts(QKeySequence.Cut)
+ a.setShortcuts(QKeySequence.StandardKey.Cut)
a.setEnabled(self.hasSelectedText())
a = menu.addAction(_('&Copy'), self.copy)
- a.setShortcuts(QKeySequence.Copy)
+ a.setShortcuts(QKeySequence.StandardKey.Copy)
a.setEnabled(self.hasSelectedText())
if not self.isReadOnly():
a = menu.addAction(_('&Paste'), self.paste)
- a.setShortcuts(QKeySequence.Paste)
+ a.setShortcuts(QKeySequence.StandardKey.Paste)
a = menu.addAction(_('&Delete'), self.removeSelectedText)
- a.setShortcuts(QKeySequence.Delete)
+ a.setShortcuts(QKeySequence.StandardKey.Delete)
a.setEnabled(self.hasSelectedText())
menu.addSeparator()
a = menu.addAction(_('Select &All'), self.selectAll)
- a.setShortcuts(QKeySequence.SelectAll)
+ a.setShortcuts(QKeySequence.StandardKey.SelectAll)
return menu

# compability mode with QScintilla from Ubuntu 10.04
@@ -286,7 +286,7 @@
super(Scintilla, self).__init__(parent)
self.autoUseTabs = True
self.setUtf8(True)
- self.setWrapVisualFlags(QsciScintilla.WrapFlagByBorder)
+ self.setWrapVisualFlags(QsciScintilla.WrapVisualFlag.WrapFlagByBorder)
self.textChanged.connect(self._resetfindcond)
self._resetfindcond()
self.highlightLines = set()
@@ -544,8 +544,8 @@
self.setIconSize(qtlib.smallIconSize())

a = self.addAction(qtlib.geticon('window-close'), '')
- a.setShortcut(Qt.Key_Escape)
- a.setShortcutContext(Qt.WidgetWithChildrenShortcut)
+ a.setShortcut(Qt.Key.Key_Escape)
+ a.setShortcutContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
a.triggered.connect(self.hide)
self.addWidget(qtlib.Spacer(2, 2))

@@ -560,15 +560,15 @@
self.addWidget(self._wrapchk)

self._prevact = self.addAction(qtlib.geticon('go-up'), _('Prev'))
- self._prevact.setShortcuts(QKeySequence.FindPrevious)
+ self._prevact.setShortcuts(QKeySequence.StandardKey.FindPrevious)
self._nextact = self.addAction(qtlib.geticon('go-down'), _('Next'))
- self._nextact.setShortcuts(QKeySequence.FindNext)
+ self._nextact.setShortcuts(QKeySequence.StandardKey.FindNext)
for a in [self._prevact, self._nextact]:
- a.setShortcutContext(Qt.WidgetWithChildrenShortcut)
+ a.setShortcutContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
a.triggered.connect(self._emitSearchRequested)
w = self.widgetForAction(a)
w.setAutoRaise(False) # no flat button
- w.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
+ w.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)

self._le.textChanged.connect(self._updateSearchButtons)

@@ -587,7 +587,7 @@
self._updateSearchButtons()

def keyPressEvent(self, event):
- if event.key() in (Qt.Key_Enter, Qt.Key_Return):
+ if event.key() in (Qt.Key.Key_Enter, Qt.Key.Key_Return):
return # handled by returnPressed
super(SearchToolBar, self).keyPressEvent(event)

@@ -678,15 +678,15 @@

def __init__(self, parent=None, keys=None, keyseqs=None):
super(KeyPressInterceptor, self).__init__(parent)
- self._keys = {Qt.Key_Escape}
- self._keyseqs = [QKeySequence.Refresh]
+ self._keys = {Qt.Key.Key_Escape}
+ self._keyseqs = [QKeySequence.StandardKey.Refresh]
if keys:
self._keys.update(keys)
if keyseqs:
self._keyseqs.extend(keyseqs)

def eventFilter(self, watched, event):
- if event.type() != QEvent.KeyPress:
+ if event.type() != QEvent.Type.KeyPress:
return super(KeyPressInterceptor, self).eventFilter(
watched, event)
if self._isinterceptable(event):
@@ -704,7 +704,7 @@
def unbindConflictedKeys(sci):
cmdset = sci.standardCommands()
try:
- cmd = cmdset.boundTo(Qt.CTRL + Qt.Key_L)
+ cmd = cmdset.boundTo(Qt.Modifier.CTRL + Qt.Key.Key_L)
if cmd:
cmd.setKey(0)
except AttributeError: # old QScintilla does not have boundTo()
@@ -712,17 +712,17 @@

def qsciEolModeFromOs():
if os.name.startswith('nt'):
- return QsciScintilla.EolWindows
+ return QsciScintilla.EolMode.EolWindows
else:
- return QsciScintilla.EolUnix
+ return QsciScintilla.EolMode.EolUnix

def qsciEolModeFromLine(line):
if line.endswith('\r\n'):
- return QsciScintilla.EolWindows
+ return QsciScintilla.EolMode.EolWindows
elif line.endswith('\r'):
- return QsciScintilla.EolMac
+ return QsciScintilla.EolMode.EolMac
elif line.endswith('\n'):
- return QsciScintilla.EolUnix
+ return QsciScintilla.EolMode.EolUnix
else:
return qsciEolModeFromOs()

@@ -811,12 +811,12 @@
"""Open a simple modal file editing dialog"""
dialog = QDialog()
dialog.setWindowFlags(dialog.windowFlags()
- & ~Qt.WindowContextHelpButtonHint
- | Qt.WindowMaximizeButtonHint)
+ & ~Qt.WindowType.WindowContextHelpButtonHint
+ | Qt.WindowType.WindowMaximizeButtonHint)
dialog.setWindowTitle(filename)
dialog.setLayout(QVBoxLayout())
editor = Scintilla()
- editor.setBraceMatching(QsciScintilla.SloppyBraceMatch)
+ editor.setBraceMatching(QsciScintilla.BraceMatch.SloppyBraceMatch)
editor.installEventFilter(KeyPressInterceptor(dialog))
editor.setMarginLineNumbers(1, True)
editor.setMarginWidth(1, '000')
@@ -827,7 +827,7 @@
editor.setLexer(lexer)

if opts.get('foldable'):
- editor.setFolding(QsciScintilla.BoxedTreeFoldStyle)
+ editor.setFolding(QsciScintilla.FoldStyle.BoxedTreeFoldStyle)
dialog.layout().addWidget(editor)

searchbar = SearchToolBar(dialog)
@@ -839,8 +839,8 @@
if text:
searchbar.setPattern(text)
searchbar.show()
- searchbar.setFocus(Qt.OtherFocusReason)
- qtlib.newshortcutsforstdkey(QKeySequence.Find, dialog, showsearchbar)
+ searchbar.setFocus(Qt.FocusReason.OtherFocusReason)
+ qtlib.newshortcutsforstdkey(QKeySequence.StandardKey.Find, dialog, showsearchbar)
dialog.addActions(searchbar.editorActions())
dialog.layout().addWidget(searchbar)

@@ -857,11 +857,11 @@
dialog.restoreGeometry(qtlib.readByteArray(s, geomname))

if not readFile(editor, filename):
- return QDialog.Rejected
+ return QDialog.DialogCode.Rejected
ret = dialog.exec_()
- if ret != QDialog.Accepted:
+ if ret != QDialog.DialogCode.Accepted:
return ret
if not writeFile(editor, filename):
- return QDialog.Rejected
+ return QDialog.DialogCode.Rejected
s.setValue(geomname, dialog.saveGeometry())
return ret
diff --git a/tortoisehg/hgqt/qtapp.py b/tortoisehg/hgqt/qtapp.py
--- a/tortoisehg/hgqt/qtapp.py
+++ b/tortoisehg/hgqt/qtapp.py
@@ -141,7 +141,7 @@
# can be emitted by another thread; postpones it until next
# eventloop of main (GUI) thread.
self._exceptionOccured.connect(self.putexception,
- Qt.QueuedConnection)
+ Qt.ConnectionType.QueuedConnection)

self._origexcepthook = None
if not self._ui.configbool(b'tortoisehg', b'traceback'):
@@ -231,7 +231,7 @@
for fd in (rfd, wfd):
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
- self._wakeupsn = QSocketNotifier(rfd, QSocketNotifier.Read, self)
+ self._wakeupsn = QSocketNotifier(rfd, QSocketNotifier.Type.Read, self)
self._wakeupsn.activated.connect(self._handleWakeup)
self._origwakeupfd = signal.set_wakeup_fd(wfd)

@@ -359,7 +359,7 @@
reply = socket.readAll()
if data == reply:
return True
- elif socket.error() == QLocalSocket.ConnectionRefusedError:
+ elif socket.error() == QLocalSocket.LocalSocketError.ConnectionRefusedError:
# last server process was crashed?
QLocalServer.removeServer(servername)
return False
@@ -379,8 +379,8 @@
f = QFont(hglib.tounicode(lf.lfFaceName))
f.setItalic(lf.lfItalic)
if lf.lfWeight != win32con.FW_DONTCARE:
- weights = [(0, QFont.Light), (400, QFont.Normal), (600, QFont.DemiBold),
- (700, QFont.Bold), (800, QFont.Black)]
+ weights = [(0, QFont.Weight.Light), (400, QFont.Weight.Normal), (600, QFont.Weight.DemiBold),
+ (700, QFont.Weight.Bold), (800, QFont.Weight.Black)]
n, w = [e for e in weights if e[0] <= lf.lfWeight][-1]
f.setWeight(w)
f.setPixelSize(abs(lf.lfHeight))
@@ -390,8 +390,12 @@
"""Return path to Qt's translation file (.qm)"""
if getattr(sys, 'frozen', False) and os.name == 'nt':
return ':/translations'
+ elif QT_API == 'PyQt5':
+ # QLibraryInfo.LibraryPath.PluginsPath is not available with
+ # PyQt 5.13.2/Qt 5.9.9
+ return QLibraryInfo.location(QLibraryInfo.TranslationsPath)
else:
- return QLibraryInfo.location(QLibraryInfo.TranslationsPath)
+ return QLibraryInfo.location(QLibraryInfo.LibraryPath.TranslationsPath)

class QtRunner(QObject):
"""Run Qt app and hold its windows
@@ -419,7 +423,7 @@
self._opendialog(dlgfunc, args, opts)
return

- QSettings.setDefaultFormat(QSettings.IniFormat)
+ QSettings.setDefaultFormat(QSettings.Format.IniFormat)

self._ui = ui
self._config = hgconfig.HgConfig(ui)
@@ -427,7 +431,7 @@

self._mainapp.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
if sys.platform == 'darwin':
- self._mainapp.setAttribute(Qt.AA_DontShowIconsInMenus, True)
+ self._mainapp.setAttribute(Qt.ApplicationAttribute.AA_DontShowIconsInMenus, True)

self._exccatcher = ExceptionCatcher(ui, self._mainapp, self)
self._gc = GarbageCollector(ui, self)
@@ -457,7 +461,7 @@
# stop services after control returns to the main event loop
self._mainapp.setQuitOnLastWindowClosed(False)
self._mainapp.lastWindowClosed.connect(self._quitGracefully,
- Qt.QueuedConnection)
+ Qt.ConnectionType.QueuedConnection)

dlg, reporoot = self._createdialog(dlgfunc, args, opts)
self._mainreporoot = reporoot
@@ -540,7 +544,7 @@
if not dlg:
return

- dlg.setAttribute(Qt.WA_DeleteOnClose)
+ dlg.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
if reporoot:
dlg.destroyed.connect(self._reporeleaser.map)
self._reporeleaser.setMapping(dlg, reporoot)
@@ -622,8 +626,8 @@
# This assumes that the client process has
# called allowSetForegroundWindow(-1) right before
# sending the request
- wb.setWindowState(wb.windowState() & ~Qt.WindowMinimized
- | Qt.WindowActive)
+ wb.setWindowState(wb.windowState() & ~Qt.WindowState.WindowMinimized
+ | Qt.WindowState.WindowActive)
wb.show()
wb.raise_()
wb.activateWindow()
diff --git a/tortoisehg/hgqt/qtlib.py b/tortoisehg/hgqt/qtlib.py
--- a/tortoisehg/hgqt/qtlib.py
+++ b/tortoisehg/hgqt/qtlib.py
@@ -378,7 +378,7 @@
"""True if white-on-black color scheme is preferable"""
if not palette:
palette = QApplication.palette()
- return palette.color(QPalette.Base).black() >= 0x80
+ return palette.color(QPalette.ColorRole.Base).black() >= 0x80

# _styles maps from ui labels to effects
# _effects maps an effect to font style properties. We define a limited
@@ -678,7 +678,7 @@
for size, subdir, sfx in _SCALABLE_ICON_PATHS:
path = iconpath(subdir, name + sfx)
if QFile.exists(path):
- for mode in (QIcon.Normal, QIcon.Active):
+ for mode in (QIcon.Mode.Normal, QIcon.Mode.Active):
o.addFile(path, size, mode)
if not o.isNull():
return o
@@ -705,7 +705,7 @@
"""Generate an overlaid icon"""
pixmap = base.pixmap(16, 16)
painter = QPainter(pixmap)
- painter.setCompositionMode(QPainter.CompositionMode_SourceOver)
+ painter.setCompositionMode(QPainter.CompositionMode.CompositionMode_SourceOver)
painter.drawPixmap(0, 0, overlay.pixmap(16, 16))
del painter
return QIcon(pixmap)
@@ -758,7 +758,7 @@

def smallIconSize():
style = QApplication.style()
- s = style.pixelMetric(QStyle.PM_SmallIconSize)
+ s = style.pixelMetric(QStyle.PixelMetric.PM_SmallIconSize)
s = _fixIconSizeForRetinaDisplay(s)
return QSize(s, s)

@@ -769,7 +769,7 @@
style = QCommonStyle()
else:
style = QApplication.style()
- s = style.pixelMetric(QStyle.PM_ToolBarIconSize)
+ s = style.pixelMetric(QStyle.PixelMetric.PM_ToolBarIconSize)
s = _fixIconSizeForRetinaDisplay(s)
return QSize(s, s)

@@ -835,17 +835,17 @@
return msg.exec_()

def InfoMsgBox(*args, **kargs):
- return CommonMsgBox(QMessageBox.Information, *args, **kargs)
+ return CommonMsgBox(QMessageBox.Icon.Information, *args, **kargs)

def WarningMsgBox(*args, **kargs):
- return CommonMsgBox(QMessageBox.Warning, *args, **kargs)
+ return CommonMsgBox(QMessageBox.Icon.Warning, *args, **kargs)

def ErrorMsgBox(*args, **kargs):
- return CommonMsgBox(QMessageBox.Critical, *args, **kargs)
+ return CommonMsgBox(QMessageBox.Icon.Critical, *args, **kargs)

def QuestionMsgBox(*args, **kargs):
btn = QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No
- res = CommonMsgBox(QMessageBox.Question, buttons=btn, *args, **kargs)
+ res = CommonMsgBox(QMessageBox.Icon.Question, buttons=btn, *args, **kargs)
return res == QMessageBox.StandardButton.Yes

class CustomPrompt(QMessageBox):
@@ -859,7 +859,7 @@
self.setDetailedText('\n'.join(hglib.tounicode(f) for f in files))
self.hotkeys = {}
for i, s in enumerate(choices):
- btn = self.addButton(s, QMessageBox.AcceptRole)
+ btn = self.addButton(s, QMessageBox.ButtonRole.AcceptRole)
try:
char = s[s.index('&')+1].lower()
self.hotkeys[char] = btn
@@ -884,7 +884,7 @@
# type: (Text, Text, QWidget, List[Text], Optional[Text]) -> None
QDialog.__init__(self, parent)
self.setWindowTitle(title)
- self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
+ self.setWindowFlags(self.windowFlags() & ~Qt.WindowType.WindowContextHelpButtonHint)

self.box = QHBoxLayout()
self.vbox = QVBoxLayout()
@@ -933,7 +933,7 @@
of src/gui/widgets/qcombobox.cpp.
"""
assert isinstance(combo, QComboBox) and combo.isEditable()
- combo.completer().setCaseSensitivity(Qt.CaseSensitive)
+ combo.completer().setCaseSensitivity(Qt.CaseSensitivity.CaseSensitive)

class BadCompletionBlocker(QObject):
"""Disable unexpected inline completion by enter key if selectAll()-ed
@@ -948,7 +948,7 @@
>>> combo.setEditText('initial value')
>>> combo.lineEdit().selectAll()
>>> QApplication.sendEvent(
- ... combo, QKeyEvent(QEvent.KeyPress, Qt.Key_Enter, Qt.NoModifier))
+ ... combo, QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_Enter, Qt.KeyboardModifier.NoModifier))
True
>>> str(combo.currentText())
'history value'
@@ -962,7 +962,7 @@
>>> combo.setEditText('initial value')
>>> combo.lineEdit().selectAll()
>>> QApplication.sendEvent(
- ... combo, QKeyEvent(QEvent.KeyPress, Qt.Key_Enter, Qt.NoModifier))
+ ... combo, QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_Enter, Qt.KeyboardModifier.NoModifier))
True
>>> str(combo.currentText())
'initial value'
@@ -979,8 +979,8 @@
def eventFilter(self, watched, event):
if watched is not self.parent():
return super(BadCompletionBlocker, self).eventFilter(watched, event)
- if (event.type() != QEvent.KeyPress
- or event.key() not in (Qt.Key_Enter, Qt.Key_Return)
+ if (event.type() != QEvent.Type.KeyPress
+ or event.key() not in (Qt.Key.Key_Enter, Qt.Key.Key_Return)
or not watched.isEditable()):
return False
# deselect without completion if all text selected
@@ -1001,7 +1001,7 @@
self._copyActionProps()

def actionEvent(self, event):
- if (event.type() == QEvent.ActionChanged
+ if (event.type() == QEvent.Type.ActionChanged
and event.action() is self._defaultAction):
self._copyActionProps()
super(ActionPushButton, self).actionEvent(event)
@@ -1099,16 +1099,16 @@
def __init__(self, parent=None):
QWidget.__init__(self, parent)
# same policy as status bar of QMainWindow
- self.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed)
+ self.setSizePolicy(QSizePolicy.Policy.Ignored, QSizePolicy.Policy.Fixed)

box = QHBoxLayout()
box.setContentsMargins(*(0,)*4)
self.status_icon = QLabel()
self.status_icon.setMaximumSize(16, 16)
- self.status_icon.setAlignment(Qt.AlignCenter)
+ self.status_icon.setAlignment(Qt.AlignmentFlag.AlignCenter)
box.addWidget(self.status_icon)
self.status_text = QLabel()
- self.status_text.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)
+ self.status_text.setAlignment(Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignLeft)
box.addWidget(self.status_text)
box.addStretch(0)

@@ -1160,9 +1160,9 @@
box.addWidget(label)

sep = QFrame()
- sep.setFrameShadow(QFrame.Sunken)
- sep.setFrameShape(QFrame.HLine)
- box.addWidget(sep, 1, Qt.AlignVCenter)
+ sep.setFrameShadow(QFrame.Shadow.Sunken)
+ sep.setFrameShape(QFrame.Shape.HLine)
+ box.addWidget(sep, 1, Qt.AlignmentFlag.AlignVCenter)

self.setLayout(box)

@@ -1308,7 +1308,7 @@
if key not in self._keytodlgs:
self._keytodlgs[key] = []
self._keytodlgs[key].append(dlg)
- dlg.setAttribute(Qt.WA_DeleteOnClose)
+ dlg.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
dlg.destroyed.connect(self._cleanupdlgs)
return dlg

@@ -1431,10 +1431,10 @@
_('Unable to translate input to local encoding.'),
parent=self)

-def getTextInput(parent, title, label, mode=QLineEdit.Normal, text='',
+def getTextInput(parent, title, label, mode=QLineEdit.EchoMode.Normal, text='',
flags=Qt.WindowFlags()):
- flags |= (Qt.CustomizeWindowHint | Qt.WindowTitleHint
- | Qt.WindowCloseButtonHint)
+ flags |= (Qt.WindowType.CustomizeWindowHint | Qt.WindowType.WindowTitleHint
+ | Qt.WindowType.WindowCloseButtonHint)
dlg = _EncodingSafeInputDialog(parent, flags)
dlg.setWindowTitle(title)
dlg.setLabelText(label)
@@ -1489,7 +1489,7 @@
else:
filterbgcolor = QColor('darkgrey')
self._filterpalette = QPalette()
- self._filterpalette.setColor(QPalette.Base, filterbgcolor)
+ self._filterpalette.setColor(QPalette.ColorRole.Base, filterbgcolor)

def enablefilterpalette(self, enabled=False):
targetwidget = self._targetwref()
diff --git a/tortoisehg/hgqt/quickop.py b/tortoisehg/hgqt/quickop.py
--- a/tortoisehg/hgqt/quickop.py
+++ b/tortoisehg/hgqt/quickop.py
@@ -64,7 +64,7 @@
""" Dialog for performing quick dirstate operations """
def __init__(self, repoagent, command, pats, parent):
QDialog.__init__(self, parent)
- self.setWindowFlags(Qt.Window)
+ self.setWindowFlags(Qt.WindowType.Window)
self.pats = pats
self._repoagent = repoagent
self._cmdsession = cmdcore.nullCmdSession()
@@ -171,7 +171,7 @@
self.stwidget.refreshWctx()
QShortcut(QKeySequence('Ctrl+Return'), self, self.accept)
QShortcut(QKeySequence('Ctrl+Enter'), self, self.accept)
- qtlib.newshortcutsforstdkey(QKeySequence.Refresh, self,
+ qtlib.newshortcutsforstdkey(QKeySequence.StandardKey.Refresh, self,
self.stwidget.refreshWctx)
QShortcut(QKeySequence('Escape'), self, self.reject)

@@ -196,10 +196,10 @@
sess.commandFinished.connect(self.commandFinished)
sess.progressReceived.connect(self.statusbar.setProgress)
self._cmddialog.setSession(sess)
- self.bb.button(QDialogButtonBox.Ok).setEnabled(False)
+ self.bb.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)

def commandFinished(self, ret):
- self.bb.button(QDialogButtonBox.Ok).setEnabled(True)
+ self.bb.button(QDialogButtonBox.StandardButton.Ok).setEnabled(True)
self.statusbar.clearProgress()
if ret == 0:
shlib.shell_notify(self.files)
diff --git a/tortoisehg/hgqt/rebase.py b/tortoisehg/hgqt/rebase.py
--- a/tortoisehg/hgqt/rebase.py
+++ b/tortoisehg/hgqt/rebase.py
@@ -68,7 +68,7 @@
super(RebaseDialog, self).__init__(parent)
self.setWindowIcon(qtlib.geticon('hg-rebase'))
self.setWindowFlags(self.windowFlags()
- & ~Qt.WindowContextHelpButtonHint)
+ & ~Qt.WindowType.WindowContextHelpButtonHint)
self._repoagent = repoagent
self._cmdsession = cmdcore.nullCmdSession()
repo = repoagent.rawRepo()
@@ -147,13 +147,13 @@
box.addWidget(self._stbar)

bbox = QDialogButtonBox()
- self.cancelbtn = bbox.addButton(QDialogButtonBox.Cancel)
+ self.cancelbtn = bbox.addButton(QDialogButtonBox.StandardButton.Cancel)
self.cancelbtn.clicked.connect(self.reject)
self.rebasebtn = bbox.addButton(_('Rebase'),
- QDialogButtonBox.ActionRole)
+ QDialogButtonBox.ButtonRole.ActionRole)
self.rebasebtn.clicked.connect(self.rebase)
self.abortbtn = bbox.addButton(_('Abort'),
- QDialogButtonBox.ActionRole)
+ QDialogButtonBox.ButtonRole.ActionRole)
self.abortbtn.clicked.connect(self.abort)
box.addWidget(bbox)
self.bbox = bbox
diff --git a/tortoisehg/hgqt/rejects.py b/tortoisehg/hgqt/rejects.py
--- a/tortoisehg/hgqt/rejects.py
+++ b/tortoisehg/hgqt/rejects.py
@@ -49,7 +49,7 @@
super(RejectsDialog, self).__init__(parent)
self.setWindowTitle(_('Merge rejected patch chunks into %s') %
hglib.tounicode(path))
- self.setWindowFlags(Qt.Window)
+ self.setWindowFlags(Qt.WindowType.Window)
self.path = path

layout = QVBoxLayout()
@@ -58,7 +58,7 @@
editor.setBraceMatching(qsci.SloppyBraceMatch)
editor.setFolding(qsci.BoxedTreeFoldStyle)
editor.installEventFilter(qscilib.KeyPressInterceptor(self))
- editor.setContextMenuPolicy(Qt.CustomContextMenu)
+ editor.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
editor.customContextMenuRequested.connect(self._onMenuRequested)
self.baseLineColor = editor.markerDefine(qsci.Background, -1)
editor.setMarkerBackgroundColor(QColor('lightblue'), self.baseLineColor)
@@ -70,8 +70,8 @@
searchbar.hide()
def showsearchbar():
searchbar.show()
- searchbar.setFocus(Qt.OtherFocusReason)
- qtlib.newshortcutsforstdkey(QKeySequence.Find, self, showsearchbar)
+ searchbar.setFocus(Qt.FocusReason.OtherFocusReason)
+ qtlib.newshortcutsforstdkey(QKeySequence.StandardKey.Find, self, showsearchbar)
self.addActions(searchbar.editorActions())
layout.addWidget(searchbar)

diff --git a/tortoisehg/hgqt/rename.py b/tortoisehg/hgqt/rename.py
--- a/tortoisehg/hgqt/rename.py
+++ b/tortoisehg/hgqt/rename.py
@@ -55,7 +55,7 @@
iscopy=False):
# type: (RepoAgent, Optional[QWidget], Optional[Text], Optional[Text], bool) -> None
super(RenameWidget, self).__init__(parent)
- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self._repoagent = repoagent

form = QFormLayout()
diff --git a/tortoisehg/hgqt/repofilter.py b/tortoisehg/hgqt/repofilter.py
--- a/tortoisehg/hgqt/repofilter.py
+++ b/tortoisehg/hgqt/repofilter.py
@@ -132,7 +132,7 @@
self.just_got_focus = False

def focusInEvent(self, ev):
- if ev.reason() == Qt.MouseFocusReason:
+ if ev.reason() == Qt.FocusReason.MouseFocusReason:
self.just_got_focus = True
super(SelectAllLineEdit, self).focusInEvent(ev)

@@ -185,13 +185,13 @@

self.revsetcombo = combo = QComboBox()
combo.setEditable(True)
- combo.setInsertPolicy(QComboBox.NoInsert)
+ combo.setInsertPolicy(QComboBox.InsertPolicy.NoInsert)
# don't calculate size hint from history contents, just use as much
# space as possible. this way, the branch combo can be enlarged up
# to its preferred width.
combo.setSizeAdjustPolicy(
- QComboBox.AdjustToMinimumContentsLengthWithIcon)
- combo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
+ QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon)
+ combo.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
combo.setMinimumContentsLength(20)
qtlib.allowCaseChangingInput(combo)
le = combo.lineEdit()
@@ -228,7 +228,7 @@
self.editorBtn.clicked.connect(self.openEditor)
self.addWidget(self.editorBtn)

- icon = self.style().standardIcon(QStyle.SP_TrashIcon)
+ icon = self.style().standardIcon(QStyle.StandardPixmap.SP_TrashIcon)
self.deleteBtn = QToolButton()
self.deleteBtn.setIcon(icon)
self.deleteBtn.setToolTip(_('Delete selected query from history'))
@@ -293,7 +293,7 @@

def eventFilter(self, watched, event):
if watched is self.revsetcombo.lineEdit():
- if event.type() == QEvent.Resize:
+ if event.type() == QEvent.Type.Resize:
self._updateQueryTypeGeometry()
return False
return super(RepoFilterBar, self).eventFilter(watched, event)
@@ -422,7 +422,7 @@

def _initBranchFilter(self):
self._branchLabel = QToolButton(
- text=_('Branch'), popupMode=QToolButton.InstantPopup,
+ text=_('Branch'), popupMode=QToolButton.ToolButtonPopupMode.InstantPopup,
statusTip=_('Display graph the named branch only'))
self._branchMenu = QMenu(self._branchLabel)
self._abranchAction = self._branchMenu.addAction(
@@ -438,8 +438,8 @@

self._branchCombo = QComboBox()
self._branchCombo.setEditable(True)
- self._branchCombo.setInsertPolicy(QComboBox.NoInsert)
- self._branchCombo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
+ self._branchCombo.setInsertPolicy(QComboBox.InsertPolicy.NoInsert)
+ self._branchCombo.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToContents)
self._branchCombo.setLineEdit(SelectAllLineEdit())
self._branchCombo.lineEdit().editingFinished.connect(
self._lineBranchChanged)
@@ -448,7 +448,7 @@
self._branchCombo.currentIndexChanged.connect(self._emitBranchChanged)
completer = QCompleter(self._branchCombo.model(), self._branchCombo)
if hasattr(completer, 'setFilterMode'): # Qt>=5.2
- completer.setFilterMode(Qt.MatchContains)
+ completer.setFilterMode(Qt.MatchFlag.MatchContains)
self._branchCombo.setCompleter(completer)

self.addWidget(self._branchLabel)
@@ -502,7 +502,7 @@
self._branchCombo.setItemData(self._branchCombo.count() - 1, '')
for i, branch in enumerate(branches, self._branchCombo.count()):
self._branchCombo.addItem(branch)
- self._branchCombo.setItemData(i, branch, Qt.ToolTipRole)
+ self._branchCombo.setItemData(i, branch, Qt.ItemDataRole.ToolTipRole)
self._branchCombo.setItemData(i, branch)
self._branchCombo.setEnabled(self.filterEnabled and bool(branches))
self.setBranch(curbranch)
diff --git a/tortoisehg/hgqt/repomodel.py b/tortoisehg/hgqt/repomodel.py
--- a/tortoisehg/hgqt/repomodel.py
+++ b/tortoisehg/hgqt/repomodel.py
@@ -120,8 +120,8 @@
HIDDENREV_COLOR = QColor('#666666')
TROUBLED_COLOR = QColor(172, 34, 34)

-GraphNodeRole = Qt.UserRole + 0
-LabelsRole = Qt.UserRole + 1 # [(text, style), ...]
+GraphNodeRole = Qt.ItemDataRole.UserRole + 0
+LabelsRole = Qt.ItemDataRole.UserRole + 1 # [(text, style), ...]

def _parsebranchcolors(value):
# type: (Text) -> List[Tuple[Text, Text]]
@@ -559,22 +559,22 @@
self._branch_colors[branch] = graph.COLORS[idx]
return self._branch_colors[branch]

- def data(self, index, role=Qt.DisplayRole):
+ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
# type: (QModelIndex, int) -> Any
if not index.isValid():
return None
gnode = self.graph[index.row()]
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
if self._hasFileColumn() and index.column() == FileColumn:
return hglib.tounicode(gnode.extra[0])
- if role == Qt.FontRole:
+ if role == Qt.ItemDataRole.FontRole:
if index.column() in (NodeColumn, GitNodeColumn, ConvertedColumn):
return QFont("Monospace")
if index.column() == DescColumn and gnode.wdparent:
font = QApplication.font('QAbstractItemView')
font.setBold(True)
return font
- if role == Qt.ForegroundRole:
+ if role == Qt.ItemDataRole.ForegroundRole:
if (gnode.shape == graph.NODE_SHAPE_UNAPPLIEDPATCH
and index.column() != DescColumn):
return UNAPPLIED_PATCH_COLOR
@@ -587,7 +587,7 @@
except error.RevlogError as e:
if 'THGDEBUG' in os.environ:
raise
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
return hglib.tounicode(str(e))
else:
return None
@@ -621,12 +621,12 @@
gnode = self.graph[row]
ctx = self.repo[gnode.rev]

- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
textfunc = self._columnmap.get(column)
if textfunc is None:
return None
return textfunc(self, ctx)
- elif role == Qt.ForegroundRole:
+ elif role == Qt.ItemDataRole.ForegroundRole:
color = None
if gnode.instabilities:
color = TROUBLED_COLOR
@@ -656,14 +656,14 @@
row = index.row()
if row >= len(self.graph) and not self.repo.ui.debugflag:
# TODO: should not happen; internal data went wrong (issue #754)
- return Qt.NoItemFlags
+ return Qt.ItemFlag.NoItemFlags
rev, isunapplied = self.graph.getrevstate(row)
if not self.isActiveRev(rev):
- return Qt.NoItemFlags
+ return Qt.ItemFlag.NoItemFlags
if isunapplied:
- flags |= Qt.ItemIsDragEnabled | Qt.ItemIsDropEnabled
+ flags |= Qt.ItemFlag.ItemIsDragEnabled | Qt.ItemFlag.ItemIsDropEnabled
if rev is None:
- flags |= Qt.ItemIsDropEnabled
+ flags |= Qt.ItemFlag.ItemIsDropEnabled
return flags

def isActiveRev(self, rev):
@@ -680,7 +680,7 @@
return [mqpatchmimetype]

def supportedDropActions(self):
- return Qt.MoveAction
+ return Qt.DropAction.MoveAction

def mimeData(self, indexes):
# type: (List[QModelIndex]) -> QMimeData
@@ -719,9 +719,9 @@
self._repoagent.runCommand(cmdline)
return True

- def headerData(self, section, orientation, role=Qt.DisplayRole):
+ def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole):
# type: (int, int, int) -> Optional[Text]
- if orientation == Qt.Horizontal and role == Qt.DisplayRole:
+ if orientation == Qt.Orientation.Horizontal and role == Qt.ItemDataRole.DisplayRole:
return self.allColumnHeaders()[section][1]

def defaultIndex(self):
@@ -739,7 +739,7 @@
if self._selectedrevs and rev not in self._selectedrevs:
rev = max(self._selectedrevs)
index = self.indexFromRev(rev)
- if index.flags() & Qt.ItemIsEnabled:
+ if index.flags() & Qt.ItemFlag.ItemIsEnabled:
return index

if self._filterbranch:
@@ -750,7 +750,7 @@
if not isinstance(gnode.rev, int):
continue
index = self.index(row, 0)
- if index.flags() & Qt.ItemIsEnabled:
+ if index.flags() & Qt.ItemFlag.ItemIsEnabled:
return index
return QModelIndex()

diff --git a/tortoisehg/hgqt/reporegistry.py b/tortoisehg/hgqt/reporegistry.py
--- a/tortoisehg/hgqt/reporegistry.py
+++ b/tortoisehg/hgqt/reporegistry.py
@@ -81,12 +81,12 @@
self.setDragEnabled(True)
self.setAcceptDrops(True)
self.setAutoScroll(True)
- self.setDragDropMode(QAbstractItemView.DragDrop)
- self.setDefaultDropAction(Qt.MoveAction)
+ self.setDragDropMode(QAbstractItemView.DragDropMode.DragDrop)
+ self.setDefaultDropAction(Qt.DropAction.MoveAction)
self.setDropIndicatorShown(True)
- self.setEditTriggers(QAbstractItemView.DoubleClicked
- | QAbstractItemView.EditKeyPressed)
- self.setSelectionBehavior(QAbstractItemView.SelectRows)
+ self.setEditTriggers(QAbstractItemView.EditTrigger.DoubleClicked
+ | QAbstractItemView.EditTrigger.EditKeyPressed)
+ self.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)

def dragEnterEvent(self, event):
if event.source() is self:
@@ -98,9 +98,9 @@
for u in d.urls():
root = paths.find_root(u.toLocalFile())
if root:
- event.setDropAction(Qt.LinkAction)
+ event.setDropAction(Qt.DropAction.LinkAction)
event.accept()
- self.setState(QAbstractItemView.DraggingState)
+ self.setState(QAbstractItemView.State.DraggingState)
break

def dropLocation(self, event):
@@ -115,7 +115,7 @@
indicator = self.dropIndicatorPosition()
group = index.parent()
row = index.row()
- if indicator == QAbstractItemView.BelowItem:
+ if indicator == QAbstractItemView.DropIndicatorPosition.BelowItem:
row = index.row() + 1

return index, group, row
@@ -164,22 +164,22 @@
m.loadSubrepos(repoindex)
accept = True
if accept:
- event.setDropAction(Qt.LinkAction)
+ event.setDropAction(Qt.DropAction.LinkAction)
event.accept()
self.dropAccepted.emit()
self.setAutoScroll(False)
- self.setState(QAbstractItemView.NoState)
+ self.setState(QAbstractItemView.State.NoState)
self.viewport().update()
self.setAutoScroll(True)

def keyPressEvent(self, event):
- if (event.key() in (Qt.Key_Enter, Qt.Key_Return)
- and self.state() != QAbstractItemView.EditingState):
+ if (event.key() in (Qt.Key.Key_Enter, Qt.Key.Key_Return)
+ and self.state() != QAbstractItemView.State.EditingState):
index = self.currentIndex()
if index.isValid():
self.openRequested.emit(index)
return
- if event.key() == Qt.Key_Delete:
+ if event.key() == Qt.Key.Key_Delete:
index = self.currentIndex()
if index.isValid():
self.removeRequested.emit(index)
@@ -195,7 +195,7 @@
self.msg = item.details()
self.showMessage.emit(self.msg)

- if event.buttons() == Qt.NoButton:
+ if event.buttons() == Qt.MouseButton.NoButton:
# Bail out early to avoid tripping over this bug:
# https://bugreports.qt.io/browse/QTBUG-10180
return
@@ -234,9 +234,9 @@
self.watcher = None
self._setupSettingActions()

- self.setFeatures(QDockWidget.DockWidgetClosable |
- QDockWidget.DockWidgetMovable |
- QDockWidget.DockWidgetFloatable)
+ self.setFeatures(QDockWidget.DockWidgetFeature.DockWidgetClosable |
+ QDockWidget.DockWidgetFeature.DockWidgetMovable |
+ QDockWidget.DockWidgetFeature.DockWidgetFloatable)
self.setWindowTitle(_('Repository Registry'))

mainframe = QFrame()
@@ -252,7 +252,7 @@
tv.setFirstColumnSpanned(0, QModelIndex(), True)
tv.setColumnHidden(1, True)

- tv.setContextMenuPolicy(Qt.CustomContextMenu)
+ tv.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
tv.customContextMenuRequested.connect(self._onMenuRequested)
tv.showMessage.connect(self.showMessage)
tv.openRequested.connect(self._openRepoAt)
diff --git a/tortoisehg/hgqt/repotab.py b/tortoisehg/hgqt/repotab.py
--- a/tortoisehg/hgqt/repotab.py
+++ b/tortoisehg/hgqt/repotab.py
@@ -78,7 +78,7 @@
# delay until the next event loop so that the current tab won't be
# gone in the middle of switching tabs (issue #4253)
repomanager.repositoryDestroyed.connect(self.closeRepo,
- Qt.QueuedConnection)
+ Qt.ConnectionType.QueuedConnection)

vbox = QVBoxLayout(self)
vbox.setContentsMargins(0, 0, 0, 0)
@@ -99,7 +99,7 @@
vbox.addWidget(tabbar)

self._initTabMenuActions()
- tabbar.setContextMenuPolicy(Qt.CustomContextMenu)
+ tabbar.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
tabbar.customContextMenuRequested.connect(self._onTabMenuRequested)

self._initTabSwitchActions()
@@ -119,8 +119,8 @@

self._updateTabSwitchActions()

- QShortcut(QKeySequence.NextChild, self, self._next_tab)
- QShortcut(QKeySequence.PreviousChild, self, self._prev_tab)
+ QShortcut(QKeySequence.StandardKey.NextChild, self, self._next_tab)
+ QShortcut(QKeySequence.StandardKey.PreviousChild, self, self._prev_tab)

def openRepo(self, root, bundle=None):
"""Open the specified repository in new tab"""
@@ -262,7 +262,7 @@
menu.addAction(self._actions['reopenlastclosedgroup'])
elif self._lastclosedpaths:
menu.addAction(self._actions['reopenlastclosed'])
- menu.setAttribute(Qt.WA_DeleteOnClose)
+ menu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
menu.popup(self._tabbar.mapToGlobal(point))

@pyqtSlot()
diff --git a/tortoisehg/hgqt/repotreeitem.py b/tortoisehg/hgqt/repotreeitem.py
--- a/tortoisehg/hgqt/repotreeitem.py
+++ b/tortoisehg/hgqt/repotreeitem.py
@@ -215,7 +215,7 @@
return []

def flags(self):
- return Qt.NoItemFlags
+ return Qt.ItemFlag.NoItemFlags

def removeRows(self, row, count):
cs = self.childs
@@ -253,7 +253,7 @@
return True

def getSupportedDragDropActions(self):
- return Qt.MoveAction
+ return Qt.DropAction.MoveAction


class RepoItem(RepoTreeItem):
@@ -297,7 +297,7 @@
self._shortname = uname

def data(self, column, role):
- if role == Qt.DecorationRole and column == 0:
+ if role == Qt.ItemDataRole.DecorationRole and column == 0:
baseiconname = 'hg'
if paths.is_unc_path(self.rootpath()):
baseiconname = 'thg-remote-repo'
@@ -307,7 +307,7 @@
elif self._sharedpath:
ico = qtlib.getoverlaidicon(ico, qtlib.geticon('hg-sharedrepo'))
return ico
- elif role in (Qt.DisplayRole, Qt.EditRole):
+ elif role in (Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.EditRole):
return [self.shortname, self.shortpath][column]()

def getCommonPath(self):
@@ -341,8 +341,8 @@
return acts

def flags(self):
- return (Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled
- | Qt.ItemIsEditable)
+ return (Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsDragEnabled
+ | Qt.ItemFlag.ItemIsEditable)

def dump(self, xw):
xw.writeAttribute('root', self._root)
@@ -483,7 +483,7 @@
xmltagname = 'subrepo'

def data(self, column, role):
- if role == Qt.DecorationRole and column == 0:
+ if role == Qt.ItemDataRole.DecorationRole and column == 0:
return _newSubrepoIcon('hg', valid=self._valid)
else:
return super(StandaloneSubrepoItem, self).data(column, role)
@@ -493,7 +493,7 @@
xmltagname = 'subrepo'

def data(self, column, role):
- if role == Qt.DecorationRole and column == 0:
+ if role == Qt.ItemDataRole.DecorationRole and column == 0:
return _newSubrepoIcon('hg', valid=self._valid)
else:
return super(SubrepoItem, self).data(column, role)
@@ -507,10 +507,10 @@
return acts

def getSupportedDragDropActions(self):
- return Qt.CopyAction
+ return Qt.DropAction.CopyAction

def flags(self):
- return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled
+ return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsDragEnabled

# possibly this should not be a RepoItem because it lacks common functions
class AlienSubrepoItem(RepoItem):
@@ -522,7 +522,7 @@
self._repotype = repotype

def data(self, column, role):
- if role == Qt.DecorationRole and column == 0:
+ if role == Qt.ItemDataRole.DecorationRole and column == 0:
return _newSubrepoIcon(self._repotype)
else:
return super(AlienSubrepoItem, self).data(column, role)
@@ -531,7 +531,7 @@
return ['explore', 'terminal', 'copypath']

def flags(self):
- return Qt.ItemIsEnabled | Qt.ItemIsSelectable
+ return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable

def repotype(self):
return self._repotype
@@ -574,10 +574,10 @@
self._commonpath = ''

def data(self, column, role):
- if role == Qt.DecorationRole:
+ if role == Qt.ItemDataRole.DecorationRole:
if column == 0:
s = QApplication.style()
- ico = s.standardIcon(QStyle.SP_DirIcon)
+ ico = s.standardIcon(QStyle.StandardPixmap.SP_DirIcon)
return ico
return None
if column == 0:
@@ -604,8 +604,8 @@
'reloadRegistry']

def flags(self):
- return (Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDropEnabled
- | Qt.ItemIsDragEnabled | Qt.ItemIsEditable)
+ return (Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsDropEnabled
+ | Qt.ItemFlag.ItemIsDragEnabled | Qt.ItemFlag.ItemIsEditable)

def childRoots(self):
return [c._root for c in self.childs if isinstance(c, RepoItem)]
diff --git a/tortoisehg/hgqt/repotreemodel.py b/tortoisehg/hgqt/repotreemodel.py
--- a/tortoisehg/hgqt/repotreemodel.py
+++ b/tortoisehg/hgqt/repotreemodel.py
@@ -74,7 +74,7 @@
xr = QXmlStreamReader(source)
while not xr.atEnd():
t = xr.readNext()
- if (t == QXmlStreamReader.StartElement
+ if (t == QXmlStreamReader.TokenType.StartElement
and xr.name() in ('repo', 'subrepo')):
rti = repotreeitem.undumpObject(xr)
assert isinstance(rti, repotreeitem.RepoItem)
@@ -163,35 +163,35 @@
else:
return self.rootItem.columnCount()

- def data(self, index, role=Qt.DisplayRole):
+ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
if not index.isValid():
return None
- if role not in (Qt.DisplayRole, Qt.EditRole, Qt.DecorationRole,
- Qt.FontRole):
+ if role not in (Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.EditRole, Qt.ItemDataRole.DecorationRole,
+ Qt.ItemDataRole.FontRole):
return None
item = index.internalPointer()
- if role == Qt.FontRole and item is self._activeRepoItem:
+ if role == Qt.ItemDataRole.FontRole and item is self._activeRepoItem:
font = QFont()
font.setBold(True)
return font
else:
return item.data(index.column(), role)

- def headerData(self, section, orientation, role=Qt.DisplayRole):
- if role == Qt.DisplayRole:
- if orientation == Qt.Horizontal:
+ def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole):
+ if role == Qt.ItemDataRole.DisplayRole:
+ if orientation == Qt.Orientation.Horizontal:
if section == 1:
return _('Path')
return None

def flags(self, index):
if not index.isValid():
- return Qt.NoItemFlags
+ return Qt.ItemFlag.NoItemFlags
item = index.internalPointer()
return item.flags()

def supportedDropActions(self):
- return Qt.CopyAction | Qt.MoveAction | Qt.LinkAction
+ return Qt.DropAction.CopyAction | Qt.DropAction.MoveAction | Qt.DropAction.LinkAction

def removeRows(self, row, count, parent=QModelIndex()):
item = parent.internalPointer()
@@ -244,7 +244,7 @@
if group is None:
return False
# Avoid copying subrepos multiple times
- if Qt.CopyAction == action and self.getRepoItem(itemread.rootpath()):
+ if Qt.DropAction.CopyAction == action and self.getRepoItem(itemread.rootpath()):
return False
if row < 0:
row = 0
@@ -255,8 +255,8 @@
self.allrepos = itemread
return True

- def setData(self, index, value, role=Qt.EditRole):
- if not index.isValid() or role != Qt.EditRole:
+ def setData(self, index, value, role=Qt.ItemDataRole.EditRole):
+ if not index.isValid() or role != Qt.ItemDataRole.EditRole:
return False
if not value:
return False
diff --git a/tortoisehg/hgqt/repoview.py b/tortoisehg/hgqt/repoview.py
--- a/tortoisehg/hgqt/repoview.py
+++ b/tortoisehg/hgqt/repoview.py
@@ -95,14 +95,14 @@
vh = self.verticalHeader()
vh.hide()
vh.setMinimumSectionSize(0) # we'll set fixed size later
- vh.setSectionResizeMode(QHeaderView.Fixed)
+ vh.setSectionResizeMode(QHeaderView.ResizeMode.Fixed)

header = self.horizontalHeader()
header.setSectionsClickable(False)
header.setSectionsMovable(True)
- header.setDefaultAlignment(Qt.AlignLeft)
+ header.setDefaultAlignment(Qt.AlignmentFlag.AlignLeft)
header.setHighlightSections(False)
- header.setContextMenuPolicy(Qt.CustomContextMenu)
+ header.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
header.customContextMenuRequested.connect(self.headerMenuRequest)
header.sectionMoved.connect(self.columnsVisibilityChanged)
header.sectionMoved.connect(self._saveColumnSettings)
@@ -116,10 +116,10 @@
LabeledDelegate(self, margin=0))

self.setAcceptDrops(True)
- self.setDefaultDropAction(Qt.MoveAction)
+ self.setDefaultDropAction(Qt.DropAction.MoveAction)
self.setDragEnabled(True)
self.setDropIndicatorShown(True)
- self.setDragDropMode(QAbstractItemView.InternalMove)
+ self.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove)

# do not pass self.style() to HgRepoViewStyle() because it would steal
# the ownership from QApplication and cause SEGV after the deletion of
@@ -127,8 +127,8 @@
self.setStyle(HgRepoViewStyle())
self._paletteswitcher = qtlib.PaletteSwitcher(self)

- self.setSelectionMode(QAbstractItemView.ExtendedSelection)
- self.setSelectionBehavior(QAbstractItemView.SelectRows)
+ self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
+ self.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)

self.doubleClicked.connect(self.revActivated)
if repoagent.configBool('tortoisehg', 'copy_hash_selection'):
@@ -168,7 +168,7 @@
dlg = ColumnSelectDialog(self.colselect[1],
self.model(), self.visibleColumns())
dlg.setRowHeight(self.defaultRowHeight())
- if dlg.exec_() == QDialog.Accepted:
+ if dlg.exec_() == QDialog.DialogCode.Accepted:
self.setVisibleColumns(dlg.selectedColumns())
self.resizeColumns()
self.setDefaultRowHeight(dlg.rowHeight())
@@ -327,7 +327,7 @@
if rev is not None:
clip = QApplication.clipboard()
if clip.supportsSelection():
- clip.setText(str(self.repo[rev]), QClipboard.Selection)
+ clip.setText(str(self.repo[rev]), QClipboard.Mode.Selection)

def revActivated(self, index):
rev = self.revFromindex(index)
@@ -464,8 +464,8 @@
assert model is not None
idx = model.indexFromRev(rev)
if idx.isValid():
- flags = (QItemSelectionModel.ClearAndSelect
- | QItemSelectionModel.Rows)
+ flags = (QItemSelectionModel.SelectionFlag.ClearAndSelect
+ | QItemSelectionModel.SelectionFlag.Rows)
self.selectionModel().setCurrentIndex(idx, flags)
self.scrollTo(idx)

@@ -528,7 +528,7 @@
"Override a style's drawPrimitive method to customize the drop indicator"

def drawPrimitive(self, element, option, painter, widget=None):
- if element == QStyle.PE_IndicatorItemViewItemDrop:
+ if element == QStyle.PrimitiveElement.PE_IndicatorItemViewItemDrop:
# Drop indicators should be painted using the full viewport width
if option.rect.height() != 0:
vp = widget.viewport().rect()
@@ -541,10 +541,10 @@

def get_style(line_type, active):
if line_type == graph.LINE_TYPE_GRAFT:
- return Qt.DashLine
+ return Qt.PenStyle.DashLine
if line_type == graph.LINE_TYPE_OBSOLETE:
- return Qt.DotLine
- return Qt.SolidLine
+ return Qt.PenStyle.DotLine
+ return Qt.PenStyle.SolidLine

def get_width(line_type, active):
if line_type >= graph.LINE_TYPE_FAMILY or not active:
@@ -585,7 +585,7 @@
painter.save()
try:
painter.setClipRect(option.rect)
- painter.setRenderHint(QPainter.Antialiasing)
+ painter.setRenderHint(QPainter.RenderHint.Antialiasing)
painter.translate(option.rect.topLeft())
self._drawEdges(painter, index, gnode, visibleend)
if gnode.x < visibleend:
@@ -645,7 +645,7 @@
dot_color = QColor("gray")
radius = self._dotradius() * 0.8
else:
- fg = index.data(Qt.ForegroundRole)
+ fg = index.data(Qt.ItemDataRole.ForegroundRole)
if not fg:
# work around integrity error in HgRepoListModel, which may
# provide a valid index for stripped revision and data()
@@ -832,7 +832,7 @@
style = option.widget.style()
else:
style = QApplication.style()
- rect = style.subElementRect(QStyle.SE_ItemViewItemDecoration, option,
+ rect = style.subElementRect(QStyle.SubElement.SE_ItemViewItemDecoration, option,
option.widget)

# for maximum readability, use vivid color regardless of option.state
@@ -863,7 +863,7 @@

self.setWindowTitle(name)
self.setWindowFlags(self.windowFlags() & \
- ~Qt.WindowContextHelpButtonHint)
+ ~Qt.WindowType.WindowContextHelpButtonHint)
self.setMinimumSize(250, 265)

disabled = [c for c in all if c not in curcolumns]
@@ -877,14 +877,14 @@
for c in curcolumns + disabled:
item = QListWidgetItem(colnames[c])
item.columnid = c
- item.setFlags(Qt.ItemIsSelectable |
- Qt.ItemIsEnabled |
- Qt.ItemIsDragEnabled |
- Qt.ItemIsUserCheckable)
+ item.setFlags(Qt.ItemFlag.ItemIsSelectable |
+ Qt.ItemFlag.ItemIsEnabled |
+ Qt.ItemFlag.ItemIsDragEnabled |
+ Qt.ItemFlag.ItemIsUserCheckable)
if c in curcolumns:
- item.setCheckState(Qt.Checked)
+ item.setCheckState(Qt.CheckState.Checked)
else:
- item.setCheckState(Qt.Unchecked)
+ item.setCheckState(Qt.CheckState.Unchecked)
list.addItem(item)
list.setDragDropMode(QListView.InternalMove)
layout.addRow(list)
@@ -908,7 +908,7 @@
cols = []
for i in pycompat.xrange(self.list.count()):
item = self.list.item(i)
- if item.checkState() == Qt.Checked:
+ if item.checkState() == Qt.CheckState.Checked:
# TODO: better to use data(role) instead
cols.append(item.columnid) # pytype: disable=attribute-error
return cols
diff --git a/tortoisehg/hgqt/repowidget.py b/tortoisehg/hgqt/repowidget.py
--- a/tortoisehg/hgqt/repowidget.py
+++ b/tortoisehg/hgqt/repowidget.py
@@ -248,7 +248,7 @@
QTimer.singleShot(0, self._initView)

def setupUi(self):
- self.repotabs_splitter = QSplitter(orientation=Qt.Vertical)
+ self.repotabs_splitter = QSplitter(orientation=Qt.Orientation.Vertical)
self.setLayout(QVBoxLayout())
self.layout().setContentsMargins(0, 0, 0, 0)
self.layout().setSpacing(0)
@@ -738,7 +738,7 @@
self.showMessageSignal.emit(msg)

def keyPressEvent(self, event):
- if self._repoviewFrame.activeInfoBar() and event.key() == Qt.Key_Escape:
+ if self._repoviewFrame.activeInfoBar() and event.key() == Qt.Key.Key_Escape:
self.clearInfoBar(infobar.INFO)
else:
QWidget.keyPressEvent(self, event)
@@ -780,7 +780,7 @@
def dragEnterEvent(self, event):
paths = [pycompat.unicode(u.toLocalFile()) for u in event.mimeData().urls()]
if self.detectPatches(paths):
- event.setDropAction(Qt.CopyAction)
+ event.setDropAction(Qt.DropAction.CopyAction)
event.accept()

def dropEvent(self, event):
@@ -788,7 +788,7 @@
patches = self.detectPatches(paths)
if not patches:
return
- event.setDropAction(Qt.CopyAction)
+ event.setDropAction(Qt.DropAction.CopyAction)
event.accept()
self.thgimport(patches)

@@ -848,7 +848,7 @@
dlg = cmdui.CmdSessionDialog(self)
dlg.setWindowIcon(qtlib.geticon('hg-verify'))
dlg.setWindowTitle(_('%s - verify repository') % self.repoDisplayName())
- dlg.setWindowFlags(dlg.windowFlags() | Qt.WindowMaximizeButtonHint)
+ dlg.setWindowFlags(dlg.windowFlags() | Qt.WindowType.WindowMaximizeButtonHint)
dlg.setSession(self._repoagent.runCommand(cmdline, self))
dlg.exec_()

@@ -858,7 +858,7 @@
dlg.setWindowIcon(qtlib.geticon('hg-recover'))
dlg.setWindowTitle(_('%s - recover repository')
% self.repoDisplayName())
- dlg.setWindowFlags(dlg.windowFlags() | Qt.WindowMaximizeButtonHint)
+ dlg.setWindowFlags(dlg.windowFlags() | Qt.WindowType.WindowMaximizeButtonHint)
dlg.setSession(self._repoagent.runCommand(cmdline, self))
dlg.exec_()

@@ -897,8 +897,8 @@

def purge(self):
dlg = purge.PurgeDialog(self._repoagent, self)
- dlg.setWindowFlags(Qt.Sheet)
- dlg.setWindowModality(Qt.WindowModal)
+ dlg.setWindowFlags(Qt.WindowType.Sheet)
+ dlg.setWindowModality(Qt.WindowModality.WindowModal)
dlg.showMessage.connect(self.showMessage)
dlg.progress.connect(self.progress)
dlg.exec_()
@@ -939,9 +939,9 @@
assert model is not None
assert selmodel is not None
index = selmodel.currentIndex()
- if not (index.flags() & Qt.ItemIsEnabled):
+ if not (index.flags() & Qt.ItemFlag.ItemIsEnabled):
index = model.defaultIndex()
- f = QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows
+ f = QItemSelectionModel.SelectionFlag.ClearAndSelect | QItemSelectionModel.SelectionFlag.Rows
selmodel.setCurrentIndex(index, f)
self.repoview.scrollTo(index)
self.repoview.enablefilterpalette(bool(model.revset()))
@@ -1063,10 +1063,10 @@
def updateTaskTabs(self):
val = self._repoagent.configString('tortoisehg', 'tasktabs').lower()
if val == 'east':
- self.taskTabsWidget.setTabPosition(QTabWidget.East)
+ self.taskTabsWidget.setTabPosition(QTabWidget.TabPosition.East)
self.taskTabsWidget.tabBar().show()
elif val == 'west':
- self.taskTabsWidget.setTabPosition(QTabWidget.West)
+ self.taskTabsWidget.setTabPosition(QTabWidget.TabPosition.West)
self.taskTabsWidget.tabBar().show()
else:
self.taskTabsWidget.tabBar().hide()
@@ -1415,7 +1415,7 @@

self._addCustomToolsSubMenu(menu, 'workbench.revdetails.custom-menu')

- menu.setAttribute(Qt.WA_DeleteOnClose)
+ menu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
menu.popup(point)

def _popupPairSelectionMenu(self, point):
@@ -1453,7 +1453,7 @@

self._addCustomToolsSubMenu(menu, 'workbench.pairselection.custom-menu')

- menu.setAttribute(Qt.WA_DeleteOnClose)
+ menu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
menu.popup(point)

def _popupMultipleSelectionMenu(self, point):
@@ -1477,7 +1477,7 @@
self._addCustomToolsSubMenu(menu,
'workbench.multipleselection.custom-menu')

- menu.setAttribute(Qt.WA_DeleteOnClose)
+ menu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
menu.popup(point)

def _popupIncomingBundleMenu(self, point):
@@ -1488,7 +1488,7 @@
'Repository.visualDiff',
])

- menu.setAttribute(Qt.WA_DeleteOnClose)
+ menu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
menu.popup(point)

def _popupUnappliedPatchMenu(self, point):
@@ -1505,13 +1505,13 @@
'PatchQueue.launchOptionsDialog',
])

- menu.setAttribute(Qt.WA_DeleteOnClose)
+ menu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
menu.popup(point)

def _createNamedAction(self, name, attrs, exts=None, icon=None, cb=None):
# type: (Text, Set[Text], Optional[Set[Text]], Optional[Text], Optional[Callable]) -> QAction
act = QAction(self)
- act.setShortcutContext(Qt.WidgetWithChildrenShortcut)
+ act.setShortcutContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
if icon:
act.setIcon(qtlib.geticon(icon))
if cb:
@@ -1978,7 +1978,7 @@
branch=self.repo[self.rev].branch())

def manifestRevision(self):
- if QApplication.keyboardModifiers() & Qt.ShiftModifier:
+ if QApplication.keyboardModifiers() & Qt.KeyboardModifier.ShiftModifier:
self._dialogs.openNew(RepoWidget._createManifestDialog)
else:
dlg = self._dialogs.open(RepoWidget._createManifestDialog)
@@ -2630,7 +2630,7 @@
self._edittbar = tbar = self.addToolBar(_('&Edit Toolbar'))
tbar.setObjectName('edittbar')
a = tbar.addAction(qtlib.geticon('view-refresh'), _('&Refresh'))
- a.setShortcuts(QKeySequence.Refresh)
+ a.setShortcuts(QKeySequence.StandardKey.Refresh)
a.triggered.connect(self.refresh)

tbar = rw.filterBar()
diff --git a/tortoisehg/hgqt/resolve.py b/tortoisehg/hgqt/resolve.py
--- a/tortoisehg/hgqt/resolve.py
+++ b/tortoisehg/hgqt/resolve.py
@@ -71,8 +71,8 @@
self._repoagent = repoagent
self._cmdsession = cmdcore.nullCmdSession()
self.setWindowFlags(self.windowFlags()
- & ~Qt.WindowContextHelpButtonHint
- | Qt.WindowMaximizeButtonHint)
+ & ~Qt.WindowType.WindowContextHelpButtonHint
+ | Qt.WindowType.WindowMaximizeButtonHint)
self.setWindowTitle(_('Resolve Conflicts - %s')
% repoagent.displayName())
self.setWindowIcon(qtlib.geticon('hg-merge'))
@@ -87,7 +87,7 @@

self.refreshButton = tb = QToolButton(self)
tb.setIcon(qtlib.geticon('view-refresh'))
- tb.setShortcut(QKeySequence.Refresh)
+ tb.setShortcut(QKeySequence.StandardKey.Refresh)
tb.clicked.connect(self.refresh)
self.stlabel = QLabel()
hbox.addWidget(tb)
@@ -143,7 +143,7 @@
self.utree.setSortingEnabled(True)
hbox.addWidget(self.utree)

- self.utree.setContextMenuPolicy(Qt.CustomContextMenu)
+ self.utree.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.utreecmenu = QMenu(self)
mergeactions = QActionGroup(self)
mergeactions.triggered.connect(self._mergeByAction)
@@ -197,7 +197,7 @@
self.rtree.setSortingEnabled(True)
hbox.addWidget(self.rtree)

- self.rtree.setContextMenuPolicy(Qt.CustomContextMenu)
+ self.rtree.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.rtreecmenu = QMenu(self)
cmedit = self.rtreecmenu.addAction(_('&Edit File'))
cmedit.setToolTip(_('Edit resolved file'))
@@ -235,7 +235,7 @@
self.layout().addLayout(hbox)

self.tcombo = ToolsCombo(self.repo, self)
- self.tcombo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
+ self.tcombo.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToContents)

hbox.addWidget(QLabel(_('Detected merge/diff tools:')))
hbox.addWidget(self.tcombo)
@@ -414,7 +414,7 @@
model = self.utree.model()
smodel = self.utree.selectionModel()
assert model is not None
- sflags = QItemSelectionModel.Select | QItemSelectionModel.Rows
+ sflags = QItemSelectionModel.SelectionFlag.Select | QItemSelectionModel.SelectionFlag.Rows
for i, path in enumerate(u):
if path in paths:
smodel.select(model.index(i, 0), sflags)
@@ -523,11 +523,11 @@
return 0 # no child
return len(self.headers)

- def data(self, index, role=Qt.DisplayRole):
+ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
# type: (QModelIndex, int) -> Optional[Text]
if not index.isValid():
return None
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
data = self.rows[index.row()][index.column()]
return hglib.tounicode(data)
return None
@@ -537,12 +537,12 @@
flags = super(PathsModel, self).flags(index)
if not index.isValid():
return flags
- flags |= Qt.ItemIsDragEnabled
+ flags |= Qt.ItemFlag.ItemIsDragEnabled
return flags

- def headerData(self, col, orientation, role=Qt.DisplayRole):
+ def headerData(self, col, orientation, role=Qt.ItemDataRole.DisplayRole):
# type: (int, int, int) -> Optional[Text]
- if role != Qt.DisplayRole or orientation != Qt.Horizontal:
+ if role != Qt.ItemDataRole.DisplayRole or orientation != Qt.Orientation.Horizontal:
return None
else:
return self.headers[col]
diff --git a/tortoisehg/hgqt/revdetails.py b/tortoisehg/hgqt/revdetails.py
--- a/tortoisehg/hgqt/revdetails.py
+++ b/tortoisehg/hgqt/revdetails.py
@@ -112,7 +112,7 @@
return self._repoagent.rawRepo()

def setupUi(self):
- self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
+ self.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Expanding)

# + basevbox -------------------------------------------------------+
# |+ filelistsplit ........ |
@@ -133,13 +133,13 @@
basevbox.addWidget(self.filelistsplit)

self.splitternames.append('filelistsplit')
- self.filelistsplit.setOrientation(Qt.Horizontal)
+ self.filelistsplit.setOrientation(Qt.Orientation.Horizontal)
self.filelistsplit.setChildrenCollapsible(False)

self.filelisttbar = QToolBar(_('File List Toolbar'))
self.filelisttbar.setIconSize(qtlib.smallIconSize())
self.filelist = HgFileListView(self)
- self.filelist.setContextMenuPolicy(Qt.CustomContextMenu)
+ self.filelist.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.filelist.customContextMenuRequested.connect(self.menuRequest)
self.filelist.doubleClicked.connect(self.onDoubleClick)
self._filelistpaletteswitcher = qtlib.PaletteSwitcher(self.filelist)
@@ -158,7 +158,7 @@

vbox = QVBoxLayout(self.fileviewframe)
vbox.setSpacing(0)
- vbox.setSizeConstraint(QLayout.SetDefaultConstraint)
+ vbox.setSizeConstraint(QLayout.SizeConstraint.SetDefaultConstraint)
vbox.setContentsMargins(0, 0, 0, 0)
panelframevbox = vbox

@@ -167,16 +167,16 @@
self.messagesplitter.setStyle(QStyleFactory.create('Plastique'))

self.splitternames.append('messagesplitter')
- self.messagesplitter.setSizePolicy(QSizePolicy.Preferred,
- QSizePolicy.Expanding)
+ self.messagesplitter.setSizePolicy(QSizePolicy.Policy.Preferred,
+ QSizePolicy.Policy.Expanding)
self.messagesplitter.setMinimumSize(QSize(50, 50))
- self.messagesplitter.setFrameShape(QFrame.NoFrame)
+ self.messagesplitter.setFrameShape(QFrame.Shape.NoFrame)
self.messagesplitter.setLineWidth(0)
self.messagesplitter.setMidLineWidth(0)
- self.messagesplitter.setOrientation(Qt.Vertical)
+ self.messagesplitter.setOrientation(Qt.Orientation.Vertical)
self.messagesplitter.setOpaqueResize(True)
self.message = QTextBrowser(self.messagesplitter,
- lineWrapMode=QTextEdit.NoWrap,
+ lineWrapMode=QTextEdit.LineWrapMode.NoWrap,
openLinks=False)
self.message.minimumSizeHint = lambda: QSize(0, 25)
self.message.anchorClicked.connect(self._forwardAnchorClicked)
@@ -277,7 +277,7 @@
m = QMenu(w)
m.addActions(self._parentToggleGroup.actions())
w.setMenu(m)
- w.setPopupMode(QToolButton.MenuButtonPopup)
+ w.setPopupMode(QToolButton.ToolButtonPopupMode.MenuButtonPopup)
self._actionParentToggle = a = tbar.addWidget(w)
a.setIcon(qtlib.geticon('hg-merged-both'))
a.setToolTip(_('Toggle parent to be used as the base revision'))
@@ -292,12 +292,12 @@
def eventFilter(self, watched, event):
# switch between filter and list seamlessly
if watched is self.filefilter:
- if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Down:
+ if event.type() == QEvent.Type.KeyPress and event.key() == Qt.Key.Key_Down:
self.filelist.setFocus()
return True
return False
elif watched is self.filelist:
- if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Up:
+ if event.type() == QEvent.Type.KeyPress and event.key() == Qt.Key.Key_Up:
index = self.filelist.currentIndex()
if index.row() == 0 and not index.parent().isValid():
self.filefilter.setFocus()
@@ -437,7 +437,7 @@
m.addSeparator()
m.addAction(self._actionFlatFileList)

- contextmenu.setAttribute(Qt.WA_DeleteOnClose)
+ contextmenu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
contextmenu.popup(self.filelist.viewport().mapToGlobal(point))

def _setupFileMenu(self, contextmenu):
@@ -513,9 +513,9 @@
model.setFlat(flat)
view.setRootIsDecorated(not flat)
if flat:
- view.setTextElideMode(Qt.ElideLeft)
+ view.setTextElideMode(Qt.TextElideMode.ElideLeft)
else:
- view.setTextElideMode(Qt.ElideRight)
+ view.setTextElideMode(Qt.TextElideMode.ElideRight)
self._expandShortFileList()

def fileStatusFilter(self):
@@ -561,7 +561,7 @@

def __init__(self, repoagent, rev='.', parent=None):
QDialog.__init__(self, parent)
- self.setWindowFlags(Qt.Window)
+ self.setWindowFlags(Qt.WindowType.Window)
self.setWindowIcon(qtlib.geticon('hg-log'))
self._repoagent = repoagent

@@ -589,7 +589,7 @@

self.revdetails = revdetails
self.setRev(rev)
- qtlib.newshortcutsforstdkey(QKeySequence.Refresh, self, self.refresh)
+ qtlib.newshortcutsforstdkey(QKeySequence.StandardKey.Refresh, self, self.refresh)

def setRev(self, rev):
self.revdetails.onRevisionSelected(rev)
diff --git a/tortoisehg/hgqt/revert.py b/tortoisehg/hgqt/revert.py
--- a/tortoisehg/hgqt/revert.py
+++ b/tortoisehg/hgqt/revert.py
@@ -39,7 +39,7 @@
self.setWindowTitle(_('Revert - %s') % repoagent.displayName())

f = self.windowFlags()
- self.setWindowFlags(f & ~Qt.WindowContextHelpButtonHint)
+ self.setWindowFlags(f & ~Qt.WindowType.WindowContextHelpButtonHint)
self.wfiles = wfiles

self.setLayout(QVBoxLayout())
@@ -107,7 +107,7 @@
cmdline = hglib.buildcmdargs('revert', all=True, rev=rev)
else:
cmdline = hglib.buildcmdargs('revert', rev=rev, *self.wfiles)
- self.bbox.button(QDialogButtonBox.Ok).setEnabled(False)
+ self.bbox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
self._cmdsession = sess = self._repoagent.runCommand(cmdline, self)
sess.commandFinished.connect(self._onCommandFinished)

diff --git a/tortoisehg/hgqt/revset.py b/tortoisehg/hgqt/revset.py
--- a/tortoisehg/hgqt/revset.py
+++ b/tortoisehg/hgqt/revset.py
@@ -141,7 +141,7 @@
# the repository name in the dialog title
self.setWindowTitle(_('Revision Set Query')
+ ' - ' + repoagent.displayName())
- self.setWindowFlags(Qt.Window)
+ self.setWindowFlags(Qt.WindowType.Window)

layout = QVBoxLayout()
layout.setContentsMargins(*(4,)*4)
@@ -160,7 +160,7 @@
self.stbar = cmdui.ThgStatusBar(self)
self.stbar.setSizeGripEnabled(False)
# same policy as status bar of QMainWindow
- self.stbar.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed)
+ self.stbar.setSizePolicy(QSizePolicy.Policy.Ignored, QSizePolicy.Policy.Fixed)
self.stbar.lbl.setOpenExternalLinks(True)

hbox = QHBoxLayout()
@@ -325,21 +325,21 @@
self.setCaretLineBackgroundColor(QColor("#e6fff0"))
self.setCaretLineVisible(True)
self.setAutoIndent(True)
- self.setMatchedBraceBackgroundColor(Qt.yellow)
+ self.setMatchedBraceBackgroundColor(Qt.GlobalColor.yellow)
self.setIndentationsUseTabs(False)
- self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
+ self.setBraceMatching(QsciScintilla.BraceMatch.SloppyBraceMatch)

- self.setWrapMode(QsciScintilla.WrapWord)
- self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
- self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
+ self.setWrapMode(QsciScintilla.WrapMode.WrapWord)
+ self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
+ self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)

- sp = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
+ sp = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)
sp.setHorizontalStretch(1)
sp.setVerticalStretch(0)
self.setSizePolicy(sp)

self.setAutoCompletionThreshold(2)
- self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
+ self.setAutoCompletionSource(QsciScintilla.AutoCompletionSource.AcsAPIs)
self.setAutoCompletionFillupsEnabled(True)
self.setLexer(QsciLexerPython(self))
self.lexer().setFont(qtlib.getfont('fontcomment').font())
@@ -352,10 +352,10 @@
self.apis.prepare()

def keyPressEvent(self, event):
- if event.key() == Qt.Key_Escape:
+ if event.key() == Qt.Key.Key_Escape:
event.ignore()
return
- if event.key() in (Qt.Key_Enter, Qt.Key_Return):
+ if event.key() in (Qt.Key.Key_Enter, Qt.Key.Key_Return):
if not self.isListActive():
event.ignore()
self.returnPressed.emit()
diff --git a/tortoisehg/hgqt/serve.py b/tortoisehg/hgqt/serve.py
--- a/tortoisehg/hgqt/serve.py
+++ b/tortoisehg/hgqt/serve.py
@@ -63,8 +63,8 @@
def __init__(self, ui, webconf, parent=None):
# type: (uimod.ui, Optional[IniConfig], Optional[QWidget]) -> None
super(ServeDialog, self).__init__(parent)
- self.setWindowFlags((self.windowFlags() | Qt.WindowMinimizeButtonHint)
- & ~Qt.WindowContextHelpButtonHint)
+ self.setWindowFlags((self.windowFlags() | Qt.WindowType.WindowMinimizeButtonHint)
+ & ~Qt.WindowType.WindowContextHelpButtonHint)
self.setWindowIcon(qtlib.geticon('hg-serve'))

self._qui = Ui_ServeDialog()
@@ -206,7 +206,7 @@
self._qui.port_edit.setValue(port)

def keyPressEvent(self, event):
- if self.isstarted() and event.key() == Qt.Key_Escape:
+ if self.isstarted() and event.key() == Qt.Key.Key_Escape:
self.stop()
return

diff --git a/tortoisehg/hgqt/settings.py b/tortoisehg/hgqt/settings.py
--- a/tortoisehg/hgqt/settings.py
+++ b/tortoisehg/hgqt/settings.py
@@ -260,7 +260,7 @@
QLineEdit.__init__(self, parent, toolTip=opts['tooltip'])
self.opts = opts
self.curvalue = None
- self.setEchoMode(QLineEdit.Password)
+ self.setEchoMode(QLineEdit.EchoMode.Password)
self.setMinimumWidth(ENTRY_WIDTH)

class TextEntry(QTextEdit):
@@ -1018,7 +1018,7 @@
'of the deny_push list are examined before the allow_push list.')),
)),

-({'name': 'proxy', 'label': _('Proxy'), 'icon': QStyle.SP_DriveNetIcon}, (
+({'name': 'proxy', 'label': _('Proxy'), 'icon': QStyle.StandardPixmap.SP_DriveNetIcon}, (
_fi(_('Host'), 'http_proxy.host', genEditCombo,
_('Host name and (optional) port of proxy server, for '
'example "myproxy:8000"')),
@@ -1068,7 +1068,7 @@
)),

({'name': 'diff', 'label': _('Diff and Annotate'),
- 'icon': QStyle.SP_FileDialogContentsView}, (
+ 'icon': QStyle.StandardPixmap.SP_FileDialogContentsView}, (
_fi(_('Patch EOL'), 'patch.eol',
(genDefaultCombo, ['auto', 'strict', 'crlf', 'lf']),
_('Normalize file line endings during and after patch to lf or '
@@ -1310,8 +1310,8 @@
def __init__(self, configrepo=False, focus=None, parent=None, root=None):
QDialog.__init__(self, parent)
self.setWindowTitle(_('TortoiseHg Settings'))
- self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint
- | Qt.WindowMaximizeButtonHint)
+ self.setWindowFlags(self.windowFlags() & ~Qt.WindowType.WindowContextHelpButtonHint
+ | Qt.WindowType.WindowMaximizeButtonHint)
self.setWindowIcon(qtlib.geticon('thg-repoconfig'))

if not hasattr(wconfig.config(), 'write'):
@@ -1482,9 +1482,9 @@
self.fnedit = QLineEdit()
self.fnedit.setReadOnly(True)
self.fnedit.setFrame(False)
- self.fnedit.setFocusPolicy(Qt.ClickFocus)
+ self.fnedit.setFocusPolicy(Qt.FocusPolicy.ClickFocus)
p = self.fnedit.palette()
- p.setColor(QPalette.Base, Qt.transparent)
+ p.setColor(QPalette.ColorRole.Base, Qt.GlobalColor.transparent)
self.fnedit.setPalette(p)
edit = QPushButton(_('Edit File'))
edit.clicked.connect(self.editClicked)
@@ -1500,7 +1500,7 @@
bothbox = QHBoxLayout()
layout.addLayout(bothbox, 8)
pageList = QListWidget()
- pageList.setResizeMode(QListView.Fixed)
+ pageList.setResizeMode(QListView.ResizeMode.Fixed)
if qtlib.IS_RETINA:
pageList.setIconSize(qtlib.listviewRetinaIconSize())
stack = QStackedWidget()
@@ -1736,9 +1736,9 @@
return (), [frame]

def eventFilter(self, obj, event):
- if event.type() in (QEvent.Enter, QEvent.FocusIn):
+ if event.type() in (QEvent.Type.Enter, QEvent.Type.FocusIn):
self.desctext.setHtml(obj.toolTip())
- if event.type() == QEvent.ToolTip:
+ if event.type() == QEvent.Type.ToolTip:
return True # tooltip is shown in self.desctext
return False

diff --git a/tortoisehg/hgqt/shellconf.py b/tortoisehg/hgqt/shellconf.py
--- a/tortoisehg/hgqt/shellconf.py
+++ b/tortoisehg/hgqt/shellconf.py
@@ -120,11 +120,11 @@
w.itemClicked.connect(self.listItemClicked)

style = QApplication.style()
- icon = style.standardIcon(QStyle.SP_ArrowLeft)
+ icon = style.standardIcon(QStyle.StandardPixmap.SP_ArrowLeft)
self.top_button = w = QPushButton(icon, '')
grid.addWidget(w, 2, 1)
w.clicked.connect(self.top_clicked)
- icon = style.standardIcon(QStyle.SP_ArrowRight)
+ icon = style.standardIcon(QStyle.StandardPixmap.SP_ArrowRight)
self.sub_button = w = QPushButton(icon, '')
grid.addWidget(w, 3, 1)
w.clicked.connect(self.sub_clicked)
diff --git a/tortoisehg/hgqt/shelve.py b/tortoisehg/hgqt/shelve.py
--- a/tortoisehg/hgqt/shelve.py
+++ b/tortoisehg/hgqt/shelve.py
@@ -49,7 +49,7 @@

def __init__(self, repoagent, parent=None):
QDialog.__init__(self, parent)
- self.setWindowFlags(Qt.Window)
+ self.setWindowFlags(Qt.WindowType.Window)

self.setWindowIcon(qtlib.geticon('hg-shelve'))

@@ -69,7 +69,7 @@
layout.addLayout(self.tbarhbox)

self.splitter = QSplitter(self)
- self.splitter.setOrientation(Qt.Horizontal)
+ self.splitter.setOrientation(Qt.Orientation.Horizontal)
self.splitter.setChildrenCollapsible(False)
self.splitter.setObjectName('splitter')
layout.addWidget(self.splitter, 1)
@@ -161,7 +161,7 @@
self.tbarhbox.addWidget(self.rbar)
self.refreshAction = a = QAction(_('Refresh'), self)
a.setIcon(qtlib.geticon('view-refresh'))
- a.setShortcuts(QKeySequence.Refresh)
+ a.setShortcuts(QKeySequence.StandardKey.Refresh)
a.triggered.connect(self.refreshCombos)
self.rbar.addAction(self.refreshAction)
self.actionNew = a = QAction(_('New Shelf'), self)
diff --git a/tortoisehg/hgqt/shortcutregistry.py b/tortoisehg/hgqt/shortcutregistry.py
--- a/tortoisehg/hgqt/shortcutregistry.py
+++ b/tortoisehg/hgqt/shortcutregistry.py
@@ -71,8 +71,8 @@
# RepoView/RepoWidget navigation, etc.
'RepoView.changePhaseMenu': (_('Change &Phase to'), None),
'RepoView.filterByRevisionsMenu': (_('Filter b&y'), None),
- 'RepoView.goBack': (_('Back'), QKeySequence.Back),
- 'RepoView.goForward': (_('Forward'), QKeySequence.Forward),
+ 'RepoView.goBack': (_('Back'), QKeySequence.StandardKey.Back),
+ 'RepoView.goForward': (_('Forward'), QKeySequence.StandardKey.Forward),
'RepoView.goToCommonAncestor': (_('Goto common ancestor'), None),
'RepoView.goToRevision': (_('&Goto Revision...'), 'Ctrl+/'),
'RepoView.goToWorkingParent': (_('Go to current revision'), 'Ctrl+.'),
@@ -148,23 +148,23 @@
'Workbench.about': (_("&About TortoiseHg"), None),
'Workbench.aboutQt': (_('About &Qt'), None),
'Workbench.cloneRepository': (_('Clon&e Repository...'),
- ('Shift', QKeySequence.New)),
- 'Workbench.closeRepository': (_("&Close Repository"), QKeySequence.Close),
+ ('Shift', QKeySequence.StandardKey.New)),
+ 'Workbench.closeRepository': (_("&Close Repository"), QKeySequence.StandardKey.Close),
'Workbench.explorerHelp': (_('E&xplorer Help'), None),
'Workbench.help': (_('&Help'), None),
- 'Workbench.newRepository': (_('&New Repository...'), QKeySequence.New),
+ 'Workbench.newRepository': (_('&New Repository...'), QKeySequence.StandardKey.New),
'Workbench.newWorkbench': (_('New &Workbench'), 'Shift+Ctrl+W'),
'Workbench.openFileManager': (_('E&xplore'), 'Ctrl+Shift+X'),
'Workbench.openReadme': (_('&Readme'), 'Ctrl+F1'),
- 'Workbench.openRepository': (_('&Open Repository...'), QKeySequence.Open),
- 'Workbench.openSettings': (_('&Settings'), QKeySequence.Preferences),
+ 'Workbench.openRepository': (_('&Open Repository...'), QKeySequence.StandardKey.Open),
+ 'Workbench.openSettings': (_('&Settings'), QKeySequence.StandardKey.Preferences),
'Workbench.openShortcutSettings': (_('S&hortcut Settings'), None),
'Workbench.openTerminal': (_('&Terminal'), 'Ctrl+Shift+T'),
- 'Workbench.quit': (_('E&xit'), QKeySequence.Quit),
- 'Workbench.refresh': (_('&Refresh'), [QKeySequence.Refresh,
+ 'Workbench.quit': (_('E&xit'), QKeySequence.StandardKey.Quit),
+ 'Workbench.refresh': (_('&Refresh'), [QKeySequence.StandardKey.Refresh,
'Ctrl+F5']), # Ctrl+ to ignore status
'Workbench.refreshTaskTabs': (_('Refresh &Task Tab'),
- ('Shift', QKeySequence.Refresh)),
+ ('Shift', QKeySequence.StandardKey.Refresh)),
'Workbench.showConsole': (_('Show Conso&le'), 'Ctrl+L'),
'Workbench.showPatchQueue': (_('Show &Patch Queue'), None),
'Workbench.showRepoRegistry': (_('Sh&ow Repository Registry'),
@@ -188,20 +188,20 @@
seqs.extend(_parseDefaultKeySequences(d))
return seqs
if hglib.isbasestring(data):
- return [QKeySequence(data, QKeySequence.PortableText)]
+ return [QKeySequence(data, QKeySequence.SequenceFormat.PortableText)]
if isinstance(data, tuple):
mod, key = data
- kstr = QKeySequence(key).toString(QKeySequence.PortableText)
- return [QKeySequence('%s+%s' % (mod, kstr), QKeySequence.PortableText)]
+ kstr = QKeySequence(key).toString(QKeySequence.SequenceFormat.PortableText)
+ return [QKeySequence('%s+%s' % (mod, kstr), QKeySequence.SequenceFormat.PortableText)]
return QKeySequence.keyBindings(data)

def _parseUserKeySequences(data):
# type: (List[Text]) -> List[QKeySequence]
- return [QKeySequence(s, QKeySequence.PortableText) for s in data]
+ return [QKeySequence(s, QKeySequence.SequenceFormat.PortableText) for s in data]

def _formatKeySequences(seqs):
# type: (List[QKeySequence]) -> List[Text]
- return [b.toString(QKeySequence.PortableText) for b in seqs]
+ return [b.toString(QKeySequence.SequenceFormat.PortableText) for b in seqs]

def _formatToolTip(label, toolTip, seqs):
# type: (Text, Text, List[QKeySequence]) -> Text
@@ -237,7 +237,7 @@
return '%s %s(%s)%s' % (
label,
_TOOLTIP_SHORTCUT_START_TAG,
- seqs[0].toString(QKeySequence.NativeText),
+ seqs[0].toString(QKeySequence.SequenceFormat.NativeText),
_TOOLTIP_SHORTCUT_END_TAG)


diff --git a/tortoisehg/hgqt/shortcutsettings.py b/tortoisehg/hgqt/shortcutsettings.py
--- a/tortoisehg/hgqt/shortcutsettings.py
+++ b/tortoisehg/hgqt/shortcutsettings.py
@@ -137,7 +137,7 @@
return it.text(0)

def _setCurrentByName(self, name):
- items = self._view.findItems(name, Qt.MatchExactly)
+ items = self._view.findItems(name, Qt.MatchFlag.MatchExactly)
if items:
self._view.setCurrentItem(items[0])
else:
@@ -218,7 +218,7 @@

buttons = QDialogButtonBox(self)
buttons.setStandardButtons(
- QDialogButtonBox.Save | QDialogButtonBox.Cancel)
+ QDialogButtonBox.StandardButton.Save | QDialogButtonBox.StandardButton.Cancel)
buttons.accepted.connect(self.accept)
buttons.rejected.connect(self.reject)
vbox.addWidget(buttons)
diff --git a/tortoisehg/hgqt/sign.py b/tortoisehg/hgqt/sign.py
--- a/tortoisehg/hgqt/sign.py
+++ b/tortoisehg/hgqt/sign.py
@@ -40,7 +40,7 @@
if opts is None:
opts = {}
self.setWindowFlags(self.windowFlags() &
- ~Qt.WindowContextHelpButtonHint)
+ ~Qt.WindowType.WindowContextHelpButtonHint)

self._repoagent = repoagent
self._cmdsession = cmdcore.nullCmdSession()
@@ -50,13 +50,13 @@
base = QVBoxLayout()
base.setSpacing(0)
base.setContentsMargins(*(0,)*4)
- base.setSizeConstraint(QLayout.SetMinAndMaxSize)
+ base.setSizeConstraint(QLayout.SizeConstraint.SetMinAndMaxSize)
self.setLayout(base)

## main layout grid
formwidget = QWidget(self)
- formwidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
- form = QFormLayout(fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow)
+ formwidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
+ form = QFormLayout(fieldGrowthPolicy=QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow)
formwidget.setLayout(form)
base.addWidget(formwidget)

@@ -110,8 +110,8 @@

## horizontal separator
self.sep = QFrame()
- self.sep.setFrameShadow(QFrame.Sunken)
- self.sep.setFrameShape(QFrame.HLine)
+ self.sep.setFrameShadow(QFrame.Shadow.Sunken)
+ self.sep.setFrameShape(QFrame.Shape.HLine)
self.layout().addWidget(self.sep)

## status line
diff --git a/tortoisehg/hgqt/status.py b/tortoisehg/hgqt/status.py
--- a/tortoisehg/hgqt/status.py
+++ b/tortoisehg/hgqt/status.py
@@ -135,7 +135,7 @@

SP = QSizePolicy

- split = QSplitter(Qt.Horizontal)
+ split = QSplitter(Qt.Orientation.Horizontal)
split.setChildrenCollapsible(False)
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
@@ -207,13 +207,13 @@
self.clearPatternBtn.setVisible(bool(self.pats))

tv.setAllColumnsShowFocus(True)
- tv.setContextMenuPolicy(Qt.CustomContextMenu)
+ tv.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
tv.setDragDropMode(QTreeView.DragOnly)
tv.setItemsExpandable(False)
tv.setRootIsDecorated(False)
tv.setSelectionMode(QTreeView.ExtendedSelection)
- tv.setTextElideMode(Qt.ElideLeft)
- tv.sortByColumn(COL_STATUS, Qt.AscendingOrder)
+ tv.setTextElideMode(Qt.TextElideMode.ElideLeft)
+ tv.sortByColumn(COL_STATUS, Qt.SortOrder.AscendingOrder)
tv.doubleClicked.connect(self.onRowDoubleClicked)
tv.customContextMenuRequested.connect(self.onMenuRequest)
le.textEdited.connect(self.setFilter)
@@ -224,8 +224,8 @@
self.le = le
self._tvpaletteswitcher = qtlib.PaletteSwitcher(tv)

- self._togglefileshortcut = a = QShortcut(Qt.Key_Space, tv)
- a.setContext(Qt.WidgetShortcut)
+ self._togglefileshortcut = a = QShortcut(Qt.Key.Key_Space, tv)
+ a.setContext(Qt.ShortcutContext.WidgetShortcut)
a.setEnabled(False)
a.activated.connect(self._toggleSelectedFiles)

@@ -276,14 +276,14 @@
@pyqtSlot()
def checkAllNone(self):
state = self.checkAllNoneBtn.checkState()
- if state == Qt.Checked:
+ if state == Qt.CheckState.Checked:
self.checkAll()
self.checkAllNoneBtn.setToolTip(self.checkNoneTT)
else:
- if state == Qt.Unchecked:
+ if state == Qt.CheckState.Unchecked:
self.checkNone()
self.checkAllNoneBtn.setToolTip(self.checkAllTT)
- if state != Qt.PartiallyChecked:
+ if state != Qt.CheckState.PartiallyChecked:
self.checkAllNoneBtn.setTristate(False)

def getTitle(self):
@@ -364,7 +364,7 @@
optmenu = menu
optmenu.addActions(self.statusfilter.actions())

- menu.setAttribute(Qt.WA_DeleteOnClose)
+ menu.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose)
menu.popup(self.tv.viewport().mapToGlobal(point))

def _setupFileMenu(self, menu):
@@ -506,7 +506,7 @@
# reset selection, or select first row
curidx = tm.index(0, 0)
selmodel = self.tv.selectionModel()
- flags = QItemSelectionModel.Select | QItemSelectionModel.Rows
+ flags = QItemSelectionModel.SelectionFlag.Select | QItemSelectionModel.SelectionFlag.Rows
if self.reselection:
selected, current = self.reselection
for i, row in enumerate(tm.getAllRows()):
@@ -519,7 +519,7 @@
selmodel.currentChanged.connect(self.onCurrentChange)
selmodel.selectionChanged.connect(self.onSelectionChange)
if curidx and curidx.isValid():
- selmodel.setCurrentIndex(curidx, QItemSelectionModel.Current)
+ selmodel.setCurrentIndex(curidx, QItemSelectionModel.SelectionFlag.Current)
self.onSelectionChange()

self._togglefileshortcut.setEnabled(True)
@@ -569,12 +569,12 @@
if model:
model.checkCount = len(self.getChecked())
if model.checkCount == 0:
- state = Qt.Unchecked
+ state = Qt.CheckState.Unchecked
elif model.checkCount == len(model.rows):
- state = Qt.Checked
+ state = Qt.CheckState.Checked
else:
- state = Qt.PartiallyChecked
- self.checkAllNoneBtn.setTristate(state == Qt.PartiallyChecked)
+ state = Qt.CheckState.PartiallyChecked
+ self.checkAllNoneBtn.setTristate(state == Qt.CheckState.PartiallyChecked)
self.checkAllNoneBtn.setCheckState(state)

@pyqtSlot(str, bool)
@@ -661,15 +661,15 @@
assert model is not None
selmodel = self.tv.selectionModel()
for index in selmodel.selectedRows(COL_PATH):
- model.setData(index, value, Qt.CheckStateRole)
+ model.setData(index, value, Qt.ItemDataRole.CheckStateRole)

@pyqtSlot()
def _checkSelectedFiles(self):
- self._setCheckStateOfSelectedFiles(Qt.Checked)
+ self._setCheckStateOfSelectedFiles(Qt.CheckState.Checked)

@pyqtSlot()
def _uncheckSelectedFiles(self):
- self._setCheckStateOfSelectedFiles(Qt.Unchecked)
+ self._setCheckStateOfSelectedFiles(Qt.CheckState.Unchecked)

@pyqtSlot()
def _toggleSelectedFiles(self):
@@ -678,11 +678,11 @@
assert model is not None
assert selmodel is not None
for index in selmodel.selectedRows(COL_PATH):
- if model.data(index, Qt.CheckStateRole) == Qt.Checked:
- newvalue = Qt.Unchecked
+ if model.data(index, Qt.ItemDataRole.CheckStateRole) == Qt.CheckState.Checked:
+ newvalue = Qt.CheckState.Unchecked
else:
- newvalue = Qt.Checked
- model.setData(index, newvalue, Qt.CheckStateRole)
+ newvalue = Qt.CheckState.Checked
+ model.setData(index, newvalue, Qt.ItemDataRole.CheckStateRole)


class StatusThread(QThread):
@@ -776,7 +776,7 @@

class WctxFileTree(QTreeView):

- def scrollTo(self, index, hint=QAbstractItemView.EnsureVisible):
+ def scrollTo(self, index, hint=QAbstractItemView.ScrollHint.EnsureVisible):
# don't update horizontal position by selection change
orighoriz = self.horizontalScrollBar().value()
super(WctxFileTree, self).scrollTo(index, hint)
@@ -911,25 +911,25 @@
return None

if index.column() == COL_PATH:
- if role == Qt.CheckStateRole and self.checkable:
+ if role == Qt.ItemDataRole.CheckStateRole and self.checkable:
path = self.rows[index.row()][0]
if path in self.partials:
changes = self.partials[path]
if changes.excludecount == 0:
- return Qt.Checked
+ return Qt.CheckState.Checked
elif changes.excludecount == len(changes.hunks):
- return Qt.Unchecked
+ return Qt.CheckState.Unchecked
else:
- return Qt.PartiallyChecked
+ return Qt.CheckState.PartiallyChecked
if self.checked[path]:
- return Qt.Checked
+ return Qt.CheckState.Checked
else:
- return Qt.Unchecked
- elif role == Qt.DisplayRole:
+ return Qt.CheckState.Unchecked
+ elif role == Qt.ItemDataRole.DisplayRole:
return ""
- elif role == Qt.ToolTipRole:
+ elif role == Qt.ItemDataRole.ToolTipRole:
return _('Checked count: %d') % self.checkCount
- elif role == Qt.DisplayRole:
+ elif role == Qt.ItemDataRole.DisplayRole:
return self.rows[index.row()][index.column()]
elif role == Qt.TextColorRole:
path, status, mst, upath, ext, sz = self.rows[index.row()]
@@ -937,11 +937,11 @@
return _colors.get(mst.lower(), QColor('black'))
else:
return _colors.get(status, QColor('black'))
- elif role == Qt.ToolTipRole:
+ elif role == Qt.ItemDataRole.ToolTipRole:
path, status, mst, upath, ext, sz = self.rows[index.row()]
return statusMessage(status, mst, upath)
'''
- elif role == Qt.DecorationRole and index.column() == COL_STATUS:
+ elif role == Qt.ItemDataRole.DecorationRole and index.column() == COL_STATUS:
if status in statusTypes:
ico = QIcon()
ico.addPixmap(QPixmap('icons/' + statusTypes[status].icon))
@@ -949,19 +949,19 @@
'''
return None

- def setData(self, index, value, role=Qt.EditRole):
+ def setData(self, index, value, role=Qt.ItemDataRole.EditRole):
if not index.isValid():
return False
- if (index.column() == COL_PATH and role == Qt.CheckStateRole
+ if (index.column() == COL_PATH and role == Qt.ItemDataRole.CheckStateRole
and self.checkable):
if self.data(index, role) == value:
return True
- if value not in (Qt.Checked, Qt.Unchecked):
- # Qt.PartiallyChecked cannot be set explicitly
+ if value not in (Qt.CheckState.Checked, Qt.CheckState.Unchecked):
+ # Qt.CheckState.PartiallyChecked cannot be set explicitly
return False
path = self.rows[index.row()][COL_PATH]
upath = self.rows[index.row()][COL_PATH_DISPLAY]
- self.checked[path] = checked = (value == Qt.Checked)
+ self.checked[path] = checked = (value == Qt.CheckState.Checked)
self.checkToggled.emit(upath, checked)
self.checkCountChanged.emit()
self.dataChanged.emit(index, index)
@@ -969,15 +969,15 @@
return False

def headerData(self, col, orientation, role):
- if role != Qt.DisplayRole or orientation != Qt.Horizontal:
+ if role != Qt.ItemDataRole.DisplayRole or orientation != Qt.Orientation.Horizontal:
return None
else:
return self.headers[col]

def flags(self, index):
- flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled
+ flags = Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsDragEnabled
if index.column() == COL_PATH and self.checkable:
- flags |= Qt.ItemIsUserCheckable
+ flags |= Qt.ItemFlag.ItemIsUserCheckable
return flags

def mimeTypes(self):
@@ -1081,7 +1081,7 @@
# Already sorted!
pass
else:
- if order == Qt.DescendingOrder:
+ if order == Qt.SortOrder.DescendingOrder:
# We want the secondary sort to be by _ascending_ path,
# even when the primary sort is in descending order
self.rows.reverse()
@@ -1099,7 +1099,7 @@
else:
self.rows.sort(key=lambda x: x[col])

- if order == Qt.DescendingOrder:
+ if order == Qt.SortOrder.DescendingOrder:
self.rows.reverse()
self.layoutChanged.emit()
self.endResetModel()
@@ -1208,7 +1208,7 @@
"""Create button with drop-down menu for status filter"""
button = QToolButton(parent)
button.setIcon(qtlib.geticon('hg-status'))
- button.setPopupMode(QToolButton.InstantPopup)
+ button.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
menu = QMenu(button)
menu.addActions(actiongroup.actions())
button.setMenu(menu)
@@ -1243,10 +1243,10 @@
parent=self)

self.setWindowTitle(self.stwidget.getTitle())
- self.setWindowFlags(Qt.Window)
+ self.setWindowFlags(Qt.WindowType.Window)
self.loadSettings()

- qtlib.newshortcutsforstdkey(QKeySequence.Refresh, self,
+ qtlib.newshortcutsforstdkey(QKeySequence.StandardKey.Refresh, self,
self.stwidget.refreshWctx)
QTimer.singleShot(0, self.stwidget.refreshWctx)

diff --git a/tortoisehg/hgqt/sync.py b/tortoisehg/hgqt/sync.py
--- a/tortoisehg/hgqt/sync.py
+++ b/tortoisehg/hgqt/sync.py
@@ -216,7 +216,7 @@
tb.addWidget(self.optionsbutton)

self.targetcombo = QComboBox()
- self.targetcombo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
+ self.targetcombo.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self.targetcombo.setSizeAdjustPolicy(
QComboBox.AdjustToMinimumContentsLength)
self.targetcombo.setEnabled(False)
@@ -248,7 +248,7 @@
tbar.addWidget(qtlib.Spacer(2, 2))

style = QApplication.style()
- a = tbar.addAction(style.standardIcon(QStyle.SP_DialogSaveButton),
+ a = tbar.addAction(style.standardIcon(QStyle.StandardPixmap.SP_DialogSaveButton),
_('Save'))
a.setToolTip(_('Save current URL under an alias'))
self.savebutton = a
@@ -276,7 +276,7 @@
self.hgrctv.removeAlias.connect(self.removeAlias)
self.hgrctv.menuRequest.connect(self.menuRequest)
pathsframe = QFrame()
- pathsframe.setFrameStyle(QFrame.StyledPanel|QFrame.Raised)
+ pathsframe.setFrameStyle(QFrame.Shape.StyledPanel|QFrame.Shadow.Raised)
pathsbox = QVBoxLayout()
pathsbox.setContentsMargins(0, 0, 0, 0)
pathsframe.setLayout(pathsbox)
@@ -291,7 +291,7 @@
self.reltv.clicked.connect(self.hgrctv.clearSelection)
self.hgrctv.clicked.connect(self.reltv.clearSelection)
pathsframe = QFrame()
- pathsframe.setFrameStyle(QFrame.StyledPanel|QFrame.Raised)
+ pathsframe.setFrameStyle(QFrame.Shape.StyledPanel|QFrame.Shadow.Raised)
pathsbox = QVBoxLayout()
pathsbox.setContentsMargins(0, 0, 0, 0)
pathsframe.setLayout(pathsbox)
@@ -334,13 +334,13 @@
uname = hglib.tounicode(name)
self.targetcombo.addItem(_('branch: ') + uname, ('--branch', name))
self.targetcombo.setItemData(self.targetcombo.count() - 1, name,
- Qt.ToolTipRole)
+ Qt.ItemDataRole.ToolTipRole)
for name in sorted(self.repo._bookmarks):
uname = hglib.tounicode(name)
self.targetcombo.addItem(_('bookmark: ') + uname,
('--bookmark', name))
self.targetcombo.setItemData(self.targetcombo.count() - 1, name,
- Qt.ToolTipRole)
+ Qt.ItemDataRole.ToolTipRole)

def _findTargetIndex(self, ctx):
for name in ctx.bookmarks():
@@ -375,9 +375,9 @@

def editOptions(self):
dlg = OptionsDialog(self._repoagent, self.opts, self)
- dlg.setWindowFlags(Qt.Sheet)
- dlg.setWindowModality(Qt.WindowModal)
- if dlg.exec_() == QDialog.Accepted:
+ dlg.setWindowFlags(Qt.WindowType.Sheet)
+ dlg.setWindowModality(Qt.WindowModality.WindowModal)
+ if dlg.exec_() == QDialog.DialogCode.Accepted:
self.opts.update(dlg.outopts)
self.refreshUrl()

@@ -471,7 +471,7 @@

def pathSelected(self, index):
aliasindex = index.sibling(index.row(), 0)
- alias = aliasindex.data(Qt.DisplayRole)
+ alias = aliasindex.data(Qt.ItemDataRole.DisplayRole)
self.curalias = hglib.fromunicode(alias)
path = index.model().realUrl(index)
self.setEditUrl(hglib.tounicode(path))
@@ -488,8 +488,8 @@
model = self.hgrctv.model()
assert model is not None
for col in (0, 1): # search known (alias, url)
- ixs = model.match(model.index(0, col), Qt.DisplayRole, newurl, 1,
- Qt.MatchFixedString | Qt.MatchCaseSensitive)
+ ixs = model.match(model.index(0, col), Qt.ItemDataRole.DisplayRole, newurl, 1,
+ Qt.MatchFlag.MatchFixedString | Qt.MatchFlag.MatchCaseSensitive)
if ixs:
self.hgrctv.setCurrentIndex(ixs[0])
self.pathSelected(ixs[0]) # in case of row not changed
@@ -500,24 +500,24 @@
def dragEnterEvent(self, event):
data = event.mimeData()
if data.hasUrls() or data.hasText():
- event.setDropAction(Qt.CopyAction)
+ event.setDropAction(Qt.DropAction.CopyAction)
event.acceptProposedAction()

def dragMoveEvent(self, event):
data = event.mimeData()
if data.hasUrls() or data.hasText():
- event.setDropAction(Qt.CopyAction)
+ event.setDropAction(Qt.DropAction.CopyAction)
event.acceptProposedAction()

def dropEvent(self, event):
data = event.mimeData()
if data.hasUrls():
url = pycompat.unicode(data.urls()[0].toString())
- event.setDropAction(Qt.CopyAction)
+ event.setDropAction(Qt.DropAction.CopyAction)
event.accept()
elif data.hasText():
url = pycompat.unicode(data.text())
- event.setDropAction(Qt.CopyAction)
+ event.setDropAction(Qt.DropAction.CopyAction)
event.accept()
else:
return
@@ -582,9 +582,9 @@
alias = hglib.fromunicode(self.menualias)
urlu = pycompat.unicode(self.menuurl)
dlg = SaveDialog(self._repoagent, alias, urlu, self, edit=True)
- dlg.setWindowFlags(Qt.Sheet)
- dlg.setWindowModality(Qt.WindowModal)
- if dlg.exec_() == QDialog.Accepted:
+ dlg.setWindowFlags(Qt.WindowType.Sheet)
+ dlg.setWindowModality(Qt.WindowModality.WindowModal)
+ if dlg.exec_() == QDialog.DialogCode.Accepted:
self.curalias = hglib.fromunicode(dlg.aliasentry.text())
self.setEditUrl(dlg.urlentry.text())
self.reload()
@@ -600,9 +600,9 @@

def keyPressEvent(self, event):
sess = self._cmdsession
- if event.matches(QKeySequence.Refresh):
+ if event.matches(QKeySequence.StandardKey.Refresh):
self.reload()
- elif event.key() == Qt.Key_Escape and not sess.isFinished():
+ elif event.key() == Qt.Key.Key_Escape and not sess.isFinished():
sess.abort()
else:
return super(SyncWidget, self).keyPressEvent(event)
@@ -618,9 +618,9 @@
else:
alias = b'new'
dlg = SaveDialog(self._repoagent, alias, self.currentUrl(), self)
- dlg.setWindowFlags(Qt.Sheet)
- dlg.setWindowModality(Qt.WindowModal)
- if dlg.exec_() == QDialog.Accepted:
+ dlg.setWindowFlags(Qt.WindowType.Sheet)
+ dlg.setWindowModality(Qt.WindowModality.WindowModal)
+ if dlg.exec_() == QDialog.DialogCode.Accepted:
self.curalias = hglib.fromunicode(dlg.aliasentry.text())
self.reload()

@@ -639,8 +639,8 @@
parent=self)
return
dlg = SecureDialog(self._repoagent, self.currentUrl(), self)
- dlg.setWindowFlags(Qt.Sheet)
- dlg.setWindowModality(Qt.WindowModal)
+ dlg.setWindowFlags(Qt.WindowType.Sheet)
+ dlg.setWindowModality(Qt.WindowModality.WindowModal)
dlg.exec_()

@pyqtSlot()
@@ -1036,8 +1036,8 @@

def postpullclicked(self):
dlg = PostPullDialog(self._repoagent, self)
- dlg.setWindowFlags(Qt.Sheet)
- dlg.setWindowModality(Qt.WindowModal)
+ dlg.setWindowFlags(Qt.WindowType.Sheet)
+ dlg.setWindowModality(Qt.WindowModality.WindowModal)
dlg.exec_()

def emailclicked(self):
@@ -1118,7 +1118,7 @@
self.setLayout(layout)
self.setWindowTitle(_('Post Pull Behavior'))
self.setWindowFlags(self.windowFlags() &
- ~Qt.WindowContextHelpButtonHint)
+ ~Qt.WindowType.WindowContextHelpButtonHint)

lbl = QLabel(_('Select post-pull operation for this repository'))
layout.addWidget(lbl)
@@ -1222,11 +1222,11 @@

self.setWindowTitle(_('Save Path'))
self.setWindowFlags(self.windowFlags() &
- ~Qt.WindowContextHelpButtonHint)
+ ~Qt.WindowType.WindowContextHelpButtonHint)

self.origurl = hglib.fromunicode(urlu)
self.setLayout(QFormLayout())
- self.layout().setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
+ self.layout().setFieldGrowthPolicy(QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow)

self.origalias = alias
self.aliasentry = QLineEdit(hglib.tounicode(self.origalias))
@@ -1353,7 +1353,7 @@

@pyqtSlot()
def _updateUi(self):
- savebtn = self.bb.button(QDialogButtonBox.Save)
+ savebtn = self.bb.button(QDialogButtonBox.StandardButton.Save)
savebtn.setEnabled(bool(self.aliasentry.text()
and self.urlentry.text()))

@@ -1381,7 +1381,7 @@
uhost = hglib.tounicode(u.host)
self.setWindowTitle(_('Security: ') + uhost)
self.setWindowFlags(self.windowFlags() & \
- ~Qt.WindowContextHelpButtonHint)
+ ~Qt.WindowType.WindowContextHelpButtonHint)

# if the already user has an [auth] configuration for this URL, use it
cleanurl = urlutil.removeauth(hglib.fromunicode(urlu))
@@ -1472,7 +1472,7 @@
k = b'password'
c = hglib.tounicode(u.passwd or auth.get(k, b''))
self._authentries[k] = e = QLineEdit(c)
- e.setEchoMode(QLineEdit.Password)
+ e.setEchoMode(QLineEdit.EchoMode.Password)
e.setToolTip(
_('''Optional. Password to authenticate with. If not given, and the remote
site requires basic or digest authentication, the user will be prompted for
@@ -1622,20 +1622,20 @@

def contextMenuEvent(self, event):
for index in self.selectedRows():
- alias = index.data(Qt.DisplayRole)
- url = index.sibling(index.row(), 1).data(Qt.DisplayRole)
+ alias = index.data(Qt.ItemDataRole.DisplayRole)
+ url = index.sibling(index.row(), 1).data(Qt.ItemDataRole.DisplayRole)
self.menuRequest.emit(event.globalPos(), url, alias, self.editable)
return

def keyPressEvent(self, event):
- if self.editable and event.matches(QKeySequence.Delete):
+ if self.editable and event.matches(QKeySequence.StandardKey.Delete):
self.deleteSelected()
else:
return super(PathsTree, self).keyPressEvent(event)

def deleteSelected(self):
for index in self.selectedRows():
- alias = index.data(Qt.DisplayRole)
+ alias = index.data(Qt.ItemDataRole.DisplayRole)
r = qtlib.QuestionMsgBox(_('Confirm path delete'),
_('Delete %s from your repo configuration file?') % alias,
parent=self)
@@ -1667,15 +1667,15 @@
return 0 # no child
return len(self.headers)

- def data(self, index, role=Qt.DisplayRole):
+ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
if not index.isValid():
return None
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
return self.rows[index.row()][index.column()]
return None

- def headerData(self, col, orientation, role=Qt.DisplayRole):
- if role != Qt.DisplayRole or orientation != Qt.Horizontal:
+ def headerData(self, col, orientation, role=Qt.ItemDataRole.DisplayRole):
+ if role != Qt.ItemDataRole.DisplayRole or orientation != Qt.Orientation.Horizontal:
return None
else:
return self.headers[col]
@@ -1695,7 +1695,7 @@
return ['text/uri-list']

def flags(self, index):
- flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled
+ flags = Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsDragEnabled
return flags

def realUrl(self, index):
diff --git a/tortoisehg/hgqt/tag.py b/tortoisehg/hgqt/tag.py
--- a/tortoisehg/hgqt/tag.py
+++ b/tortoisehg/hgqt/tag.py
@@ -62,7 +62,7 @@
if opts is None:
opts = {}
self.setWindowFlags(self.windowFlags() &
- ~Qt.WindowContextHelpButtonHint)
+ ~Qt.WindowType.WindowContextHelpButtonHint)

self._repoagent = repoagent
self._cmdsession = cmdcore.nullCmdSession()
@@ -73,12 +73,12 @@
base = QVBoxLayout()
base.setSpacing(0)
base.setContentsMargins(0, 0, 0, 0)
- base.setSizeConstraint(QLayout.SetMinAndMaxSize)
+ base.setSizeConstraint(QLayout.SizeConstraint.SetMinAndMaxSize)
self.setLayout(base)

formwidget = QWidget(self)
- formwidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
- form = QFormLayout(fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow)
+ formwidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
+ form = QFormLayout(fieldGrowthPolicy=QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow)
formwidget.setLayout(form)
base.addWidget(formwidget)

@@ -142,8 +142,8 @@

## horizontal separator
self.sep = QFrame()
- self.sep.setFrameShadow(QFrame.Sunken)
- self.sep.setFrameShape(QFrame.HLine)
+ self.sep.setFrameShadow(QFrame.Shadow.Sunken)
+ self.sep.setFrameShape(QFrame.Shape.HLine)
base.addWidget(self.sep)

## status line
diff --git a/tortoisehg/hgqt/thgimport.py b/tortoisehg/hgqt/thgimport.py
--- a/tortoisehg/hgqt/thgimport.py
+++ b/tortoisehg/hgqt/thgimport.py
@@ -67,8 +67,8 @@
def __init__(self, repoagent, parent, **opts):
super(ImportDialog, self).__init__(parent)
self.setWindowFlags(self.windowFlags()
- & ~Qt.WindowContextHelpButtonHint
- | Qt.WindowMaximizeButtonHint)
+ & ~Qt.WindowType.WindowContextHelpButtonHint
+ | Qt.WindowType.WindowMaximizeButtonHint)
self.setWindowTitle(_('Import - %s') % repoagent.displayName())
self.setWindowIcon(qtlib.geticon('hg-import'))

@@ -106,14 +106,14 @@
grid.addLayout(srcbox, 1, 1)
self.p0chk = QCheckBox(_('Do not strip paths (-p0), '
'required for SVN patches'))
- grid.addWidget(self.p0chk, 2, 1, Qt.AlignLeft)
+ grid.addWidget(self.p0chk, 2, 1, Qt.AlignmentFlag.AlignLeft)

### patch list
self.cslist = cslist.ChangesetList(self.repo)
cslistrow = 4
cslistcol = 1
grid.addWidget(self.cslist, cslistrow, cslistcol)
- grid.addWidget(QLabel(_('Preview:')), 3, 0, Qt.AlignLeft | Qt.AlignTop)
+ grid.addWidget(QLabel(_('Preview:')), 3, 0, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)
statbox = QHBoxLayout()
self.status = QLabel("")
statbox.addWidget(self.status)
@@ -139,7 +139,7 @@
QTimer.singleShot(0, self.checkStatus)

self._runbutton = cmd.addButton(_('&Import'),
- QDialogButtonBox.AcceptRole)
+ QDialogButtonBox.ButtonRole.AcceptRole)
self._runbutton.clicked.connect(self._runCommand)

grid.setRowStretch(cslistrow, 1)
@@ -179,7 +179,7 @@
self._cmdcontrol.showStatusMessage('')

def keyPressEvent(self, event):
- if event.matches(QKeySequence.Refresh):
+ if event.matches(QKeySequence.StandardKey.Refresh):
self.checkStatus()
else:
return super(ImportDialog, self).keyPressEvent(event)
diff --git a/tortoisehg/hgqt/thgstrip.py b/tortoisehg/hgqt/thgstrip.py
--- a/tortoisehg/hgqt/thgstrip.py
+++ b/tortoisehg/hgqt/thgstrip.py
@@ -57,7 +57,7 @@
super(StripWidget, self).__init__(parent)
if opts is None:
opts = {}
- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
self._repoagent = repoagent

grid = QGridLayout()
@@ -70,9 +70,9 @@
combo.setEditable(True)
grid.addWidget(QLabel(_('Strip:')), 0, 0)
grid.addWidget(combo, 0, 1)
- grid.addWidget(QLabel(_('Preview:')), 1, 0, Qt.AlignLeft | Qt.AlignTop)
+ grid.addWidget(QLabel(_('Preview:')), 1, 0, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)
self.status = QLabel("")
- grid.addWidget(self.status, 1, 1, Qt.AlignLeft | Qt.AlignTop)
+ grid.addWidget(self.status, 1, 1, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)

if rev is None:
rev = hglib.tounicode(self.repo.dirstate.branch())
@@ -94,7 +94,7 @@
### options
optbox = QVBoxLayout()
optbox.setSpacing(6)
- grid.addWidget(QLabel(_('Options:')), 3, 0, Qt.AlignLeft | Qt.AlignTop)
+ grid.addWidget(QLabel(_('Options:')), 3, 0, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop)
grid.addLayout(optbox, 3, 1)

self._optchks = {}
diff --git a/tortoisehg/hgqt/topic.py b/tortoisehg/hgqt/topic.py
--- a/tortoisehg/hgqt/topic.py
+++ b/tortoisehg/hgqt/topic.py
@@ -44,7 +44,7 @@
def __init__(self, repoagent, rev, parent=None):
super(TopicDialog, self).__init__(parent)
self.setWindowFlags(self.windowFlags() &
- ~Qt.WindowContextHelpButtonHint)
+ ~Qt.WindowType.WindowContextHelpButtonHint)
self._repoagent = repoagent
repo = repoagent.rawRepo()
self._cmdsession = cmdcore.nullCmdSession()
@@ -54,13 +54,13 @@
base = QVBoxLayout()
base.setSpacing(0)
base.setContentsMargins(*(0,)*4)
- base.setSizeConstraint(QLayout.SetMinAndMaxSize)
+ base.setSizeConstraint(QLayout.SizeConstraint.SetMinAndMaxSize)
self.setLayout(base)

# main layout grid
formwidget = QWidget(self)
- formwidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
- form = QFormLayout(fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow)
+ formwidget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
+ form = QFormLayout(fieldGrowthPolicy=QFormLayout.FieldGrowthPolicy.AllNonFixedFieldsGrow)
formwidget.setLayout(form)
base.addWidget(formwidget)

@@ -90,8 +90,8 @@

# horizontal separator
self.sep = QFrame()
- self.sep.setFrameShadow(QFrame.Sunken)
- self.sep.setFrameShape(QFrame.HLine)
+ self.sep.setFrameShadow(QFrame.Shadow.Sunken)
+ self.sep.setFrameShape(QFrame.Shape.HLine)
self.layout().addWidget(self.sep)

# status line
diff --git a/tortoisehg/hgqt/update.py b/tortoisehg/hgqt/update.py
--- a/tortoisehg/hgqt/update.py
+++ b/tortoisehg/hgqt/update.py
@@ -61,7 +61,7 @@
super(UpdateWidget, self).__init__(parent)
if opts is None:
opts = {}
- self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
+ self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
self._repoagent = repoagent
repo = repoagent.rawRepo()

@@ -378,14 +378,14 @@

opts.append('merge')

- dlg = QMessageBox(QMessageBox.Question, _('Confirm Update'),
+ dlg = QMessageBox(QMessageBox.Icon.Question, _('Confirm Update'),
'', QMessageBox.StandardButton.Cancel, self)
buttonnames = {}
for name in opts:
label, desc = data[name]
msg += '\n'
msg += desc
- btn = dlg.addButton(label, QMessageBox.ActionRole)
+ btn = dlg.addButton(label, QMessageBox.ButtonRole.ActionRole)
buttonnames[btn] = name
dlg.setDefaultButton(QMessageBox.StandardButton.Cancel)
dlg.setText(msg)
diff --git a/tortoisehg/hgqt/webconf.py b/tortoisehg/hgqt/webconf.py
--- a/tortoisehg/hgqt/webconf.py
+++ b/tortoisehg/hgqt/webconf.py
@@ -80,21 +80,21 @@
def setstdicon(w, name):
w.setIcon(self.style().standardIcon(name))

- setstdicon(self._qui.open_button, QStyle.SP_DialogOpenButton)
- setstdicon(self._qui.save_button, QStyle.SP_DialogSaveButton)
+ setstdicon(self._qui.open_button, QStyle.StandardPixmap.SP_DialogOpenButton)
+ setstdicon(self._qui.save_button, QStyle.StandardPixmap.SP_DialogSaveButton)
self._qui.add_button.setIcon(qtlib.geticon('hg-add'))
self._qui.edit_button.setIcon(qtlib.geticon('edit-file'))
self._qui.remove_button.setIcon(qtlib.geticon('hg-remove'))

def dragEnterEvent(self, event):
if self._getlocalpath_from_dropevent(event):
- event.setDropAction(Qt.LinkAction)
+ event.setDropAction(Qt.DropAction.LinkAction)
event.accept()

def dropEvent(self, event):
localpath = self._getlocalpath_from_dropevent(event)
if localpath:
- event.setDropAction(Qt.LinkAction)
+ event.setDropAction(Qt.DropAction.LinkAction)
event.accept()
self._addpathmap(localpath=localpath)

@@ -230,12 +230,12 @@
invalidpaths=None, parent=None):
# type: (Text, Text, Optional[Text], Optional[Text], Optional[Iterable[Text]], Optional[QWidget]) -> None
super(_PathDialog, self).__init__(parent)
- self.setWindowFlags((self.windowFlags() | Qt.WindowMinimizeButtonHint)
- & ~Qt.WindowContextHelpButtonHint)
+ self.setWindowFlags((self.windowFlags() | Qt.WindowType.WindowMinimizeButtonHint)
+ & ~Qt.WindowType.WindowContextHelpButtonHint)
self.resize(QFontMetrics(self.font()).width('M') * 50, self.height())
self.setWindowTitle(title)
self._invalidpaths = set(invalidpaths or [])
- self.setLayout(QFormLayout(fieldGrowthPolicy=QFormLayout.ExpandingFieldsGrow))
+ self.setLayout(QFormLayout(fieldGrowthPolicy=QFormLayout.FieldGrowthPolicy.ExpandingFieldsGrow))
self._initfields()
self._initbuttons(acceptlabel)
self._path_edit.setText(path or os.path.basename(localpath or ''))
@@ -260,7 +260,7 @@

addfield('path', _('Path:'))
self._localpath_browse_button = QToolButton(
- icon=self.style().standardIcon(QStyle.SP_DialogOpenButton))
+ icon=self.style().standardIcon(QStyle.StandardPixmap.SP_DialogOpenButton))
addfield('localpath', _('Local Path:'), self._localpath_browse_button)
self._localpath_browse_button.clicked.connect(self._browse_localpath)

@@ -268,8 +268,8 @@
# type: (Text) -> None
"""initialize dialog buttons"""
self._buttons = QDialogButtonBox(self)
- self._accept_button = self._buttons.addButton(QDialogButtonBox.Ok)
- self._reject_button = self._buttons.addButton(QDialogButtonBox.Cancel)
+ self._accept_button = self._buttons.addButton(QDialogButtonBox.StandardButton.Ok)
+ self._reject_button = self._buttons.addButton(QDialogButtonBox.StandardButton.Cancel)
self._accept_button.setText(acceptlabel)
self._buttons.accepted.connect(self.accept)
self._buttons.rejected.connect(self.reject)
@@ -350,7 +350,7 @@
# type: (QModelIndex, int) -> Any
if not index.isValid():
return None
- if role == Qt.DisplayRole:
+ if role == Qt.ItemDataRole.DisplayRole:
v = self._config.items(b'paths')[index.row()][index.column()]
return hglib.tounicode(v)
return None
@@ -369,7 +369,7 @@

def headerData(self, section, orientation, role):
# type: (int, int, int) -> Any
- if role != Qt.DisplayRole or orientation != Qt.Horizontal:
+ if role != Qt.ItemDataRole.DisplayRole or orientation != Qt.Orientation.Horizontal:
return None
return self._COLUMNS[section][0]

diff --git a/tortoisehg/hgqt/workbench.py b/tortoisehg/hgqt/workbench.py
--- a/tortoisehg/hgqt/workbench.py
+++ b/tortoisehg/hgqt/workbench.py
@@ -82,20 +82,20 @@
rr.progressReceived.connect(self.statusbar.progress)
self._repomanager.repositoryChanged.connect(rr.scanRepo)
rr.hide()
- self.addDockWidget(Qt.LeftDockWidgetArea, rr)
+ self.addDockWidget(Qt.DockWidgetArea.LeftDockWidgetArea, rr)

self.mqpatches = p = mq.MQPatchesWidget(actionregistry, self)
p.setObjectName('MQPatchesWidget')
p.patchSelected.connect(self.gotorev)
p.hide()
- self.addDockWidget(Qt.LeftDockWidgetArea, p)
+ self.addDockWidget(Qt.DockWidgetArea.LeftDockWidgetArea, p)

cmdagent = cmdcore.CmdAgent(ui, self)
self._console = LogDockWidget(repomanager, cmdagent, self)
self._console.setObjectName('Log')
self._console.hide()
self._console.visibilityChanged.connect(self._updateShowConsoleAction)
- self.addDockWidget(Qt.BottomDockWidgetArea, self._console)
+ self.addDockWidget(Qt.DockWidgetArea.BottomDockWidgetArea, self._console)

self._setupActions()

@@ -127,7 +127,7 @@

self.repoTabsWidget = tw = repotab.RepoTabWidget(
self._config, self._actionregistry, self._repomanager, self)
- sp = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+ sp = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
sp.setHorizontalStretch(1)
sp.setVerticalStretch(1)
sp.setHeightForWidth(tw.sizePolicy().hasHeightForWidth())
@@ -431,7 +431,7 @@

self._lastRepoSyncPath = {}
self.urlCombo = QComboBox(self)
- self.urlCombo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
+ self.urlCombo.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToContents)
self.urlCombo.currentIndexChanged.connect(self._updateSyncUrl)
self.urlComboAction = self.synctbar.addWidget(self.urlCombo)
# hide it because workbench could be started without open repo
@@ -490,7 +490,7 @@
itemdata = (pathdict[a], pathdict[a])
tooltip = pathdict[a]
self.urlCombo.addItem(itemtext, itemdata)
- self.urlCombo.setItemData(n, tooltip, Qt.ToolTipRole)
+ self.urlCombo.setItemData(n, tooltip, Qt.ItemDataRole.ToolTipRole)
# Try to select the previously selected path, if any
prevpath = self._lastRepoSyncPath.get(repoagent.rootPath())
if prevpath:
@@ -533,7 +533,7 @@
tooltip = _('There are no configured sync paths.\n'
'Open the Synchronize tab to configure them.')
else:
- tooltip = self.urlCombo.itemData(index, Qt.ToolTipRole)
+ tooltip = self.urlCombo.itemData(index, Qt.ItemDataRole.ToolTipRole)
self.urlCombo.setToolTip(tooltip)

def _updateSyncActionToolTip(self, index):
@@ -755,7 +755,7 @@
for u in d.urls():
root = paths.find_root(pycompat.unicode(u.toLocalFile()))
if root:
- event.setDropAction(Qt.LinkAction)
+ event.setDropAction(Qt.DropAction.LinkAction)
event.accept()
break

@@ -768,7 +768,7 @@
self.showRepo(root)
accept = True
if accept:
- event.setDropAction(Qt.LinkAction)
+ event.setDropAction(Qt.DropAction.LinkAction)
event.accept()

def _updateMenu(self):
@@ -890,7 +890,7 @@

@pyqtSlot()
def refresh(self):
- clear = QApplication.keyboardModifiers() & Qt.ControlModifier
+ clear = QApplication.keyboardModifiers() & Qt.KeyboardModifier.ControlModifier
w = self._currentRepoWidget()
if w:
# check unnoticed changes to emit corresponding signals

Yuya Nishihara

unread,
Apr 4, 2022, 10:07:34 PM4/4/22
to Matt Harbison, thg...@googlegroups.com
On Mon, 04 Apr 2022 20:02:36 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_h...@yahoo.com>
> # Date 1649086340 14400
> # Mon Apr 04 11:32:20 2022 -0400
> # Node ID abcb33e2ccdc60bc7e279f6d5378a7bd263e43ea
> # Parent f1e47bf79221fb84cc22b058f33ec74f41cca211
> # EXP-Topic pyqt6
> qtcompat: replace most enum references with fully qualified names for PyQt6

Queued, thanks.
Reply all
Reply to author
Forward
0 new messages