Qmmp
uihelper.h
1 /***************************************************************************
2  * Copyright (C) 2008-2016 by Ilya Kotov *
3  * forkotov02@ya.ru *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 #ifndef UiHelper_H
21 #define UiHelper_H
22 
23 #include <QObject>
24 #include <QMap>
25 #include <QList>
26 #include <QPointer>
27 #include <QStringList>
28 #include <QApplication>
29 #include <QPointer>
30 #include "playlistmanager.h"
31 #include "playlistmodel.h"
32 
33 class QAction;
34 class QMenu;
35 class QWidget;
36 class General;
37 class GeneralFactory;
38 class JumpToTrackDialog;
39 
43 class UiHelper : public QObject
44 {
45  Q_OBJECT
46 public:
51  UiHelper(QObject *parent = 0);
55  ~UiHelper();
59  enum MenuType
60  {
61  TOOLS_MENU = 0,
63  };
67  bool visibilityControl();
74  void addAction(QAction *action, MenuType type = TOOLS_MENU);
78  void removeAction(QAction *action);
82  QList<QAction *> actions(MenuType type = TOOLS_MENU);
89  QMenu *createMenu(MenuType type, const QString &title = QString(), QWidget *parent = 0);
95  void addFiles(QWidget *parent = qApp->activeWindow(),
102  void playFiles(QWidget *parent = qApp->activeWindow(),
109  void addDirectory(QWidget *parent = qApp->activeWindow(),
116  void addUrl(QWidget *parent = qApp->activeWindow(),
123  void loadPlayList(QWidget *parent = qApp->activeWindow(),
130  void savePlayList(QWidget *parent = qApp->activeWindow(),
137  void jumpToTrack(QWidget *parent = qApp->activeWindow(),
143  void about(QWidget *parent = 0);
147  static UiHelper* instance();
148 
149 public slots:
153  void toggleVisibility();
157  void showMainWindow();
161  void exit();
162 
163 signals:
168  void toggleVisibilityCalled();
173  void showMainWindowCalled();
174 
175 private slots:
176  void removeAction(QObject *action);
177  void addSelectedFiles(const QStringList &files, bool play);
178  void playSelectedFiles(const QStringList &files);
179  void disconnectPl();
180 
181 private:
182  QMap <GeneralFactory*, General*> m_generals;
183  QList <QAction*> m_toolsActions;
184  QList <QAction*> m_playlistActions;
185  QPointer<QMenu> m_toolsMenu;
186  QPointer<QMenu> m_playlistMenu;
187  QString m_lastDir;
188  QPointer <JumpToTrackDialog> m_jumpDialog;
189  PlayListModel *m_model;
190  static UiHelper* m_instance;
191 };
192 
193 #endif
The General class provides simple access to general plugins.
Definition: general.h:33
static UiHelper * instance()
The PlayListModel class provides a data model for the playlist.
Definition: playlistmodel.h:101
void jumpToTrack(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())
void toggleVisibilityCalled()
void savePlayList(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())
void removeAction(QAction *action)
static PlayListManager * instance()
void toggleVisibility()
Definition: uihelper.h:61
void showMainWindow()
QMenu * createMenu(MenuType type, const QString &title=QString(), QWidget *parent=0)
void addAction(QAction *action, MenuType type=TOOLS_MENU)
void showMainWindowCalled()
void exit()
PlayListModel * selectedPlayList() const
void playFiles(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())
Definition: uihelper.h:62
bool visibilityControl()
void about(QWidget *parent=0)
General plugin interface.
Definition: generalfactory.h:55
void addDirectory(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())
void loadPlayList(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())
QList< QAction * > actions(MenuType type=TOOLS_MENU)
The UiHelper class provides simple api to access general plugins and some gui features.
Definition: uihelper.h:43
UiHelper(QObject *parent=0)
void addFiles(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())
void addUrl(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())
MenuType
Definition: uihelper.h:59