~chrisccoulson/unity-2d/lp873027

« back to all changes in this revision

Viewing changes to panel/app/panelmanager.cpp

  • Committer: Tarmac
  • Author(s): Łukasz 'sil2100' Zemczak
  • Date: 2011-09-29 13:16:59 UTC
  • mfrom: (739.2.8 trunk.lp839628)
  • Revision ID: tarmac-20110929131659-n9cs8ohr0m3n5iaz
[panel] Handle the F10 key press, starting the panel menu navigation when possible.

Fixes: https://bugs.launchpad.net/unity/+bug/839628
Fixes: https://bugs.launchpad.net/unity-2d/+bug/853766

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <config.h>
27
27
#include <panelstyle.h>
28
28
#include <indicatorsmanager.h>
 
29
#include <hotkeymonitor.h>
 
30
#include <hotkey.h>
29
31
 
30
32
// Unity
31
33
#include <unity2dpanel.h>
124
126
        panel->move(desktop->screenGeometry(i).topLeft());
125
127
    }
126
128
    connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int)));
 
129
 
 
130
    /* A F10 keypress opens the first menu of the visible application or of the first
 
131
       indicator on the panel */
 
132
    Hotkey* F10 = HotkeyMonitor::instance().getHotkeyFor(Qt::Key_F10, Qt::NoModifier);
 
133
    connect(F10, SIGNAL(released()), SLOT(onF10Pressed()));
127
134
}
128
135
 
129
136
PanelManager::~PanelManager()
161
168
                       << "installed plugin providing it.";
162
169
        } else {
163
170
            if (screen == leftmost || !onlyLeftmost) {
164
 
                QWidget *applet = provider->createApplet(panel);
 
171
                QWidget* applet = provider->createApplet(panel);
165
172
                if (applet == 0) {
166
173
                    qWarning() << "The panel applet plugin for" << appletName
167
174
                               << "did not return a valid plugin.";
218
225
    }
219
226
}
220
227
 
 
228
void PanelManager::onF10Pressed()
 
229
{
 
230
    QDesktopWidget* desktop = QApplication::desktop();
 
231
    int screen = desktop->screenNumber(QCursor::pos());
 
232
    Unity2dPanel* panel;
 
233
    
 
234
    if (screen >= m_panels.size()) {
 
235
        return;
 
236
    }
 
237
    panel = m_panels[screen];
 
238
    if (panel != NULL) {
 
239
        QEvent* event = new QEvent(Unity2dPanel::SHOW_FIRST_MENU_EVENT);
 
240
        QCoreApplication::postEvent(panel, event);
 
241
    }
 
242
}
 
243
 
221
244
#include "panelmanager.moc"
222
245