| 1 |
/*************************************************************************** |
| 2 |
begin : Fre Nov 15 2002 |
| 3 |
copyright : (C) Mark Kretschmann <markey@web.de> |
| 4 |
: (C) Max Howell <max.howell@methylblue.com> |
| 5 |
***************************************************************************/ |
| 6 |
|
| 7 |
/*************************************************************************** |
| 8 |
* * |
| 9 |
* This program is free software; you can redistribute it and/or modify * |
| 10 |
* it under the terms of the GNU General Public License as published by * |
| 11 |
* the Free Software Foundation; either version 2 of the License, or * |
| 12 |
* (at your option) any later version. * |
| 13 |
* * |
| 14 |
***************************************************************************/ |
| 15 |
|
| 16 |
#ifndef MAINWINDOW_H |
| 17 |
#define MAINWINDOW_H |
| 18 |
|
| 19 |
#include "amarok_export.h" |
| 20 |
#include "meta/Meta.h" |
| 21 |
#include "EngineObserver.h" |
| 22 |
#include "browsers/BrowserWidget.h" |
| 23 |
|
| 24 |
#include <KMainWindow> |
| 25 |
#include <KVBox> |
| 26 |
|
| 27 |
#include <QPointer> |
| 28 |
|
| 29 |
class CollectionWidget; |
| 30 |
class ContextWidget; |
| 31 |
class MainToolbar; |
| 32 |
class MainWindow; |
| 33 |
class PlaylistFileProvider; |
| 34 |
class SearchWidget; |
| 35 |
|
| 36 |
namespace PlaylistBrowserNS { class PlaylistBrowser; } |
| 37 |
|
| 38 |
namespace Plasma { class Containment; } |
| 39 |
namespace Playlist { class Widget; } |
| 40 |
|
| 41 |
namespace Context { |
| 42 |
class ContextScene; |
| 43 |
class ContextView; |
| 44 |
class ToolbarView; |
| 45 |
} |
| 46 |
|
| 47 |
class KMenu; |
| 48 |
class QMenuBar; |
| 49 |
class QSplitter; |
| 50 |
class QTimer; |
| 51 |
|
| 52 |
namespace The { |
| 53 |
AMAROK_EXPORT MainWindow* mainWindow(); |
| 54 |
} |
| 55 |
|
| 56 |
//This should only change if docks or toolbars are added or removed, and in this case a new src/data/DefaultDockLayyout |
| 57 |
//file should be created as well |
| 58 |
#define LAYOUT_VERSION 0 |
| 59 |
|
| 60 |
/** |
| 61 |
* @class MainWindow |
| 62 |
* @short The MainWindow widget class. |
| 63 |
* |
| 64 |
* This is the main window widget. |
| 65 |
*/ |
| 66 |
class AMAROK_EXPORT MainWindow : public KMainWindow, public EngineObserver, public Meta::Observer |
| 67 |
{ |
| 68 |
friend MainWindow* The::mainWindow(); |
| 69 |
|
| 70 |
Q_OBJECT |
| 71 |
|
| 72 |
public: |
| 73 |
MainWindow(); |
| 74 |
~MainWindow(); |
| 75 |
|
| 76 |
//allows us to switch browsers from within other browsers etc |
| 77 |
void showBrowser( const QString& name ); |
| 78 |
void addBrowser( const QString &name, QWidget *widget, const QString &text, const QString &icon ); |
| 79 |
|
| 80 |
//takes into account minimized, multiple desktops, etc. |
| 81 |
bool isReallyShown() const; |
| 82 |
|
| 83 |
void activate(); |
| 84 |
|
| 85 |
BrowserWidget *browserWidget() const { return m_browsers; } |
| 86 |
QPointer<KMenu> ToolsMenu() const { return m_toolsMenu; } |
| 87 |
QPointer<KMenu> SettingsMenu() const { return m_settingsMenu; } |
| 88 |
QPointer<Playlist::Widget> playlistWidget() { return m_playlistWidget; } |
| 89 |
void deleteBrowsers(); |
| 90 |
|
| 91 |
QString activeBrowserName(); |
| 92 |
|
| 93 |
CollectionWidget * collectionBrowser(); |
| 94 |
PlaylistBrowserNS::PlaylistBrowser * playlistBrowser(); |
| 95 |
|
| 96 |
//will return the size of the rect defined top, right and left by the main toolbar and bottom by the context view. |
| 97 |
QSize backgroundSize(); |
| 98 |
|
| 99 |
int contextXOffset(); |
| 100 |
QRect contextRectGlobal(); |
| 101 |
QPoint globalBackgroundOffset(); |
| 102 |
|
| 103 |
bool isLayoutLocked(); |
| 104 |
|
| 105 |
signals: |
| 106 |
void loveTrack( Meta::TrackPtr ); |
| 107 |
|
| 108 |
public slots: |
| 109 |
void showHide(); |
| 110 |
void loveTrack(); |
| 111 |
void playAudioCD(); |
| 112 |
void hideContextView( bool hide ); |
| 113 |
|
| 114 |
void setLayoutLocked( bool locked ); |
| 115 |
|
| 116 |
protected: |
| 117 |
//Reimplemented from EngineObserver |
| 118 |
virtual void engineStateChanged( Phonon::State state, Phonon::State oldState = Phonon::StoppedState ); |
| 119 |
|
| 120 |
//Reimplemented from Meta::Observer |
| 121 |
using Observer::metadataChanged; |
| 122 |
virtual void metadataChanged( Meta::TrackPtr track ); |
| 123 |
|
| 124 |
private slots: |
| 125 |
void slotShrinkBrowsers( int index ); |
| 126 |
void savePlaylist() const; |
| 127 |
void exportPlaylist() const; |
| 128 |
void slotShowCoverManager() const; |
| 129 |
void slotPlayMedia(); |
| 130 |
void slotAddLocation( bool directPlay = false ); |
| 131 |
void slotAddStream(); |
| 132 |
void showScriptSelector(); |
| 133 |
|
| 134 |
protected: |
| 135 |
virtual void closeEvent( QCloseEvent* ); |
| 136 |
virtual void keyPressEvent( QKeyEvent* ); |
| 137 |
virtual QSize sizeHint() const; |
| 138 |
virtual void resizeEvent ( QResizeEvent * event ); |
| 139 |
|
| 140 |
virtual void paletteChange( const QPalette & oldPalette ); |
| 141 |
|
| 142 |
private slots: |
| 143 |
void setRating1() { setRating( 1 ); } |
| 144 |
void setRating2() { setRating( 2 ); } |
| 145 |
void setRating3() { setRating( 3 ); } |
| 146 |
void setRating4() { setRating( 4 ); } |
| 147 |
void setRating5() { setRating( 5 ); } |
| 148 |
|
| 149 |
private: |
| 150 |
void init(); |
| 151 |
void setRating( int n ); |
| 152 |
void showBrowser( const int index ); |
| 153 |
|
| 154 |
/** |
| 155 |
* Try to restore saved layout, if this fails, try to use the default layout. |
| 156 |
*/ |
| 157 |
void restoreLayout(); |
| 158 |
|
| 159 |
CollectionWidget * m_collectionBrowser; |
| 160 |
PlaylistBrowserNS::PlaylistBrowser * m_playlistBrowser; |
| 161 |
|
| 162 |
QPointer<QMenuBar> m_menubar; |
| 163 |
QPointer<KMenu> m_toolsMenu; |
| 164 |
QPointer<KMenu> m_settingsMenu; |
| 165 |
QPointer<BrowserWidget> m_browsers; |
| 166 |
QStringList m_browserNames; |
| 167 |
QPointer<KMenu> m_searchMenu; |
| 168 |
//QPointer<KVBox> m_statusbarArea; |
| 169 |
|
| 170 |
QPointer<SearchWidget> m_searchWidget; |
| 171 |
QPointer<MainToolbar> m_controlBar; |
| 172 |
QPointer<Playlist::Widget> m_playlistWidget; |
| 173 |
QPointer<QTimer> m_timer; //search filter timer |
| 174 |
QPointer<QSplitter> m_splitter; |
| 175 |
|
| 176 |
QByteArray m_splitterState; |
| 177 |
|
| 178 |
QPointer<ContextWidget> m_contextWidget; |
| 179 |
QPointer<Context::ContextScene> m_corona; |
| 180 |
QPointer<Context::ContextView> m_contextView; |
| 181 |
QPointer<Context::ToolbarView> m_contextToolbarView; |
| 182 |
|
| 183 |
PlaylistFileProvider *m_playlistFiles; |
| 184 |
Meta::TrackPtr m_currentTrack; |
| 185 |
|
| 186 |
QDockWidget * m_browsersDock; |
| 187 |
QDockWidget * m_contextDock; |
| 188 |
QDockWidget * m_playlistDock; |
| 189 |
|
| 190 |
QWidget * m_browserDummyTitleBarWidget; |
| 191 |
QWidget * m_contextDummyTitleBarWidget; |
| 192 |
QWidget * m_playlistDummyTitleBarWidget; |
| 193 |
|
| 194 |
|
| 195 |
void createActions(); |
| 196 |
void createMenus(); |
| 197 |
int m_lastBrowser; |
| 198 |
int m_searchField; |
| 199 |
|
| 200 |
static QPointer<MainWindow> s_instance; |
| 201 |
|
| 202 |
bool m_layoutLocked; |
| 203 |
|
| 204 |
private slots: |
| 205 |
void createContextView( Plasma::Containment *c ); |
| 206 |
}; |
| 207 |
|
| 208 |
|
| 209 |
#endif //AMAROK_PLAYLISTWINDOW_H |