Qmmp
|
00001 /*************************************************************************** 00002 * Copyright (C) 2008-2016 by Ilya Kotov * 00003 * forkotov02@hotmail.ru * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 00019 ***************************************************************************/ 00020 #ifndef UiHelper_H 00021 #define UiHelper_H 00022 00023 #include <QObject> 00024 #include <QMap> 00025 #include <QList> 00026 #include <QPointer> 00027 #include <QStringList> 00028 #include <QApplication> 00029 #include <QPointer> 00030 #include "playlistmanager.h" 00031 #include "playlistmodel.h" 00032 00033 class QAction; 00034 class QMenu; 00035 class QWidget; 00036 class General; 00037 class GeneralFactory; 00038 class JumpToTrackDialog; 00039 00043 class UiHelper : public QObject 00044 { 00045 Q_OBJECT 00046 public: 00051 UiHelper(QObject *parent = 0); 00055 ~UiHelper(); 00059 enum MenuType 00060 { 00061 TOOLS_MENU = 0, 00062 PLAYLIST_MENU 00063 }; 00067 bool visibilityControl(); 00074 void addAction(QAction *action, MenuType type = TOOLS_MENU); 00078 void removeAction(QAction *action); 00082 QList<QAction *> actions(MenuType type = TOOLS_MENU); 00089 QMenu *createMenu(MenuType type, const QString &title = QString(), QWidget *parent = 0); 00095 void addFiles(QWidget *parent = qApp->activeWindow(), 00096 PlayListModel *model = PlayListManager::instance()->selectedPlayList()); 00102 void playFiles(QWidget *parent = qApp->activeWindow(), 00103 PlayListModel *model = PlayListManager::instance()->selectedPlayList()); 00109 void addDirectory(QWidget *parent = qApp->activeWindow(), 00110 PlayListModel *model = PlayListManager::instance()->selectedPlayList()); 00116 void addUrl(QWidget *parent = qApp->activeWindow(), 00117 PlayListModel *model = PlayListManager::instance()->selectedPlayList()); 00123 void loadPlayList(QWidget *parent = qApp->activeWindow(), 00124 PlayListModel *model = PlayListManager::instance()->selectedPlayList()); 00130 void savePlayList(QWidget *parent = qApp->activeWindow(), 00131 PlayListModel *model = PlayListManager::instance()->selectedPlayList()); 00137 void jumpToTrack(QWidget *parent = qApp->activeWindow(), 00138 PlayListModel *model = PlayListManager::instance()->selectedPlayList()); 00143 void about(QWidget *parent = 0); 00147 static UiHelper* instance(); 00148 00149 public slots: 00153 void toggleVisibility(); 00157 void showMainWindow(); 00161 void exit(); 00162 00163 signals: 00168 void toggleVisibilityCalled(); 00173 void showMainWindowCalled(); 00174 00175 private slots: 00176 void removeAction(QObject *action); 00177 void addSelectedFiles(const QStringList &files, bool play); 00178 void playSelectedFiles(const QStringList &files); 00179 void disconnectPl(); 00180 00181 private: 00182 QMap <GeneralFactory*, General*> m_generals; 00183 QList <QAction*> m_toolsActions; 00184 QList <QAction*> m_playlistActions; 00185 QPointer<QMenu> m_toolsMenu; 00186 QPointer<QMenu> m_playlistMenu; 00187 QString m_lastDir; 00188 QPointer <JumpToTrackDialog> m_jumpDialog; 00189 PlayListModel *m_model; 00190 static UiHelper* m_instance; 00191 }; 00192 00193 #endif