improve qconfig C++ code
cover improve qconfig C++ code
While playing around with qconfig I made some cleanups that I seemed to forgot to send out. This uses more of the Qt API that is already present to make the code a bit nicer (YMMV). Especially it adds some keyboard shortcuts for the default actions (Save, Save as and the like).
Rolf Eike Beer (7):
kconfig: qconf: simplify character replacement
kconfig: qconf: use default platform shortcuts
kconfig: qconf: use nullptr in C++11 code
kconfig: qconf: use QCommandLineParser
kconfig: qconf: use preferred form of QString API
kconfig: qconf: use QString to store path to configuration file
kconfig: qconf: use QByteArray API instead of manually constructing a string
Signature · 13 lines
Rolf Eike Beer emlix GmbH Headquarters: Berliner Str. 12, 37073 Göttingen, Germany Phone +49 (0)551 30664-0, e-mail [email protected] District Court of Göttingen, Registry Number HR B 3160 Managing Directors: Heike Jordan, Dr. Uwe Kracke VAT ID No. DE 205 198 055 Office Berlin: Panoramastr. 1, 10178 Berlin, Germany Office Bonn: Bachstr. 6, 53115 Bonn, Germany http://www.emlix.com emlix - your embedded Linux partner
PATCH 1/7 kconfig: qconf: use QByteArray API instead of manually constructing a string
Using a naked char[] here isn't necessary as QByteArray has a nice API for all of this. Calling constData() will also always return a 0-terminated string so no further handling is required. And then the whole manual memory handling can go away as QByteArray will care for this when it goes out of scope.
--- scripts/kconfig/qconf.cc | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
scripts/kconfig/qconf.cc +4 -13
@@ -1165,25 +1165,17 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char void ConfigInfoView::clicked(const QUrl &url) { QByteArray str = url.toEncoded(); - const std::size_t count = str.size(); - char *data = new char[count + 2]; // '$' + '\0' struct symbol **result; struct menu *m = NULL; - if (count < 1) { - delete[] data; + if (str.isEmpty()) return; - } - - memcpy(data, str.constData(), count); - data[count] = '\0'; /* Seek for exact match */ - data[0] = '^'; - strcat(data, "$"); - result = sym_re_search(data); + str[0] = '^'; + str.append('$'); + result = sym_re_search(str.constData()); if (!result) { - delete[] data; return; }
@@ -1206,7 +1198,6 @@ void ConfigInfoView::clicked(const QUrl &url) } free(result); - delete[] data; } void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)
Signature · 17 lines
2.47.0 -- Rolf Eike Beer emlix GmbH Headquarters: Berliner Str. 12, 37073 Göttingen, Germany Phone +49 (0)551 30664-0, e-mail [email protected] District Court of Göttingen, Registry Number HR B 3160 Managing Directors: Heike Jordan, Dr. Uwe Kracke VAT ID No. DE 205 198 055 Office Berlin: Panoramastr. 1, 10178 Berlin, Germany Office Bonn: Bachstr. 6, 53115 Bonn, Germany http://www.emlix.com emlix - your embedded Linux partner
Re: [PATCH 1/7] kconfig: qconf: use QByteArray API instead of manually constructing a string
Quoted 8 lines · Rolf Eike Beer
Using a naked char[] here isn't necessary as QByteArray has a nice API for all of this. Calling
constData()will also always return a 0-terminated string so no further handling is required. And then the whole manual memory handling can go away as QByteArray will care for this when it goes out of scope.Signed-off-by Rolf Eike Beer <[email protected]>---
I do not need this patch because I can refactor this function even deeper.
I have locally kept several clean-up patches, but I have not got around to submitting them.
I will send some of them later.
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH 1/7] kconfig: qconf: use QByteArray API instead of manually constructing a string
Quoted 11 lines · Masahiro Yamada
Quoted 8 lines · Rolf Eike Beer
Using a naked char[] here isn't necessary as QByteArray has a nice API for all of this. Calling
constData()will also always return a 0-terminated string so no further handling is required. And then the whole manual memory handling can go away as QByteArray will care for this when it goes out of scope.Signed-off-by Rolf Eike Beer <[email protected]>---
Quoted 6 lines
I do not need this patch because I can refactor this function even deeper.
I have locally kept several clean-up patches, but I have not got around to submitting them.
I will send some of them later.
https://lore.kernel.org/linux-kbuild/[email protected]/T/#u
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH 1/7] kconfig: qconf: use QByteArray API instead of manually constructing a string
Quoted 1 line · On Mittwoch, 23. Oktober 2024 21:07:41 Mitteleuropäische Sommerzeit Masahiro…
On Thu, Oct 24, 2024 at 1:37 AM Masahiro Yamada <[email protected]>
Quoted 12 lines · wrote:
Quoted 12 lines · Rolf Eike Beer
Quoted 8 lines
Using a naked char[] here isn't necessary as QByteArray has a nice API for all of this. Calling
constData()will also always return a 0-terminated string so no further handling is required. And then the whole manual memory handling can go away as QByteArray will care for this when it goes out of scope.Signed-off-by Rolf Eike Beer <[email protected]>---
I do not need this patch because I can refactor this function even deeper.
Quoted 7 lines
Quoted 4 lines
I have locally kept several clean-up patches, but I have not got around to submitting them.
I will send some of them later.
https://lore.kernel.org/linux-kbuild/20241023181823.138524-12-masahiroy@kern
el.org/T/#u
Even better, thanks!
Signature · 13 lines
Rolf Eike Beer emlix GmbH Headquarters: Berliner Str. 12, 37073 Göttingen, Germany Phone +49 (0)551 30664-0, e-mail [email protected] District Court of Göttingen, Registry Number HR B 3160 Managing Directors: Heike Jordan, Dr. Uwe Kracke VAT ID No. DE 205 198 055 Office Berlin: Panoramastr. 1, 10178 Berlin, Germany Office Bonn: Bachstr. 6, 53115 Bonn, Germany http://www.emlix.com emlix - your embedded Linux partner
PATCH 2/7 kconfig: qconf: use QString to store path to configuration file
In reply to Rolf Eike BeerThis is the native type used by the file dialogs and avoids any hassle with filename encoding when converting this back and forth to a character array.
--- scripts/kconfig/qconf.cc | 24 ++++++------------------ scripts/kconfig/qconf.h | 2 +- 2 files changed, 7 insertions(+), 19 deletions(-)
scripts/kconfig/qconf.cc +6 -18
@@ -1380,7 +1380,7 @@ ConfigMainWindow::ConfigMainWindow(void) conf_set_changed_callback(conf_changed); - configname = xstrdup(conf_get_configname()); + configname = conf_get_configname(); QAction *saveAsAction = new QAction("Save &As...", this); connect(saveAsAction, &QAction::triggered,
@@ -1519,28 +1519,22 @@ ConfigMainWindow::ConfigMainWindow(void) void ConfigMainWindow::loadConfig(void) { QString str; - QByteArray ba; - const char *name; str = QFileDialog::getOpenFileName(this, "", configname); if (str.isNull()) return; - ba = str.toLocal8Bit(); - name = ba.data(); - - if (conf_read(name)) + if (conf_read(str.toLocal8Bit().constData())) QMessageBox::information(this, "qconf", "Unable to load configuration!"); - free(configname); - configname = xstrdup(name); + configname = str; ConfigList::updateListAllForAll(); } bool ConfigMainWindow::saveConfig(void) { - if (conf_write(configname)) { + if (conf_write(configname.toLocal8Bit().constData())) { QMessageBox::information(this, "qconf", "Unable to save configuration!"); return false; }
@@ -1552,23 +1546,17 @@ bool ConfigMainWindow::saveConfig(void) void ConfigMainWindow::saveConfigAs(void) { QString str; - QByteArray ba; - const char *name; str = QFileDialog::getSaveFileName(this, "", configname); if (str.isNull()) return; - ba = str.toLocal8Bit(); - name = ba.data(); - - if (conf_write(name)) { + if (conf_write(str.toLocal8Bit().constData())) { QMessageBox::information(this, "qconf", "Unable to save configuration!"); } conf_write_autoconf(0); - free(configname); - configname = xstrdup(name); + configname = str; } void ConfigMainWindow::searchConfig(void)
scripts/kconfig/qconf.h +1 -1
@@ -237,7 +237,7 @@ public slots: class ConfigMainWindow : public QMainWindow {Q_OBJECT - char *configname; + QString configname;static QAction *saveAction;static void conf_changed (bool ); public:
Signature · 17 lines
2.47.0 -- Rolf Eike Beer emlix GmbH Headquarters: Berliner Str. 12, 37073 Göttingen, Germany Phone +49 (0)551 30664-0, e-mail [email protected] District Court of Göttingen, Registry Number HR B 3160 Managing Directors: Heike Jordan, Dr. Uwe Kracke VAT ID No. DE 205 198 055 Office Berlin: Panoramastr. 1, 10178 Berlin, Germany Office Bonn: Bachstr. 6, 53115 Bonn, Germany http://www.emlix.com emlix - your embedded Linux partner
Re: [PATCH 2/7] kconfig: qconf: use QString to store path to configuration file
Quoted 6 lines · Rolf Eike Beer
This is the native type used by the file dialogs and avoids any hassle with filename encoding when converting this back and forth to a character array.
Signed-off-by Rolf Eike Beer <[email protected]>---
Applied to linux-kbuild.
Thanks!
--
Best Regards
Masahiro Yamada
PATCH 3/7 kconfig: qconf: use preferred form of QString API
In reply to Rolf Eike Beer--- scripts/kconfig/qconf.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
scripts/kconfig/qconf.cc +4 -4
@@ -1520,8 +1520,8 @@ void ConfigMainWindow::loadConfig(void) { QString str; - str = QFileDialog::getOpenFileName(this, "", configname); - if (str.isNull()) + str = QFileDialog::getOpenFileName(this, QString(), configname); + if (str.isEmpty()) return; if (conf_read(str.toLocal8Bit().constData()))
@@ -1547,8 +1547,8 @@ void ConfigMainWindow::saveConfigAs(void) { QString str; - str = QFileDialog::getSaveFileName(this, "", configname); - if (str.isNull()) + str = QFileDialog::getSaveFileName(this, QString(), configname); + if (str.isEmpty()) return; if (conf_write(str.toLocal8Bit().constData())) {
Signature · 17 lines
2.47.0 -- Rolf Eike Beer emlix GmbH Headquarters: Berliner Str. 12, 37073 Göttingen, Germany Phone +49 (0)551 30664-0, e-mail [email protected] District Court of Göttingen, Registry Number HR B 3160 Managing Directors: Heike Jordan, Dr. Uwe Kracke VAT ID No. DE 205 198 055 Office Berlin: Panoramastr. 1, 10178 Berlin, Germany Office Bonn: Bachstr. 6, 53115 Bonn, Germany http://www.emlix.com emlix - your embedded Linux partner
Re: [PATCH 3/7] kconfig: qconf: use preferred form of QString API
The code looks good to me, but please describe something in the commit message body.
For example, you can quote:
"We recommend that you always use the isEmpty() function and avoid isNull()" from the QString documentation. [1]
[1] https://doc.qt.io/qt-6/qstring.html#distinction-between-null-and-empty-strings
Quoted 49 lines · Rolf Eike Beer
Signed-off-by Rolf Eike Beer <[email protected]>--- scripts/kconfig/qconf.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)scripts/kconfig/qconf.cc +4
-5@@ -1520,8 +1520,8 @@ void ConfigMainWindow::loadConfig(void) { QString str; - str = QFileDialog::getOpenFileName(this, "", configname); - if (str.isNull()) + str = QFileDialog::getOpenFileName(this, QString(), configname); + if (str.isEmpty()) return; if (conf_read(str.toLocal8Bit().constData()))@@ -1547,8 +1547,8 @@ void ConfigMainWindow::saveConfigAs(void) { QString str; - str = QFileDialog::getSaveFileName(this, "", configname); - if (str.isNull()) + str = QFileDialog::getSaveFileName(this, QString(), configname); + if (str.isEmpty()) return; if (conf_write(str.toLocal8Bit().constData())) { --2.47.0
--
Rolf Eike Beeremlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany Phone +49 (0)551 30664-0, e-mail [email protected] District Court of Göttingen, Registry Number HR B 3160 Managing Directors: Heike Jordan, Dr. Uwe Kracke VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com
Quoted 3 lines
emlix - your embedded Linux partner
--
Best Regards
Masahiro Yamada
PATCH 4/7 kconfig: qconf: use QCommandLineParser
In reply to Rolf Eike BeerThis has a much nicer output without manual processing. It also adds window management options from Qt for free.
--- scripts/kconfig/qconf.cc | 44 ++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 27 deletions(-)
scripts/kconfig/qconf.cc +17 -27
@@ -8,6 +8,7 @@ #include <QActionGroup> #include <QApplication> #include <QCloseEvent> +#include <QCommandLineParser> #include <QDebug> #include <QFileDialog> #include <QLabel>
@@ -1844,41 +1845,30 @@ void fixup_rootmenu(struct menu *menu) } } -static const char *progname; - -static void usage(void) -{ - printf("%s [-s] <config>\n", progname); - exit(0); -} - int main(int ac, char** av) { ConfigMainWindow* v; - const char *name; + configApp = new QApplication(ac, av); + QCommandLineParser cmdline; + QCommandLineOption silent("s", "silent"); - progname = av[0]; - if (ac > 1 && av[1][0] == '-') { - switch (av[1][1]) { - case 's': - conf_set_message_callback(NULL); - break; - case 'h': - case '?': - usage(); - } - name = av[2]; - } else - name = av[1]; - if (!name) - usage(); + cmdline.addOption(silent); + cmdline.addHelpOption(); + cmdline.addPositionalArgument("file", "config file to open", "Kconfig"); + + cmdline.process(*configApp); + + if (cmdline.isSet(silent)) + conf_set_message_callback(NULL); - conf_parse(name); + QStringList args = cmdline.positionalArguments(); + if (args.isEmpty()) + cmdline.showHelp(1); + + conf_parse(args.first().toLocal8Bit().constData()); fixup_rootmenu(&rootmenu); //zconfdump(stdout); - configApp = new QApplication(ac, av); - configSettings = new ConfigSettings(); configSettings->beginGroup("/kconfig/qconf"); v = new ConfigMainWindow();
Signature · 18 lines
2.47.0 -- Rolf Eike Beer emlix GmbH Headquarters: Berliner Str. 12, 37073 Göttingen, Germany Phone +49 (0)551 30664-0, e-mail [email protected] District Court of Göttingen, Registry Number HR B 3160 Managing Directors: Heike Jordan, Dr. Uwe Kracke VAT ID No. DE 205 198 055 Office Berlin: Panoramastr. 1, 10178 Berlin, Germany Office Bonn: Bachstr. 6, 53115 Bonn, Germany http://www.emlix.com emlix - your embedded Linux partner
Re: [PATCH 4/7] kconfig: qconf: use QCommandLineParser
Quoted 6 lines · Rolf Eike Beer
This has a much nicer output without manual processing. It also adds window management options from Qt for free.
Signed-off-by Rolf Eike Beer <[email protected]>---
The help message looks as follows:
$ ./scripts/kconfig/qconf --help QSocketNotifier: Can only be used with threads started with QThread Usage: ./scripts/kconfig/qconf [options] Kconfig
Options:
-s silent -h, --help Displays help on commandline options. --help-all Displays help including Qt specific options.
Arguments:
file config file to open
I want to see something better for the explanation of '-s' and I want 'file' and 'Kconfig' to match.
scripts/kconfig/qconf.cc void fixup_rootmenu(struct menu *menu) · line 1852
Quoted 6 lines
int
main(int ac, char** av){ ConfigMainWindow* v;scripts/kconfig/qconf.cc +2
-1- const char *name; + configApp = new QApplication(ac, av); + QCommandLineParser cmdline;
Please rename 'cmdline' to 'parser' because this is used in the code example.
Quoted 1 line
+ QCommandLineOption
silent("s", "silent");
How about this ?
silent("s", "Print this message and exit.");
The description is consistent with
"./scripts/kconfig/conf --help".
scripts/kconfig/qconf.cc void fixup_rootmenu(struct menu *menu) · line 1857
Quoted 3 lines
scripts/kconfig/qconf.cc +3
-0+ cmdline.addOption(silent); + cmdline.addHelpOption(); + cmdline.addPositionalArgument("file", "config file to open", "Kconfig");
I think the third parameter is unneeded.
Then, the help message will look better.
--
Best Regards
Masahiro Yamada
Re: [PATCH 4/7] kconfig: qconf: use QCommandLineParser
Quoted 16 lines · Masahiro Yamada
Quoted 6 lines · Rolf Eike Beer
This has a much nicer output without manual processing. It also adds window management options from Qt for free.
Signed-off-by Rolf Eike Beer <[email protected]>---
The help message looks as follows:
$ ./scripts/kconfig/qconf --help QSocketNotifier: Can only be used with threads started with QThread Usage: ./scripts/kconfig/qconf [options] Kconfig
Quoted 7 lines
Options:
-s silent -h, --help Displays help on commandline options. --help-all Displays help including Qt specific options.Arguments:
file config file to open
"config file" is a bit confusing. (it sounds like ".config").
The positional argument specifies the top-level Kconfig.
I added this to the help of scripts/kconfig/conf:
https://lore.kernel.org/linux-kbuild/[email protected]/T/#u
Best Regards
Masahiro Yamada
PATCH 5/7 kconfig: qconf: use nullptr in C++11 code
In reply to Rolf Eike BeerThis is type safe as it can't be accidentially assigned to something not a pointer.
--- scripts/kconfig/qconf.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
scripts/kconfig/qconf.cc +8 -8
@@ -874,7 +874,7 @@ skip: void ConfigList::focusInEvent(QFocusEvent *e) { - struct menu *menu = NULL; + struct menu *menu = nullptr; Parent::focusInEvent(e);
@@ -933,7 +933,7 @@ void ConfigList::setAllOpen(bool open) } ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) - : Parent(parent), sym(0), _menu(0) + : Parent(parent), sym(nullptr), _menu(nullptr) { setObjectName(name); setOpenLinks(false);
@@ -985,7 +985,7 @@ void ConfigInfoView::setInfo(struct menu *m) if (_menu == m) return; _menu = m; - sym = NULL; + sym = nullptr; if (!_menu) clear(); else
@@ -1167,7 +1167,7 @@ void ConfigInfoView::clicked(const QUrl &url) { QByteArray str = url.toEncoded(); struct symbol **result; - struct menu *m = NULL; + struct menu *m = nullptr; if (str.isEmpty()) return;
@@ -1208,7 +1208,7 @@ void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event) } ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow *parent) - : Parent(parent), result(NULL) + : Parent(parent), result(nullptr) { setObjectName("search"); setWindowTitle("Search Config");
@@ -1281,7 +1281,7 @@ void ConfigSearchWindow::search(void) { struct symbol **p; struct property *prop; - ConfigItem *lastItem = NULL; + ConfigItem *lastItem = nullptr; free(result); list->clear();
@@ -1580,7 +1580,7 @@ void ConfigMainWindow::changeMenu(struct menu *menu) void ConfigMainWindow::setMenuLink(struct menu *menu) { struct menu *parent; - ConfigList* list = NULL; + ConfigList* list = nullptr; ConfigItem* item; if (configList->menuSkip(menu))
@@ -1859,7 +1859,7 @@ int main(int ac, char** av) cmdline.process(*configApp); if (cmdline.isSet(silent)) - conf_set_message_callback(NULL); + conf_set_message_callback(nullptr); QStringList args = cmdline.positionalArguments(); if (args.isEmpty())
Signature · 17 lines
2.47.0 -- Rolf Eike Beer emlix GmbH Headquarters: Berliner Str. 12, 37073 Göttingen, Germany Phone +49 (0)551 30664-0, e-mail [email protected] District Court of Göttingen, Registry Number HR B 3160 Managing Directors: Heike Jordan, Dr. Uwe Kracke VAT ID No. DE 205 198 055 Office Berlin: Panoramastr. 1, 10178 Berlin, Germany Office Bonn: Bachstr. 6, 53115 Bonn, Germany http://www.emlix.com emlix - your embedded Linux partner
Re: [PATCH 5/7] kconfig: qconf: use nullptr in C++11 code
Quoted 3 lines · Rolf Eike Beer
This is type safe as it can't be accidentially assigned to something not a pointer.
This is incomplete because there are more call sites that use 0 instead of nullptr.
For example, you can replace nextItem(0) with nextItem(nullptr)
Anyway, I do not need this patch for now because qconf is under refactoring, and I will remove a lot of code.
Please come back with a more comprehensive patch
some months later if you are still interested.
--
Best Regards
Masahiro Yamada
Re: [PATCH 5/7] kconfig: qconf: use nullptr in C++11 code
Quoted 7 lines · On Mittwoch, 23. Oktober 2024 18:41:09 Mitteleuropäische Sommerzeit Masahiro…
Quoted 2 lines · Rolf Eike Beer
This is type safe as it can't be accidentially assigned to something not a pointer.
This is incomplete because there are more call sites that use 0 instead of nullptr.
Quoted 7 lines
For example, you can replace nextItem(0) with nextItem(nullptr)
Anyway, I do not need this patch for now because qconf is under refactoring, and I will remove a lot of code.
Please come back with a more comprehensive patch
some months later if you are still interested.
This was just some obvious cases I came accross, nothing complete. If you are going to touch code anyway I personally would recommend using nullptr whenever you touch that things anyway and maybe someone can clean up the rest later. But this is nothing that does any change in behavior, so I'm fine with dropping it.
Regards,
Eike
Signature · 13 lines
Rolf Eike Beer emlix GmbH Headquarters: Berliner Str. 12, 37073 Göttingen, Germany Phone +49 (0)551 30664-0, e-mail [email protected] District Court of Göttingen, Registry Number HR B 3160 Managing Directors: Heike Jordan, Dr. Uwe Kracke VAT ID No. DE 205 198 055 Office Berlin: Panoramastr. 1, 10178 Berlin, Germany Office Bonn: Bachstr. 6, 53115 Bonn, Germany http://www.emlix.com emlix - your embedded Linux partner
PATCH 6/7 kconfig: qconf: use default platform shortcuts
In reply to Rolf Eike BeerThis renames "Load" to "Open" and switches Ctrl-L to Ctrl-O for the default platforms. This may break the workflow for those used to it, but will make it actually work for everyone else like me who would just expect the default behavior. Add some more standard shortcuts where available. If they replace the existing shortcuts they would have the same value in my case.
--- scripts/kconfig/qconf.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
scripts/kconfig/qconf.cc +7 -5
@@ -1361,21 +1361,22 @@ ConfigMainWindow::ConfigMainWindow(void) configList->setFocus(); backAction = new QAction(QPixmap(xpm_back), "Back", this); + backAction->setShortcut(QKeySequence::Back); connect(backAction, &QAction::triggered, this, &ConfigMainWindow::goBack); QAction *quitAction = new QAction("&Quit", this); - quitAction->setShortcut(Qt::CTRL | Qt::Key_Q); + quitAction->setShortcut(QKeySequence::Quit); connect(quitAction, &QAction::triggered, this, &ConfigMainWindow::close); - QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this); - loadAction->setShortcut(Qt::CTRL | Qt::Key_L); + QAction *loadAction = new QAction(QPixmap(xpm_load), "&Open", this); + loadAction->setShortcut(QKeySequence::Open); connect(loadAction, &QAction::triggered, this, &ConfigMainWindow::loadConfig); saveAction = new QAction(QPixmap(xpm_save), "&Save", this); - saveAction->setShortcut(Qt::CTRL | Qt::Key_S); + saveAction->setShortcut(QKeySequence::Save); connect(saveAction, &QAction::triggered, this, &ConfigMainWindow::saveConfig);
@@ -1384,10 +1385,11 @@ ConfigMainWindow::ConfigMainWindow(void) configname = conf_get_configname(); QAction *saveAsAction = new QAction("Save &As...", this); + saveAsAction->setShortcut(QKeySequence::SaveAs); connect(saveAsAction, &QAction::triggered, this, &ConfigMainWindow::saveConfigAs); QAction *searchAction = new QAction("&Find", this); - searchAction->setShortcut(Qt::CTRL | Qt::Key_F); + searchAction->setShortcut(QKeySequence::Find); connect(searchAction, &QAction::triggered, this, &ConfigMainWindow::searchConfig); singleViewAction = new QAction(QPixmap(xpm_single_view), "Single View", this);
Signature · 16 lines
2.47.0 -- Rolf Eike Beer emlix GmbH Headquarters: Berliner Str. 12, 37073 Göttingen, Germany Phone +49 (0)551 30664-0, e-mail [email protected] District Court of Göttingen, Registry Number HR B 3160 Managing Directors: Heike Jordan, Dr. Uwe Kracke VAT ID No. DE 205 198 055 Office Berlin: Panoramastr. 1, 10178 Berlin, Germany Office Bonn: Bachstr. 6, 53115 Bonn, Germany http://www.emlix.com emlix - your embedded Linux partner
Re: [PATCH 6/7] kconfig: qconf: use default platform shortcuts
Quoted 9 lines · Rolf Eike Beer
This renames "Load" to "Open" and switches Ctrl-L to Ctrl-O for the default platforms. This may break the workflow for those used to it, but will make it actually work for everyone else like me who would just expect the default behavior. Add some more standard shortcuts where available. If they replace the existing shortcuts they would have the same value in my case.
Signed-off-by Rolf Eike Beer <[email protected]>---
Applied to linux-kbuild. Thanks!
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH 7/7 kconfig: qconf: simplify character replacement
In reply to Rolf Eike BeerReplace the hand crafted lookup table with a QHash. This has the nice benefit that the added offsets can not get out of sync with the length of the replacement strings.
--- scripts/kconfig/qconf.cc | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-)
scripts/kconfig/qconf.cc +12 -21
@@ -1123,28 +1123,19 @@ QString ConfigInfoView::print_filter(const QString &str) { QRegularExpression re("[<>&\"\\n]"); QString res = str; + + QHash<QChar, QString> patterns; + patterns['<'] = "<"; + patterns['>'] = ">"; + patterns['&'] = "&"; + patterns['"'] = """; + patterns['\n'] = "<br>"; + for (int i = 0; (i = res.indexOf(re, i)) >= 0;) { - switch (res[i].toLatin1()) { - case '<': - res.replace(i, 1, "<"); - i += 4; - break; - case '>': - res.replace(i, 1, ">"); - i += 4; - break; - case '&': - res.replace(i, 1, "&"); - i += 5; - break; - case '"': - res.replace(i, 1, """); - i += 6; - break; - case '\n': - res.replace(i, 1, "<br>"); - i += 4; - break; + const QString n = patterns.value(res[i], QString()); + if (!n.isEmpty()) { + res.replace(i, 1, n); + i += n.length(); } } return res;
Signature · 17 lines
2.47.0 -- Rolf Eike Beer emlix GmbH Headquarters: Berliner Str. 12, 37073 Göttingen, Germany Phone +49 (0)551 30664-0, e-mail [email protected] District Court of Göttingen, Registry Number HR B 3160 Managing Directors: Heike Jordan, Dr. Uwe Kracke VAT ID No. DE 205 198 055 Office Berlin: Panoramastr. 1, 10178 Berlin, Germany Office Bonn: Bachstr. 6, 53115 Bonn, Germany http://www.emlix.com emlix - your embedded Linux partner
Re: [PATCH 7/7] kconfig: qconf: simplify character replacement
Quoted 7 lines · Rolf Eike Beer
Replace the hand crafted lookup table with a QHash. This has the nice benefit that the added offsets can not get out of sync with the length of the replacement strings.
Signed-off-by Rolf Eike Beer <[email protected]>---
Applied to linux-kbuild. Thanks!
Signature · 2 lines
Best Regards Masahiro Yamada