Skip to content

Commit 7d1300e

Browse files
committed
kconfig: qconf: fix the popup menu in the ConfigInfoView window
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 <[email protected]>
1 parent d85de33 commit 7d1300e

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

scripts/kconfig/qconf.cc

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,16 @@ ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
10121012
configSettings->endGroup();
10131013
connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
10141014
}
1015+
1016+
contextMenu = createStandardContextMenu();
1017+
QAction *action = new QAction("Show Debug Info", contextMenu);
1018+
1019+
action->setCheckable(true);
1020+
connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
1021+
connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setChecked(bool)));
1022+
action->setChecked(showDebug());
1023+
contextMenu->addSeparator();
1024+
contextMenu->addAction(action);
10151025
}
10161026

10171027
void ConfigInfoView::saveSettings(void)
@@ -1268,23 +1278,10 @@ void ConfigInfoView::clicked(const QUrl &url)
12681278
delete data;
12691279
}
12701280

1271-
QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos)
1272-
{
1273-
QMenu* popup = Parent::createStandardContextMenu(pos);
1274-
QAction* action = new QAction("Show Debug Info", popup);
1275-
1276-
action->setCheckable(true);
1277-
connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
1278-
connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setChecked(bool)));
1279-
action->setChecked(showDebug());
1280-
popup->addSeparator();
1281-
popup->addAction(action);
1282-
return popup;
1283-
}
1284-
1285-
void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e)
1281+
void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)
12861282
{
1287-
Parent::contextMenuEvent(e);
1283+
contextMenu->popup(event->globalPos());
1284+
event->accept();
12881285
}
12891286

12901287
ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow *parent)

scripts/kconfig/qconf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ public slots:
215215
class ConfigInfoView : public QTextBrowser {
216216
Q_OBJECT
217217
typedef class QTextBrowser Parent;
218+
QMenu *contextMenu;
218219
public:
219220
ConfigInfoView(QWidget* parent, const char *name = 0);
220221
bool showDebug(void) const { return _showDebug; }
@@ -235,8 +236,7 @@ public slots:
235236
QString debug_info(struct symbol *sym);
236237
static QString print_filter(const QString &str);
237238
static void expr_print_help(void *data, struct symbol *sym, const char *str);
238-
QMenu *createStandardContextMenu(const QPoint & pos);
239-
void contextMenuEvent(QContextMenuEvent *e);
239+
void contextMenuEvent(QContextMenuEvent *event);
240240

241241
struct symbol *sym;
242242
struct menu *_menu;

0 commit comments

Comments
 (0)