aboutsummaryrefslogtreecommitdiff
path: root/src/corelib/widgets/mapplicationwindow_p.h
blob: e3e9d885ce2802fdbe32684bde3a0b99365ff998 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#ifndef MAPPLICATIONWINDOW_P_H
#define MAPPLICATIONWINDOW_P_H

#include "mwindow_p.h"
#include "mapplicationwindow.h"
#include "mapplicationpagemodel.h"
#include "mescapebuttonpanelmodel.h"
#include <QPointer>
#include <QTimer>
#include "mapplicationwindowstyle.h"

#ifdef HAVE_CONTEXTSUBSCRIBER
# include "contextproperty.h"
#endif

class QGraphicsItemAnimation;
class QTimeLine;
class MScene;
class MNavigationBar;
class MApplicationMenu;
class MToolBar;
class MDockWidget;
class MHomeButtonPanel;
class MEscapeButtonPanel;
class MApplicationPage;
class MApplicationPageInfo;
class MApplicationWindow;
class MSceneWindowEvent;
class QActionEvent;

class MApplicationWindowPrivate : public MWindowPrivate
{
    Q_DECLARE_PUBLIC(MApplicationWindow)

public:
    MApplicationWindowPrivate();
    virtual ~MApplicationWindowPrivate();

    QPointer<MApplicationPage> page;
    QPointer<MNavigationBar> navigationBar;
    QPointer<MToolBar> toolBar;
    QPointer<MDockWidget> dockWidget;
    QPointer<MHomeButtonPanel> homeButtonPanel;
    QPointer<MApplicationMenu> menu;
    QPointer<MSceneWindow> statusBar;
    QTimer autoHideComponentsTimer;
    QList<MSceneWindow *> componentsOnAutoHide;
    bool pageAreaMaximized;
#ifdef Q_WS_X11
    bool    isChained;
    WId     chainParentWinId;
    QString chainTaskTitle;
#endif

#ifdef HAVE_CONTEXTSUBSCRIBER
    ContextProperty callStatusProperty;
#endif

    // TODO: Use some API like "bool MSceneWindow::isAppearing()" or something,
    //       once it becomes available, instead of manually tracking the scene windows
    //       appear/disappear statuses.
    bool showingStatusBar;
    bool showingNavigationBar;
    bool showingDockWidget;

    QTimer navigationBarVisibilityUpdateTimer;

    bool navigationBarPressed;

    void manageActions();
    void distributeAction(QAction *action, QAction *before);
    void refreshArrowIconVisibility();

    void setComponentDisplayMode(MSceneWindow *component,
                                 MApplicationPageModel::ComponentDisplayMode displayMode);
    void removeComponentFromAutoHide(MSceneWindow *component);

    /*!
     Connects the \a page's state such as the active navigation bar configuration and registered actions
     to the application window's common components.
     */
    void connectPage(MApplicationPage *page);

    /*!
     Disconnects the \a page's state from the application window.
     */
    void disconnectPage(MApplicationPage *page);

    /*!
        \brief Makes the dock widget either visible (when invisible) if a
        toolbar has been docked with some actions OR invisible (when visible)
        if a docked toolbar has 0 actions
     */
    void updateDockWidgetVisibility();

    void _q_updateNavigationBarVisibility();

    // Update the navigation bar visibility at a subsequent event.
    void _q_scheduleNavigationBarVisibilityUpdate();

    void sceneWindowAppearEvent(MSceneWindowEvent *ev);
    void sceneWindowDisappearEvent(MSceneWindowEvent *ev);
    void sceneWindowDismissEvent(MSceneWindowEvent *ev);

    void applicationPageAppearEvent(MSceneWindowEvent *ev);
    void applicationPageDisappearEvent(MSceneWindowEvent *ev);

    void windowStateChangeEvent(QWindowStateChangeEvent *event);

    /*!
     Opens menu and disables a toolbar and an escape button.
     */
    void openMenu();
    void closeMenu();
    bool isMenuOpen() const;
#ifdef Q_WS_X11
    void addMStatusBarOverlayProperty();
    void appendMApplicationWindowTypeProperty();
#endif

    void setupPageEscape();
#ifdef Q_WS_X11
    bool setupPageEscapeChainedApplication();
#endif
    void setupPageEscapeAuto();
    void setupPageEscapeBack();
    void setupPageEscapeClose();
    void tearDownPageEscape();
    void _q_updatePageEscapeAuto();

    /*!
     * Maximizes visible area for page by hiding all other components (e.g. navigation bar).
     * Overrides each page's own preference for displaying components.
     */
    void maximizePageArea();

    /*!
     * Restores page area to current page's preference.
     */
    void restorePageArea();

    /*!
     * Whether the dock widget is needed or not
     */
    bool needsDockWidget();

    /*!
     * Set viewtype of the toolbar (tools or tabs)
     */
    void setToolBarViewType(const MTheme::ViewType& viewType);

    MApplicationWindowStyleContainer& style();
    const MApplicationWindowStyleContainer& style() const;
    virtual MApplicationWindowStyleContainer* createStyleContainer() const;

private:
    MApplicationWindowStyleContainer* styleContainer;

    void init();
    void initAutoHideComponentsTimer();
    void removePageActions();
    QAction* findCheckedAction(const QList<QAction *> &actions) const;
#ifdef Q_WS_X11
    void setWindowChainedProperty( const WId &parentWinId, const WId &childWinId );
#endif
public:
    void _q_pageTitleChanged(MApplicationPage *, const QString &);
    void _q_actionUpdated(QActionEvent *e);
    void _q_placeToolBar();
    void _q_handlePageModelModifications(const QList<const char *>&);
    void _q_menuAppeared();
    void _q_menuDisappeared();
    void _q_updateStatusBarVisibility();
    void _q_navigationBarStateChanged(MSceneWindow::SceneWindowState newState, MSceneWindow::SceneWindowState oldState);
#ifdef M_OS_MAEMO5
    void _q_exitAppView();
#endif //M_OS_MAEMO5
    void _q_updatePageExposedContentRect();
    void _q_enablePaintUpdates();
    void _q_handleInSwitcherVisibilityChange();
    void _q_updateStyle();
    void _q_setupNavigationBarCustomContent();
};

#endif