Commit 077af782 authored by Boris Kolpackov's avatar Boris Kolpackov Committed by Masahiro Yamada

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: default avatarBoris Kolpackov <boris@codesynthesis.com>
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 45a7371d
...@@ -5,7 +5,8 @@ cflags=$1 ...@@ -5,7 +5,8 @@ cflags=$1
libs=$2 libs=$2
bin=$3 bin=$3
PKG="Qt5Core Qt5Gui Qt5Widgets" PKG5="Qt5Core Qt5Gui Qt5Widgets"
PKG6="Qt6Core Qt6Gui Qt6Widgets"
if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then
echo >&2 "*" echo >&2 "*"
...@@ -14,16 +15,26 @@ if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then ...@@ -14,16 +15,26 @@ if [ -z "$(command -v ${HOSTPKG_CONFIG})" ]; then
exit 1 exit 1
fi fi
if ${HOSTPKG_CONFIG} --exists $PKG; then if ${HOSTPKG_CONFIG} --exists $PKG6; then
${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags} ${HOSTPKG_CONFIG} --cflags ${PKG6} > ${cflags}
${HOSTPKG_CONFIG} --libs ${PKG} > ${libs} # Qt6 requires C++17.
echo -std=c++17 >> ${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} ${HOSTPKG_CONFIG} --variable=host_bins Qt5Core > ${bin}
exit 0 exit 0
fi fi
echo >&2 "*" echo >&2 "*"
echo >&2 "* Could not find Qt5 via ${HOSTPKG_CONFIG}." echo >&2 "* Could not find Qt6 or Qt5 via ${HOSTPKG_CONFIG}."
echo >&2 "* Please install Qt5 and make sure it's in PKG_CONFIG_PATH" echo >&2 "* Please install Qt6 or Qt5 and make sure it's in PKG_CONFIG_PATH"
echo >&2 "* You need $PKG" echo >&2 "* You need $PKG6 for Qt6"
echo >&2 "* You need $PKG5 for Qt5"
echo >&2 "*" echo >&2 "*"
exit 1 exit 1
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
*/ */
#include <QAction> #include <QAction>
#include <QActionGroup>
#include <QApplication> #include <QApplication>
#include <QCloseEvent> #include <QCloseEvent>
#include <QDebug> #include <QDebug>
#include <QDesktopWidget>
#include <QFileDialog> #include <QFileDialog>
#include <QLabel> #include <QLabel>
#include <QLayout> #include <QLayout>
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <QMenu> #include <QMenu>
#include <QMenuBar> #include <QMenuBar>
#include <QMessageBox> #include <QMessageBox>
#include <QRegularExpression>
#include <QScreen>
#include <QToolBar> #include <QToolBar>
#include <stdlib.h> #include <stdlib.h>
...@@ -1126,7 +1128,7 @@ QString ConfigInfoView::debug_info(struct symbol *sym) ...@@ -1126,7 +1128,7 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
QString ConfigInfoView::print_filter(const QString &str) QString ConfigInfoView::print_filter(const QString &str)
{ {
QRegExp re("[<>&\"\\n]"); QRegularExpression re("[<>&\"\\n]");
QString res = str; QString res = str;
for (int i = 0; (i = res.indexOf(re, i)) >= 0;) { for (int i = 0; (i = res.indexOf(re, i)) >= 0;) {
switch (res[i].toLatin1()) { switch (res[i].toLatin1()) {
...@@ -1322,15 +1324,15 @@ ConfigMainWindow::ConfigMainWindow(void) ...@@ -1322,15 +1324,15 @@ ConfigMainWindow::ConfigMainWindow(void)
int width, height; int width, height;
char title[256]; char title[256];
QDesktopWidget *d = configApp->desktop();
snprintf(title, sizeof(title), "%s%s", snprintf(title, sizeof(title), "%s%s",
rootmenu.prompt->text, rootmenu.prompt->text,
"" ""
); );
setWindowTitle(title); setWindowTitle(title);
width = configSettings->value("/window width", d->width() - 64).toInt(); QRect g = configApp->primaryScreen()->geometry();
height = configSettings->value("/window height", d->height() - 64).toInt(); width = configSettings->value("/window width", g.width() - 64).toInt();
height = configSettings->value("/window height", g.height() - 64).toInt();
resize(width, height); resize(width, height);
x = configSettings->value("/window x"); x = configSettings->value("/window x");
y = configSettings->value("/window y"); y = configSettings->value("/window y");
...@@ -1379,17 +1381,17 @@ ConfigMainWindow::ConfigMainWindow(void) ...@@ -1379,17 +1381,17 @@ ConfigMainWindow::ConfigMainWindow(void)
this, &ConfigMainWindow::goBack); this, &ConfigMainWindow::goBack);
QAction *quitAction = new QAction("&Quit", this); QAction *quitAction = new QAction("&Quit", this);
quitAction->setShortcut(Qt::CTRL + Qt::Key_Q); quitAction->setShortcut(Qt::CTRL | Qt::Key_Q);
connect(quitAction, &QAction::triggered, connect(quitAction, &QAction::triggered,
this, &ConfigMainWindow::close); this, &ConfigMainWindow::close);
QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this); 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, connect(loadAction, &QAction::triggered,
this, &ConfigMainWindow::loadConfig); this, &ConfigMainWindow::loadConfig);
saveAction = new QAction(QPixmap(xpm_save), "&Save", this); 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, connect(saveAction, &QAction::triggered,
this, &ConfigMainWindow::saveConfig); this, &ConfigMainWindow::saveConfig);
...@@ -1403,7 +1405,7 @@ ConfigMainWindow::ConfigMainWindow(void) ...@@ -1403,7 +1405,7 @@ ConfigMainWindow::ConfigMainWindow(void)
connect(saveAsAction, &QAction::triggered, connect(saveAsAction, &QAction::triggered,
this, &ConfigMainWindow::saveConfigAs); this, &ConfigMainWindow::saveConfigAs);
QAction *searchAction = new QAction("&Find", this); QAction *searchAction = new QAction("&Find", this);
searchAction->setShortcut(Qt::CTRL + Qt::Key_F); searchAction->setShortcut(Qt::CTRL | Qt::Key_F);
connect(searchAction, &QAction::triggered, connect(searchAction, &QAction::triggered,
this, &ConfigMainWindow::searchConfig); this, &ConfigMainWindow::searchConfig);
singleViewAction = new QAction(QPixmap(xpm_single_view), "Single View", this); singleViewAction = new QAction(QPixmap(xpm_single_view), "Single View", this);
...@@ -1750,11 +1752,21 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e) ...@@ -1750,11 +1752,21 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
e->accept(); e->accept();
return; return;
} }
QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning,
QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); QMessageBox mb(QMessageBox::Icon::Warning, "qconf",
mb.setButtonText(QMessageBox::Yes, "&Save Changes"); "Save configuration?");
mb.setButtonText(QMessageBox::No, "&Discard Changes");
mb.setButtonText(QMessageBox::Cancel, "Cancel Exit"); 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()) { switch (mb.exec()) {
case QMessageBox::Yes: case QMessageBox::Yes:
if (saveConfig()) if (saveConfig())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment