Skip to content

Commit 077af78

Browse files
boris-kolpackovmasahir0y
authored andcommitted
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. Signed-off-by: Boris Kolpackov <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 45a7371 commit 077af78

File tree

2 files changed

+44
-21
lines changed

2 files changed

+44
-21
lines changed

scripts/kconfig/qconf-cfg.sh

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ cflags=$1
55
libs=$2
66
bin=$3
77

8-
PKG="Qt5Core Qt5Gui Qt5Widgets"
8+
PKG5="Qt5Core Qt5Gui Qt5Widgets"
9+
PKG6="Qt6Core Qt6Gui Qt6Widgets"
910

1011
if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then
1112
echo >&2 "*"
@@ -14,16 +15,26 @@ if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then
1415
exit 1
1516
fi
1617

17-
if ${HOSTPKG_CONFIG} --exists $PKG; then
18-
${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags}
19-
${HOSTPKG_CONFIG} --libs ${PKG} > ${libs}
18+
if ${HOSTPKG_CONFIG} --exists $PKG6; then
19+
${HOSTPKG_CONFIG} --cflags ${PKG6} > ${cflags}
20+
# Qt6 requires C++17.
21+
echo -std=c++17 >> ${cflags}
22+
${HOSTPKG_CONFIG} --libs ${PKG6} > ${libs}
23+
${HOSTPKG_CONFIG} --variable=libexecdir Qt6Core > ${bin}
24+
exit 0
25+
fi
26+
27+
if ${HOSTPKG_CONFIG} --exists $PKG5; then
28+
${HOSTPKG_CONFIG} --cflags ${PKG5} > ${cflags}
29+
${HOSTPKG_CONFIG} --libs ${PKG5} > ${libs}
2030
${HOSTPKG_CONFIG} --variable=host_bins Qt5Core > ${bin}
2131
exit 0
2232
fi
2333

2434
echo >&2 "*"
25-
echo >&2 "* Could not find Qt5 via ${HOSTPKG_CONFIG}."
26-
echo >&2 "* Please install Qt5 and make sure it's in PKG_CONFIG_PATH"
27-
echo >&2 "* You need $PKG"
35+
echo >&2 "* Could not find Qt6 or Qt5 via ${HOSTPKG_CONFIG}."
36+
echo >&2 "* Please install Qt6 or Qt5 and make sure it's in PKG_CONFIG_PATH"
37+
echo >&2 "* You need $PKG6 for Qt6"
38+
echo >&2 "* You need $PKG5 for Qt5"
2839
echo >&2 "*"
2940
exit 1

scripts/kconfig/qconf.cc

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55
*/
66

77
#include <QAction>
8+
#include <QActionGroup>
89
#include <QApplication>
910
#include <QCloseEvent>
1011
#include <QDebug>
11-
#include <QDesktopWidget>
1212
#include <QFileDialog>
1313
#include <QLabel>
1414
#include <QLayout>
1515
#include <QList>
1616
#include <QMenu>
1717
#include <QMenuBar>
1818
#include <QMessageBox>
19+
#include <QRegularExpression>
20+
#include <QScreen>
1921
#include <QToolBar>
2022

2123
#include <stdlib.h>
@@ -1126,7 +1128,7 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
11261128

11271129
QString ConfigInfoView::print_filter(const QString &str)
11281130
{
1129-
QRegExp re("[<>&\"\\n]");
1131+
QRegularExpression re("[<>&\"\\n]");
11301132
QString res = str;
11311133
for (int i = 0; (i = res.indexOf(re, i)) >= 0;) {
11321134
switch (res[i].toLatin1()) {
@@ -1322,15 +1324,15 @@ ConfigMainWindow::ConfigMainWindow(void)
13221324
int width, height;
13231325
char title[256];
13241326

1325-
QDesktopWidget *d = configApp->desktop();
13261327
snprintf(title, sizeof(title), "%s%s",
13271328
rootmenu.prompt->text,
13281329
""
13291330
);
13301331
setWindowTitle(title);
13311332

1332-
width = configSettings->value("/window width", d->width() - 64).toInt();
1333-
height = configSettings->value("/window height", d->height() - 64).toInt();
1333+
QRect g = configApp->primaryScreen()->geometry();
1334+
width = configSettings->value("/window width", g.width() - 64).toInt();
1335+
height = configSettings->value("/window height", g.height() - 64).toInt();
13341336
resize(width, height);
13351337
x = configSettings->value("/window x");
13361338
y = configSettings->value("/window y");
@@ -1379,17 +1381,17 @@ ConfigMainWindow::ConfigMainWindow(void)
13791381
this, &ConfigMainWindow::goBack);
13801382

13811383
QAction *quitAction = new QAction("&Quit", this);
1382-
quitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
1384+
quitAction->setShortcut(Qt::CTRL | Qt::Key_Q);
13831385
connect(quitAction, &QAction::triggered,
13841386
this, &ConfigMainWindow::close);
13851387

13861388
QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this);
1387-
loadAction->setShortcut(Qt::CTRL + Qt::Key_L);
1389+
loadAction->setShortcut(Qt::CTRL | Qt::Key_L);
13881390
connect(loadAction, &QAction::triggered,
13891391
this, &ConfigMainWindow::loadConfig);
13901392

13911393
saveAction = new QAction(QPixmap(xpm_save), "&Save", this);
1392-
saveAction->setShortcut(Qt::CTRL + Qt::Key_S);
1394+
saveAction->setShortcut(Qt::CTRL | Qt::Key_S);
13931395
connect(saveAction, &QAction::triggered,
13941396
this, &ConfigMainWindow::saveConfig);
13951397

@@ -1403,7 +1405,7 @@ ConfigMainWindow::ConfigMainWindow(void)
14031405
connect(saveAsAction, &QAction::triggered,
14041406
this, &ConfigMainWindow::saveConfigAs);
14051407
QAction *searchAction = new QAction("&Find", this);
1406-
searchAction->setShortcut(Qt::CTRL + Qt::Key_F);
1408+
searchAction->setShortcut(Qt::CTRL | Qt::Key_F);
14071409
connect(searchAction, &QAction::triggered,
14081410
this, &ConfigMainWindow::searchConfig);
14091411
singleViewAction = new QAction(QPixmap(xpm_single_view), "Single View", this);
@@ -1750,11 +1752,21 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
17501752
e->accept();
17511753
return;
17521754
}
1753-
QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning,
1754-
QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape);
1755-
mb.setButtonText(QMessageBox::Yes, "&Save Changes");
1756-
mb.setButtonText(QMessageBox::No, "&Discard Changes");
1757-
mb.setButtonText(QMessageBox::Cancel, "Cancel Exit");
1755+
1756+
QMessageBox mb(QMessageBox::Icon::Warning, "qconf",
1757+
"Save configuration?");
1758+
1759+
QPushButton *yb = mb.addButton(QMessageBox::Yes);
1760+
QPushButton *db = mb.addButton(QMessageBox::No);
1761+
QPushButton *cb = mb.addButton(QMessageBox::Cancel);
1762+
1763+
yb->setText("&Save Changes");
1764+
db->setText("&Discard Changes");
1765+
cb->setText("Cancel Exit");
1766+
1767+
mb.setDefaultButton(yb);
1768+
mb.setEscapeButton(cb);
1769+
17581770
switch (mb.exec()) {
17591771
case QMessageBox::Yes:
17601772
if (saveConfig())

0 commit comments

Comments
 (0)