Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1721 fix: Support Scintilla editor on Debian with Qt6 #1813

Merged
merged 4 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/Python/mcgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ set(CPACK_NSIS_DISPLAY_NAME "${NSIS_NAME}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${NSIS_NAME}")

# Debian
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${FLAVOR}, ${FLAVOR}-tools-python-${P}doc, ${FLAVOR}-tools-python-mccodelib, python3, python3-pyqt5.qsci")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${FLAVOR}, ${FLAVOR}-tools-python-${P}doc, ${FLAVOR}-tools-python-mccodelib, python3, python3-pyqt6.qsci")
set(CPACK_DEBIAN_PACKAGE_REPLACES "${FLAVOR}-tools-python-${P}gui-3.5.1")

# RPM
Expand Down
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

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

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
2 changes: 1 addition & 1 deletion tools/Python/mcplot/matplotlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ set(CPACK_NSIS_DISPLAY_NAME "${NSIS_NAME}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${NSIS_NAME}")

# Debian
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${FLAVOR}, python3-matplotlib, python3-pyqt5, python3-mplexporter, python3-tornado")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${FLAVOR}, python3-matplotlib, python3-pyqt6, python3-mplexporter, python3-tornado")
set(CPACK_DEBIAN_PACKAGE_REPLACES "${FLAVOR}-tools-python-${P}plot-matplotlib-3.5.1")

# RPM
Expand Down