From b1fa777750627dc746cd4fc6ef9758cc3f160ffa Mon Sep 17 00:00:00 2001 From: Doug Date: Sat, 24 Feb 2024 11:39:12 -0500 Subject: [PATCH 01/22] Builds with qt6. --- CMakeLists.txt | 20 +++++----- ....cmake.in => qtermwidget6-config.cmake.in} | 0 examples/cpp/main.cpp | 12 +++--- lib/ColorScheme.cpp | 10 ++--- lib/Emulation.cpp | 2 +- lib/HistorySearch.cpp | 11 +++--- lib/HistorySearch.h | 5 ++- lib/KeyboardTranslator.cpp | 28 ++++++++------ lib/Pty.cpp | 4 +- lib/Pty.h | 2 +- lib/Session.cpp | 4 +- lib/TerminalDisplay.cpp | 38 ++++++++----------- lib/Vt102Emulation.cpp | 5 +-- lib/kprocess.h | 2 - lib/kptyprocess.cpp | 7 ++-- lib/kptyprocess.h | 9 ++++- lib/qtermwidget.cpp | 23 +++++------ lib/qtermwidget.h | 3 -- lib/qtermwidget_interface.h | 4 +- 19 files changed, 93 insertions(+), 96 deletions(-) rename cmake/{qtermwidget5-config.cmake.in => qtermwidget6-config.cmake.in} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce50ed02..b2fe5e11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,12 +32,13 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") set(CMAKE_INCLUDE_CURRENT_DIR ON) # Minimum Versions -set(QT_MINIMUM_VERSION "5.15.0") +set(QT_MINIMUM_VERSION "6.1.0") set(LXQTBT_MINIMUM_VERSION "0.13.0") -find_package(Qt5Widgets "${QT_MINIMUM_VERSION}" REQUIRED) -find_package(Qt5LinguistTools "${QT_MINIMUM_VERSION}" REQUIRED) -find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED) +find_package(Qt6Widgets "${QT_MINIMUM_VERSION}" REQUIRED) +find_package(Qt6LinguistTools "${QT_MINIMUM_VERSION}" REQUIRED) +find_package(Qt6Core5Compat "${QT_MINIMUM_VERSION}" REQUIRED) +find_package(lxqt2-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED) if(USE_UTF8PROC) find_package(Utf8Proc REQUIRED) @@ -55,7 +56,7 @@ if(APPLE) endif() endif() -set(QTERMWIDGET_LIBRARY_NAME qtermwidget5) +set(QTERMWIDGET_LIBRARY_NAME qtermwidget6) # main library @@ -130,9 +131,9 @@ set(QTERMWIDGET_INCLUDE_DIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}/${QTERMWIDGET_LIBR CHECK_FUNCTION_EXISTS(updwtmpx HAVE_UPDWTMPX) -qt5_wrap_cpp(MOCS ${HDRS}) -qt5_wrap_ui(UI_SRCS ${UI}) -set(PKG_CONFIG_REQ "Qt5Widgets") +qt6_wrap_cpp(MOCS ${HDRS}) +qt6_wrap_ui(UI_SRCS ${UI}) +set(PKG_CONFIG_REQ "Qt6Widgets") lxqt_translate_ts(QTERMWIDGET_QM TRANSLATION_DIR "lib/translations" @@ -147,7 +148,8 @@ lxqt_translate_ts(QTERMWIDGET_QM ) add_library(${QTERMWIDGET_LIBRARY_NAME} SHARED ${SRCS} ${MOCS} ${UI_SRCS} ${QTERMWIDGET_QM}) -target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} Qt5::Widgets) +target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} Qt6::Widgets) +target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} Qt6::Core5Compat) set_target_properties( ${QTERMWIDGET_LIBRARY_NAME} PROPERTIES SOVERSION ${QTERMWIDGET_VERSION_MAJOR} VERSION ${QTERMWIDGET_VERSION} diff --git a/cmake/qtermwidget5-config.cmake.in b/cmake/qtermwidget6-config.cmake.in similarity index 100% rename from cmake/qtermwidget5-config.cmake.in rename to cmake/qtermwidget6-config.cmake.in diff --git a/examples/cpp/main.cpp b/examples/cpp/main.cpp index 779d7bb5..23be40ea 100644 --- a/examples/cpp/main.cpp +++ b/examples/cpp/main.cpp @@ -36,12 +36,12 @@ int main(int argc, char *argv[]) QMenuBar *menuBar = new QMenuBar(mainWindow); QMenu *actionsMenu = new QMenu(QStringLiteral("Actions"), menuBar); menuBar->addMenu(actionsMenu); - actionsMenu->addAction(QStringLiteral("Find..."), console, &QTermWidget::toggleShowSearchBar, - QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_F)); - actionsMenu->addAction(QStringLiteral("Copy"), console, &QTermWidget::copyClipboard, - QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C)); - actionsMenu->addAction(QStringLiteral("Paste"), console, &QTermWidget::pasteClipboard, - QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V)); + actionsMenu->addAction(QStringLiteral("Find..."), QKeySequence(QLatin1String("Ctrl+Shift+F")), + console, &QTermWidget::toggleShowSearchBar); + actionsMenu->addAction(QStringLiteral("Copy"), QKeySequence(QLatin1String("Ctrl+Shift+C")), + console, &QTermWidget::copyClipboard); + actionsMenu->addAction(QStringLiteral("Paste"), QKeySequence(QLatin1String("Ctrl+Shift+V")), + console, &QTermWidget::pasteClipboard); actionsMenu->addAction(QStringLiteral("About Qt"), &app, &QApplication::aboutQt); mainWindow->setMenuBar(menuBar); diff --git a/lib/ColorScheme.cpp b/lib/ColorScheme.cpp index 6af2058c..7082de67 100644 --- a/lib/ColorScheme.cpp +++ b/lib/ColorScheme.cpp @@ -339,7 +339,7 @@ void ColorScheme::readColorEntry(QSettings * s , int index) bool ok = false; // XXX: Undocumented(?) QSettings behavior: values with commas are parsed // as QStringList and others QString - if (colorValue.type() == QVariant::StringList) + if (colorValue.typeId() == QVariant::StringList) { QStringList rgbList = colorValue.toStringList(); colorStr = rgbList.join(QLatin1Char(',')); @@ -364,10 +364,10 @@ void ColorScheme::readColorEntry(QSettings * s , int index) if (hexColorPattern.match(colorStr).hasMatch()) { // Parsing is always ok as already matched by the regexp - r = colorStr.midRef(1, 2).toInt(nullptr, 16); - g = colorStr.midRef(3, 2).toInt(nullptr, 16); - b = colorStr.midRef(5, 2).toInt(nullptr, 16); - ok = true; + r = colorStr.mid(1, 2).toInt(nullptr, 16); + g = colorStr.mid(3, 2).toInt(nullptr, 16); + b = colorStr.mid(5, 2).toInt(nullptr, 16); + ok = true; } } if (!ok) diff --git a/lib/Emulation.cpp b/lib/Emulation.cpp index 08267d26..8f10ea2b 100644 --- a/lib/Emulation.cpp +++ b/lib/Emulation.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include diff --git a/lib/HistorySearch.cpp b/lib/HistorySearch.cpp index 33c6f4ef..9df3e946 100644 --- a/lib/HistorySearch.cpp +++ b/lib/HistorySearch.cpp @@ -24,7 +24,7 @@ #include "Emulation.h" #include "HistorySearch.h" -HistorySearch::HistorySearch(EmulationPtr emulation, const QRegExp& regExp, +HistorySearch::HistorySearch(EmulationPtr emulation, const QRegularExpression& regExp, bool forwards, int startColumn, int startLine, QObject* parent) : QObject(parent), @@ -41,7 +41,7 @@ HistorySearch::~HistorySearch() { void HistorySearch::search() { bool found = false; - if (! m_regExp.isEmpty()) + if (! m_regExp.pattern().isEmpty()) { if (m_forwards) { found = search(m_startColumn, m_startLine, -1, m_emulation->lineCount()) || search(0, 0, m_startColumn, m_startLine); @@ -104,22 +104,23 @@ bool HistorySearch::search(int startColumn, int startLine, int endColumn, int en // So now we can log for m_regExp in the string between startColumn and endPosition int matchStart; + QRegularExpressionMatch match; if (m_forwards) { - matchStart = string.indexOf(m_regExp, startColumn); + matchStart = string.indexOf(m_regExp, startColumn, &match); if (matchStart >= endPosition) matchStart = -1; } else { - matchStart = string.lastIndexOf(m_regExp, endPosition - 1); + matchStart = string.lastIndexOf(m_regExp, endPosition - 1, &match); if (matchStart < startColumn) matchStart = -1; } if (matchStart > -1) { - int matchEnd = matchStart + m_regExp.matchedLength() - 1; + int matchEnd = matchStart + match.capturedLength() - 1; qDebug() << "Found in string from" << matchStart << "to" << matchEnd; // Translate startPos and endPos to startColum, startLine, endColumn and endLine in history. diff --git a/lib/HistorySearch.h b/lib/HistorySearch.h index 403343d8..9762db24 100644 --- a/lib/HistorySearch.h +++ b/lib/HistorySearch.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -38,7 +39,7 @@ class HistorySearch : public QObject Q_OBJECT public: - explicit HistorySearch(EmulationPtr emulation, const QRegExp& regExp, bool forwards, + explicit HistorySearch(EmulationPtr emulation, const QRegularExpression& regExp, bool forwards, int startColumn, int startLine, QObject* parent); ~HistorySearch() override; @@ -55,7 +56,7 @@ class HistorySearch : public QObject EmulationPtr m_emulation; - QRegExp m_regExp; + QRegularExpression m_regExp; bool m_forwards = false; int m_startColumn = 0; int m_startLine = 0; diff --git a/lib/KeyboardTranslator.cpp b/lib/KeyboardTranslator.cpp index e0f28331..fc04ebea 100644 --- a/lib/KeyboardTranslator.cpp +++ b/lib/KeyboardTranslator.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include "tools.h" @@ -539,10 +540,10 @@ QList KeyboardTranslatorReader::tokenize(const text = text.simplified(); // title line: keyboard "title" - static QRegExp title(QLatin1String("keyboard\\s+\"(.*)\"")); + static QRegularExpression title(QLatin1String("keyboard\\s+\"(.*)\"")); // key line: key KeySequence : "output" // key line: key KeySequence : command - static QRegExp key(QLatin1String("key\\s+([\\w\\+\\s\\-\\*\\.]+)\\s*:\\s*(\"(.*)\"|\\w+)")); + static QRegularExpression key(QLatin1String("key\\s+([\\w\\+\\s\\-\\*\\.]+)\\s*:\\s*(\"(.*)\"|\\w+)")); QList list; if ( text.isEmpty() ) @@ -550,30 +551,33 @@ QList KeyboardTranslatorReader::tokenize(const return list; } - if ( title.exactMatch(text) ) + const auto titleMatch = title.match(text); + const auto keyMatch = key.match(text); + + if ( titleMatch.hasMatch() ) { Token titleToken = { Token::TitleKeyword , QString() }; - Token textToken = { Token::TitleText , title.capturedTexts().at(1) }; + Token textToken = { Token::TitleText , titleMatch.captured(1) }; list << titleToken << textToken; } - else if ( key.exactMatch(text) ) + else if ( keyMatch.hasMatch() ) { Token keyToken = { Token::KeyKeyword , QString() }; - Token sequenceToken = { Token::KeySequence , key.capturedTexts().value(1).remove(QLatin1Char(' ')) }; + Token sequenceToken = { Token::KeySequence , keyMatch.captured(1).remove(QLatin1Char(' ')) }; list << keyToken << sequenceToken; - if ( key.capturedTexts().at(3).isEmpty() ) + if ( keyMatch.captured(3).isEmpty() ) { // capturedTexts()[2] is a command - Token commandToken = { Token::Command , key.capturedTexts().at(2) }; + Token commandToken = { Token::Command , keyMatch.captured(2) }; list << commandToken; } else { // capturedTexts()[3] is the output string - Token outputToken = { Token::OutputText , key.capturedTexts().at(3) }; + Token outputToken = { Token::OutputText , keyMatch.captured(3) }; list << outputToken; } } @@ -676,7 +680,9 @@ QByteArray KeyboardTranslator::Entry::escapedText(bool expandWildCards,Qt::Keybo if ( replacement == 'x' ) { - result.replace(i,1,"\\x"+QByteArray(1,ch).toHex()); + QByteArray escaped("\\x"); + escaped += QByteArray(1,ch).toHex(); + result.replace(i, 1, QByteArrayView(escaped)); } else if ( replacement != 0 ) { result.remove(i,1); @@ -694,7 +700,7 @@ QByteArray KeyboardTranslator::Entry::unescape(const QByteArray& input) const for ( int i = 0 ; i < result.count()-1 ; i++ ) { - QByteRef ch = result[i]; + char ch = result[i]; if ( ch == '\\' ) { char replacement[2] = {0,0}; diff --git a/lib/Pty.cpp b/lib/Pty.cpp index 75a23a13..35412a7a 100644 --- a/lib/Pty.cpp +++ b/lib/Pty.cpp @@ -326,9 +326,9 @@ int Pty::foregroundProcessGroup() const return 0; } -void Pty::setupChildProcess() +void Pty::onSetupChildProcess() { - KPtyProcess::setupChildProcess(); + KPtyProcess::onSetupChildProcess(); // reset all signal handlers // this ensures that terminal applications respond to diff --git a/lib/Pty.h b/lib/Pty.h index f427a53a..446c1374 100644 --- a/lib/Pty.h +++ b/lib/Pty.h @@ -189,7 +189,7 @@ Q_OBJECT void receivedData(const char* buffer, int length); protected: - void setupChildProcess() override; + void onSetupChildProcess() override; private slots: // called when data is received from the terminal process diff --git a/lib/Session.cpp b/lib/Session.cpp index a40f9986..90b43af0 100644 --- a/lib/Session.cpp +++ b/lib/Session.cpp @@ -30,13 +30,13 @@ // Qt #include -#include #include #include #include #include #include #include +#include #include "Pty.h" //#include "kptyprocess.h" @@ -381,7 +381,7 @@ void Session::setUserTitle( int what, const QString & caption ) if (what == 31) { QString cwd=caption; - cwd=cwd.replace( QRegExp(QLatin1String("^~")), QDir::homePath() ); + cwd=cwd.replace( QRegularExpression(QLatin1String("^~")), QDir::homePath() ); emit openUrlRequest(cwd); } diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index 2fb30894..fd000593 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -275,16 +275,10 @@ void TerminalDisplay::setVTFont(const QFont& f) { QFont font = f; - // This was originally set for OS X only: - // mac uses floats for font width specification. - // this ensures the same handling for all platforms - // but then there was revealed that various Linux distros - // have this problem too... - font.setStyleStrategy(QFont::ForceIntegerMetrics); - + // Check if font is not fixed pitch and print a warning if ( !QFontInfo(font).fixedPitch() ) { - qDebug() << "Using a variable-width font in the terminal. This may cause performance degradation and display/alignment errors."; + qDebug() << "Using a variable-width font in the terminal. This may cause performance degradation and display/alignment errors."; } // hint that text should be drawn without anti-aliasing. @@ -293,7 +287,7 @@ void TerminalDisplay::setVTFont(const QFont& f) font.setStyleStrategy( QFont::NoAntialias ); // experimental optimization. Konsole assumes that the terminal is using a - // mono-spaced font, in which case kerning information should have an effect. + // mono-spaced font, in which case kerning information should have no effect. // Disabling kerning saves some computation when rendering text. font.setKerning(false); @@ -1619,7 +1613,7 @@ int TerminalDisplay::textWidth(const int startColumn, const int length, const in QFontMetrics fm(font()); int result = 0; for (int column = 0; column < length; column++) { - result += fm.horizontalAdvance(_image[loc(startColumn + column, line)].character); + result += fm.horizontalAdvance(QChar(static_cast(_image[loc(startColumn + column, line)].character))); } return result; } @@ -2126,8 +2120,8 @@ void TerminalDisplay::mouseMoveEvent(QMouseEvent* ev) // int distance = KGlobalSettings::dndEventDelay(); int distance = QApplication::startDragDistance(); - if ( ev->x() > dragInfo.start.x() + distance || ev->x() < dragInfo.start.x() - distance || - ev->y() > dragInfo.start.y() + distance || ev->y() < dragInfo.start.y() - distance) + if ( ev->position().x() > dragInfo.start.x() + distance || ev->position().x() < dragInfo.start.x() - distance || + ev->position().y() > dragInfo.start.y() + distance || ev->position().y() < dragInfo.start.y() - distance) { // we've left the drag square, we can start a real drag operation now emit isBusySelecting(false); // Ok.. we can breath again. @@ -2221,9 +2215,9 @@ void TerminalDisplay::extendSelection( const QPoint& position ) QPoint left = left_not_right ? here : _iPntSelCorr; i = loc(left.x(),left.y()); if (i>=0 && i<=_imageSize) { - selClass = charClass(_image[i].character); + selClass = charClass(QChar(static_cast(_image[i].character))); while ( ((left.x()>0) || (left.y()>0 && (_lineProperties[left.y()-1] & LINE_WRAPPED) )) - && charClass(_image[i-1].character) == selClass ) + && charClass(QChar(static_cast(_image[i-1].character))) == selClass ) { i--; if (left.x()>0) left.rx()--; else {left.rx()=_usedColumns-1; left.ry()--;} } } @@ -2231,9 +2225,9 @@ void TerminalDisplay::extendSelection( const QPoint& position ) QPoint right = left_not_right ? _iPntSelCorr : here; i = loc(right.x(),right.y()); if (i>=0 && i<=_imageSize) { - selClass = charClass(_image[i].character); + selClass = charClass(QChar(static_cast(_image[i].character))); while( ((right.x()<_usedColumns-1) || (right.y()<_usedLines-1 && (_lineProperties[right.y()] & LINE_WRAPPED) )) - && charClass(_image[i+1].character) == selClass ) + && charClass(QChar(static_cast(_image[i-1].character))) == selClass ) { i++; if (right.x()<_usedColumns-1) right.rx()++; else {right.rx()=0; right.ry()++; } } } @@ -2303,7 +2297,7 @@ void TerminalDisplay::extendSelection( const QPoint& position ) { i = loc(right.x(),right.y()); if (i>=0 && i<=_imageSize) { - selClass = charClass(_image[i-1].character); + selClass = charClass(QChar(static_cast(_image[i-1].character))); /* if (selClass == ' ') { while ( right.x() < _usedColumns-1 && charClass(_image[i+1].character) == selClass && (right.y()<_usedLines-1) && @@ -2491,12 +2485,12 @@ void TerminalDisplay::mouseDoubleClickEvent(QMouseEvent* ev) _wordSelectionMode = true; // find word boundaries... - QChar selClass = charClass(_image[i].character); + QChar selClass = charClass(QChar(static_cast(_image[i].character))); { // find the start of the word int x = bgnSel.x(); while ( ((x>0) || (bgnSel.y()>0 && (_lineProperties[bgnSel.y()-1] & LINE_WRAPPED) )) - && charClass(_image[i-1].character) == selClass ) + && charClass(QChar(static_cast(_image[i-1].character))) == selClass ) { i--; if (x>0) @@ -2515,7 +2509,7 @@ void TerminalDisplay::mouseDoubleClickEvent(QMouseEvent* ev) i = loc( endSel.x(), endSel.y() ); x = endSel.x(); while( ((x<_usedColumns-1) || (endSel.y()<_usedLines-1 && (_lineProperties[endSel.y()] & LINE_WRAPPED) )) - && charClass(_image[i+1].character) == selClass ) + && charClass(QChar(static_cast(_image[i+1].character))) == selClass ) { i++; if (x<_usedColumns-1) @@ -2624,13 +2618,13 @@ void TerminalDisplay::mouseTripleClickEvent(QMouseEvent* ev) if (_tripleClickMode == SelectForwardsFromCursor) { // find word boundary start int i = loc(_iPntSel.x(),_iPntSel.y()); - QChar selClass = charClass(_image[i].character); + QChar selClass = charClass(QChar(static_cast(_image[i].character))); int x = _iPntSel.x(); while ( ((x>0) || (_iPntSel.y()>0 && (_lineProperties[_iPntSel.y()-1] & LINE_WRAPPED) ) ) - && charClass(_image[i-1].character) == selClass ) + && charClass(QChar(static_cast(_image[i-1].character))) == selClass ) { i--; if (x>0) diff --git a/lib/Vt102Emulation.cpp b/lib/Vt102Emulation.cpp index 2a9aa131..2ceb3f29 100644 --- a/lib/Vt102Emulation.cpp +++ b/lib/Vt102Emulation.cpp @@ -31,7 +31,6 @@ // Qt #include #include -#include #include // Konsole @@ -954,8 +953,8 @@ void Vt102Emulation::sendMouseEvent( int cb, int cx, int cy , int eventType ) // coordinate+32, no matter what the locale is. We could easily // convert manually, but QString can also do it for us. QChar coords[2]; - coords[0] = cx + 0x20; - coords[1] = cy + 0x20; + coords[0] = QChar(cx + 0x20); + coords[1] = QChar(cy + 0x20); QString coordsStr = QString(coords, 2); QByteArray utf8 = coordsStr.toUtf8(); snprintf(command, sizeof(command), "\033[M%c%s", cb + 0x20, utf8.constData()); diff --git a/lib/kprocess.h b/lib/kprocess.h index 3dc4616b..1dc370ba 100644 --- a/lib/kprocess.h +++ b/lib/kprocess.h @@ -327,8 +327,6 @@ class KProcess : public QProcess private: // hide those - using QProcess::setReadChannelMode; - using QProcess::readChannelMode; using QProcess::setProcessChannelMode; using QProcess::processChannelMode; }; diff --git a/lib/kptyprocess.cpp b/lib/kptyprocess.cpp index e73ef345..c05f1dfd 100644 --- a/lib/kptyprocess.cpp +++ b/lib/kptyprocess.cpp @@ -40,6 +40,9 @@ KPtyProcess::KPtyProcess(QObject *parent) : KPtyProcess(-1, parent) { + setChildProcessModifier([this](){ + ChildProcessSetup(); + }); } KPtyProcess::KPtyProcess(int ptyMasterFd, QObject *parent) : @@ -121,7 +124,7 @@ KPtyDevice *KPtyProcess::pty() const return d->pty.get(); } -void KPtyProcess::setupChildProcess() +void KPtyProcess::onSetupChildProcess() { Q_D(KPtyProcess); @@ -139,8 +142,6 @@ void KPtyProcess::setupChildProcess() if (d->ptyChannels & StderrChannel) dup2(d->pty->slaveFd(), 2); - - KProcess::setupChildProcess(); } //#include "kptyprocess.moc" diff --git a/lib/kptyprocess.h b/lib/kptyprocess.h index 4d90823c..26711fa4 100644 --- a/lib/kptyprocess.h +++ b/lib/kptyprocess.h @@ -141,11 +141,16 @@ class KPtyProcess : public KProcess */ KPtyDevice *pty() const; + /** + * Do child process setup. + */ + void ChildProcessSetup() { onSetupChildProcess(); }; + protected: /** - * @reimp + * Child process configuration */ - void setupChildProcess() override; + virtual void onSetupChildProcess(); private: std::unique_ptr const d_ptr; diff --git a/lib/qtermwidget.cpp b/lib/qtermwidget.cpp index b7f54346..1aec5a99 100644 --- a/lib/qtermwidget.cpp +++ b/lib/qtermwidget.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "ColorTables.h" #include "Session.h" @@ -167,9 +168,13 @@ void QTermWidget::search(bool forwards, bool next) //qDebug() << "current selection starts at: " << startColumn << startLine; //qDebug() << "current cursor position: " << m_impl->m_terminalDisplay->screenWindow()->cursorPosition(); - QRegExp regExp(m_searchBar->searchText()); - regExp.setPatternSyntax(m_searchBar->useRegularExpression() ? QRegExp::RegExp : QRegExp::FixedString); - regExp.setCaseSensitivity(m_searchBar->matchCase() ? Qt::CaseSensitive : Qt::CaseInsensitive); + QRegularExpression regExp; + if (m_searchBar->useRegularExpression()) { + regExp.setPattern(m_searchBar->searchText()); + } else { + regExp.setPattern(QRegularExpression::escape(m_searchBar->searchText())); + } + regExp.setPatternOptions(m_searchBar->matchCase() ? QRegularExpression::NoPatternOption : QRegularExpression::CaseInsensitiveOption); HistorySearch *historySearch = new HistorySearch(m_impl->m_session->emulation(), regExp, forwards, startColumn, startLine, this); @@ -266,7 +271,7 @@ void QTermWidget::startTerminalTeletype() void QTermWidget::init(int startnow) { m_layout = new QVBoxLayout(); - m_layout->setMargin(0); + m_layout->setContentsMargins(0,0,0,0); setLayout(m_layout); // translations @@ -826,16 +831,6 @@ void QTermWidget::setTrimPastedTrailingNewlines(bool trimPastedTrailingNewlines) m_impl->m_terminalDisplay->setTrimPastedTrailingNewlines(trimPastedTrailingNewlines); } -QString QTermWidget::wordCharacters() const -{ - return m_impl->m_terminalDisplay->wordCharacters(); -} - -void QTermWidget::setWordCharacters(const QString& chars) -{ - m_impl->m_terminalDisplay->setWordCharacters(chars); -} - QTermWidgetInterface* QTermWidget::createWidget(int startnow) const { return new QTermWidget(startnow); diff --git a/lib/qtermwidget.h b/lib/qtermwidget.h index c5805918..d7532fc4 100644 --- a/lib/qtermwidget.h +++ b/lib/qtermwidget.h @@ -258,9 +258,6 @@ class QTERMWIDGET_EXPORT QTermWidget : public QWidget, public QTermWidgetInterfa void setConfirmMultilinePaste(bool confirmMultilinePaste) override; void setTrimPastedTrailingNewlines(bool trimPastedTrailingNewlines) override; - QString wordCharacters() const override; - void setWordCharacters(const QString& chars) override; - QTermWidgetInterface *createWidget(int startnow) const override; signals: void finished(); diff --git a/lib/qtermwidget_interface.h b/lib/qtermwidget_interface.h index 18422798..2b9f19b1 100644 --- a/lib/qtermwidget_interface.h +++ b/lib/qtermwidget_interface.h @@ -99,11 +99,9 @@ class QTermWidgetInterface { virtual void setBoldIntense(bool boldIntense) = 0; virtual void setConfirmMultilinePaste(bool confirmMultilinePaste) = 0; virtual void setTrimPastedTrailingNewlines(bool trimPastedTrailingNewlines) = 0; - virtual QString wordCharacters() const = 0; - virtual void setWordCharacters(const QString& chars) = 0; virtual QTermWidgetInterface* createWidget(int startnow) const = 0; }; -#define QTermWidgetInterface_iid "lxqt.qtermwidget.QTermWidgetInterface/1.5" +#define QTermWidgetInterface_iid "lxqt.qtermwidget.QTermWidgetInterface/1.0" Q_DECLARE_INTERFACE(QTermWidgetInterface, QTermWidgetInterface_iid) From b40b77b47e9f445f0a4b0e8669037ab070075a19 Mon Sep 17 00:00:00 2001 From: Doug Date: Sat, 24 Feb 2024 11:39:12 -0500 Subject: [PATCH 02/22] Fixed some warnings. --- lib/Emulation.cpp | 2 +- lib/KeyboardTranslator.cpp | 12 ++++++------ lib/Pty.cpp | 2 +- lib/ShellCommand.cpp | 6 +++--- lib/TerminalCharacterDecoder.cpp | 2 +- lib/Vt102Emulation.cpp | 4 ++-- lib/tools.cpp | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/Emulation.cpp b/lib/Emulation.cpp index 8f10ea2b..86218f71 100644 --- a/lib/Emulation.cpp +++ b/lib/Emulation.cpp @@ -136,7 +136,7 @@ void Emulation::setScreen(int n) if (_currentScreen != old) { // tell all windows onto this emulation to switch to the newly active screen - for(ScreenWindow* window : qAsConst(_windows)) + for(ScreenWindow* window : std::as_const(_windows)) window->setScreen(_currentScreen); } } diff --git a/lib/KeyboardTranslator.cpp b/lib/KeyboardTranslator.cpp index fc04ebea..eaaac6c8 100644 --- a/lib/KeyboardTranslator.cpp +++ b/lib/KeyboardTranslator.cpp @@ -354,11 +354,11 @@ bool KeyboardTranslatorReader::decodeSequence(const QString& text, KeyboardTranslator::States tempFlags = flags; KeyboardTranslator::States tempFlagMask = flagMask; - for ( int i = 0 ; i < text.count() ; i++ ) + for ( int i = 0 ; i < text.size() ; i++ ) { const QChar& ch = text[i]; bool isFirstLetter = i == 0; - bool isLastLetter = ( i == text.count()-1 ); + bool isLastLetter = ( i == text.size()-1 ); endOfItem = true; if ( ch.isLetterOrNumber() ) { @@ -658,7 +658,7 @@ QByteArray KeyboardTranslator::Entry::escapedText(bool expandWildCards,Qt::Keybo { QByteArray result(text(expandWildCards,modifiers)); - for ( int i = 0 ; i < result.count() ; i++ ) + for ( int i = 0 ; i < result.size() ; i++ ) { char ch = result[i]; char replacement = 0; @@ -697,7 +697,7 @@ QByteArray KeyboardTranslator::Entry::unescape(const QByteArray& input) const { QByteArray result(input); - for ( int i = 0 ; i < result.count()-1 ; i++ ) + for ( int i = 0 ; i < result.size()-1 ; i++ ) { char ch = result[i]; @@ -722,9 +722,9 @@ QByteArray KeyboardTranslator::Entry::unescape(const QByteArray& input) const // with the corresponding character value char hexDigits[3] = {0}; - if ( (i < result.count()-2) && isxdigit(result[i+2]) ) + if ( (i < result.size()-2) && isxdigit(result[i+2]) ) hexDigits[0] = result[i+2]; - if ( (i < result.count()-3) && isxdigit(result[i+3]) ) + if ( (i < result.size()-3) && isxdigit(result[i+3]) ) hexDigits[1] = result[i+3]; unsigned charValue = 0; diff --git a/lib/Pty.cpp b/lib/Pty.cpp index 35412a7a..46c10280 100644 --- a/lib/Pty.cpp +++ b/lib/Pty.cpp @@ -300,7 +300,7 @@ void Pty::sendData(const char* data, int length) void Pty::dataReceived() { QByteArray data = pty()->readAll(); - emit receivedData(data.constData(),data.count()); + emit receivedData(data.constData(),data.size()); } void Pty::lockPty(bool lock) diff --git a/lib/ShellCommand.cpp b/lib/ShellCommand.cpp index 03afa452..46127c9f 100644 --- a/lib/ShellCommand.cpp +++ b/lib/ShellCommand.cpp @@ -38,10 +38,10 @@ ShellCommand::ShellCommand(const QString & fullCommand) QString builder; - for ( int i = 0 ; i < fullCommand.count() ; i++ ) { + for ( int i = 0 ; i < fullCommand.size() ; i++ ) { QChar ch = fullCommand[i]; - const bool isLastChar = ( i == fullCommand.count() - 1 ); + const bool isLastChar = ( i == fullCommand.size() - 1 ); const bool isQuote = ( ch == QLatin1Char('\'') || ch == QLatin1Char('\"') ); if ( !isLastChar && isQuote ) { @@ -51,7 +51,7 @@ ShellCommand::ShellCommand(const QString & fullCommand) builder.append(ch); } - if ( (ch.isSpace() && !inQuotes) || ( i == fullCommand.count()-1 ) ) { + if ( (ch.isSpace() && !inQuotes) || ( i == fullCommand.size()-1 ) ) { _arguments << builder; builder.clear(); } diff --git a/lib/TerminalCharacterDecoder.cpp b/lib/TerminalCharacterDecoder.cpp index aa13b410..b42010bd 100644 --- a/lib/TerminalCharacterDecoder.cpp +++ b/lib/TerminalCharacterDecoder.cpp @@ -75,7 +75,7 @@ void PlainTextDecoder::decodeLine(const Character* const characters, int count, if (_recordLinePositions && _output->string()) { - int pos = _output->string()->count(); + int pos = _output->string()->size(); _linePositions << pos; } diff --git a/lib/Vt102Emulation.cpp b/lib/Vt102Emulation.cpp index 2ceb3f29..f4d45466 100644 --- a/lib/Vt102Emulation.cpp +++ b/lib/Vt102Emulation.cpp @@ -1105,7 +1105,7 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent* event, bool fromPaste) "into characters to send to the terminal " "is missing."); reset(); - receiveData( translatorError.toUtf8().constData() , translatorError.count() ); + receiveData( translatorError.toUtf8().constData() , translatorError.size() ); } } @@ -1341,7 +1341,7 @@ char Vt102Emulation::eraseChar() const Qt::Key_Backspace, Qt::NoModifier, KeyboardTranslator::NoState); - if ( entry.text().count() > 0 ) + if ( entry.text().size() > 0 ) return entry.text().at(0); else return '\b'; diff --git a/lib/tools.cpp b/lib/tools.cpp index 4291fae6..7ca9236c 100644 --- a/lib/tools.cpp +++ b/lib/tools.cpp @@ -89,7 +89,7 @@ const QStringList get_color_schemes_dirs() } #endif - for (const QString& custom_dir : qAsConst(custom_color_schemes_dirs)) + for (const QString& custom_dir : std::as_const(custom_color_schemes_dirs)) { d.setPath(custom_dir); if (d.exists()) From f28854711fa41ff6d8fdfc468396c156a936e842 Mon Sep 17 00:00:00 2001 From: Doug Date: Sat, 24 Feb 2024 11:39:12 -0500 Subject: [PATCH 03/22] Fixed another warning. --- lib/qtermwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/qtermwidget.cpp b/lib/qtermwidget.cpp index 1aec5a99..ebcd7228 100644 --- a/lib/qtermwidget.cpp +++ b/lib/qtermwidget.cpp @@ -286,7 +286,7 @@ void QTermWidget::init(int startnow) m_translator = new QTranslator(this); - for (const QString& dir : qAsConst(dirs)) { + for (const QString& dir : std::as_const(dirs)) { //qDebug() << "Trying to load translation file from dir" << dir; if (m_translator->load(QLocale::system(), QLatin1String("qtermwidget"), QLatin1String(QLatin1String("_")), dir)) { qApp->installTranslator(m_translator); From 184c9fe91906d7bc3886d770e89da1bbf596f6ae Mon Sep 17 00:00:00 2001 From: Doug Date: Sat, 24 Feb 2024 11:39:12 -0500 Subject: [PATCH 04/22] Fix the final warnings. --- lib/KeyboardTranslator.cpp | 2 +- lib/TerminalDisplay.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/KeyboardTranslator.cpp b/lib/KeyboardTranslator.cpp index eaaac6c8..2983fdc7 100644 --- a/lib/KeyboardTranslator.cpp +++ b/lib/KeyboardTranslator.cpp @@ -454,7 +454,7 @@ bool KeyboardTranslatorReader::parseAsKeyCode(const QString& item , int& keyCode QKeySequence sequence = QKeySequence::fromString(item); if ( !sequence.isEmpty() ) { - keyCode = sequence[0]; + keyCode = sequence[0].toCombined(); if ( sequence.count() > 1 ) { diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index fd000593..3018f65a 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -3314,6 +3314,7 @@ void AutoScrollHandler::timerEvent(QTimerEvent* event) QMouseEvent mouseEvent( QEvent::MouseMove, widget()->mapFromGlobal(QCursor::pos()), + QCursor::pos(), Qt::NoButton, Qt::LeftButton, Qt::NoModifier); From c880ab27d375ea847a17ad3f71e4194a1539a615 Mon Sep 17 00:00:00 2001 From: Marcus Britanicus Date: Mon, 26 Feb 2024 15:39:33 +0530 Subject: [PATCH 05/22] Fix issue cursor positioning issues --- lib/TerminalDisplay.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index 3018f65a..0ccfb757 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -291,6 +291,15 @@ void TerminalDisplay::setVTFont(const QFont& f) // Disabling kerning saves some computation when rendering text. font.setKerning(false); + // QFont::ForceIntegerMetrics has been removed. + // Set full hinting instead to ensure the letters are aligned properly. + font.setHintingPreference(QFont::PreferFullHinting); + + // "Draw intense colors in bold font" feature needs to use different font weights. StyleName + // property, when set, doesn't allow weight changes. Since all properties (weight, stretch, + // italic, etc) are stored in QFont independently, in almost all cases styleName is not needed. + font.setStyleName(QString()); + QWidget::setFont(font); fontChange(font); } From f085cd8d6e88c35b06d6f4413b07be6d6a672b47 Mon Sep 17 00:00:00 2001 From: Doug Date: Tue, 5 Mar 2024 09:41:30 -0500 Subject: [PATCH 06/22] Removed tab --- lib/ColorScheme.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ColorScheme.cpp b/lib/ColorScheme.cpp index 7082de67..f749a83c 100644 --- a/lib/ColorScheme.cpp +++ b/lib/ColorScheme.cpp @@ -367,7 +367,7 @@ void ColorScheme::readColorEntry(QSettings * s , int index) r = colorStr.mid(1, 2).toInt(nullptr, 16); g = colorStr.mid(3, 2).toInt(nullptr, 16); b = colorStr.mid(5, 2).toInt(nullptr, 16); - ok = true; + ok = true; } } if (!ok) From 08fc85c1c4e08154bf438c183aa47f89e587e3b4 Mon Sep 17 00:00:00 2001 From: Doug Date: Thu, 7 Mar 2024 09:35:16 -0500 Subject: [PATCH 07/22] Fix the example. --- examples/cpp/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/cpp/main.cpp b/examples/cpp/main.cpp index 23be40ea..ea085ccb 100644 --- a/examples/cpp/main.cpp +++ b/examples/cpp/main.cpp @@ -36,11 +36,11 @@ int main(int argc, char *argv[]) QMenuBar *menuBar = new QMenuBar(mainWindow); QMenu *actionsMenu = new QMenu(QStringLiteral("Actions"), menuBar); menuBar->addMenu(actionsMenu); - actionsMenu->addAction(QStringLiteral("Find..."), QKeySequence(QLatin1String("Ctrl+Shift+F")), + actionsMenu->addAction(QStringLiteral("Find..."), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_F), console, &QTermWidget::toggleShowSearchBar); - actionsMenu->addAction(QStringLiteral("Copy"), QKeySequence(QLatin1String("Ctrl+Shift+C")), + actionsMenu->addAction(QStringLiteral("Copy"), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_C), console, &QTermWidget::copyClipboard); - actionsMenu->addAction(QStringLiteral("Paste"), QKeySequence(QLatin1String("Ctrl+Shift+V")), + actionsMenu->addAction(QStringLiteral("Paste"), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_V), console, &QTermWidget::pasteClipboard); actionsMenu->addAction(QStringLiteral("About Qt"), &app, &QApplication::aboutQt); mainWindow->setMenuBar(menuBar); From c5e5f1f0acbe2bbb96fda6a2c7f429f7421fe2fb Mon Sep 17 00:00:00 2001 From: Doug Date: Mon, 11 Mar 2024 07:04:50 -0400 Subject: [PATCH 08/22] Tab to space in terminal display. --- lib/TerminalDisplay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index 0ccfb757..c526eb1c 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -278,7 +278,7 @@ void TerminalDisplay::setVTFont(const QFont& f) // Check if font is not fixed pitch and print a warning if ( !QFontInfo(font).fixedPitch() ) { - qDebug() << "Using a variable-width font in the terminal. This may cause performance degradation and display/alignment errors."; + qDebug() << "Using a variable-width font in the terminal. This may cause performance degradation and display/alignment errors."; } // hint that text should be drawn without anti-aliasing. From 94ee191c0624653562c651b5fcbcdb5a9a97442c Mon Sep 17 00:00:00 2001 From: Doug Date: Mon, 11 Mar 2024 07:23:42 -0400 Subject: [PATCH 09/22] Remove chagnes that were accidently reverted. --- lib/qtermwidget.cpp | 11 +++++++++++ lib/qtermwidget.h | 3 +++ lib/qtermwidget_interface.h | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/qtermwidget.cpp b/lib/qtermwidget.cpp index ebcd7228..7614a814 100644 --- a/lib/qtermwidget.cpp +++ b/lib/qtermwidget.cpp @@ -831,6 +831,17 @@ void QTermWidget::setTrimPastedTrailingNewlines(bool trimPastedTrailingNewlines) m_impl->m_terminalDisplay->setTrimPastedTrailingNewlines(trimPastedTrailingNewlines); } +QString QTermWidget::wordCharacters() const +{ + return m_impl->m_terminalDisplay->wordCharacters(); +} + +void QTermWidget::setWordCharacters(const QString& chars) +{ + m_impl->m_terminalDisplay->setWordCharacters(chars); +} + + QTermWidgetInterface* QTermWidget::createWidget(int startnow) const { return new QTermWidget(startnow); diff --git a/lib/qtermwidget.h b/lib/qtermwidget.h index d7532fc4..c5805918 100644 --- a/lib/qtermwidget.h +++ b/lib/qtermwidget.h @@ -258,6 +258,9 @@ class QTERMWIDGET_EXPORT QTermWidget : public QWidget, public QTermWidgetInterfa void setConfirmMultilinePaste(bool confirmMultilinePaste) override; void setTrimPastedTrailingNewlines(bool trimPastedTrailingNewlines) override; + QString wordCharacters() const override; + void setWordCharacters(const QString& chars) override; + QTermWidgetInterface *createWidget(int startnow) const override; signals: void finished(); diff --git a/lib/qtermwidget_interface.h b/lib/qtermwidget_interface.h index 2b9f19b1..18422798 100644 --- a/lib/qtermwidget_interface.h +++ b/lib/qtermwidget_interface.h @@ -99,9 +99,11 @@ class QTermWidgetInterface { virtual void setBoldIntense(bool boldIntense) = 0; virtual void setConfirmMultilinePaste(bool confirmMultilinePaste) = 0; virtual void setTrimPastedTrailingNewlines(bool trimPastedTrailingNewlines) = 0; + virtual QString wordCharacters() const = 0; + virtual void setWordCharacters(const QString& chars) = 0; virtual QTermWidgetInterface* createWidget(int startnow) const = 0; }; -#define QTermWidgetInterface_iid "lxqt.qtermwidget.QTermWidgetInterface/1.0" +#define QTermWidgetInterface_iid "lxqt.qtermwidget.QTermWidgetInterface/1.5" Q_DECLARE_INTERFACE(QTermWidgetInterface, QTermWidgetInterface_iid) From 975be81f1008cdc6ef183462dd01578d4094f04c Mon Sep 17 00:00:00 2001 From: Doug Date: Tue, 26 Mar 2024 13:33:53 -0400 Subject: [PATCH 10/22] Updated README comments to reflect move to qt6. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e77d2ab7..3b2dff8a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Overview -A terminal emulator widget for Qt 5. +A terminal emulator widget for Qt 6. QTermWidget is an open-source project originally based on the KDE4 Konsole application, but it took its own direction later on. The main goal of this project is to provide a Unicode-enabled, embeddable Qt widget for using as a built-in console (or terminal emulation widget). @@ -45,7 +45,7 @@ License: BSD-3-clause ### Compiling sources -The only runtime dependency is qtbase ≥ 5.12.0. +The only runtime dependency is qtbase ≥ 6.6.0. Build dependencies are as follows: - CMake ≥ 3.1.0 serves as the build system and therefore needs to be present to compile. - The latest [lxqt-build-tools](https://github.com/lxqt/lxqt-build-tools/) is also needed for compilation. From bcd4ff7c4df15313a5ab7f3cd09950ae08b4e38f Mon Sep 17 00:00:00 2001 From: Doug Date: Tue, 26 Mar 2024 14:20:59 -0400 Subject: [PATCH 11/22] Remove ChildProcessSetup and directly call onsetupChildProcess. --- lib/kptyprocess.cpp | 2 +- lib/kptyprocess.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/kptyprocess.cpp b/lib/kptyprocess.cpp index c05f1dfd..2ccd3bab 100644 --- a/lib/kptyprocess.cpp +++ b/lib/kptyprocess.cpp @@ -41,7 +41,7 @@ KPtyProcess::KPtyProcess(QObject *parent) : KPtyProcess(-1, parent) { setChildProcessModifier([this](){ - ChildProcessSetup(); + onSetupChildProcess(); }); } diff --git a/lib/kptyprocess.h b/lib/kptyprocess.h index 26711fa4..ee1234d3 100644 --- a/lib/kptyprocess.h +++ b/lib/kptyprocess.h @@ -141,11 +141,6 @@ class KPtyProcess : public KProcess */ KPtyDevice *pty() const; - /** - * Do child process setup. - */ - void ChildProcessSetup() { onSetupChildProcess(); }; - protected: /** * Child process configuration From faee5311ca5b8ef5aab783d9e1d9fa49789ae19c Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen <645432-yan12125@users.noreply.gitlab.com> Date: Sun, 10 Mar 2024 19:16:14 +0800 Subject: [PATCH 12/22] Try CI --- .ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/build.sh b/.ci/build.sh index a5cee646..c1cb5b90 100644 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -3,7 +3,7 @@ set -ex source shared-ci/prepare-archlinux.sh # See *depends in https://github.com/archlinuxcn/repo/blob/master/archlinuxcn/qtermwidget-git/PKGBUILD -pacman -S --noconfirm --needed git cmake lxqt-build-tools-git qt5-tools python-pyqt5 pyqt-builder sip +pacman -S --noconfirm --needed git cmake lxqt-build-tools-git qt6-5compat qt6-tools python-pyqt6 pyqt-builder sip cmake -B build -S . \ -DBUILD_EXAMPLE=ON \ From a3d5546e3ebaee148f09c86e24c0bd47c0f8ac0b Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen <645432-yan12125@users.noreply.gitlab.com> Date: Thu, 28 Mar 2024 12:23:19 +0800 Subject: [PATCH 13/22] Use PyQt6 --- pyqt/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyqt/pyproject.toml b/pyqt/pyproject.toml index c567f3e1..d55bc69f 100644 --- a/pyqt/pyproject.toml +++ b/pyqt/pyproject.toml @@ -7,4 +7,4 @@ build-backend = "sipbuild.api" [tool.sip.metadata] name = "QTermWidget" version = "1.4.0" -requires-dist = ["PyQt5"] +requires-dist = ["PyQt6"] From 40cbc8d388b6440b8b37e90454dc74ef6b337de3 Mon Sep 17 00:00:00 2001 From: Doug Date: Thu, 28 Mar 2024 09:16:41 -0400 Subject: [PATCH 14/22] Made change suggested by marcusbritanicus --- pyqt/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyqt/project.py b/pyqt/project.py index 11798c64..cd630518 100644 --- a/pyqt/project.py +++ b/pyqt/project.py @@ -11,5 +11,5 @@ def __init__(self, project): self._project = project def apply_user_defaults(self, tool): - self.libraries.append('qtermwidget5') + self.libraries.append('qtermwidget6') super().apply_user_defaults(tool) From c4cedb9f6f86d50ca4fd4b5c54ab66e2ebc05427 Mon Sep 17 00:00:00 2001 From: Doug Date: Thu, 28 Mar 2024 09:27:44 -0400 Subject: [PATCH 15/22] Temporary CI workaround suggested by marcusbritanicus. --- .ci/build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.ci/build.sh b/.ci/build.sh index c1cb5b90..15790f3a 100644 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -5,6 +5,9 @@ source shared-ci/prepare-archlinux.sh # See *depends in https://github.com/archlinuxcn/repo/blob/master/archlinuxcn/qtermwidget-git/PKGBUILD pacman -S --noconfirm --needed git cmake lxqt-build-tools-git qt6-5compat qt6-tools python-pyqt6 pyqt-builder sip +#Temporary workaround suggested by marcusbritanicus +sudo ln -s /usr/bin/qmake6 /usr/bin/qmake + cmake -B build -S . \ -DBUILD_EXAMPLE=ON \ -DQTERMWIDGET_USE_UTEMPTER=ON From 0f2cbfeaecd2de38712b7784e50849d80fba1556 Mon Sep 17 00:00:00 2001 From: Doug Date: Thu, 4 Apr 2024 11:53:58 -0400 Subject: [PATCH 16/22] Removed all the qt5 compatibility code. Also removed codec support. --- CMakeLists.txt | 2 -- README.md | 4 --- lib/Emulation.cpp | 31 +++-------------- lib/Emulation.h | 22 ++---------- lib/Filter.cpp | 67 ++++++++++++++++++++----------------- lib/Filter.h | 14 ++++---- lib/SearchBar.cpp | 1 - lib/SearchBar.h | 2 +- lib/Session.cpp | 8 +---- lib/Session.h | 3 -- lib/Vt102Emulation.cpp | 14 ++++---- lib/Vt102Emulation.h | 4 ++- lib/qtermwidget.cpp | 9 ----- lib/qtermwidget.h | 3 -- lib/qtermwidget_interface.h | 1 - 15 files changed, 62 insertions(+), 123 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2fe5e11..aeb1e16c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,6 @@ set(LXQTBT_MINIMUM_VERSION "0.13.0") find_package(Qt6Widgets "${QT_MINIMUM_VERSION}" REQUIRED) find_package(Qt6LinguistTools "${QT_MINIMUM_VERSION}" REQUIRED) -find_package(Qt6Core5Compat "${QT_MINIMUM_VERSION}" REQUIRED) find_package(lxqt2-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED) if(USE_UTF8PROC) @@ -149,7 +148,6 @@ lxqt_translate_ts(QTERMWIDGET_QM add_library(${QTERMWIDGET_LIBRARY_NAME} SHARED ${SRCS} ${MOCS} ${UI_SRCS} ${QTERMWIDGET_QM}) target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} Qt6::Widgets) -target_link_libraries(${QTERMWIDGET_LIBRARY_NAME} Qt6::Core5Compat) set_target_properties( ${QTERMWIDGET_LIBRARY_NAME} PROPERTIES SOVERSION ${QTERMWIDGET_VERSION_MAJOR} VERSION ${QTERMWIDGET_VERSION} diff --git a/README.md b/README.md index 3b2dff8a..2e0e4d2b 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,6 @@ void | setSilenceTimeout(int _seconds_) void | setTerminalFont(QFont &_font_) void | setTerminalOpacity(qreal _level_) void | setTerminalSizeHint(bool _enabled_) -void | setTextCodec(QTextCodec *_codec_) void | setWorkingDirectory(const QString &_dir_) void | startShellProgram() void | startTerminalTeletype() @@ -325,9 +324,6 @@ Sets terminal font. Default is application font with family Monospace, size 10. __void setTerminalSizeHint(bool _enabled_)__\ Exposes TerminalDisplay::TerminalSizeHint. -__void setTextCodec(QTextCodec *_codec_)__\ -Sets text codec, default is UTF-8. - diff --git a/lib/Emulation.cpp b/lib/Emulation.cpp index 86218f71..db220eb3 100644 --- a/lib/Emulation.cpp +++ b/lib/Emulation.cpp @@ -49,11 +49,10 @@ using namespace Konsole; Emulation::Emulation() : _currentScreen(nullptr), - _codec(nullptr), - _decoder(nullptr), _keyTranslator(nullptr), _usesMouse(false), - _bracketedPasteMode(false) + _bracketedPasteMode(false), + _fromUtf8(QStringEncoder::Utf16) { // create screens with a default size _screen[0] = new Screen(40,80); @@ -126,7 +125,6 @@ Emulation::~Emulation() delete _screen[0]; delete _screen[1]; - delete _decoder; } void Emulation::setScreen(int n) @@ -157,27 +155,6 @@ const HistoryType& Emulation::history() const return _screen[0]->getScroll(); } -void Emulation::setCodec(const QTextCodec * qtc) -{ - if (qtc) - _codec = qtc; - else - setCodec(LocaleCodec); - - delete _decoder; - _decoder = _codec->makeDecoder(); - - emit useUtf8Request(utf8()); -} - -void Emulation::setCodec(EmulationCodec codec) -{ - if ( codec == Utf8Codec ) - setCodec( QTextCodec::codecForName("utf8") ); - else if ( codec == LocaleCodec ) - setCodec( QTextCodec::codecForLocale() ); -} - void Emulation::setKeyBindings(const QString& name) { _keyTranslator = KeyboardTranslatorManager::instance()->findTranslator(name); @@ -247,8 +224,8 @@ void Emulation::receiveData(const char* text, int length) * U+10FFFF * https://unicodebook.readthedocs.io/unicode_encodings.html#surrogates */ - QString utf16Text = _decoder->toUnicode(text,length); - std::wstring unicodeText = utf16Text.toStdWString(); + auto encoded = _fromUtf8(QString::fromUtf8(text, length)); + std::wstring unicodeText = encoded.data.toStdWString(); //send characters to terminal emulator for (size_t i=0;i //#include -#include #include #include +#include #include "qtermwidget_export.h" #include "KeyboardTranslator.h" @@ -190,20 +190,6 @@ Q_OBJECT */ virtual void writeToStream(TerminalCharacterDecoder* decoder,int startLine,int endLine); - /** Returns the codec used to decode incoming characters. See setCodec() */ - const QTextCodec* codec() const { return _codec; } - /** Sets the codec used to decode incoming characters. */ - void setCodec(const QTextCodec*); - - /** - * Convenience method. - * Returns true if the current codec used to decode incoming - * characters is UTF-8 - */ - bool utf8() const - { Q_ASSERT(_codec); return _codec->mibEnum() == 106; } - - /** TODO Document me */ virtual char eraseChar() const; @@ -483,10 +469,6 @@ public slots: // scrollbars are not enabled in this mode ) - //decodes an incoming C-style character stream into a unicode QString using - //the current text codec. (this allows for rendering of non-ASCII characters in text files etc.) - const QTextCodec* _codec; - QTextDecoder* _decoder; const KeyboardTranslator* _keyTranslator; // the keyboard layout protected slots: @@ -512,7 +494,7 @@ private slots: bool _bracketedPasteMode; QTimer _bulkTimer1{this}; QTimer _bulkTimer2{this}; - + QStringEncoder _fromUtf8; }; } diff --git a/lib/Filter.cpp b/lib/Filter.cpp index f2192929..c60b2237 100644 --- a/lib/Filter.cpp +++ b/lib/Filter.cpp @@ -338,11 +338,11 @@ QStringList RegExpFilter::HotSpot::capturedTexts() const return _capturedTexts; } -void RegExpFilter::setRegExp(const QRegExp& regExp) +void RegExpFilter::setRegExp(const QRegularExpression& regExp) { _searchText = regExp; } -QRegExp RegExpFilter::regExp() const +QRegularExpression RegExpFilter::regExp() const { return _searchText; } @@ -352,7 +352,6 @@ QRegExp RegExpFilter::regExp() const }*/ void RegExpFilter::process() { - int pos = 0; const QString* text = buffer(); Q_ASSERT( text ); @@ -360,35 +359,41 @@ void RegExpFilter::process() // ignore any regular expressions which match an empty string. // otherwise the while loop below will run indefinitely static const QString emptyString; - if ( _searchText.exactMatch(emptyString) ) - return; - - while(pos >= 0) + auto match = _searchText.match(emptyString, 0, + QRegularExpression::NormalMatch, QRegularExpression::AnchorAtOffsetMatchOption); + if (match.hasMatch()) { - pos = _searchText.indexIn(*text,pos); - - if ( pos >= 0 ) - { - int startLine = 0; - int endLine = 0; - int startColumn = 0; - int endColumn = 0; + return; + } - getLineColumn(pos,startLine,startColumn); - getLineColumn(pos + _searchText.matchedLength(),endLine,endColumn); + match = _searchText.match(*text); + while (match.hasMatch()) { + int startLine = 0; + int endLine = 0; + int startColumn = 0; + int endColumn = 0; + + QStringList captureList; + for (int i = 0; i <= match.lastCapturedIndex(); i++) { + QString text = match.captured(i); + captureList.append(text); + } + + getLineColumn(match.capturedStart(), startLine, startColumn); + getLineColumn(match.capturedEnd(), endLine, endColumn); - RegExpFilter::HotSpot* spot = newHotSpot(startLine,startColumn, - endLine,endColumn); - spot->setCapturedTexts(_searchText.capturedTexts()); + RegExpFilter::HotSpot* spot = newHotSpot(startLine, startColumn, endLine, endColumn); + spot->setCapturedTexts(captureList); - addHotSpot( spot ); - pos += _searchText.matchedLength(); + addHotSpot(spot); - // if matchedLength == 0, the program will get stuck in an infinite loop - if ( _searchText.matchedLength() == 0 ) - pos = -1; + // if capturedLength == 0, the program will get stuck in an infinite loop + if (match.capturedLength() == 0) { + break; } - } + + match = _searchText.match(*text, match.capturedEnd()); + } } RegExpFilter::HotSpot* RegExpFilter::newHotSpot(int startLine,int startColumn, @@ -417,9 +422,9 @@ UrlFilter::HotSpot::UrlType UrlFilter::HotSpot::urlType() const { QString url = capturedTexts().constFirst(); - if ( FullUrlRegExp.exactMatch(url) ) + if ( FullUrlRegExp.match(url).hasMatch() ) return StandardUrl; - else if ( EmailAddressRegExp.exactMatch(url) ) + else if ( EmailAddressRegExp.match(url).hasMatch() ) return Email; else return Unknown; @@ -465,13 +470,13 @@ void UrlFilter::HotSpot::activate(const QString& actionName) //regexp matches: // full url: // protocolname:// or www. followed by anything other than whitespaces, <, >, ' or ", and ends before whitespaces, <, >, ', ", ], !, comma and dot -const QRegExp UrlFilter::FullUrlRegExp(QLatin1String("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]]")); +const QRegularExpression UrlFilter::FullUrlRegExp(QRegularExpression::anchoredPattern(QLatin1String("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]]"))); // email address: // [word chars, dots or dashes]@[word chars, dots or dashes].[word chars] -const QRegExp UrlFilter::EmailAddressRegExp(QLatin1String("\\b(\\w|\\.|-)+@(\\w|\\.|-)+\\.\\w+\\b")); +const QRegularExpression UrlFilter::EmailAddressRegExp(QRegularExpression::anchoredPattern(QLatin1String("\\b(\\w|\\.|-)+@(\\w|\\.|-)+\\.\\w+\\b"))); // matches full url or email address -const QRegExp UrlFilter::CompleteUrlRegExp(QLatin1Char('(')+FullUrlRegExp.pattern()+QLatin1Char('|')+ +const QRegularExpression UrlFilter::CompleteUrlRegExp(QLatin1Char('(')+FullUrlRegExp.pattern()+QLatin1Char('|')+ EmailAddressRegExp.pattern()+QLatin1Char(')')); UrlFilter::UrlFilter() diff --git a/lib/Filter.h b/lib/Filter.h index 3d8d4b7c..12847d10 100644 --- a/lib/Filter.h +++ b/lib/Filter.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include // Local #include "qtermwidget_export.h" @@ -214,9 +214,9 @@ class QTERMWIDGET_EXPORT RegExpFilter : public Filter * Regular expressions which match the empty string are treated as not matching * anything. */ - void setRegExp(const QRegExp& text); + void setRegExp(const QRegularExpression& text); /** Returns the regular expression which the filter searches for in blocks of text */ - QRegExp regExp() const; + QRegularExpression regExp() const; /** * Reimplemented to search the filter's text buffer for text matching regExp() @@ -235,7 +235,7 @@ class QTERMWIDGET_EXPORT RegExpFilter : public Filter int endLine,int endColumn); private: - QRegExp _searchText; + QRegularExpression _searchText; }; class FilterObject; @@ -287,11 +287,11 @@ class QTERMWIDGET_EXPORT UrlFilter : public RegExpFilter private: - static const QRegExp FullUrlRegExp; - static const QRegExp EmailAddressRegExp; + static const QRegularExpression FullUrlRegExp; + static const QRegularExpression EmailAddressRegExp; // combined OR of FullUrlRegExp and EmailAddressRegExp - static const QRegExp CompleteUrlRegExp; + static const QRegularExpression CompleteUrlRegExp; signals: void activated(const QUrl& url, bool fromContextMenu); }; diff --git a/lib/SearchBar.cpp b/lib/SearchBar.cpp index 1de92f45..db0f69bc 100644 --- a/lib/SearchBar.cpp +++ b/lib/SearchBar.cpp @@ -18,7 +18,6 @@ */ #include #include -#include #include #include "SearchBar.h" diff --git a/lib/SearchBar.h b/lib/SearchBar.h index 1200884f..c836f189 100644 --- a/lib/SearchBar.h +++ b/lib/SearchBar.h @@ -19,7 +19,7 @@ #ifndef _SEARCHBAR_H #define _SEARCHBAR_H -#include +#include #include "ui_SearchBar.h" #include "HistorySearch.h" diff --git a/lib/Session.cpp b/lib/Session.cpp index 90b43af0..2d892171 100644 --- a/lib/Session.cpp +++ b/lib/Session.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -103,7 +102,7 @@ Session::Session(QObject* parent) : this, &Session::cursorChanged); //connect teletype to emulation backend - _shellProcess->setUtf8Mode(_emulation->utf8()); + _shellProcess->setUtf8Mode(true); connect( _shellProcess,SIGNAL(receivedData(const char *,int)),this, SLOT(onReceiveBlock(const char *,int)) ); @@ -143,11 +142,6 @@ bool Session::isRunning() const return _shellProcess->state() == QProcess::Running; } -void Session::setCodec(QTextCodec * codec) const -{ - emulation()->setCodec(codec); -} - void Session::setProgram(const QString & program) { _program = ShellCommand::expand(program); diff --git a/lib/Session.h b/lib/Session.h index e8b95614..96fea0a8 100644 --- a/lib/Session.h +++ b/lib/Session.h @@ -340,9 +340,6 @@ class Session : public QObject { */ void setSize(const QSize & size); - /** Sets the text codec used by this session's terminal emulation. */ - void setCodec(QTextCodec * codec) const; - /** * Sets whether the session has a dark background or not. The session * uses this information to set the COLORFGBG variable in the process's diff --git a/lib/Vt102Emulation.cpp b/lib/Vt102Emulation.cpp index f4d45466..97688385 100644 --- a/lib/Vt102Emulation.cpp +++ b/lib/Vt102Emulation.cpp @@ -44,7 +44,8 @@ Vt102Emulation::Vt102Emulation() : Emulation(), prevCC(0), _titleUpdateTimer(new QTimer(this)), - _reportFocusEvents(false) + _reportFocusEvents(false), + _toUtf8(QStringEncoder::Utf8) { _titleUpdateTimer->setSingleShot(true); QObject::connect(_titleUpdateTimer, &QTimer::timeout, @@ -71,7 +72,6 @@ void Vt102Emulation::reset() _screen[0]->reset(); resetCharset(1); _screen[1]->reset(); - setCodec(LocaleCodec); bufferedUpdate(); } @@ -511,8 +511,8 @@ void Vt102Emulation::processToken(int token, wchar_t p, int q) case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100 case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100 - case TY_ESC_CS('%', 'G') : setCodec (Utf8Codec ); break; //LINUX - case TY_ESC_CS('%', '@') : setCodec (LocaleCodec ); break; //LINUX + case TY_ESC_CS('%', 'G') : /*No longer updating codec*/ break; //LINUX + case TY_ESC_CS('%', '@') : /*No longer updating codec*/ break; //LINUX case TY_ESC_DE('3' ) : /* Double height line, top half */ _currentScreen->setLineProperty( LINE_DOUBLEWIDTH , true ); @@ -1073,7 +1073,8 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent* event, bool fromPaste) } else if ( !entry.text().isEmpty() ) { - textToSend += _codec->fromUnicode(QString::fromUtf8(entry.text(true,modifiers))); + QByteArray bytes = _toUtf8(QString::fromUtf8(entry.text(true,modifiers))); + textToSend += bytes; } else if((modifiers & KeyboardTranslator::CTRL_MOD) && event->key() >= 0x40 && event->key() < 0x5f) { textToSend += (event->key() & 0x1f); @@ -1088,7 +1089,8 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent* event, bool fromPaste) textToSend += "\033[6~"; } else { - textToSend += _codec->fromUnicode(event->text()); + QByteArray bytes = _toUtf8(event->text()); + textToSend += bytes; } if (!fromPaste && textToSend.length()) { diff --git a/lib/Vt102Emulation.h b/lib/Vt102Emulation.h index fdbcecd9..524e9cf9 100644 --- a/lib/Vt102Emulation.h +++ b/lib/Vt102Emulation.h @@ -193,7 +193,9 @@ private slots: QHash _pendingTitleUpdates; QTimer* _titleUpdateTimer; - bool _reportFocusEvents; + bool _reportFocusEvents; + + QStringEncoder _toUtf8; }; } diff --git a/lib/qtermwidget.cpp b/lib/qtermwidget.cpp index 7614a814..6f7e707e 100644 --- a/lib/qtermwidget.cpp +++ b/lib/qtermwidget.cpp @@ -92,8 +92,6 @@ Session *TermWidgetImpl::createSession(QWidget* parent) session->setArguments(args); session->setAutoClose(true); - session->setCodec(QTextCodec::codecForName("UTF-8")); - session->setFlowControlEnabled(true); session->setHistoryType(HistoryTypeBuffer(1000)); @@ -433,13 +431,6 @@ void QTermWidget::setArgs(const QStringList &args) m_impl->m_session->setArguments(args); } -void QTermWidget::setTextCodec(QTextCodec *codec) -{ - if (!m_impl->m_session) - return; - m_impl->m_session->setCodec(codec); -} - void QTermWidget::setColorScheme(const QString& origName) { const ColorScheme *cs = nullptr; diff --git a/lib/qtermwidget.h b/lib/qtermwidget.h index c5805918..10942dc6 100644 --- a/lib/qtermwidget.h +++ b/lib/qtermwidget.h @@ -100,9 +100,6 @@ class QTERMWIDGET_EXPORT QTermWidget : public QWidget, public QTermWidgetInterfa // Shell program args, default is none void setArgs(const QStringList & args) override; - //Text codec, default is UTF-8 - void setTextCodec(QTextCodec * codec) override; - /** @brief Sets the color scheme, default is white on black * * @param[in] name The name of the color scheme, either returned from diff --git a/lib/qtermwidget_interface.h b/lib/qtermwidget_interface.h index 18422798..2ea83af6 100644 --- a/lib/qtermwidget_interface.h +++ b/lib/qtermwidget_interface.h @@ -56,7 +56,6 @@ class QTermWidgetInterface { virtual void setWorkingDirectory(const QString & dir) = 0; virtual QString workingDirectory() = 0; virtual void setArgs(const QStringList & args) = 0; - virtual void setTextCodec(QTextCodec * codec) = 0; virtual void setColorScheme(const QString & name) = 0; virtual QStringList getAvailableColorSchemes() = 0; virtual void setHistorySize(int lines) = 0; From 651d0bf1a1fcabc124564f2e46c319a4c5fa6ef0 Mon Sep 17 00:00:00 2001 From: Doug Date: Thu, 4 Apr 2024 12:06:17 -0400 Subject: [PATCH 17/22] Removed codec function from sip file. --- pyqt/sip/qtermwidget.sip | 1 - 1 file changed, 1 deletion(-) diff --git a/pyqt/sip/qtermwidget.sip b/pyqt/sip/qtermwidget.sip index 21a10f8d..e023a781 100644 --- a/pyqt/sip/qtermwidget.sip +++ b/pyqt/sip/qtermwidget.sip @@ -47,7 +47,6 @@ public: void setWorkingDirectory(const QString & dir); QString workingDirectory(); void setArgs(QStringList & args); - void setTextCodec(QTextCodec *codec); void setColorScheme(const QString & name); QStringList getAvailableColorSchemes(); static QStringList availableColorSchemes(); From 3cbbb16f50c83e1d874265dd030fce54c58c073d Mon Sep 17 00:00:00 2001 From: Doug Date: Fri, 5 Apr 2024 07:16:32 -0400 Subject: [PATCH 18/22] Improved CI fix by marcusbritanicus --- .ci/build.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.ci/build.sh b/.ci/build.sh index 15790f3a..84716662 100644 --- a/.ci/build.sh +++ b/.ci/build.sh @@ -5,13 +5,10 @@ source shared-ci/prepare-archlinux.sh # See *depends in https://github.com/archlinuxcn/repo/blob/master/archlinuxcn/qtermwidget-git/PKGBUILD pacman -S --noconfirm --needed git cmake lxqt-build-tools-git qt6-5compat qt6-tools python-pyqt6 pyqt-builder sip -#Temporary workaround suggested by marcusbritanicus -sudo ln -s /usr/bin/qmake6 /usr/bin/qmake - cmake -B build -S . \ -DBUILD_EXAMPLE=ON \ -DQTERMWIDGET_USE_UTEMPTER=ON make -C build cd pyqt -CXXFLAGS="-I$PWD/../lib -I$PWD/../build/lib" LDFLAGS="-L$PWD/../build" sip-wheel --verbose +CXXFLAGS="-I$PWD/../lib -I$PWD/../build/lib" LDFLAGS="-L$PWD/../build" sip-wheel --verbose --qmake=/usr/bin/qmake6 From a968c1cf212cf759e4e8a8af4b62de4e082b35fc Mon Sep 17 00:00:00 2001 From: Doug Date: Fri, 5 Apr 2024 13:42:35 -0400 Subject: [PATCH 19/22] Attempting to fix warning. --- lib/Emulation.cpp | 3 ++- lib/Vt102Emulation.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Emulation.cpp b/lib/Emulation.cpp index db220eb3..c88ac12a 100644 --- a/lib/Emulation.cpp +++ b/lib/Emulation.cpp @@ -224,7 +224,8 @@ void Emulation::receiveData(const char* text, int length) * U+10FFFF * https://unicodebook.readthedocs.io/unicode_encodings.html#surrogates */ - auto encoded = _fromUtf8(QString::fromUtf8(text, length)); + QString str = QString::fromUtf8(text, length); + auto encoded = _fromUtf8(str); std::wstring unicodeText = encoded.data.toStdWString(); //send characters to terminal emulator diff --git a/lib/Vt102Emulation.cpp b/lib/Vt102Emulation.cpp index 97688385..f76092d9 100644 --- a/lib/Vt102Emulation.cpp +++ b/lib/Vt102Emulation.cpp @@ -1073,7 +1073,8 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent* event, bool fromPaste) } else if ( !entry.text().isEmpty() ) { - QByteArray bytes = _toUtf8(QString::fromUtf8(entry.text(true,modifiers))); + QString str = QString::fromUtf8(entry.text(true,modifiers)); + QByteArray bytes = _toUtf8(str); textToSend += bytes; } else if((modifiers & KeyboardTranslator::CTRL_MOD) && event->key() >= 0x40 && event->key() < 0x5f) { From 3daf2c66ba3cfc2d67a6930fca7dc2a3db79d66b Mon Sep 17 00:00:00 2001 From: Doug Date: Fri, 5 Apr 2024 14:38:27 -0400 Subject: [PATCH 20/22] Fixed deprecated function warning. --- lib/kpty.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kpty.cpp b/lib/kpty.cpp index 544749f0..47f8dc8e 100644 --- a/lib/kpty.cpp +++ b/lib/kpty.cpp @@ -511,7 +511,7 @@ void KPty::login(const char * user, const char * remotehost) #ifdef HAVE_UTEMPTER Q_D(KPty); - addToUtmp(d->ttyName.constData(), remotehost, d->masterFd); + utempter_add_record(d->masterFd, remotehost); Q_UNUSED(user) #else # ifdef HAVE_UTMPX @@ -597,7 +597,7 @@ void KPty::logout() #ifdef HAVE_UTEMPTER Q_D(KPty); - removeLineFromUtmp(d->ttyName.constData(), d->masterFd); + utempter_remove_record(d->masterFd); #else Q_D(KPty); From 75fa7351152a54b910c629353dbed99a4b0ff20a Mon Sep 17 00:00:00 2001 From: Doug Date: Sat, 6 Apr 2024 19:14:52 -0400 Subject: [PATCH 21/22] Bumped the version to 2.0.0. --- CMakeLists.txt | 4 ++-- pyqt/pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aeb1e16c..d6dbbc05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,8 +21,8 @@ option(USE_UTF8PROC "Use libutf8proc for better Unicode support. Default OFF" OF # just change version for releases # keep this in sync with the version in pyqt/pyproject.toml -set(QTERMWIDGET_VERSION_MAJOR "1") -set(QTERMWIDGET_VERSION_MINOR "4") +set(QTERMWIDGET_VERSION_MAJOR "2") +set(QTERMWIDGET_VERSION_MINOR "0") set(QTERMWIDGET_VERSION_PATCH "0") set(QTERMWIDGET_VERSION "${QTERMWIDGET_VERSION_MAJOR}.${QTERMWIDGET_VERSION_MINOR}.${QTERMWIDGET_VERSION_PATCH}") diff --git a/pyqt/pyproject.toml b/pyqt/pyproject.toml index d55bc69f..b6200cf4 100644 --- a/pyqt/pyproject.toml +++ b/pyqt/pyproject.toml @@ -6,5 +6,5 @@ build-backend = "sipbuild.api" [tool.sip.metadata] name = "QTermWidget" -version = "1.4.0" +version = "2.0.0" requires-dist = ["PyQt6"] From a760241ebe8b9f92cae5d9ab55b84902ee35122a Mon Sep 17 00:00:00 2001 From: Doug Date: Mon, 15 Apr 2024 10:54:04 -0400 Subject: [PATCH 22/22] Removed anchored pattern for email and url. URL underlining is now working like qt5. --- lib/Filter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Filter.cpp b/lib/Filter.cpp index c60b2237..a4944260 100644 --- a/lib/Filter.cpp +++ b/lib/Filter.cpp @@ -470,10 +470,10 @@ void UrlFilter::HotSpot::activate(const QString& actionName) //regexp matches: // full url: // protocolname:// or www. followed by anything other than whitespaces, <, >, ' or ", and ends before whitespaces, <, >, ', ", ], !, comma and dot -const QRegularExpression UrlFilter::FullUrlRegExp(QRegularExpression::anchoredPattern(QLatin1String("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]]"))); +const QRegularExpression UrlFilter::FullUrlRegExp(QLatin1String("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]]")); // email address: // [word chars, dots or dashes]@[word chars, dots or dashes].[word chars] -const QRegularExpression UrlFilter::EmailAddressRegExp(QRegularExpression::anchoredPattern(QLatin1String("\\b(\\w|\\.|-)+@(\\w|\\.|-)+\\.\\w+\\b"))); +const QRegularExpression UrlFilter::EmailAddressRegExp(QLatin1String("\\b(\\w|\\.|-)+@(\\w|\\.|-)+\\.\\w+\\b")); // matches full url or email address const QRegularExpression UrlFilter::CompleteUrlRegExp(QLatin1Char('(')+FullUrlRegExp.pattern()+QLatin1Char('|')+