1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org
4
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>>
5
* Copyright 2012, Leo Franchi <lfranchi@kde.org>
7
* Tomahawk is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
12
* Tomahawk is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
21
#ifndef TOMAHAWKACTIONCOLLECTION_H
22
#define TOMAHAWKACTIONCOLLECTION_H
26
#include <QtGui/QAction>
27
#include <QtGui/QMenuBar>
29
class DLLEXPORT ActionCollection : public QObject
34
// Categories for custom-registered actions
35
enum ActionDestination {
40
static ActionCollection* instance();
42
ActionCollection( QObject *parent );
48
* This method returns a main menu bar, suitable for Windows, Mac and X11.
50
QMenuBar *createMenuBar( QWidget *parent );
53
* Returns a QMenu with all the entries that would normally be in the main menu,
54
* arranged in a sensible way. The compressed menu makes absolutely no sense on Mac,
55
* and fairly little sense on Unity and other X11 desktop configurations which pull
56
* out the menu bar from the window.
58
QMenu *createCompactMenu( QWidget *parent );
60
QAction* getAction( const QString& name );
61
QList< QAction* > getAction( ActionDestination category );
62
QObject* actionNotifier( QAction* );
65
* Add an action for a specific category. The action will show up
66
* where the relevant category is displayed.
68
* e.g. if you register a Playlist action, it will be shown when
69
* there is a context menu shown for a playlist.
71
* When the QAction* is shown, it will have a "payload" property that is set
72
* to the <specific type> that is being shown.
74
* Additionally you can pass a QObject* that will be notified before the given
75
* action is shown. The slot "aboutToShow( QAction*, <specific type> ) will be called,
78
* <specific type> corresponds to the category: playlist_ptr for Playlists, etc.
80
* The Action Collection takes ownership of the action. It's time to let go.
82
void addAction( ActionDestination category, QAction* action, QObject* notify = 0 );
85
* Remove an action from one or all specific categories
87
void removeAction( QAction* action );
88
void removeAction( QAction* action, ActionDestination category );
91
void togglePrivateListeningMode();
94
void privacyModeChanged();
97
static ActionCollection* s_instance;
99
QHash< QString, QAction* > m_actionCollection;
100
QHash< ActionDestination, QList< QAction* > > m_categoryActions;
101
QHash< QAction*, QObject* > m_actionNotifiers;