summaryrefslogtreecommitdiff
path: root/demo/player/playerpage.h
blob: a72152ce0adac5f6d32c74d7980d3796a5b668c0 (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
/*************************************************************************
This file is part of libresourceqt

Copyright (C) 2010 Nokia Corporation.

This library is free software; you can redistribute
it and/or modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation
version 2.1 of the License.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA.
*************************************************************************/

#pragma once

#include <QtGui>
#include <QFileDialog>

#include <MApplicationPage>
#include <MVideoWidget>
#include <MLayout>
#include <MLinearLayoutPolicy>
#include <MButton>
#include <MSlider>
#include <MOrientationChangeEvent>
#include <MApplicationMenu>
#include <MAction>
#include <MLabel>
#include <MSeekBar>
#include <MSceneManager>

#include "playerwidget.h"

/**
  * \mainpage Policy-aware Player
  *
  * Demonstrates how to use libresourceqt to create a policy-aware application.
  *
  * There are two classes:
  * \see PlayerPage creates the UI consisting of a control bar and a video widget
  * \see PlayerWidget contains all of policy-related customizations
  * to make the application behave well in concurrent world.
  *
  */

/**
  * PlayerPage class creates the UI of the application.  It contains a menu,
  * a control bar to control the playback, and PlayerWidget that does the actual playback.
  * For policy-related functionality please refer to PlayerWidget, this class merely
  * creates the mechanics of the UI for the demo application.
  *
  * \see PlayerWidget
  * \see MApplicationPage
  */

class PlayerPage : public MApplicationPage
{
    Q_OBJECT
public:
    PlayerPage();

private:
    void     createContent();
    void     makeControlBar(MLinearLayoutPolicy *controlBarPolicy);
    void     orientationChangeEvent(MOrientationChangeEvent *event);
    void     openFile(QString dir);
    void     setEnabled(MWidget *widget, bool enabled);
    MButton* makeButton(QString iconID, bool enabled = true);
    void     updateLabelsVisibility();

    MLinearLayoutPolicy *layoutPolicy, *controlBarPolicy;
    MButton             *btnLoadAudio, *btnLoadVideo, *btnPlay;
    MSeekBar            *seekbar;
    PlayerWidget        *playerWidget;
    MLabel              *lblTitle, *lblPosition;
    MAction             *menuAction;

    bool seekbarPressed;
    bool labelsVisible;

private slots:
    void openAudioFile();
    void openVideoFile();

    void togglePolicyAwareness();
    void setPlayingIcon();
    void setPausedIcon();
    void playOrPause();
    void onPositionChanged();
    void sliderPressed();
    void seekToNewPosition();
};