diff --git a/.ci/build.sh b/.ci/build.sh index a5cee646..84716662 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 \ @@ -11,4 +11,4 @@ cmake -B build -S . \ 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index ce50ed02..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}") @@ -32,12 +32,12 @@ 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(lxqt2-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED) if(USE_UTF8PROC) find_package(Utf8Proc REQUIRED) @@ -55,7 +55,7 @@ if(APPLE) endif() endif() -set(QTERMWIDGET_LIBRARY_NAME qtermwidget5) +set(QTERMWIDGET_LIBRARY_NAME qtermwidget6) # main library @@ -130,9 +130,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 +147,7 @@ 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) set_target_properties( ${QTERMWIDGET_LIBRARY_NAME} PROPERTIES SOVERSION ${QTERMWIDGET_VERSION_MAJOR} VERSION ${QTERMWIDGET_VERSION} diff --git a/README.md b/README.md index e77d2ab7..2e0e4d2b 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. @@ -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/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..ea085ccb 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(Qt::CTRL | Qt::SHIFT | Qt::Key_F), + console, &QTermWidget::toggleShowSearchBar); + actionsMenu->addAction(QStringLiteral("Copy"), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_C), + console, &QTermWidget::copyClipboard); + 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); diff --git a/lib/ColorScheme.cpp b/lib/ColorScheme.cpp index 6af2058c..f749a83c 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,9 +364,9 @@ 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); + 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; } } diff --git a/lib/Emulation.cpp b/lib/Emulation.cpp index 08267d26..c88ac12a 100644 --- a/lib/Emulation.cpp +++ b/lib/Emulation.cpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -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) @@ -136,7 +134,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); } } @@ -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,9 @@ 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(); + QString str = QString::fromUtf8(text, length); + auto encoded = _fromUtf8(str); + 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..a4944260 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(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(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/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..2983fdc7 100644 --- a/lib/KeyboardTranslator.cpp +++ b/lib/KeyboardTranslator.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include "tools.h" @@ -353,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() ) { @@ -453,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 ) { @@ -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; } } @@ -654,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; @@ -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); @@ -691,10 +697,10 @@ 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++ ) { - QByteRef ch = result[i]; + char ch = result[i]; if ( ch == '\\' ) { char replacement[2] = {0,0}; @@ -716,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 75a23a13..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) @@ -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/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 a40f9986..2d892171 100644 --- a/lib/Session.cpp +++ b/lib/Session.cpp @@ -30,13 +30,12 @@ // Qt #include -#include #include #include -#include #include #include #include +#include #include "Pty.h" //#include "kptyprocess.h" @@ -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); @@ -381,7 +375,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/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/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/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index 2fb30894..c526eb1c 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -275,13 +275,7 @@ 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."; @@ -293,10 +287,19 @@ 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); + // 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); } @@ -1619,7 +1622,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 +2129,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 +2224,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 +2234,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 +2306,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 +2494,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 +2518,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 +2627,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) @@ -3320,6 +3323,7 @@ void AutoScrollHandler::timerEvent(QTimerEvent* event) QMouseEvent mouseEvent( QEvent::MouseMove, widget()->mapFromGlobal(QCursor::pos()), + QCursor::pos(), Qt::NoButton, Qt::LeftButton, Qt::NoModifier); diff --git a/lib/Vt102Emulation.cpp b/lib/Vt102Emulation.cpp index 2a9aa131..f76092d9 100644 --- a/lib/Vt102Emulation.cpp +++ b/lib/Vt102Emulation.cpp @@ -31,7 +31,6 @@ // Qt #include #include -#include #include // Konsole @@ -45,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, @@ -72,7 +72,6 @@ void Vt102Emulation::reset() _screen[0]->reset(); resetCharset(1); _screen[1]->reset(); - setCodec(LocaleCodec); bufferedUpdate(); } @@ -512,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 ); @@ -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()); @@ -1074,7 +1073,9 @@ void Vt102Emulation::sendKeyEvent(QKeyEvent* event, bool fromPaste) } else if ( !entry.text().isEmpty() ) { - textToSend += _codec->fromUnicode(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) { textToSend += (event->key() & 0x1f); @@ -1089,7 +1090,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()) { @@ -1106,7 +1108,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() ); } } @@ -1342,7 +1344,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/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/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/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); diff --git a/lib/kptyprocess.cpp b/lib/kptyprocess.cpp index e73ef345..2ccd3bab 100644 --- a/lib/kptyprocess.cpp +++ b/lib/kptyprocess.cpp @@ -40,6 +40,9 @@ KPtyProcess::KPtyProcess(QObject *parent) : KPtyProcess(-1, parent) { + setChildProcessModifier([this](){ + onSetupChildProcess(); + }); } 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..ee1234d3 100644 --- a/lib/kptyprocess.h +++ b/lib/kptyprocess.h @@ -143,9 +143,9 @@ class KPtyProcess : public KProcess 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..6f7e707e 100644 --- a/lib/qtermwidget.cpp +++ b/lib/qtermwidget.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "ColorTables.h" #include "Session.h" @@ -91,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)); @@ -167,9 +166,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 +269,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 @@ -281,7 +284,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); @@ -428,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; @@ -836,6 +832,7 @@ 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..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; 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()) 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) diff --git a/pyqt/pyproject.toml b/pyqt/pyproject.toml index c567f3e1..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" -requires-dist = ["PyQt5"] +version = "2.0.0" +requires-dist = ["PyQt6"] 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();