mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2025-12-06 08:52:55 +01:00
qt6 QFont.Normal/Bold & QTextEdit.NoWrap
This commit is contained in:
parent
fa2b3c9511
commit
c7a542fd17
2 changed files with 23 additions and 7 deletions
|
|
@ -23,6 +23,12 @@ from PyQt5.Qt import (QApplication, QDialog, QWidget, QTableWidget, QVBoxLayout,
|
||||||
QLineEdit, QComboBox, QProgressDialog, QTimer, QDialogButtonBox,
|
QLineEdit, QComboBox, QProgressDialog, QTimer, QDialogButtonBox,
|
||||||
QScrollArea, QPixmap, Qt, QAbstractItemView, QTextEdit,
|
QScrollArea, QPixmap, Qt, QAbstractItemView, QTextEdit,
|
||||||
pyqtSignal, QGroupBox, QFrame)
|
pyqtSignal, QGroupBox, QFrame)
|
||||||
|
try:
|
||||||
|
# qt6 Calibre v6+
|
||||||
|
QTextEditNoWrap = QTextEdit.LineWrapMode.NoWrap
|
||||||
|
except:
|
||||||
|
# qt5 Calibre v2-5
|
||||||
|
QTextEditNoWrap = QTextEdit.NoWrap
|
||||||
|
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
show_download_options = 'fff:add new/update dialogs:show_download_options'
|
show_download_options = 'fff:add new/update dialogs:show_download_options'
|
||||||
|
|
@ -224,7 +230,7 @@ class AddNewDialog(SizePersistedDialog):
|
||||||
|
|
||||||
self.url = DroppableQTextEdit(self)
|
self.url = DroppableQTextEdit(self)
|
||||||
self.url.setToolTip("UrlTooltip")
|
self.url.setToolTip("UrlTooltip")
|
||||||
self.url.setLineWrapMode(QTextEdit.NoWrap)
|
self.url.setLineWrapMode(QTextEditNoWrap)
|
||||||
self.l.addWidget(self.url)
|
self.l.addWidget(self.url)
|
||||||
|
|
||||||
self.groupbox = QGroupBox(_("Show Download Options"))
|
self.groupbox = QGroupBox(_("Show Download Options"))
|
||||||
|
|
@ -1236,7 +1242,7 @@ class EditTextDialog(SizePersistedDialog):
|
||||||
self.l.addWidget(self.label)
|
self.l.addWidget(self.label)
|
||||||
|
|
||||||
self.textedit = QTextEdit(self)
|
self.textedit = QTextEdit(self)
|
||||||
self.textedit.setLineWrapMode(QTextEdit.NoWrap)
|
self.textedit.setLineWrapMode(QTextEditNoWrap)
|
||||||
self.textedit.setReadOnly(read_only)
|
self.textedit.setReadOnly(read_only)
|
||||||
self.textedit.setText(text)
|
self.textedit.setText(text)
|
||||||
self.l.addWidget(self.textedit)
|
self.l.addWidget(self.textedit)
|
||||||
|
|
@ -1309,7 +1315,7 @@ class IniTextDialog(SizePersistedDialog):
|
||||||
entry_keywords=get_valid_entry_keywords(),
|
entry_keywords=get_valid_entry_keywords(),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.textedit.setLineWrapMode(QTextEdit.NoWrap)
|
self.textedit.setLineWrapMode(QTextEditNoWrap)
|
||||||
try:
|
try:
|
||||||
self.textedit.setFont(QFont("Courier",
|
self.textedit.setFont(QFont("Courier",
|
||||||
parent.font().pointSize()+1))
|
parent.font().pointSize()+1))
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,17 @@ import re
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
from PyQt5.Qt import (QApplication, Qt, QColor, QSyntaxHighlighter, QTextCharFormat, QBrush, QFont)
|
from PyQt5.Qt import (QApplication, Qt, QColor, QSyntaxHighlighter,
|
||||||
|
QTextCharFormat, QBrush, QFont)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# qt6 Calibre v6+
|
||||||
|
QFontNormal = QFont.Weight.Normal
|
||||||
|
QFontBold = QFont.Weight.Bold
|
||||||
|
except:
|
||||||
|
# qt5 Calibre v2-5
|
||||||
|
QFontNormal = QFont.Normal
|
||||||
|
QFontBold = QFont.Bold
|
||||||
|
|
||||||
from fanficfare.six import string_types
|
from fanficfare.six import string_types
|
||||||
|
|
||||||
|
|
@ -80,13 +90,13 @@ class IniHighlighter(QSyntaxHighlighter):
|
||||||
self.highlightingRules.append( HighlightingRule( r"^(add_to_)?"+rekeywords+r"(_filelist)?\s*[:=]", colors['knownkeywords'] ) )
|
self.highlightingRules.append( HighlightingRule( r"^(add_to_)?"+rekeywords+r"(_filelist)?\s*[:=]", colors['knownkeywords'] ) )
|
||||||
|
|
||||||
# *all* sections -- change known later.
|
# *all* sections -- change known later.
|
||||||
self.highlightingRules.append( HighlightingRule( r"^\[[^\]]+\].*?$", colors['errors'], QFont.Bold, blocknum=1 ) )
|
self.highlightingRules.append( HighlightingRule( r"^\[[^\]]+\].*?$", colors['errors'], QFontBold, blocknum=1 ) )
|
||||||
|
|
||||||
if sections:
|
if sections:
|
||||||
# *known* sections
|
# *known* sections
|
||||||
resections = r'('+(r'|'.join(sections))+r')'
|
resections = r'('+(r'|'.join(sections))+r')'
|
||||||
resections = resections.replace('.','\.') #escape dots.
|
resections = resections.replace('.','\.') #escape dots.
|
||||||
self.highlightingRules.append( HighlightingRule( r"^\["+resections+r"\]\s*$", colors['knownsections'], QFont.Bold, blocknum=2 ) )
|
self.highlightingRules.append( HighlightingRule( r"^\["+resections+r"\]\s*$", colors['knownsections'], QFontBold, blocknum=2 ) )
|
||||||
|
|
||||||
# test story sections
|
# test story sections
|
||||||
self.teststoryRule = HighlightingRule( r"^\[teststory:([0-9]+|defaults)\]", colors['teststories'], blocknum=3 )
|
self.teststoryRule = HighlightingRule( r"^\[teststory:([0-9]+|defaults)\]", colors['teststories'], blocknum=3 )
|
||||||
|
|
@ -132,7 +142,7 @@ class IniHighlighter(QSyntaxHighlighter):
|
||||||
|
|
||||||
class HighlightingRule():
|
class HighlightingRule():
|
||||||
def __init__( self, pattern, color,
|
def __init__( self, pattern, color,
|
||||||
weight=QFont.Normal,
|
weight=QFontNormal,
|
||||||
style=Qt.SolidPattern,
|
style=Qt.SolidPattern,
|
||||||
blocknum=0):
|
blocknum=0):
|
||||||
if isinstance(pattern, string_types):
|
if isinstance(pattern, string_types):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue