Qmmp
uihelper.h
1 /***************************************************************************
2  * Copyright (C) 2008-2019 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 #include "qmmpui_export.h"
33 
34 class QAction;
35 class QMenu;
36 class QWidget;
37 class General;
38 class GeneralFactory;
39 class JumpToTrackDialog;
40 
44 class QMMPUI_EXPORT UiHelper : public QObject
45 {
46  Q_OBJECT
47 public:
52  UiHelper(QObject *parent = 0);
56  ~UiHelper();
60  enum MenuType
61  {
62  TOOLS_MENU = 0,
64  ADD_MENU
65  };
69  bool visibilityControl();
76  void addAction(QAction *action, MenuType type = TOOLS_MENU);
80  void removeAction(QAction *action);
84  QList<QAction *> actions(MenuType type = TOOLS_MENU);
91  QMenu *createMenu(MenuType type, const QString &title = QString(), QWidget *parent = 0);
98  void registerMenu(MenuType type, QMenu *menu, QAction *before = 0);
104  void addFiles(QWidget *parent = qApp->activeWindow(),
111  void playFiles(QWidget *parent = qApp->activeWindow(),
118  void addDirectory(QWidget *parent = qApp->activeWindow(),
125  void addUrl(QWidget *parent = qApp->activeWindow(),
132  void loadPlayList(QWidget *parent = qApp->activeWindow(),
139  void savePlayList(QWidget *parent = qApp->activeWindow(),
146  void jumpToTrack(QWidget *parent = qApp->activeWindow(),
152  void about(QWidget *parent = 0);
156  static UiHelper* instance();
157 
158 public slots:
162  void toggleVisibility();
166  void showMainWindow();
170  void exit();
171 
172 signals:
177  void toggleVisibilityCalled();
182  void showMainWindowCalled();
183 
184 private slots:
185  void removeAction(QObject *action);
186  void addSelectedFiles(const QStringList &files, bool play);
187  void playSelectedFiles(const QStringList &files);
188  void disconnectPl();
189 
190 private:
191  QMap <GeneralFactory*, General*> m_generals;
192  struct MenuData
193  {
194  QPointer<QMenu> menu;
195  QPointer<QAction> before;
196  QList<QAction*> actions;
197  };
198  QMap<MenuType, MenuData> m_menus;
199  QString m_lastDir;
200  QPointer <JumpToTrackDialog> m_jumpDialog;
201  PlayListModel *m_model;
202  static UiHelper* m_instance;
203 };
204 
205 #endif
The General class provides simple access to general plugins.
Definition: general.h:34
The PlayListModel class provides a data model for the playlist.
Definition: playlistmodel.h:103
static PlayListManager * instance()
PlayListModel * selectedPlayList() const
Definition: uihelper.h:63
General plugin interface.
Definition: generalfactory.h:56
The UiHelper class provides simple api to access general plugins and some gui features.
Definition: uihelper.h:44
MenuType
Definition: uihelper.h:60