Merge branch 'alpha' of tomsrv:tomamp into alpha
[tomamp] / tomamp / mainwindow.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the examples of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** Commercial Usage
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
15 **
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file.  Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23 **
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27 **
28 ** GNU General Public License Usage
29 ** Alternatively, this file may be used under the terms of the GNU
30 ** General Public License version 3.0 as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL included in the
32 ** packaging of this file.  Please review the following information to
33 ** ensure the GNU General Public License version 3.0 requirements will be
34 ** met: http://www.gnu.org/copyleft/gpl.html.
35 **
36 ** If you have questions regarding the use of this file, please contact
37 ** Nokia at qt-info@nokia.com.
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef MAINWINDOW_H
43 #define MAINWINDOW_H
44
45 #include <QMainWindow>
46 #include <QSettings>
47 #if QT_VERSION < 0x040600
48 #include <audiooutput.h>
49 #include <seekslider.h>
50 #include <mediaobject.h>
51 #include <volumeslider.h>
52 #include <backendcapabilities.h>
53 #else
54 #include <phonon/audiooutput.h>
55 #include <phonon/seekslider.h>
56 #include <phonon/mediaobject.h>
57 #include <phonon/volumeslider.h>
58 #include <phonon/backendcapabilities.h>
59 #endif
60 #include <QList>
61 #include "playlistmanager.h"
62
63 class QAction;
64 class QTableWidget;
65 class QLCDNumber;
66
67
68 class MainWindow : public QMainWindow
69 {
70     Q_OBJECT
71
72 public:
73     MainWindow();
74     ~MainWindow ();
75
76     QSize sizeHint() const
77     {
78         return QSize(800, 480);
79     }
80
81 private slots:
82     void addFiles();
83     void addFolder();
84     void addUrl ();
85     void repeatToggle ();
86     void shuffleToggle ();
87     void volumeToggle ();
88     void about();
89     void stateChanged(Phonon::State newState, Phonon::State oldState);
90     void tick(qint64 time);
91     void sourceChanged(const Phonon::MediaSource &source);
92     void aboutToFinish();
93     void finished();
94     void tableClicked(int row, int column);
95     void play();
96     void stop();
97     void next();
98     void previous();
99     void cellClicked(int row, int column);
100     void savePlaylist ();
101     void loadPlaylist ();
102     void playlistChanged (int from);
103     void itemUpdated (int index);
104     void setItem (int ind, bool doplay);
105     void removeSelectedItem ();
106     void removeAllButSelectedItem ();
107     void highlightRow (int i);
108     void unhighlightRow (int i);
109
110     void itemRemoved (int i);
111     void showOptions ();
112     void playlistControl (const QString&);
113     void upSelected();
114     void downSelected();
115     void enqueueSelected();
116
117 protected:
118     void contextMenuEvent (QContextMenuEvent*e);
119 private:
120     void setupActions();
121     void setupMenus();
122     void setupUi();
123     void setupShuffleList();
124     void setRowFromItem (int row, const PlaylistItem& item);
125     void buttonUp (int i);
126     void buttonDown (int i);
127     void buttonDel (int i);
128     void setOrientation ();
129
130     Phonon::SeekSlider *seekSlider;
131     Phonon::MediaObject *mediaObject;
132     Phonon::AudioOutput *audioOutput;
133     Phonon::VolumeSlider *volumeSlider;
134
135     PlaylistManager plman;
136
137     QAction *playAction;
138     QAction *pauseAction;
139     QAction *stopAction;
140     QAction *repeatAction;
141     QAction *shuffleAction;
142     QAction *volumeAction;
143     QAction *volumeAddedAction;
144     QAction *nextAction;
145     QAction *previousAction;
146     QAction *upAction;
147     QAction *downAction;
148     QAction *delAction;
149     QAction *addFilesAction;
150     QAction *addFoldersAction;
151     QAction *addUrlAction;
152     QAction *savePlaylistAction;
153     QAction *loadPlaylistAction;
154     QAction *clearPlaylistAction;
155     QAction *exitAction;
156     QAction *aboutAction;
157     QAction *aboutQtAction;
158     QAction *removeSelected;
159     QAction *removeAllButSelected;
160     QAction *enqueueAction;
161     QAction *optionAction;
162     QMenu   *contextMenu;
163     QToolBar *bar;
164     QLCDNumber *timeLcd;
165     QTableWidget *musicTable;
166     QStringList headers;
167     bool        repeat;
168     bool        shuffle;
169     QSettings settings;
170     QList<int>  shuffleList;
171     int lastPlayed;
172     bool isPlaying;
173 };
174
175 #endif