File indexing completed on 2024-04-21 04:47:51

0001 /****************************************************************************************
0002  * Copyright (c) 2002-2013 Mark Kretschmann <kretschmann@kde.org>                       *
0003  * Copyright (c) 2002 Max Howell <max.howell@methylblue.com>                            *
0004  *                                                                                      *
0005  * This program is free software; you can redistribute it and/or modify it under        *
0006  * the terms of the GNU General Public License as published by the Free Software        *
0007  * Foundation; either version 2 of the License, or (at your option) any later           *
0008  * version.                                                                             *
0009  *                                                                                      *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0013  *                                                                                      *
0014  * You should have received a copy of the GNU General Public License along with         *
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0016  ****************************************************************************************/
0017 
0018 #ifndef MAINWINDOW_H
0019 #define MAINWINDOW_H
0020 
0021 #include <config.h>
0022 
0023 #include "amarok_export.h"
0024 #include "core/meta/forward_declarations.h"
0025 
0026 #include <QPointer>
0027 
0028 #include <KMainWindow>
0029 #include <KToggleAction>
0030 
0031 #include <phonon/Global>
0032 
0033 class CollectionWidget;
0034 class SlimToolbar;
0035 class MainToolbar;
0036 class MainWindow;
0037 #ifdef DEBUG_BUILD_TYPE
0038 class NetworkAccessViewer;
0039 #endif // DEBUG_BUILD_TYPE
0040 
0041 namespace PlaylistBrowserNS { class PlaylistBrowser; }
0042 namespace Playlist { class Dock; }
0043 class BrowserDock;
0044 class ContextDock;
0045 
0046 
0047 class QMenu;
0048 class QMenuBar;
0049 
0050 namespace The {
0051     AMAROK_EXPORT MainWindow* mainWindow();
0052 }
0053 
0054 //This should only change if docks or toolbars are added or removed
0055 #define LAYOUT_VERSION 3
0056 
0057 /**
0058   * @class MainWindow
0059   * @short The MainWindow widget class.
0060   *
0061   * This is the main window widget.
0062   */
0063 class AMAROK_EXPORT MainWindow : public KMainWindow
0064 {
0065     Q_OBJECT
0066 
0067     public:
0068         enum AmarokDockId {
0069             AmarokDockNavigation,
0070             AmarokDockContext,
0071             AmarokDockPlaylist
0072         };
0073         
0074         MainWindow();
0075         ~MainWindow() override;
0076 
0077         void activate();
0078 
0079         //allows us to switch browsers from within other browsers etc
0080         void showBrowser( const QString& name );
0081 
0082         //ensures the dock widget is visible in case it is tabbed
0083         void showDock( AmarokDockId dockId );
0084 
0085         QPointer<BrowserDock> browserDock() const { return m_browserDock; }
0086         QPointer<QMenu> ToolsMenu() const { return m_toolsMenu; }
0087         QPointer<QMenu> SettingsMenu() const { return m_settingsMenu; }
0088         QPointer<Playlist::Dock> playlistDock() const { return m_playlistDock; }
0089         void deleteBrowsers();
0090 
0091         /* Reimplemented from QMainWindow to allow only one active toolbar at any time */
0092         QMenu* createPopupMenu() override;
0093 
0094         void addViewMenuItems(QMenu* menu);
0095 
0096         QString activeBrowserName();
0097 
0098         CollectionWidget * collectionBrowser();
0099 
0100         bool isLayoutLocked() const;
0101 
0102         /**
0103          *    If an audiocd collection is present. Stop current playback, clear playlist,
0104          *    add cd to playlist and start playback
0105          */
0106         bool playAudioCd();
0107 
0108         bool isWaitingForCd() const;
0109 
0110         /**
0111          * @return Whether the application is on the currently active virtual desktop. On non-X11 systems
0112            this is always true.
0113          */
0114         bool isOnCurrentDesktop() const;
0115 
0116     Q_SIGNALS:
0117         void loveTrack( Meta::TrackPtr track );
0118         void banTrack( Meta::TrackPtr track );
0119         void skipTrack();
0120         void switchQueueStateShortcut();
0121 
0122     public Q_SLOTS:
0123         void showHide();
0124         void slotFullScreen();
0125         void showNotificationPopup();
0126         void setLayoutLocked( bool locked );
0127         void resetLayout();
0128         void showAbout();
0129         void showReportBug();
0130 
0131     private Q_SLOTS:
0132         void setDefaultDockSizes();
0133 
0134         void slotLoveTrack();
0135         void slotBanTrack();
0136 
0137         void slotStopped();
0138         void slotPaused();
0139         void slotNewTrackPlaying();
0140         void slotMetadataChanged( Meta::TrackPtr track );
0141 
0142         void exportPlaylist();
0143         void slotShowActiveTrack() const;
0144         void slotEditTrackInfo() const;
0145         void slotShowBookmarkManager();
0146         void slotShowEqualizer();
0147         void slotShowCoverManager();
0148         void slotShowDiagnosticsDialog();
0149         void slotShowMenuBar();
0150         void slotPlayMedia();
0151         void slotAddLocation( bool directPlay = false );
0152         void slotAddStream();
0153         void slotFocusPlaylistSearch();
0154         void slotFocusCollectionSearch();
0155         void slotShufflePlaylist();
0156         void slotSeekForwardShort();
0157         void slotSeekForwardMedium();
0158         void slotSeekForwardLong();
0159         void slotSeekBackwardShort();
0160         void slotSeekBackwardMedium();
0161         void slotSeekBackwardLong();
0162         void slotPutCurrentTrackToClipboard();
0163 
0164 #ifdef DEBUG_BUILD_TYPE
0165         void showNetworkRequestViewer();
0166 #endif // DEBUG_BUILD_TYPE
0167 
0168     protected:
0169         void closeEvent( QCloseEvent* ) override;
0170         void changeEvent( QEvent *event ) override;
0171 
0172     private Q_SLOTS:
0173         void setRating1() { setRating( 1 ); }
0174         void setRating2() { setRating( 2 ); }
0175         void setRating3() { setRating( 3 ); }
0176         void setRating4() { setRating( 4 ); }
0177         void setRating5() { setRating( 5 ); }
0178 
0179     private:
0180         void init();
0181         void setRating( int n );
0182 
0183         CollectionWidget * m_collectionBrowser;
0184         PlaylistBrowserNS::PlaylistBrowser * m_playlistBrowser;
0185 
0186         QPointer<QMenuBar>  m_menubar;
0187         QPointer<QMenu>     m_toolsMenu;
0188         QPointer<QMenu>     m_settingsMenu;
0189 #ifdef DEBUG_BUILD_TYPE
0190         QPointer<NetworkAccessViewer> m_networkViewer;
0191 #endif // DEBUG_BUILD_TYPE
0192 
0193         QPointer<BrowserDock> m_browserDock;
0194         QPointer<ContextDock> m_contextDock;
0195         QPointer<Playlist::Dock> m_playlistDock;
0196 
0197         QPointer<SlimToolbar> m_slimToolbar;
0198         QPointer<MainToolbar> m_mainToolbar;
0199 
0200         void createActions();
0201         void createMenus();
0202 
0203         KToggleAction* m_showMenuBar;
0204 
0205         int m_lastBrowser;
0206         int m_searchField;
0207 
0208         bool m_waitingForCd;
0209 };
0210 
0211 
0212 #endif //AMAROK_PLAYLISTWINDOW_H
0213