Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Build with Qt6 #532

Merged
merged 24 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b1fa777
Builds with qt6.
Feb 24, 2024
b40b77b
Fixed some warnings.
Feb 24, 2024
f288547
Fixed another warning.
Feb 24, 2024
184c9fe
Fix the final warnings.
Feb 24, 2024
c880ab2
Fix issue cursor positioning issues
marcusbritanicus Feb 26, 2024
7052dc2
Merge pull request #1 from marcusbritanicus/Qt6Update
doug1234 Feb 26, 2024
f085cd8
Removed tab
Mar 5, 2024
08fc85c
Fix the example.
doug1234 Mar 7, 2024
c5e5f1f
Tab to space in terminal display.
doug1234 Mar 11, 2024
94ee191
Remove chagnes that were accidently reverted.
doug1234 Mar 11, 2024
975be81
Updated README comments to reflect move to qt6.
doug1234 Mar 26, 2024
bcd4ff7
Remove ChildProcessSetup and directly call onsetupChildProcess.
doug1234 Mar 26, 2024
faee531
Try CI
yan12125 Mar 10, 2024
a3d5546
Use PyQt6
yan12125 Mar 28, 2024
d20c815
Merge branch 'lxqt:master' into Qt6Update
doug1234 Mar 28, 2024
40cbc8d
Made change suggested by marcusbritanicus
doug1234 Mar 28, 2024
c4cedb9
Temporary CI workaround suggested by marcusbritanicus.
doug1234 Mar 28, 2024
0f2cbfe
Removed all the qt5 compatibility code. Also removed codec support.
doug1234 Apr 4, 2024
651d0bf
Removed codec function from sip file.
doug1234 Apr 4, 2024
3cbbb16
Improved CI fix by marcusbritanicus
doug1234 Apr 5, 2024
a968c1c
Attempting to fix warning.
doug1234 Apr 5, 2024
3daf2c6
Fixed deprecated function warning.
doug1234 Apr 5, 2024
75fa735
Bumped the version to 2.0.0.
doug1234 Apr 6, 2024
a760241
Removed anchored pattern for email and url. URL underlining is now w…
doug1234 Apr 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -55,7 +56,7 @@ if(APPLE)
endif()
endif()

set(QTERMWIDGET_LIBRARY_NAME qtermwidget5)
set(QTERMWIDGET_LIBRARY_NAME qtermwidget6)


# main library
Expand Down Expand Up @@ -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"
Expand All @@ -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}
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions examples/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
doug1234 marked this conversation as resolved.
Show resolved Hide resolved
actionsMenu->addAction(QStringLiteral("About Qt"), &app, &QApplication::aboutQt);
mainWindow->setMenuBar(menuBar);

Expand Down
8 changes: 4 additions & 4 deletions lib/ColorScheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(','));
Expand All @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Emulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <QClipboard>
#include <QHash>
#include <QKeyEvent>
#include <QRegExp>
#include <QRegularExpression>
#include <QTextStream>
#include <QThread>

Expand Down Expand Up @@ -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);
}
}
Expand Down
11 changes: 6 additions & 5 deletions lib/HistorySearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions lib/HistorySearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <QObject>
#include <QPointer>
#include <QMap>
#include <QRegularExpression>

#include <Session.h>
#include <ScreenWindow.h>
Expand All @@ -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;
Expand All @@ -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;
Expand Down
42 changes: 24 additions & 18 deletions lib/KeyboardTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <QKeySequence>
#include <QDir>
#include <QtDebug>
#include <QRegularExpression>

#include "tools.h"

Expand Down Expand Up @@ -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() )
{
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -539,41 +540,44 @@ QList<KeyboardTranslatorReader::Token> 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<Token> list;
if ( text.isEmpty() )
{
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;
}
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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};
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions lib/Pty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/Pty.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@

// Qt
#include <QApplication>
#include <QByteRef>
#include <QDir>
#include <QFile>
#include <QRegExp>
#include <QStringList>
#include <QFile>
#include <QtDebug>
#include <QRegularExpression>

#include "Pty.h"
//#include "kptyprocess.h"
Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/ShellCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/TerminalCharacterDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading
Loading