Skip to content

Commit

Permalink
Silence some deprecation warnings on Qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
zrax committed Mar 7, 2024
1 parent a1f2eab commit 53a1623
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
12 changes: 7 additions & 5 deletions lib/syntaxtextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,12 +1564,13 @@ void SyntaxTextEdit::LineMargin::paintEvent(QPaintEvent *paintEvent)

void SyntaxTextEdit::LineMargin::mouseMoveEvent(QMouseEvent *e)
{
QTextCursor lineCursor = m_editor->cursorForPosition(QPoint(0, e->y()));
const QPoint eventPos = e->pos();
QTextCursor lineCursor = m_editor->cursorForPosition(QPoint(0, eventPos.y()));
const int foldPixmapWidth = m_editor->m_foldOpen.width() + 4;

m_foldHoverLine = -1;
if (m_editor->showFolding()) {
if (!m_editor->showLineNumbers() || e->x() >= width() - foldPixmapWidth) {
if (!m_editor->showLineNumbers() || eventPos.x() >= width() - foldPixmapWidth) {
QTextBlock block = lineCursor.block();
if (block.isValid() && m_editor->m_highlighter->isFoldable(block))
m_foldHoverLine = block.blockNumber();
Expand Down Expand Up @@ -1600,18 +1601,19 @@ void SyntaxTextEdit::LineMargin::mousePressEvent(QMouseEvent *e)
{
m_marginSelectStart = -1;
if (e->button() == Qt::LeftButton) {
const QPoint eventPos = e->pos();
const int foldPixmapWidth = m_editor->m_foldOpen.width() + 4;
QTextCursor lineCursor = m_editor->cursorForPosition(QPoint(0, e->y()));
QTextCursor lineCursor = m_editor->cursorForPosition(QPoint(0, eventPos.y()));
if (m_editor->showLineNumbers()
&& (!m_editor->showFolding() || e->x() < width() - foldPixmapWidth)) {
&& (!m_editor->showFolding() || eventPos.x() < width() - foldPixmapWidth)) {
// Clicked in the number margin
lineCursor.setVisualNavigation(true);
lineCursor.movePosition(QTextCursor::StartOfBlock);
m_marginSelectStart = lineCursor.position();
lineCursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor);
m_editor->setTextCursor(lineCursor);
} else if (m_editor->showFolding()
&& (!m_editor->showLineNumbers() || e->x() >= width() - foldPixmapWidth)) {
&& (!m_editor->showLineNumbers() || eventPos.x() >= width() - foldPixmapWidth)) {
// Clicked in the folding margin
QTextBlock block = lineCursor.block();
if (block.isValid() && m_editor->m_highlighter->isFoldable(block)) {
Expand Down
9 changes: 8 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,15 @@ int main(int argc, char *argv[])

QTranslator qtTranslator;
if (qtTranslator.load(QLocale(), QStringLiteral("qt"), QStringLiteral("_"),
QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QLibraryInfo::path(QLibraryInfo::TranslationsPath)
#else
QLibraryInfo::location(QLibraryInfo::TranslationsPath)
#endif
))
{
QCoreApplication::installTranslator(&qtTranslator);
}

QTranslator appTranslator;
if (appTranslator.load(QLocale(), QStringLiteral("qtextpad"), QStringLiteral("_")))
Expand Down
2 changes: 1 addition & 1 deletion src/qtextpadwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ QTextPadWindow::QTextPadWindow(QWidget *parent)

#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
connect(QGuiApplication::styleHints(), &QStyleHints::colorSchemeChanged,
[this](Qt::ColorScheme colorScheme) {
[this](Qt::ColorScheme) {
if (m_defaultThemeAction->isChecked())
setDefaultEditorTheme();
});
Expand Down

0 comments on commit 53a1623

Please sign in to comment.