From 8c30e7e60d4352c4a98c6ba3f90d602d7500c1df Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 29 Aug 2020 17:14:07 +0900 Subject: kconfig: qconf: reformat the intro message The introduction message displayed by 'Help -> Introduction' does not look nice due to excessive new lines. Reformat the message. Signed-off-by: Masahiro Yamada Tested-by: Randy Dunlap --- scripts/kconfig/qconf.cc | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 8ce624a3b54b..cf33e436190e 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1836,17 +1836,24 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e) void ConfigMainWindow::showIntro(void) { - static const QString str = "Welcome to the qconf graphical configuration tool.\n\n" - "For each option, a blank box indicates the feature is disabled, a check\n" - "indicates it is enabled, and a dot indicates that it is to be compiled\n" - "as a module. Clicking on the box will cycle through the three states.\n\n" - "If you do not see an option (e.g., a device driver) that you believe\n" - "should be present, try turning on Show All Options under the Options menu.\n" - "Although there is no cross reference yet to help you figure out what other\n" - "options must be enabled to support the option you are interested in, you can\n" - "still view the help of a grayed-out option.\n\n" - "Toggling Show Debug Info under the Options menu will show the dependencies,\n" - "which you can then match by examining other options.\n\n"; + static const QString str = + "Welcome to the qconf graphical configuration tool.\n" + "\n" + "For each option, a blank box indicates the feature is " + "disabled, a check indicates it is enabled, and a dot " + "indicates that it is to be compiled as a module. Clicking on " + "the box will cycle through the three states.\n" + "\n" + "If you do not see an option (e.g., a device driver) that you " + "believe should be present, try turning on Show All Options " + "under the Options menu. Although there is no cross reference " + "yet to help you figure out what other options must be enabled " + "to support the option you are interested in, you can still " + "view the help of a grayed-out option.\n" + "\n" + "Toggling Show Debug Info under the Options menu will show the " + "dependencies, which you can then match by examining other " + "options.\n"; QMessageBox::information(this, "qconf", str); } -- cgit From 1fb752416f3fb64bfe44d94b7dd646799676b523 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 29 Aug 2020 17:14:08 +0900 Subject: kconfig: qconf: update the intro message to match to the current code I do not think "Although there is no cross reference yet ..." is valid any longer. The cross reference is supported via hyperlinks enabled by the "show Debug Info" option. Update the message. Signed-off-by: Masahiro Yamada Tested-by: Randy Dunlap --- scripts/kconfig/qconf.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index cf33e436190e..ae47693f80bf 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1846,10 +1846,10 @@ void ConfigMainWindow::showIntro(void) "\n" "If you do not see an option (e.g., a device driver) that you " "believe should be present, try turning on Show All Options " - "under the Options menu. Although there is no cross reference " - "yet to help you figure out what other options must be enabled " - "to support the option you are interested in, you can still " - "view the help of a grayed-out option.\n" + "under the Options menu. Enabling Show Debug Info will help you" + "figure out what other options must be enabled to support the " + "option you are interested in, and hyperlinks will navigate to " + "them.\n" "\n" "Toggling Show Debug Info under the Options menu will show the " "dependencies, which you can then match by examining other " -- cgit From 6a143041532e7df4bd243f4994d46112bd7137ca Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 29 Aug 2020 17:14:09 +0900 Subject: kconfig: qconf: remove unused ConfigItem::okRename() Commit 76538660fb08 ("Port xconfig to Qt5 - Remove custom ListView classes.") removed the original implementation, where ConfigItem::okRename() overrode Q3ListViewItem::okRename(). Commit 59e564408f88 ("Port xconfig to Qt5 - Put back some of the old implementation.") restored the empty stub, but it seems useless. Signed-off-by: Masahiro Yamada --- scripts/kconfig/qconf.cc | 8 -------- scripts/kconfig/qconf.h | 1 - 2 files changed, 9 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index ae47693f80bf..bf6c9187daf5 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -82,14 +82,6 @@ QIcon ConfigItem::choiceNoIcon; QIcon ConfigItem::menuIcon; QIcon ConfigItem::menubackIcon; -/* - * set the new data - * TODO check the value - */ -void ConfigItem::okRename(int col) -{ -} - /* * update the displayed of a menu entry */ diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index f97376a8123f..d41670f322b3 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -131,7 +131,6 @@ public: } ~ConfigItem(void); void init(void); - void okRename(int col); void updateMenu(void); void testUpdateMenu(bool v); ConfigList* listView() const -- cgit From f9b918fae678eacdeaad821db57a107fba6fe3a1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 29 Aug 2020 17:14:10 +0900 Subject: kconfig: qconf: move ConfigView::updateList(All) to ConfigList class ConfigView::updateList() iterates over all views, and then calls updateList() against for its ConfigList instance. This means there is no point to implement it in the ConfigView class. Move and rename as follows: ConfigView::updateList() -> ConfigList::updateListForAll() ConfigView::updateListAll() -> ConfigList::updateListAllForAll() I used QList to contain all ConfigList instances. Signed-off-by: Masahiro Yamada --- scripts/kconfig/qconf.cc | 70 +++++++++++++++++++++++------------------------- scripts/kconfig/qconf.h | 11 ++++---- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index bf6c9187daf5..7cab996c3617 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -274,7 +274,7 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) case Qt::Key_Return: case Qt::Key_Enter: sym_set_string_value(item->menu->sym, text().toLatin1()); - parent()->updateList(); + ConfigList::updateListForAll(); break; default: Parent::keyPressEvent(e); @@ -315,9 +315,16 @@ ConfigList::ConfigList(ConfigView* p, const char *name) showColumn(promptColIdx); + allLists.append(this); + reinit(); } +ConfigList::~ConfigList() +{ + allLists.removeOne(this); +} + bool ConfigList::menuSkip(struct menu *menu) { if (optMode == normalOpt && menu_is_visible(menu)) @@ -454,6 +461,28 @@ update: resizeColumnToContents(0); } +void ConfigList::updateListForAll() +{ + QListIterator it(allLists); + + while (it.hasNext()) { + ConfigList *list = it.next(); + + list->updateList(); + } +} + +void ConfigList::updateListAllForAll() +{ + QListIterator it(allLists); + + while (it.hasNext()) { + ConfigList *list = it.next(); + + list->updateList(); + } +} + void ConfigList::setValue(ConfigItem* item, tristate val) { struct symbol* sym; @@ -474,7 +503,7 @@ void ConfigList::setValue(ConfigItem* item, tristate val) return; if (oldval == no && item->menu->list) item->setExpanded(true); - parent()->updateList(); + ConfigList::updateListForAll(); break; } } @@ -508,7 +537,7 @@ void ConfigList::changeValue(ConfigItem* item) item->setExpanded(true); } if (oldexpr != newexpr) - parent()->updateList(); + ConfigList::updateListForAll(); break; case S_INT: case S_HEX: @@ -904,7 +933,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e) e->accept(); } -ConfigView*ConfigView::viewList; +QList ConfigList::allLists; QAction *ConfigList::showNormalAction; QAction *ConfigList::showAllAction; QAction *ConfigList::showPromptAction; @@ -921,21 +950,6 @@ ConfigView::ConfigView(QWidget* parent, const char *name) lineEdit = new ConfigLineEdit(this); lineEdit->hide(); verticalLayout->addWidget(lineEdit); - - this->nextView = viewList; - viewList = this; -} - -ConfigView::~ConfigView(void) -{ - ConfigView** vp; - - for (vp = &viewList; *vp; vp = &(*vp)->nextView) { - if (*vp == this) { - *vp = nextView; - break; - } - } } void ConfigView::setShowName(bool b) @@ -976,22 +990,6 @@ void ConfigList::setAllOpen(bool open) } } -void ConfigView::updateList() -{ - ConfigView* v; - - for (v = viewList; v; v = v->nextView) - v->list->updateList(); -} - -void ConfigView::updateListAll(void) -{ - ConfigView* v; - - for (v = viewList; v; v = v->nextView) - v->list->updateListAll(); -} - ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) : Parent(parent), sym(0), _menu(0) { @@ -1605,7 +1603,7 @@ void ConfigMainWindow::loadConfig(void) free(configname); configname = xstrdup(name); - ConfigView::updateListAll(); + ConfigList::updateListAllForAll(); } bool ConfigMainWindow::saveConfig(void) diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index d41670f322b3..818e00617ae3 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -44,6 +44,7 @@ class ConfigList : public QTreeWidget { typedef class QTreeWidget Parent; public: ConfigList(ConfigView* p, const char *name = 0); + ~ConfigList(); void reinit(void); ConfigItem* findConfigItem(struct menu *); ConfigView* parent(void) const @@ -108,6 +109,10 @@ public: QPalette inactivedColorGroup; QMenu* headerPopup; + static QList allLists; + static void updateListForAll(); + static void updateListAllForAll(); + static QAction *showNormalAction, *showAllAction, *showPromptAction; }; @@ -188,9 +193,6 @@ class ConfigView : public QWidget { typedef class QWidget Parent; public: ConfigView(QWidget* parent, const char *name = 0); - ~ConfigView(void); - static void updateList(); - static void updateListAll(void); bool showName(void) const { return list->showName; } bool showRange(void) const { return list->showRange; } @@ -206,9 +208,6 @@ signals: public: ConfigList* list; ConfigLineEdit* lineEdit; - - static ConfigView* viewList; - ConfigView* nextView; }; class ConfigInfoView : public QTextBrowser { -- cgit From 669a1ee46a0e2ccad769ceca70b08ee57772be94 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 29 Aug 2020 17:14:11 +0900 Subject: kconfig: qconf: show data column all the time The next commit will allow users to edit "int", "hex", "string" menus in-place from the data column. The data column should be always displayed. Signed-off-by: Masahiro Yamada --- scripts/kconfig/qconf.cc | 29 +---------------------------- scripts/kconfig/qconf.h | 5 +---- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 7cab996c3617..3ba064af905c 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -288,7 +288,7 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) ConfigList::ConfigList(ConfigView* p, const char *name) : Parent(p), updateAll(false), - showName(false), showRange(false), showData(false), mode(singleMode), optMode(normalOpt), + showName(false), showRange(false), mode(singleMode), optMode(normalOpt), rootEntry(0), headerPopup(0) { setObjectName(name); @@ -307,7 +307,6 @@ ConfigList::ConfigList(ConfigView* p, const char *name) configSettings->beginGroup(name); showName = configSettings->value("/showName", false).toBool(); showRange = configSettings->value("/showRange", false).toBool(); - showData = configSettings->value("/showData", false).toBool(); optMode = (enum optionMode)configSettings->value("/optionMode", 0).toInt(); configSettings->endGroup(); connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); @@ -338,7 +337,6 @@ bool ConfigList::menuSkip(struct menu *menu) void ConfigList::reinit(void) { - hideColumn(dataColIdx); hideColumn(yesColIdx); hideColumn(modColIdx); hideColumn(noColIdx); @@ -351,8 +349,6 @@ void ConfigList::reinit(void) showColumn(modColIdx); showColumn(yesColIdx); } - if (showData) - showColumn(dataColIdx); updateListAll(); } @@ -375,7 +371,6 @@ void ConfigList::saveSettings(void) configSettings->beginGroup(objectName()); configSettings->setValue("/showName", showName); configSettings->setValue("/showRange", showRange); - configSettings->setValue("/showData", showData); configSettings->setValue("/optionMode", (int)optMode); configSettings->endGroup(); } @@ -918,15 +913,6 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e) action, SLOT(setChecked(bool))); action->setChecked(showRange); headerPopup->addAction(action); - - action = new QAction("Show Data", this); - action->setCheckable(true); - connect(action, SIGNAL(toggled(bool)), - parent(), SLOT(setShowData(bool))); - connect(parent(), SIGNAL(showDataChanged(bool)), - action, SLOT(setChecked(bool))); - action->setChecked(showData); - headerPopup->addAction(action); } headerPopup->exec(e->globalPos()); @@ -970,15 +956,6 @@ void ConfigView::setShowRange(bool b) } } -void ConfigView::setShowData(bool b) -{ - if (list->showData != b) { - list->showData = b; - list->reinit(); - emit showDataChanged(b); - } -} - void ConfigList::setAllOpen(bool open) { QTreeWidgetItemIterator it(this); @@ -1475,9 +1452,6 @@ ConfigMainWindow::ConfigMainWindow(void) QAction *showRangeAction = new QAction("Show Range", this); showRangeAction->setCheckable(true); connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); - QAction *showDataAction = new QAction("Show Data", this); - showDataAction->setCheckable(true); - connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); QActionGroup *optGroup = new QActionGroup(this); optGroup->setExclusive(true); @@ -1530,7 +1504,6 @@ ConfigMainWindow::ConfigMainWindow(void) menu = menuBar()->addMenu("&Option"); menu->addAction(showNameAction); menu->addAction(showRangeAction); - menu->addAction(showDataAction); menu->addSeparator(); menu->addActions(optGroup->actions()); menu->addSeparator(); diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index 818e00617ae3..d01a6c620dbb 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -101,7 +101,7 @@ public: bool updateAll; - bool showName, showRange, showData; + bool showName, showRange; enum listMode mode; enum optionMode optMode; struct menu *rootEntry; @@ -196,15 +196,12 @@ public: bool showName(void) const { return list->showName; } bool showRange(void) const { return list->showRange; } - bool showData(void) const { return list->showData; } public slots: void setShowName(bool); void setShowRange(bool); - void setShowData(bool); signals: void showNameChanged(bool); void showRangeChanged(bool); - void showDataChanged(bool); public: ConfigList* list; ConfigLineEdit* lineEdit; -- cgit From 37162a68bf517b6f870d63bbbcc65a81f99bd968 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 29 Aug 2020 17:14:12 +0900 Subject: kconfig: qconf: allow to edit "int", "hex", "string" menus in-place Previously, when you double-clicked the "int", "hex", or "string" menus, a line-edit gadget showed up to allow you to input the value, which looked clumsy. Also, it was buggy; the editor opened even if the config option was not editable. For example, just try to double-click CC_VERSION_TEXT, which has no prompt. This commit sub-classes QStyleItemDelegate to allow users to edit "int", "hex", "string" menus in-place. Just double-click (or press the F2 key) in the data column. Then, an editor widget is placed on top of the item view. The two methods are overridden: createEditor - process only when the data column is being accessed and the menu is visible. Otherwise, return nullptr to disallow editing. setModelData - take the new data from the editor, and set it to the addressed symbol. If it was successful, update all the list windows. Otherwise, (the reason for the failure is possibly the input data was out of range), set the old value back to the editor. Signed-off-by: Masahiro Yamada --- scripts/kconfig/qconf.cc | 93 +++++++++++++++++++++++++++++++++++++++--------- scripts/kconfig/qconf.h | 15 ++++++++ 2 files changed, 91 insertions(+), 17 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 3ba064af905c..af8d5cc1b24b 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -180,15 +180,7 @@ void ConfigItem::updateMenu(void) case S_INT: case S_HEX: case S_STRING: - const char* data; - - data = sym_get_string_value(sym); - - setText(dataColIdx, data); - if (type == S_STRING) - prompt = QString("%1: %2").arg(prompt).arg(data); - else - prompt = QString("(%2) %1").arg(prompt).arg(data); + setText(dataColIdx, sym_get_string_value(sym)); break; } if (!sym_has_value(sym) && visible) @@ -229,6 +221,17 @@ void ConfigItem::init(void) if (list->mode != fullMode) setExpanded(true); sym_calc_value(menu->sym); + + if (menu->sym) { + enum symbol_type type = menu->sym->type; + + // Allow to edit "int", "hex", and "string" in-place in + // the data column. Unfortunately, you cannot specify + // the flags per column. Set ItemIsEditable for all + // columns here, and check the column in createEditor(). + if (type == S_INT || type == S_HEX || type == S_STRING) + setFlags(flags() | Qt::ItemIsEditable); + } } updateMenu(); } @@ -249,6 +252,61 @@ ConfigItem::~ConfigItem(void) } } +QWidget *ConfigItemDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + ConfigItem *item; + + // Only the data column is editable + if (index.column() != dataColIdx) + return nullptr; + + // You cannot edit invisible menus + item = static_cast(index.internalPointer()); + if (!item || !item->menu || !menu_is_visible(item->menu)) + return nullptr; + + return QStyledItemDelegate::createEditor(parent, option, index); +} + +void ConfigItemDelegate::setModelData(QWidget *editor, + QAbstractItemModel *model, + const QModelIndex &index) const +{ + QLineEdit *lineEdit; + ConfigItem *item; + struct symbol *sym; + bool success; + + lineEdit = qobject_cast(editor); + // If this is not a QLineEdit, use the parent's default. + // (does this happen?) + if (!lineEdit) + goto parent; + + item = static_cast(index.internalPointer()); + if (!item || !item->menu) + goto parent; + + sym = item->menu->sym; + if (!sym) + goto parent; + + success = sym_set_string_value(sym, lineEdit->text().toUtf8().data()); + if (success) { + ConfigList::updateListForAll(); + } else { + QMessageBox::information(editor, "qconf", + "Cannot set the data (maybe due to out of range).\n" + "Setting the old value."); + lineEdit->setText(sym_get_string_value(sym)); + } + +parent: + QStyledItemDelegate::setModelData(editor, model, index); +} + ConfigLineEdit::ConfigLineEdit(ConfigView* parent) : Parent(parent) { @@ -314,6 +372,8 @@ ConfigList::ConfigList(ConfigView* p, const char *name) showColumn(promptColIdx); + setItemDelegate(new ConfigItemDelegate(this)); + allLists.append(this); reinit(); @@ -534,10 +594,7 @@ void ConfigList::changeValue(ConfigItem* item) if (oldexpr != newexpr) ConfigList::updateListForAll(); break; - case S_INT: - case S_HEX: - case S_STRING: - parent()->lineEdit->show(item); + default: break; } } @@ -1802,10 +1859,12 @@ void ConfigMainWindow::showIntro(void) static const QString str = "Welcome to the qconf graphical configuration tool.\n" "\n" - "For each option, a blank box indicates the feature is " - "disabled, a check indicates it is enabled, and a dot " - "indicates that it is to be compiled as a module. Clicking on " - "the box will cycle through the three states.\n" + "For bool and tristate options, a blank box indicates the " + "feature is disabled, a check indicates it is enabled, and a " + "dot indicates that it is to be compiled as a module. Clicking " + "on the box will cycle through the three states. For int, hex, " + "and string options, double-clicking or pressing F2 on the " + "Value cell will allow you to edit the value.\n" "\n" "If you do not see an option (e.g., a device driver) that you " "believe should be present, try turning on Show All Options " diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index d01a6c620dbb..b02acf2464ec 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -172,6 +173,20 @@ public: static QIcon menuIcon, menubackIcon; }; +class ConfigItemDelegate : public QStyledItemDelegate +{ +private: + struct menu *menu; +public: + ConfigItemDelegate(QObject *parent = nullptr) + : QStyledItemDelegate(parent) {} + QWidget *createEditor(QWidget *parent, + const QStyleOptionViewItem &option, + const QModelIndex &index) const override; + void setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const override; +}; + class ConfigLineEdit : public QLineEdit { Q_OBJECT typedef class QLineEdit Parent; -- cgit From f3eea294e93facc78ffcf3881f88ea02732283a9 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 29 Aug 2020 17:14:13 +0900 Subject: kconfig: qconf: remove ConfigLineEdit class Now that "int", "hex", "string" menus are edited in-place, this class is no longer needed. Signed-off-by: Masahiro Yamada --- scripts/kconfig/qconf.cc | 39 --------------------------------------- scripts/kconfig/qconf.h | 18 ------------------ 2 files changed, 57 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index af8d5cc1b24b..461681aa5b19 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -307,42 +307,6 @@ parent: QStyledItemDelegate::setModelData(editor, model, index); } -ConfigLineEdit::ConfigLineEdit(ConfigView* parent) - : Parent(parent) -{ - connect(this, SIGNAL(editingFinished()), SLOT(hide())); -} - -void ConfigLineEdit::show(ConfigItem* i) -{ - item = i; - if (sym_get_string_value(item->menu->sym)) - setText(sym_get_string_value(item->menu->sym)); - else - setText(QString()); - Parent::show(); - setFocus(); -} - -void ConfigLineEdit::keyPressEvent(QKeyEvent* e) -{ - switch (e->key()) { - case Qt::Key_Escape: - break; - case Qt::Key_Return: - case Qt::Key_Enter: - sym_set_string_value(item->menu->sym, text().toLatin1()); - ConfigList::updateListForAll(); - break; - default: - Parent::keyPressEvent(e); - return; - } - e->accept(); - parent()->list->setFocus(); - hide(); -} - ConfigList::ConfigList(ConfigView* p, const char *name) : Parent(p), updateAll(false), @@ -990,9 +954,6 @@ ConfigView::ConfigView(QWidget* parent, const char *name) list = new ConfigList(this); verticalLayout->addWidget(list); - lineEdit = new ConfigLineEdit(this); - lineEdit->hide(); - verticalLayout->addWidget(lineEdit); } void ConfigView::setShowName(bool b) diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index b02acf2464ec..a3ee91565d49 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -20,7 +20,6 @@ class ConfigView; class ConfigList; class ConfigItem; -class ConfigLineEdit; class ConfigMainWindow; class ConfigSettings : public QSettings { @@ -187,22 +186,6 @@ public: const QModelIndex &index) const override; }; -class ConfigLineEdit : public QLineEdit { - Q_OBJECT - typedef class QLineEdit Parent; -public: - ConfigLineEdit(ConfigView* parent); - ConfigView* parent(void) const - { - return (ConfigView*)Parent::parent(); - } - void show(ConfigItem *i); - void keyPressEvent(QKeyEvent *e); - -public: - ConfigItem *item; -}; - class ConfigView : public QWidget { Q_OBJECT typedef class QWidget Parent; @@ -219,7 +202,6 @@ signals: void showRangeChanged(bool); public: ConfigList* list; - ConfigLineEdit* lineEdit; }; class ConfigInfoView : public QTextBrowser { -- cgit From 7930dd91a01fe9c0ff7664c7f0bdf38fba9047bc Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 29 Aug 2020 17:14:14 +0900 Subject: kconfig: qconf: move setShowName/Range() to ConfigList from ConfigView ConfigView::setShowName/Range() only get access to the 'list' member. Move them to the more relevant ConfigList class. Signed-off-by: Masahiro Yamada --- scripts/kconfig/qconf.cc | 53 +++++++++++++++++++++++++----------------------- scripts/kconfig/qconf.h | 12 ++++------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 461681aa5b19..5f3e5e145a99 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -920,8 +920,8 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e) action = new QAction("Show Name", this); action->setCheckable(true); connect(action, SIGNAL(toggled(bool)), - parent(), SLOT(setShowName(bool))); - connect(parent(), SIGNAL(showNameChanged(bool)), + SLOT(setShowName(bool))); + connect(this, SIGNAL(showNameChanged(bool)), action, SLOT(setChecked(bool))); action->setChecked(showName); headerPopup->addAction(action); @@ -929,8 +929,8 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e) action = new QAction("Show Range", this); action->setCheckable(true); connect(action, SIGNAL(toggled(bool)), - parent(), SLOT(setShowRange(bool))); - connect(parent(), SIGNAL(showRangeChanged(bool)), + SLOT(setShowRange(bool))); + connect(this, SIGNAL(showRangeChanged(bool)), action, SLOT(setChecked(bool))); action->setChecked(showRange); headerPopup->addAction(action); @@ -940,6 +940,26 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e) e->accept(); } +void ConfigList::setShowName(bool on) +{ + if (showName == on) + return; + + showName = on; + reinit(); + emit showNameChanged(on); +} + +void ConfigList::setShowRange(bool on) +{ + if (showRange == on) + return; + + showRange = on; + reinit(); + emit showRangeChanged(on); +} + QList ConfigList::allLists; QAction *ConfigList::showNormalAction; QAction *ConfigList::showAllAction; @@ -956,24 +976,6 @@ ConfigView::ConfigView(QWidget* parent, const char *name) verticalLayout->addWidget(list); } -void ConfigView::setShowName(bool b) -{ - if (list->showName != b) { - list->showName = b; - list->reinit(); - emit showNameChanged(b); - } -} - -void ConfigView::setShowRange(bool b) -{ - if (list->showRange != b) { - list->showRange = b; - list->reinit(); - emit showRangeChanged(b); - } -} - void ConfigList::setAllOpen(bool open) { QTreeWidgetItemIterator it(this); @@ -1465,11 +1467,12 @@ ConfigMainWindow::ConfigMainWindow(void) QAction *showNameAction = new QAction("Show Name", this); showNameAction->setCheckable(true); - connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool))); - showNameAction->setChecked(configView->showName()); + connect(showNameAction, SIGNAL(toggled(bool)), configList, SLOT(setShowName(bool))); + showNameAction->setChecked(configList->showName); + QAction *showRangeAction = new QAction("Show Range", this); showRangeAction->setCheckable(true); - connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); + connect(showRangeAction, SIGNAL(toggled(bool)), configList, SLOT(setShowRange(bool))); QActionGroup *optGroup = new QActionGroup(this); optGroup->setExclusive(true); diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index a3ee91565d49..843725584bfa 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -76,6 +76,8 @@ public slots: void updateSelection(void); void saveSettings(void); void setOptionMode(QAction *action); + void setShowName(bool on); + void setShowRange(bool on); signals: void menuChanged(struct menu *menu); @@ -83,6 +85,8 @@ signals: void itemSelected(struct menu *menu); void parentSelected(void); void gotFocus(struct menu *); + void showNameChanged(bool on); + void showRangeChanged(bool on); public: void updateListAll(void) @@ -192,14 +196,6 @@ class ConfigView : public QWidget { public: ConfigView(QWidget* parent, const char *name = 0); - bool showName(void) const { return list->showName; } - bool showRange(void) const { return list->showRange; } -public slots: - void setShowName(bool); - void setShowRange(bool); -signals: - void showNameChanged(bool); - void showRangeChanged(bool); public: ConfigList* list; }; -- cgit From 62ed165651cc71cb1b6d39ced74e47c2b26a55a5 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 29 Aug 2020 17:14:15 +0900 Subject: kconfig: qconf: remove ConfigView class Now that ConfigView only contains ConfigList, we can remove ConfigView and just use ConfigList. Signed-off-by: Masahiro Yamada --- scripts/kconfig/qconf.cc | 43 +++++++++++++++---------------------------- scripts/kconfig/qconf.h | 21 ++------------------- 2 files changed, 17 insertions(+), 47 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 5f3e5e145a99..4ece85ae7dfa 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -307,8 +307,8 @@ parent: QStyledItemDelegate::setModelData(editor, model, index); } -ConfigList::ConfigList(ConfigView* p, const char *name) - : Parent(p), +ConfigList::ConfigList(QWidget *parent, const char *name) + : QTreeWidget(parent), updateAll(false), showName(false), showRange(false), mode(singleMode), optMode(normalOpt), rootEntry(0), headerPopup(0) @@ -965,17 +965,6 @@ QAction *ConfigList::showNormalAction; QAction *ConfigList::showAllAction; QAction *ConfigList::showPromptAction; -ConfigView::ConfigView(QWidget* parent, const char *name) - : Parent(parent) -{ - setObjectName(name); - QVBoxLayout *verticalLayout = new QVBoxLayout(this); - verticalLayout->setContentsMargins(0, 0, 0, 0); - - list = new ConfigList(this); - verticalLayout->addWidget(list); -} - void ConfigList::setAllOpen(bool open) { QTreeWidgetItemIterator it(this); @@ -1302,12 +1291,12 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow *parent) split = new QSplitter(this); split->setOrientation(Qt::Vertical); - list = new ConfigView(split, "search"); - list->list->mode = listMode; + list = new ConfigList(split, "search"); + list->mode = listMode; info = new ConfigInfoView(split, "search"); - connect(list->list, SIGNAL(menuChanged(struct menu *)), + connect(list, SIGNAL(menuChanged(struct menu *)), info, SLOT(setInfo(struct menu *))); - connect(list->list, SIGNAL(menuChanged(struct menu *)), + connect(list, SIGNAL(menuChanged(struct menu *)), parent, SLOT(setMenuLink(struct menu *))); layout1->addWidget(split); @@ -1351,7 +1340,7 @@ void ConfigSearchWindow::search(void) ConfigItem *lastItem = NULL; free(result); - list->list->clear(); + list->clear(); info->clear(); result = sym_re_search(editField->text().toLatin1()); @@ -1359,7 +1348,7 @@ void ConfigSearchWindow::search(void) return; for (p = result; *p; p++) { for_all_prompts((*p), prop) - lastItem = new ConfigItem(list->list, lastItem, prop->menu, + lastItem = new ConfigItem(list, lastItem, prop->menu, menu_is_visible(prop->menu)); } } @@ -1407,23 +1396,21 @@ ConfigMainWindow::ConfigMainWindow(void) split1->setOrientation(Qt::Horizontal); split1->setChildrenCollapsible(false); - menuView = new ConfigView(widget, "menu"); - menuList = menuView->list; + menuList = new ConfigList(widget, "menu"); split2 = new QSplitter(widget); split2->setChildrenCollapsible(false); split2->setOrientation(Qt::Vertical); // create config tree - configView = new ConfigView(widget, "config"); - configList = configView->list; + configList = new ConfigList(widget, "config"); helpText = new ConfigInfoView(widget, "help"); layout->addWidget(split2); split2->addWidget(split1); - split1->addWidget(configView); - split1->addWidget(menuView); + split1->addWidget(configList); + split1->addWidget(menuList); split2->addWidget(helpText); setTabOrder(configList, helpText); @@ -1732,7 +1719,7 @@ void ConfigMainWindow::showSingleView(void) backAction->setEnabled(true); - menuView->hide(); + menuList->hide(); menuList->setRootMenu(0); configList->mode = singleMode; if (configList->rootEntry == &rootmenu) @@ -1763,7 +1750,7 @@ void ConfigMainWindow::showSplitView(void) menuList->mode = symbolMode; menuList->setRootMenu(&rootmenu); menuList->setAllOpen(true); - menuView->show(); + menuList->show(); menuList->setFocus(); } @@ -1778,7 +1765,7 @@ void ConfigMainWindow::showFullView(void) backAction->setEnabled(false); - menuView->hide(); + menuList->hide(); menuList->setRootMenu(0); configList->mode = fullMode; if (configList->rootEntry == &rootmenu) diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index 843725584bfa..1289fdaa7d82 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -17,7 +17,6 @@ #include "expr.h" -class ConfigView; class ConfigList; class ConfigItem; class ConfigMainWindow; @@ -43,14 +42,10 @@ class ConfigList : public QTreeWidget { Q_OBJECT typedef class QTreeWidget Parent; public: - ConfigList(ConfigView* p, const char *name = 0); + ConfigList(QWidget *parent, const char *name = 0); ~ConfigList(); void reinit(void); ConfigItem* findConfigItem(struct menu *); - ConfigView* parent(void) const - { - return (ConfigView*)Parent::parent(); - } void setSelected(QTreeWidgetItem *item, bool enable) { for (int i = 0; i < selectedItems().size(); i++) selectedItems().at(i)->setSelected(false); @@ -190,16 +185,6 @@ public: const QModelIndex &index) const override; }; -class ConfigView : public QWidget { - Q_OBJECT - typedef class QWidget Parent; -public: - ConfigView(QWidget* parent, const char *name = 0); - -public: - ConfigList* list; -}; - class ConfigInfoView : public QTextBrowser { Q_OBJECT typedef class QTextBrowser Parent; @@ -245,7 +230,7 @@ protected: QLineEdit* editField; QPushButton* searchButton; QSplitter* split; - ConfigView* list; + ConfigList *list; ConfigInfoView* info; struct symbol **result; @@ -280,9 +265,7 @@ protected: void closeEvent(QCloseEvent *e); ConfigSearchWindow *searchWindow; - ConfigView *menuView; ConfigList *menuList; - ConfigView *configView; ConfigList *configList; ConfigInfoView *helpText; QAction *backAction; -- cgit From a0fce283386d76f3e77f4f45b7ec6f0084510baa Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 29 Aug 2020 17:14:16 +0900 Subject: kconfig: qconf: remove Y, M, N columns There are so many ways to toggle bool / tristate options. I do not know how useful these columns are. Signed-off-by: Masahiro Yamada --- scripts/kconfig/qconf.cc | 59 ++---------------------------------------------- scripts/kconfig/qconf.h | 6 ++--- 2 files changed, 4 insertions(+), 61 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 4ece85ae7dfa..21871b7f5f8a 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -139,9 +139,6 @@ void ConfigItem::updateMenu(void) if (!sym_is_changeable(sym) && list->optMode == normalOpt) { setIcon(promptColIdx, QIcon()); - setText(noColIdx, QString()); - setText(modColIdx, QString()); - setText(yesColIdx, QString()); break; } expr = sym_get_tristate_value(sym); @@ -151,12 +148,10 @@ void ConfigItem::updateMenu(void) setIcon(promptColIdx, choiceYesIcon); else setIcon(promptColIdx, symbolYesIcon); - setText(yesColIdx, "Y"); ch = 'Y'; break; case mod: setIcon(promptColIdx, symbolModIcon); - setText(modColIdx, "M"); ch = 'M'; break; default: @@ -164,16 +159,9 @@ void ConfigItem::updateMenu(void) setIcon(promptColIdx, choiceNoIcon); else setIcon(promptColIdx, symbolNoIcon); - setText(noColIdx, "N"); ch = 'N'; break; } - if (expr != no) - setText(noColIdx, sym_tristate_within_range(sym, no) ? "_" : 0); - if (expr != mod) - setText(modColIdx, sym_tristate_within_range(sym, mod) ? "_" : 0); - if (expr != yes) - setText(yesColIdx, sym_tristate_within_range(sym, yes) ? "_" : 0); setText(dataColIdx, QChar(ch)); break; @@ -310,7 +298,7 @@ parent: ConfigList::ConfigList(QWidget *parent, const char *name) : QTreeWidget(parent), updateAll(false), - showName(false), showRange(false), mode(singleMode), optMode(normalOpt), + showName(false), mode(singleMode), optMode(normalOpt), rootEntry(0), headerPopup(0) { setObjectName(name); @@ -320,7 +308,7 @@ ConfigList::ConfigList(QWidget *parent, const char *name) setVerticalScrollMode(ScrollPerPixel); setHorizontalScrollMode(ScrollPerPixel); - setHeaderLabels(QStringList() << "Option" << "Name" << "N" << "M" << "Y" << "Value"); + setHeaderLabels(QStringList() << "Option" << "Name" << "Value"); connect(this, SIGNAL(itemSelectionChanged(void)), SLOT(updateSelection(void))); @@ -328,7 +316,6 @@ ConfigList::ConfigList(QWidget *parent, const char *name) if (name) { configSettings->beginGroup(name); showName = configSettings->value("/showName", false).toBool(); - showRange = configSettings->value("/showRange", false).toBool(); optMode = (enum optionMode)configSettings->value("/optionMode", 0).toInt(); configSettings->endGroup(); connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); @@ -361,18 +348,10 @@ bool ConfigList::menuSkip(struct menu *menu) void ConfigList::reinit(void) { - hideColumn(yesColIdx); - hideColumn(modColIdx); - hideColumn(noColIdx); hideColumn(nameColIdx); if (showName) showColumn(nameColIdx); - if (showRange) { - showColumn(noColIdx); - showColumn(modColIdx); - showColumn(yesColIdx); - } updateListAll(); } @@ -394,7 +373,6 @@ void ConfigList::saveSettings(void) if (!objectName().isEmpty()) { configSettings->beginGroup(objectName()); configSettings->setValue("/showName", showName); - configSettings->setValue("/showRange", showRange); configSettings->setValue("/optionMode", (int)optMode); configSettings->endGroup(); } @@ -841,15 +819,6 @@ void ConfigList::mouseReleaseEvent(QMouseEvent* e) } } break; - case noColIdx: - setValue(item, no); - break; - case modColIdx: - setValue(item, mod); - break; - case yesColIdx: - setValue(item, yes); - break; case dataColIdx: changeValue(item); break; @@ -925,15 +894,6 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e) action, SLOT(setChecked(bool))); action->setChecked(showName); headerPopup->addAction(action); - - action = new QAction("Show Range", this); - action->setCheckable(true); - connect(action, SIGNAL(toggled(bool)), - SLOT(setShowRange(bool))); - connect(this, SIGNAL(showRangeChanged(bool)), - action, SLOT(setChecked(bool))); - action->setChecked(showRange); - headerPopup->addAction(action); } headerPopup->exec(e->globalPos()); @@ -950,16 +910,6 @@ void ConfigList::setShowName(bool on) emit showNameChanged(on); } -void ConfigList::setShowRange(bool on) -{ - if (showRange == on) - return; - - showRange = on; - reinit(); - emit showRangeChanged(on); -} - QList ConfigList::allLists; QAction *ConfigList::showNormalAction; QAction *ConfigList::showAllAction; @@ -1457,10 +1407,6 @@ ConfigMainWindow::ConfigMainWindow(void) connect(showNameAction, SIGNAL(toggled(bool)), configList, SLOT(setShowName(bool))); showNameAction->setChecked(configList->showName); - QAction *showRangeAction = new QAction("Show Range", this); - showRangeAction->setCheckable(true); - connect(showRangeAction, SIGNAL(toggled(bool)), configList, SLOT(setShowRange(bool))); - QActionGroup *optGroup = new QActionGroup(this); optGroup->setExclusive(true); connect(optGroup, SIGNAL(triggered(QAction*)), configList, @@ -1511,7 +1457,6 @@ ConfigMainWindow::ConfigMainWindow(void) // create options menu menu = menuBar()->addMenu("&Option"); menu->addAction(showNameAction); - menu->addAction(showRangeAction); menu->addSeparator(); menu->addActions(optGroup->actions()); menu->addSeparator(); diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index 1289fdaa7d82..78b0a1dfcd53 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -29,7 +29,7 @@ public: }; enum colIdx { - promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx + promptColIdx, nameColIdx, dataColIdx }; enum listMode { singleMode, menuMode, symbolMode, fullMode, listMode @@ -72,7 +72,6 @@ public slots: void saveSettings(void); void setOptionMode(QAction *action); void setShowName(bool on); - void setShowRange(bool on); signals: void menuChanged(struct menu *menu); @@ -81,7 +80,6 @@ signals: void parentSelected(void); void gotFocus(struct menu *); void showNameChanged(bool on); - void showRangeChanged(bool on); public: void updateListAll(void) @@ -100,7 +98,7 @@ public: bool updateAll; - bool showName, showRange; + bool showName; enum listMode mode; enum optionMode optMode; struct menu *rootEntry; -- cgit From f9a825a7f65a1c94858667934c4ed59bc548dd1f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 29 Aug 2020 17:14:17 +0900 Subject: kconfig: qconf: create QApplication after option checks 'scripts/kconfig/qconf -h' just calls usage() and exits, with QApplication unused. There is no need to construct QApplication so early. Do it after the parse stage. Signed-off-by: Masahiro Yamada Tested-by: Randy Dunlap --- scripts/kconfig/qconf.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 21871b7f5f8a..f7eb093614f2 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1851,7 +1851,6 @@ int main(int ac, char** av) const char *name; progname = av[0]; - configApp = new QApplication(ac, av); if (ac > 1 && av[1][0] == '-') { switch (av[1][1]) { case 's': @@ -1872,6 +1871,8 @@ int main(int ac, char** av) conf_read(NULL); //zconfdump(stdout); + configApp = new QApplication(ac, av); + configSettings = new ConfigSettings(); configSettings->beginGroup("/kconfig/qconf"); v = new ConfigMainWindow(); -- cgit