~chrisccoulson/unity-2d/lp873027

« back to all changes in this revision

Viewing changes to panel/applets/indicator/indicatorapplet.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 <debug_p.h>
27
27
#include <indicatorsmanager.h>
28
28
#include <indicatorswidget.h>
 
29
#include <indicatorentrywidget.h>
29
30
#include <unity2dpanel.h>
30
31
 
 
32
// Bamf
 
33
#include <bamf-application.h>
 
34
#include <bamf-matcher.h>
 
35
 
31
36
// Qt
32
37
#include <QHBoxLayout>
33
38
 
53
58
 
54
59
    m_indicatorsWidget = new IndicatorsWidget(m_indicatorsManager);
55
60
    layout->addWidget(m_indicatorsWidget);
 
61
 
 
62
    if (panel != NULL) {
 
63
        panel->installEventFilter(this);
 
64
    }
 
65
}
 
66
 
 
67
bool IndicatorApplet::eventFilter(QObject* watched, QEvent* event)
 
68
{
 
69
    if (event->type() == Unity2dPanel::SHOW_FIRST_MENU_EVENT) {
 
70
        BamfApplication* app = BamfMatcher::get_default().active_application();
 
71
        bool isActiveAppVisible = app ? app->user_visible() : false;
 
72
        if (!isActiveAppVisible) {
 
73
            QList<IndicatorEntryWidget*> list = m_indicatorsWidget->entries();
 
74
            if (!list.isEmpty()) {
 
75
                IndicatorEntryWidget* el = list.first();
 
76
                if (el != NULL) {
 
77
                    el->showMenu(Qt::NoButton);
 
78
                }
 
79
            }
 
80
            return true;
 
81
        } else {
 
82
            return false;
 
83
        }
 
84
    } else {
 
85
        return QWidget::eventFilter(watched, event);
 
86
    }
56
87
}
57
88
 
58
89
void IndicatorApplet::onObjectAdded(Indicator::Ptr const& indicator)