1 /**************************************************************************************** 2 * Copyright (c) 2002-2013 Mark Kretschmann <kretschmann@kde.org> * 3 * Copyright (c) 2002 Max Howell <max.howell@methylblue.com> * 4 * * 5 * This program is free software; you can redistribute it and/or modify it under * 6 * the terms of the GNU General Public License as published by the Free Software * 7 * Foundation; either version 2 of the License, or (at your option) any later * 8 * version. * 9 * * 10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 12 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 13 * * 14 * You should have received a copy of the GNU General Public License along with * 15 * this program. If not, see <http://www.gnu.org/licenses/>. * 16 ****************************************************************************************/ 17 18 #ifndef MAINWINDOW_H 19 #define MAINWINDOW_H 20 21 #include <config.h> 22 23 #include "amarok_export.h" 24 #include "core/meta/forward_declarations.h" 25 26 #include <QPointer> 27 28 #include <KMainWindow> 29 #include <KToggleAction> 30 31 #include <phonon/Global> 32 33 class CollectionWidget; 34 class SlimToolbar; 35 class MainToolbar; 36 class MainWindow; 37 #ifdef DEBUG_BUILD_TYPE 38 class NetworkAccessViewer; 39 #endif // DEBUG_BUILD_TYPE 40 41 namespace PlaylistBrowserNS { class PlaylistBrowser; } 42 namespace Playlist { class Dock; } 43 class BrowserDock; 44 class ContextDock; 45 46 47 class QMenu; 48 class QMenuBar; 49 50 namespace The { 51 AMAROK_EXPORT MainWindow* mainWindow(); 52 } 53 54 //This should only change if docks or toolbars are added or removed 55 #define LAYOUT_VERSION 3 56 57 /** 58 * @class MainWindow 59 * @short The MainWindow widget class. 60 * 61 * This is the main window widget. 62 */ 63 class AMAROK_EXPORT MainWindow : public KMainWindow 64 { 65 Q_OBJECT 66 67 public: 68 enum AmarokDockId { 69 AmarokDockNavigation, 70 AmarokDockContext, 71 AmarokDockPlaylist 72 }; 73 74 MainWindow(); 75 ~MainWindow() override; 76 77 void activate(); 78 79 //allows us to switch browsers from within other browsers etc 80 void showBrowser( const QString& name ); 81 82 //ensures the dock widget is visible in case it is tabbed 83 void showDock( AmarokDockId dockId ); 84 browserDock()85 QPointer<BrowserDock> browserDock() const { return m_browserDock; } ToolsMenu()86 QPointer<QMenu> ToolsMenu() const { return m_toolsMenu; } SettingsMenu()87 QPointer<QMenu> SettingsMenu() const { return m_settingsMenu; } playlistDock()88 QPointer<Playlist::Dock> playlistDock() const { return m_playlistDock; } 89 void deleteBrowsers(); 90 91 /* Reimplemented from QMainWindow to allow only one active toolbar at any time */ 92 QMenu* createPopupMenu() override; 93 94 void addViewMenuItems(QMenu* menu); 95 96 QString activeBrowserName(); 97 98 CollectionWidget * collectionBrowser(); 99 100 bool isLayoutLocked() const; 101 102 /** 103 * If an audiocd collection is present. Stop current playback, clear playlist, 104 * add cd to playlist and start playback 105 */ 106 bool playAudioCd(); 107 108 bool isWaitingForCd() const; 109 110 /** 111 * @return Whether the application is on the currently active virtual desktop. On non-X11 systems 112 this is always true. 113 */ 114 bool isOnCurrentDesktop() const; 115 116 Q_SIGNALS: 117 void loveTrack( Meta::TrackPtr track ); 118 void banTrack( Meta::TrackPtr track ); 119 void skipTrack(); 120 void switchQueueStateShortcut(); 121 122 public Q_SLOTS: 123 void showHide(); 124 void slotFullScreen(); 125 void showNotificationPopup(); 126 void setLayoutLocked( bool locked ); 127 void resetLayout(); 128 void showAbout(); 129 void showReportBug(); 130 131 private Q_SLOTS: 132 void setDefaultDockSizes(); 133 134 void slotLoveTrack(); 135 void slotBanTrack(); 136 137 void slotStopped(); 138 void slotPaused(); 139 void slotNewTrackPlaying(); 140 void slotMetadataChanged( Meta::TrackPtr track ); 141 142 void exportPlaylist(); 143 void slotShowActiveTrack() const; 144 void slotEditTrackInfo() const; 145 void slotShowBookmarkManager(); 146 void slotShowEqualizer(); 147 void slotShowCoverManager(); 148 void slotShowDiagnosticsDialog(); 149 void slotShowMenuBar(); 150 void slotPlayMedia(); 151 void slotAddLocation( bool directPlay = false ); 152 void slotAddStream(); 153 void slotFocusPlaylistSearch(); 154 void slotFocusCollectionSearch(); 155 void slotShufflePlaylist(); 156 void slotSeekForwardShort(); 157 void slotSeekForwardMedium(); 158 void slotSeekForwardLong(); 159 void slotSeekBackwardShort(); 160 void slotSeekBackwardMedium(); 161 void slotSeekBackwardLong(); 162 void slotPutCurrentTrackToClipboard(); 163 164 #ifdef DEBUG_BUILD_TYPE 165 void showNetworkRequestViewer(); 166 #endif // DEBUG_BUILD_TYPE 167 168 protected: 169 void closeEvent( QCloseEvent* ) override; 170 void changeEvent( QEvent *event ) override; 171 172 private Q_SLOTS: setRating1()173 void setRating1() { setRating( 1 ); } setRating2()174 void setRating2() { setRating( 2 ); } setRating3()175 void setRating3() { setRating( 3 ); } setRating4()176 void setRating4() { setRating( 4 ); } setRating5()177 void setRating5() { setRating( 5 ); } 178 179 private: 180 void init(); 181 void setRating( int n ); 182 183 CollectionWidget * m_collectionBrowser; 184 PlaylistBrowserNS::PlaylistBrowser * m_playlistBrowser; 185 186 QPointer<QMenuBar> m_menubar; 187 QPointer<QMenu> m_toolsMenu; 188 QPointer<QMenu> m_settingsMenu; 189 #ifdef DEBUG_BUILD_TYPE 190 QPointer<NetworkAccessViewer> m_networkViewer; 191 #endif // DEBUG_BUILD_TYPE 192 193 QPointer<BrowserDock> m_browserDock; 194 QPointer<ContextDock> m_contextDock; 195 QPointer<Playlist::Dock> m_playlistDock; 196 197 QPointer<SlimToolbar> m_slimToolbar; 198 QPointer<MainToolbar> m_mainToolbar; 199 200 void createActions(); 201 void createMenus(); 202 203 KToggleAction* m_showMenuBar; 204 205 int m_lastBrowser; 206 int m_searchField; 207 208 bool m_waitingForCd; 209 }; 210 211 212 #endif //AMAROK_PLAYLISTWINDOW_H 213 214