kconfig: port qconf to work with Qt6 in addition to Qt5
v2 cover kconfig: port qconf to work with Qt6 in addition to Qt5
This patch ports qconf to work with Qt6 in addition to latest Qt5. Tested with Qt5 5.15 and Qt6 6.4. Note that earlier versions of Qt5 are no longer guaranteed to work.
Compared to the v1 patch version, v2 also changes qconf-cfg.sh to first look for Qt6 and fallback to Qt5.
Boris Kolpackov (1):
kconfig: port qconf to work with Qt6 in addition to Qt5
scripts/kconfig/qconf-cfg.sh | 23 ++++++++++++++------- scripts/kconfig/qconf.cc | 40 +++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 21 deletions(-)
--
2.40.1
PATCH v2 1/1 kconfig: port qconf to work with Qt6 in addition to Qt5
Tested with Qt5 5.15 and Qt6 6.4. Note that earlier versions of Qt5 are no longer guaranteed to work.
--- scripts/kconfig/qconf-cfg.sh | 23 ++++++++++++++------- scripts/kconfig/qconf.cc | 40 +++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 21 deletions(-)
scripts/kconfig/qconf-cfg.sh +16 -7
@@ -5,7 +5,8 @@ cflags=$1 libs=$2 bin=$3 -PKG="Qt5Core Qt5Gui Qt5Widgets" +PKG5="Qt5Core Qt5Gui Qt5Widgets" +PKG6="Qt6Core Qt6Gui Qt6Widgets" if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then echo >&2 "*"
@@ -14,16 +15,24 @@ if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then exit 1 fi -if ${HOSTPKG_CONFIG} --exists $PKG; then - ${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags} - ${HOSTPKG_CONFIG} --libs ${PKG} > ${libs} +if ${HOSTPKG_CONFIG} --exists $PKG6; then + ${HOSTPKG_CONFIG} --cflags ${PKG6} > ${cflags} + ${HOSTPKG_CONFIG} --libs ${PKG6} > ${libs} + ${HOSTPKG_CONFIG} --variable=libexecdir Qt6Core > ${bin} + exit 0 +fi + +if ${HOSTPKG_CONFIG} --exists $PKG5; then + ${HOSTPKG_CONFIG} --cflags ${PKG5} > ${cflags} + ${HOSTPKG_CONFIG} --libs ${PKG5} > ${libs} ${HOSTPKG_CONFIG} --variable=host_bins Qt5Core > ${bin} exit 0 fi echo >&2 "*" -echo >&2 "* Could not find Qt5 via ${HOSTPKG_CONFIG}." -echo >&2 "* Please install Qt5 and make sure it's in PKG_CONFIG_PATH" -echo >&2 "* You need $PKG" +echo >&2 "* Could not find Qt6 or Qt5 via ${HOSTPKG_CONFIG}." +echo >&2 "* Please install Qt6 or Qt5 and make sure it's in PKG_CONFIG_PATH" +echo >&2 "* You need $PKG6 for Qt6" +echo >&2 "* You need $PKG5 for Qt5" echo >&2 "*" exit 1
scripts/kconfig/qconf.cc +26 -14
@@ -5,10 +5,11 @@ */ #include <QAction> +#include <QActionGroup> #include <QApplication> #include <QCloseEvent> #include <QDebug> -#include <QDesktopWidget> +#include <QScreen> #include <QFileDialog> #include <QLabel> #include <QLayout>
@@ -17,6 +18,7 @@ #include <QMenuBar> #include <QMessageBox> #include <QToolBar> +#include <QRegularExpression> #include <stdlib.h>
@@ -1126,7 +1128,7 @@ QString ConfigInfoView::debug_info(struct symbol *sym) QString ConfigInfoView::print_filter(const QString &str) { - QRegExp re("[<>&\"\\n]"); + QRegularExpression re("[<>&\"\\n]"); QString res = str; for (int i = 0; (i = res.indexOf(re, i)) >= 0;) { switch (res[i].toLatin1()) {
@@ -1322,15 +1324,15 @@ ConfigMainWindow::ConfigMainWindow(void) int width, height; char title[256]; - QDesktopWidget *d = configApp->desktop(); snprintf(title, sizeof(title), "%s%s", rootmenu.prompt->text, "" ); setWindowTitle(title); - width = configSettings->value("/window width", d->width() - 64).toInt(); - height = configSettings->value("/window height", d->height() - 64).toInt(); + QRect g = configApp->primaryScreen()->geometry(); + width = configSettings->value("/window width", g.width() - 64).toInt(); + height = configSettings->value("/window height", g.height() - 64).toInt(); resize(width, height); x = configSettings->value("/window x"); y = configSettings->value("/window y");
@@ -1379,17 +1381,17 @@ ConfigMainWindow::ConfigMainWindow(void) this, &ConfigMainWindow::goBack); QAction *quitAction = new QAction("&Quit", this); - quitAction->setShortcut(Qt::CTRL + Qt::Key_Q); + quitAction->setShortcut(Qt::CTRL | Qt::Key_Q); connect(quitAction, &QAction::triggered, this, &ConfigMainWindow::close); QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this); - loadAction->setShortcut(Qt::CTRL + Qt::Key_L); + loadAction->setShortcut(Qt::CTRL | Qt::Key_L); connect(loadAction, &QAction::triggered, this, &ConfigMainWindow::loadConfig); saveAction = new QAction(QPixmap(xpm_save), "&Save", this); - saveAction->setShortcut(Qt::CTRL + Qt::Key_S); + saveAction->setShortcut(Qt::CTRL | Qt::Key_S); connect(saveAction, &QAction::triggered, this, &ConfigMainWindow::saveConfig);
@@ -1403,7 +1405,7 @@ ConfigMainWindow::ConfigMainWindow(void) connect(saveAsAction, &QAction::triggered, this, &ConfigMainWindow::saveConfigAs); QAction *searchAction = new QAction("&Find", this); - searchAction->setShortcut(Qt::CTRL + Qt::Key_F); + searchAction->setShortcut(Qt::CTRL | Qt::Key_F); connect(searchAction, &QAction::triggered, this, &ConfigMainWindow::searchConfig); singleViewAction = new QAction(QPixmap(xpm_single_view), "Single View", this);
@@ -1750,11 +1752,21 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e) e->accept(); return; } - QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning, - QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); - mb.setButtonText(QMessageBox::Yes, "&Save Changes"); - mb.setButtonText(QMessageBox::No, "&Discard Changes"); - mb.setButtonText(QMessageBox::Cancel, "Cancel Exit"); + + QMessageBox mb(QMessageBox::Icon::Warning, "qconf", + "Save configuration?"); + + QPushButton *yb = mb.addButton(QMessageBox::Yes); + QPushButton *db = mb.addButton(QMessageBox::No); + QPushButton *cb = mb.addButton(QMessageBox::Cancel); + + yb->setText("&Save Changes"); + db->setText("&Discard Changes"); + cb->setText("Cancel Exit"); + + mb.setDefaultButton(yb); + mb.setEscapeButton(cb); + switch (mb.exec()) { case QMessageBox::Yes: if (saveConfig())
Signature · 1 line
2.40.1
Quoted 6 lines · Boris Kolpackov
Tested with Qt5 5.15 and Qt6 6.4. Note that earlier versions of Qt5 are no longer guaranteed to work.
Signed-off-by Boris Kolpackov <[email protected]>---
$ make xconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/images.o
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/expr.o
LEX scripts/kconfig/lexer.lex.c
YACC scripts/kconfig/parser.tab.[ch]
HOSTCC scripts/kconfig/lexer.lex.o
HOSTCC scripts/kconfig/menu.o
HOSTCC scripts/kconfig/parser.tab.o
HOSTCC scripts/kconfig/preprocess.o
HOSTCC scripts/kconfig/symbol.o
HOSTCC scripts/kconfig/util.o
HOSTCXX scripts/kconfig/qconf.o
In file included from /usr/include/x86_64-linux-gnu/qt6/QtGui/qtguiglobal.h:7,
from /usr/include/x86_64-linux-gnu/qt6/QtGui/qaction.h:7,
from /usr/include/x86_64-linux-gnu/qt6/QtGui/QAction:1,
from scripts/kconfig/qconf.cc:7:
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:106:6: error:
#error "Qt requires a C++17 compiler"
106 | # error "Qt requires a C++17 compiler"
| ^~~~~
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:491:11: warning:
inline variables are only available with ‘-std=c++17’ or
‘-std=gnu++17’ [-Wc++17-extensions]
491 | constexpr inline Deprecated_t Deprecated = {};
| ^~~~~~
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:1009:26: error:
‘enable_if_t’ in namespace ‘std’ does not name a template type
1009 | typename = std::enable_if_t<std::is_arithmetic_v<T>
&& std::is_arithmetic_v<U> &&
| ^~~~~~~~~~~
/usr/include/x86_64-linux-gnu/qt6/QtCore/qglobal.h:1009:21: note:
‘std::enable_if_t’ is only available from C++14 onwards
1009 | typename = std::enable_if_t<std::is_arithmetic_v<T>
&& std::is_arithmetic_v<U> &&
| ^~~
[ snip tons of errors]The first error says, #error "Qt requires a C++17 compiler"
Right, g++ defaults to this:
$ g++ --version g++ (Debian 12.2.0-14) 12.2.0 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
It worked for me with the following fix-up applied.
scripts/kconfig/qconf-cfg.sh +2 -0
@@ -17,6 +17,8 @@ fi if ${HOSTPKG_CONFIG} --exists $PKG6; then ${HOSTPKG_CONFIG} --cflags ${PKG6} > ${cflags} + # Qt6 requires a C++17 compiler + echo -std=c++17 >> ${cflags} ${HOSTPKG_CONFIG} --libs ${PKG6} > ${libs} ${HOSTPKG_CONFIG} --variable=libexecdir Qt6Core > ${bin} exit 0
--
Best Regards
Masahiro Yamada