Skip to content

Commit

Permalink
Edits for Qt6 - plus debugging that needs further work
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Willendrup committed Jan 3, 2025
1 parent 8a72403 commit 1995e91
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions tools/Python/mcgui/mcgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from PyQt6.QtWidgets import QApplication, QWidget
from PyQt6.QtGui import QFont, QFontDatabase
import PyQt6 as PyQt
print("Importing Qt6 OK")
try:
from PyQt6 import Qsci
except ImportError:
Expand All @@ -28,6 +29,7 @@
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QFont, QFontDatabase
import PyQt5 as PyQt
print("importing Qt5 OK")
try:
from PyQt5 import Qsci
except ImportError:
Expand Down
18 changes: 9 additions & 9 deletions tools/Python/mcgui/viewclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def __sbEventFilter(subject, object, event):
edt = QtWidgets.QLineEdit()
edt = subject
# handle focus on
if event.type() == QtCore.QEvent.FocusIn:
if event.type() == QtCore.QEvent.Type.FocusIn:
if edt.text() == 'search...':
edt.setText('')
font = QtGui.QFont()
Expand All @@ -323,7 +323,7 @@ def __sbEventFilter(subject, object, event):
edt.setStyleSheet("color: black;")

# handle focus off
elif event.type() == QtCore.QEvent.FocusOut:
elif event.type() == QtCore.QEvent.Type.FocusOut:
if edt.text() == '':
font = QtGui.QFont()
font.setItalic(True)
Expand All @@ -332,7 +332,7 @@ def __sbEventFilter(subject, object, event):
edt.setText('search...')

# handle enter keypress (search)
elif event.type() == QtCore.QEvent.KeyPress:
elif event.type() == QtCore.QEvent.Type.KeyPress:
# return & enter
if event.key() in [0x01000004, 0x01000005]:
self.__search(subject.text().casefold())
Expand Down Expand Up @@ -503,7 +503,7 @@ def __initScintilla(self):
font.setPointSize(int(mccode_config.configuration["GUIFONTSIZE"]))

# brace matching
scintilla.setBraceMatching(Qsci.QsciScintilla.SloppyBraceMatch)
scintilla.setBraceMatching(Qsci.QsciScintilla.BraceMatch.SloppyBraceMatch)

# set lexer
lexer = Qsci.QsciLexerCPP()
Expand All @@ -518,14 +518,14 @@ def __initScintilla(self):
scintilla.__myApi = Qsci.QsciAPIs(lexer)

scintilla.setAutoCompletionThreshold(1)
scintilla.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)
scintilla.setAutoCompletionSource(Qsci.QsciScintilla.AutoCompletionSource.AcsAPIs)

# remove horizontal scrollbar
scintilla.SendScintilla(Qsci.QsciScintilla.SCI_SETHSCROLLBAR, 0)

# display default line numbers
fm = QtGui.QFontMetrics(font)
scintilla.setMarginWidth(0, fm.width( "00000" ))
scintilla.setMarginWidth(0, fm.horizontalAdvance( "00000" ))
scintilla.setMarginLineNumbers(0, True)
########################

Expand Down Expand Up @@ -595,7 +595,7 @@ def __initCallbacks(self):
# TODO: create a ctr-a on a menu to __scintilla.selectAll(bool select)

def __keyEventFilterFct(subject, object, event):
if event.type() == QtCore.QEvent.KeyRelease:
if event.type() == QtCore.QEvent.Type.KeyRelease:
# ctrl-q
if event.key() == 81 and int(event.modifiers()) == 67108864:
self.close()
Expand Down Expand Up @@ -1024,7 +1024,7 @@ def _wEventFilter(subject, object, event):
edt = QtWidgets.QLineEdit()
edt = subject
# handle focus on
if event.type() == QtCore.QEvent.FocusIn:
if event.type() == QtCore.QEvent.Type.FocusIn:
if edt.text() == edt.defval:
edt.setText('')
font = QtGui.QFont()
Expand All @@ -1034,7 +1034,7 @@ def _wEventFilter(subject, object, event):
edt.setCursorPosition(0)

# handle focus off
elif event.type() == QtCore.QEvent.FocusOut:
elif event.type() == QtCore.QEvent.Type.FocusOut:
if edt.text() == '':
font = QtGui.QFont()
font.setItalic(True)
Expand Down

0 comments on commit 1995e91

Please sign in to comment.