Qmmp
uihelper.h
1 /***************************************************************************
2  * Copyright (C) 2008-2018 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,
63  PLAYLIST_MENU
64  };
68  bool visibilityControl();
75  void addAction(QAction *action, MenuType type = TOOLS_MENU);
79  void removeAction(QAction *action);
83  QList<QAction *> actions(MenuType type = TOOLS_MENU);
90  QMenu *createMenu(MenuType type, const QString &title = QString(), QWidget *parent = 0);
96  void addFiles(QWidget *parent = qApp->activeWindow(),
103  void playFiles(QWidget *parent = qApp->activeWindow(),
110  void addDirectory(QWidget *parent = qApp->activeWindow(),
117  void addUrl(QWidget *parent = qApp->activeWindow(),
124  void loadPlayList(QWidget *parent = qApp->activeWindow(),
131  void savePlayList(QWidget *parent = qApp->activeWindow(),
138  void jumpToTrack(QWidget *parent = qApp->activeWindow(),
144  void about(QWidget *parent = 0);
148  static UiHelper* instance();
149 
150 public slots:
154  void toggleVisibility();
158  void showMainWindow();
162  void exit();
163 
164 signals:
169  void toggleVisibilityCalled();
174  void showMainWindowCalled();
175 
176 private slots:
177  void removeAction(QObject *action);
178  void addSelectedFiles(const QStringList &files, bool play);
179  void playSelectedFiles(const QStringList &files);
180  void disconnectPl();
181 
182 private:
183  QMap <GeneralFactory*, General*> m_generals;
184  QList <QAction*> m_toolsActions;
185  QList <QAction*> m_playlistActions;
186  QPointer<QMenu> m_toolsMenu;
187  QPointer<QMenu> m_playlistMenu;
188  QString m_lastDir;
189  QPointer <JumpToTrackDialog> m_jumpDialog;
190  PlayListModel *m_model;
191  static UiHelper* m_instance;
192 };
193 
194 #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
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