Skip to content

Commit

Permalink
kconfig: qconf: fix the popup menu in the ConfigInfoView window
Browse files Browse the repository at this point in the history
I do not know when ConfigInfoView::createStandardContextMenu() is
called.

Because QTextEdit::createStandardContextMenu() is not virtual,
ConfigInfoView::createStandardContextMenu() cannot override it.
Even if right-click the ConfigInfoView window, the "Show Debug Info"
menu does not show up.

Build up the menu in the constructor, and invoke it from the
contextMenuEvent().

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
  • Loading branch information
Masahiro Yamada committed Aug 18, 2020
1 parent d85de33 commit 7d1300e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
29 changes: 13 additions & 16 deletions scripts/kconfig/qconf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,16 @@ ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
configSettings->endGroup();
connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
}

contextMenu = createStandardContextMenu();
QAction *action = new QAction("Show Debug Info", contextMenu);

action->setCheckable(true);
connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setChecked(bool)));
action->setChecked(showDebug());
contextMenu->addSeparator();
contextMenu->addAction(action);
}

void ConfigInfoView::saveSettings(void)
Expand Down Expand Up @@ -1268,23 +1278,10 @@ void ConfigInfoView::clicked(const QUrl &url)
delete data;
}

QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos)
{
QMenu* popup = Parent::createStandardContextMenu(pos);
QAction* action = new QAction("Show Debug Info", popup);

action->setCheckable(true);
connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setChecked(bool)));
action->setChecked(showDebug());
popup->addSeparator();
popup->addAction(action);
return popup;
}

void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e)
void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)
{
Parent::contextMenuEvent(e);
contextMenu->popup(event->globalPos());
event->accept();
}

ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow *parent)
Expand Down
4 changes: 2 additions & 2 deletions scripts/kconfig/qconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public slots:
class ConfigInfoView : public QTextBrowser {
Q_OBJECT
typedef class QTextBrowser Parent;
QMenu *contextMenu;
public:
ConfigInfoView(QWidget* parent, const char *name = 0);
bool showDebug(void) const { return _showDebug; }
Expand All @@ -235,8 +236,7 @@ public slots:
QString debug_info(struct symbol *sym);
static QString print_filter(const QString &str);
static void expr_print_help(void *data, struct symbol *sym, const char *str);
QMenu *createStandardContextMenu(const QPoint & pos);
void contextMenuEvent(QContextMenuEvent *e);
void contextMenuEvent(QContextMenuEvent *event);

struct symbol *sym;
struct menu *_menu;
Expand Down

0 comments on commit 7d1300e

Please sign in to comment.