better extensioncheck
[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
114 protected:
115     void contextMenuEvent (QContextMenuEvent*e);
116 private:
117     void setupActions();
118     void setupMenus();
119     void setupUi();
120     void setupShuffleList();
121     void setRowFromItem (int row, const PlaylistItem& item);
122     void buttonUp (int i);
123     void buttonDown (int i);
124     void buttonDel (int i);
125
126     Phonon::SeekSlider *seekSlider;
127     Phonon::MediaObject *mediaObject;
128     Phonon::AudioOutput *audioOutput;
129     Phonon::VolumeSlider *volumeSlider;
130
131     PlaylistManager plman;
132
133     QAction *playAction;
134     QAction *pauseAction;
135     QAction *stopAction;
136     QAction *repeatAction;
137     QAction *shuffleAction;
138     QAction *volumeAction;
139     QAction *volumeAddedAction;
140     QAction *nextAction;
141     QAction *previousAction;
142     QAction *addFilesAction;
143     QAction *addFoldersAction;
144     QAction *addUrlAction;
145     QAction *savePlaylistAction;
146     QAction *loadPlaylistAction;
147     QAction *clearPlaylistAction;
148     QAction *exitAction;
149     QAction *aboutAction;
150     QAction *aboutQtAction;
151     QAction *removeSelected;
152     QAction *removeAllButSelected;
153     QAction *optionAction;
154     QMenu   *contextMenu;
155     QToolBar *bar;
156     QLCDNumber *timeLcd;
157     QTableWidget *musicTable;
158     bool        repeat;
159     bool        shuffle;
160     QSettings settings;
161     QList<int>  shuffleList;
162     int lastPlayed;
163     bool isPlaying;
164 };
165
166 #endif