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

[RFC] Add support for Qt6 #2557

Merged
merged 19 commits into from
Oct 18, 2023
Merged

[RFC] Add support for Qt6 #2557

merged 19 commits into from
Oct 18, 2023

Conversation

ctrlaltca
Copy link
Contributor

@ctrlaltca ctrlaltca commented Oct 5, 2023

This PR contains all the needed bits to get KVIrc to compile with both Qt5 and Qt6.
Big changes:

  • QRegExp usage has been ported to QRegularExpression. To avoid disruptive (and future) changes, a new KviRegExp class has been created that mimics the old interface already used in KVIrc;
  • QChar and QString are more picky when casting from an integer/char, a lot of explicit casts had to be added;
  • obligatory class and method renames to follow qt's quest for the perfect word;
  • QKeySequence (used for shortcuts) doesn't like anymore the classic Qt::Modifier + Qt::Key style, so a bit of rework had to be done to keep the definitions compatible with both Qt5 and Qt6

Changes that will need some rework (last commit):

  • QFont changed the weight scale in Qt6, in order to use the new values we'd need to fix all configuration files in all themes. By now, it uses the legacy deprecated values.
  • QTextCodec is depecated, and the new QStreamConverter only supports Utf8/16/32 and Latin1 before Qt6.5. By now we stick to qt5compat's QTextCodec.

Other warnings that needs fixing:

  • all QMessageBox calls needs to be rewritten using a different ctor (the one with StandardButtons);
  • QVariant::type() is deprecated

The plain is to get this working on CI, collect any comment and maybe start getting the good commits one by one in master.

… it should cast to time_t safely until year 2106
…rExpression

Method str_kvs_fnc_split() had to be replaced with the original version, since the newer one relied on Qt5's QStringRef
…ctor since it creates ambiguity with the previous
QFont changed the weight scale in Qt6, in order to use them we'd need to fix all configuration files in all themes.
QStreamConverter only supports Utf8/16/32 and Latin1 before Qt6.5. Stick to qt5compat's QTextCodec by now
Copy link
Member

@DarthGandalf DarthGandalf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can easily require Qt6.5+ for the Qt6 build, that shouldn't be a problem, I think

set(qt5_kvirc_modules)
# first check if Qt6 or Qt5 has to be used
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
# second, detect available modules for the specific Qt version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not do both components in the same find_package? COMPONENTS Core Widgets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first call is only used to determine if Qt5 or Qt6 will be used, and define ${QT_VERSION_MAJOR} accordingly.
All the other calls force the specific Qt version using find_package(Qt${QT_VERSION_MAJOR} ..).

This way of support both Qt5 and Qt6 without mixing them is documented here: https://doc.qt.io/qt-6/cmake-qt5-and-qt6-compatibility.html

return true;
}

bool bWild = szFla.contains('w', Qt::CaseInsensitive);
bool bContainsR = szFla.contains('r', Qt::CaseInsensitive);
if(iMaxItems == 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you move this condition down?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IceN9ne's rewrote $str.split() in 2017 making use of QStringRef, that unfortunately doesn't exists anymore in Qt6.
I reverted a part of this commit: 9e8a9d9#diff-2c8a6d9d89531ab98f04a8dce7a8d6670d4661adac0b78edd4b5a38941890befR1717

src/modules/upnp/XmlFunctions.cpp Outdated Show resolved Hide resolved
else
list = szStr.splitRef(szSep, splitBehavior, sensitivity);
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of changes in this function. I don't see in the PR description what this is for, so I don't know how to review this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed it in the PR description.

IceN9ne's rewrote $str.split() in 2017 making use of QStringRef / QString::splitRef(), but they unfortunately doesn't exists anymore in Qt6.
I reverted a part of this commit: 9e8a9d9#diff-2c8a6d9d89531ab98f04a8dce7a8d6670d4661adac0b78edd4b5a38941890befR1717
The previous version of $str.split() wasn't making use of those Qt features and could be ported without further changes

@ctrlaltca ctrlaltca merged commit 4a51c0e into master Oct 18, 2023
2 checks passed
@ctrlaltca ctrlaltca deleted the qt6 branch November 20, 2023 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants