Qmmp
|
00001 /*************************************************************************** 00002 * Copyright (C) 2008-2012 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 addFile(QWidget *parent = qApp->activeWindow(), 00096 PlayListModel *model = PlayListManager::instance()->selectedPlayList()); 00102 void addDirectory(QWidget *parent = qApp->activeWindow(), 00103 PlayListModel *model = PlayListManager::instance()->selectedPlayList()); 00109 void loadPlayList(QWidget *parent = qApp->activeWindow(), 00110 PlayListModel *model = PlayListManager::instance()->selectedPlayList()); 00116 void savePlayList(QWidget *parent = qApp->activeWindow(), 00117 PlayListModel *model = PlayListManager::instance()->selectedPlayList()); 00123 void jumpToTrack(QWidget *parent = qApp->activeWindow(), 00124 PlayListModel *model = PlayListManager::instance()->selectedPlayList()); 00129 void about(QWidget *parent = 0); 00133 static UiHelper* instance(); 00134 00135 public slots: 00139 void toggleVisibility(); 00143 void exit(); 00144 00145 signals: 00150 void toggleVisibilityCalled(); 00151 00152 private slots: 00153 void removeAction(QObject *action); 00154 00155 private: 00156 QMap <GeneralFactory*, General*> m_generals; 00157 QList <QAction*> m_toolsActions; 00158 QList <QAction*> m_playlistActions; 00159 QPointer<QMenu> m_toolsMenu; 00160 QPointer<QMenu> m_playlistMenu; 00161 QString m_lastDir; 00162 QPointer <JumpToTrackDialog> m_jumpDialog; 00163 static UiHelper* m_instance; 00164 }; 00165 00166 #endif