~tpeeters/ubuntu-ui-toolkit/10-tabsModelIndex

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/plugin/bottombarvisibilitycommunicator.cpp

  • Committer: tpeeters
  • Date: 2014-03-24 19:13:15 UTC
  • mfrom: (967.1.15 ubuntu-ui-toolkit)
  • Revision ID: tim.peeters@canonical.com-20140324191315-cgmt5x2h6v2xq1jh
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2013 Canonical Ltd.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU Lesser General Public License as published by
6
 
 * the Free Software Foundation; version 3.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 * GNU Lesser General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU Lesser General Public License
14
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 *
16
 
 */
17
 
 
18
 
#include "bottombarvisibilitycommunicator.h"
19
 
 
20
 
#include <QDBusInterface>
21
 
 
22
 
static const char* BOTTOM_BAR_VISIBILITY_COMMUNICATOR_DBUS_PATH = "/BottomBarVisibilityCommunicator";
23
 
static const char* BOTTOM_BAR_VISIBILITY_COMMUNICATOR_DBUS_INTERFACE = "com.canonical.Shell.BottomBarVisibilityCommunicator";
24
 
static const char* DBUS_SERVICE = "com.canonical.Shell.BottomBarVisibilityCommunicator";
25
 
 
26
 
/*!
27
 
    \internal
28
 
 
29
 
    BottomBarVisibilityCommunicator controller is used to communicate with the Shell BottomBarVisibilityCommunicator.
30
 
    This class allows for the bottom edge interaction to happen
31
 
 
32
 
    The shell can control the bottom bar behaviour:
33
 
     * forceHidden: If set to true, the bottom bar has to be forced to be hidden
34
 
*/
35
 
 
36
 
BottomBarVisibilityCommunicator::BottomBarVisibilityCommunicator()
37
 
 : m_shellDbusIface(NULL),
38
 
   m_position(0),
39
 
   m_forceHidden(false)
40
 
{
41
 
    m_shellDbusIface = new QDBusInterface(DBUS_SERVICE, BOTTOM_BAR_VISIBILITY_COMMUNICATOR_DBUS_PATH, BOTTOM_BAR_VISIBILITY_COMMUNICATOR_DBUS_INTERFACE, QDBusConnection::sessionBus(), this);
42
 
    if (m_shellDbusIface->isValid()) {
43
 
        connect(m_shellDbusIface, SIGNAL(forceHiddenChanged(bool)), SLOT(onShellForceHiddenChanged(bool)));
44
 
 
45
 
        const bool forceHidden = m_shellDbusIface->property("forceHidden").toDouble();
46
 
        onShellForceHiddenChanged(forceHidden);
47
 
    }
48
 
}
49
 
 
50
 
bool BottomBarVisibilityCommunicator::forceHidden() const
51
 
{
52
 
    return m_forceHidden;
53
 
}
54
 
 
55
 
double BottomBarVisibilityCommunicator::position() const
56
 
{
57
 
    return m_position;
58
 
}
59
 
 
60
 
void BottomBarVisibilityCommunicator::setPosition(double position)
61
 
{
62
 
    if (position != m_position) {
63
 
        m_position = position;
64
 
        m_shellDbusIface->setProperty("position", position);
65
 
        Q_EMIT positionChanged(position);
66
 
    }
67
 
}
68
 
 
69
 
void BottomBarVisibilityCommunicator::onShellForceHiddenChanged(bool forceHidden)
70
 
{
71
 
    if (forceHidden != m_forceHidden) {
72
 
        m_forceHidden = forceHidden;
73
 
        Q_EMIT forceHiddenChanged(forceHidden);
74
 
    }
75
 
}