Merge lp:~gerboland/unity-2d/panel-f10-keyboard-navigation-fixes into lp:unity-2d/3.0

Proposed by Gerry Boland
Status: Merged
Approved by: Gerry Boland
Approved revision: 636
Merged at revision: 640
Proposed branch: lp:~gerboland/unity-2d/panel-f10-keyboard-navigation-fixes
Merge into: lp:unity-2d/3.0
Diff against target: 135 lines (+25/-6)
3 files modified
panel/applets/appname/appnameapplet.cpp (+1/-1)
panel/applets/appname/menubarwidget.cpp (+16/-3)
panel/applets/appname/menubarwidget.h (+8/-2)
To merge this branch: bzr merge lp:~gerboland/unity-2d/panel-f10-keyboard-navigation-fixes
Reviewer Review Type Date Requested Status
Florian Boucault (community) Approve
Review via email: mp+68882@code.launchpad.net

Description of the change

[panel] F10 shortcut now correctly displays menu for keyboard navigation. Menubar displays when menus are open, and vanishes when menus close.

To post a comment you must log in.
635. By Gerry Boland

Fixes F10 menu displaybug, where menu didn't obtain focus and panel covered menubar.

Revision history for this message
Florian Boucault (fboucault) wrote :

Bug is fixed and panel works properly :)

panel/applets/appname/menubarwidget.h:
[...]
/**
 * An helper class which monitors the menubar and emits MenuBarWidget::menuBarClosed()
 * to indiciate if the menu was closed or updated.
 */

has a spelling mistake: "indiciate"

Otherwise the patch looks good.

review: Approve
636. By Gerry Boland

Fixed typo "indiciate" -> "indicate"

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panel/applets/appname/appnameapplet.cpp'
2--- panel/applets/appname/appnameapplet.cpp 2011-06-21 16:03:12 +0000
3+++ panel/applets/appname/appnameapplet.cpp 2011-07-25 13:37:28 +0000
4@@ -203,7 +203,7 @@
5 void setupMenuBarWidget()
6 {
7 m_menuBarWidget = new MenuBarWidget(0 /* Window menu */);
8- QObject::connect(m_menuBarWidget, SIGNAL(menuBarClosed()),
9+ QObject::connect(m_menuBarWidget, SIGNAL(menuBarChanged()),
10 q, SLOT(updateWidgets()));
11 QObject::connect(m_menuBarWidget, SIGNAL(isEmptyChanged()),
12 q, SLOT(updateWidgets()));
13
14=== modified file 'panel/applets/appname/menubarwidget.cpp'
15--- panel/applets/appname/menubarwidget.cpp 2011-07-13 09:00:33 +0000
16+++ panel/applets/appname/menubarwidget.cpp 2011-07-25 13:37:28 +0000
17@@ -62,6 +62,7 @@
18 MenuBarWidget::MenuBarWidget(QMenu* windowMenu, QWidget* parent)
19 : QWidget(parent)
20 , m_windowMenu(windowMenu)
21+, m_isMenuOpen(false)
22 {
23 m_activeWinId = 0;
24 setupRegistrar();
25@@ -93,7 +94,7 @@
26 void MenuBarWidget::setupMenuBar()
27 {
28 m_menuBar = new QMenuBar;
29- new MenuBarClosedHelper(this);
30+ m_menuBarMonitor = new MenuBarClosedHelper(this);
31
32 QHBoxLayout* layout = new QHBoxLayout(this);
33 layout->setMargin(0);
34@@ -111,6 +112,9 @@
35 // is drawn or not
36 connect(KeyboardModifiersMonitor::instance(), SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)),
37 m_menuBar, SLOT(update()));
38+
39+ // Watch when the menubar's menus close so that it can be hidden
40+ connect(m_menuBarMonitor, SIGNAL(menuBarClosed()), SLOT(slotMenuBarClosed()));
41 }
42
43 void MenuBarWidget::slotActiveWindowChanged(BamfWindow* /*former*/, BamfWindow* current)
44@@ -169,10 +173,18 @@
45 DBusMenuImporter* importer = static_cast<DBusMenuImporter*>(sender());
46
47 if (m_importers.value(m_activeWinId) == importer) {
48+ m_isMenuOpen = true;
49+ Q_EMIT menuBarChanged();
50 m_menuBar->setActiveAction(action);
51 }
52 }
53
54+void MenuBarWidget::slotMenuBarClosed()
55+{
56+ m_isMenuOpen = false;
57+ Q_EMIT menuBarChanged();
58+}
59+
60 QMenu* MenuBarWidget::menuForWinId(WId wid) const
61 {
62 MyDBusMenuImporter* importer = m_importers.value(wid);
63@@ -245,7 +257,7 @@
64
65 bool MenuBarWidget::isOpened() const
66 {
67- return m_menuBar->activeAction();
68+ return m_isMenuOpen;
69 }
70
71 // MenuBarClosedHelper ----------------------------------------
72@@ -283,8 +295,9 @@
73
74 void MenuBarClosedHelper::emitMenuBarClosed()
75 {
76+ //If there is still no menu action active, then menu must be closed.
77 if (!m_widget->m_menuBar->activeAction()) {
78- QMetaObject::invokeMethod(m_widget, "menuBarClosed");
79+ Q_EMIT menuBarClosed();
80 }
81 }
82
83
84=== modified file 'panel/applets/appname/menubarwidget.h'
85--- panel/applets/appname/menubarwidget.h 2011-04-13 21:17:38 +0000
86+++ panel/applets/appname/menubarwidget.h 2011-07-25 13:37:28 +0000
87@@ -43,7 +43,7 @@
88
89 /**
90 * An helper class which monitors the menubar and emits MenuBarWidget::menuBarClosed()
91- * when necessary
92+ * to indicate if the menu was closed or updated.
93 */
94 class MenuBarClosedHelper : public QObject
95 {
96@@ -51,6 +51,9 @@
97 public:
98 MenuBarClosedHelper(MenuBarWidget*);
99
100+Q_SIGNALS:
101+ void menuBarClosed();
102+
103 protected:
104 bool eventFilter(QObject*, QEvent*); //reimp
105
106@@ -72,7 +75,7 @@
107 bool isOpened() const;
108
109 Q_SIGNALS:
110- void menuBarClosed();
111+ void menuBarChanged();
112 void isEmptyChanged();
113
114 protected:
115@@ -85,17 +88,20 @@
116 void slotWindowUnregistered(WId);
117 void slotMenuUpdated();
118 void slotActionActivationRequested(QAction* action);
119+ void slotMenuBarClosed();
120 void updateMenuBar();
121
122 private:
123 Q_DISABLE_COPY(MenuBarWidget)
124
125 QMenuBar* m_menuBar;
126+ MenuBarClosedHelper* m_menuBarMonitor;
127 Registrar* m_registrar;
128 ImporterForWId m_importers;
129 WId m_activeWinId;
130 QMenu* m_windowMenu;
131 QTimer* m_updateMenuBarTimer;
132+ bool m_isMenuOpen;
133
134 void setupRegistrar();
135 void setupMenuBar();

Subscribers

People subscribed via source and target branches