Qmmp
Loading...
Searching...
No Matches
uihelper.h
1/***************************************************************************
2 * Copyright (C) 2008-2025 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 "playlistmanager.h"
30#include "playlistmodel.h"
31#include "qmmpui_export.h"
32
33class QAction;
34class QMenu;
35class QWidget;
36class General;
37class GeneralFactory;
38class JumpToTrackDialog;
39
43class QMMPUI_EXPORT UiHelper : public QObject
44{
45 Q_OBJECT
46public:
51 UiHelper(QObject *parent = nullptr);
65
75 void addAction(QAction *action, MenuType type = TOOLS_MENU);
79 void removeAction(QAction *action);
83 QList<QAction *> actions(MenuType type = TOOLS_MENU);
91 QMenu *createMenu(MenuType type, const QString &title = QString(), bool autoHide = true, QWidget *parent = nullptr);
99 void registerMenu(MenuType type, QMenu *menu, bool autoHide = false, QAction *before = nullptr);
105 void addFiles(QWidget *parent = qApp->activeWindow(),
106 PlayListModel *model = PlayListManager::instance()->selectedPlayList());
112 void playFiles(QWidget *parent = qApp->activeWindow(),
113 PlayListModel *model = PlayListManager::instance()->selectedPlayList());
119 void addDirectory(QWidget *parent = qApp->activeWindow(),
120 PlayListModel *model = PlayListManager::instance()->selectedPlayList());
126 void addUrl(QWidget *parent = qApp->activeWindow(),
127 PlayListModel *model = PlayListManager::instance()->selectedPlayList());
133 void loadPlayList(QWidget *parent = qApp->activeWindow(),
134 PlayListModel *model = PlayListManager::instance()->selectedPlayList());
140 void savePlayList(QWidget *parent = qApp->activeWindow(),
141 PlayListModel *model = PlayListManager::instance()->selectedPlayList());
147 void jumpToTrack(QWidget *parent = qApp->activeWindow(),
148 PlayListModel *model = PlayListManager::instance()->selectedPlayList());
153 void about(QWidget *parent = nullptr);
158
159public slots:
171 void exit();
181 void replaceAndPlay(const QStringList &paths);
182
183signals:
198 void widgetAdded(const QString &id);
203 void widgetRemoved(const QString &id);
208 void widgetUpdated(const QString &id);
209
210private slots:
211 void removeAction(QObject *action);
212 void addSelectedFiles(const QStringList &files, bool play);
213 void playSelectedFiles(const QStringList &files);
214 void disconnectPl();
215
216private:
217 QMap <GeneralFactory*, General*> m_generals;
218 struct MenuData
219 {
220 QPointer<QMenu> menu;
221 QPointer<QAction> before;
222 QList<QAction*> actions;
223 bool autoHide = false;
224 };
225 QMap<MenuType, MenuData> m_menus;
226 QString m_lastDir;
227 QPointer <JumpToTrackDialog> m_jumpDialog;
228 PlayListModel *m_model = nullptr;
229 static UiHelper* m_instance;
230};
231
232#endif
General plugin interface.
Definition generalfactory.h:61
The General class provides simple access to general plugins.
Definition general.h:35
static PlayListManager * instance()
The PlayListModel class provides a data model for the playlist.
Definition playlistmodel.h:88
The UiHelper class provides simple api to access general plugins and some gui features.
Definition uihelper.h:44
void showMainWindow()
void about(QWidget *parent=nullptr)
void savePlayList(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())
void toggleVisibility()
void exit()
void removeAction(QAction *action)
void showMainWindowCalled()
void addUrl(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())
QMenu * createMenu(MenuType type, const QString &title=QString(), bool autoHide=true, QWidget *parent=nullptr)
static UiHelper * instance()
void widgetRemoved(const QString &id)
UiHelper(QObject *parent=nullptr)
void addAction(QAction *action, MenuType type=TOOLS_MENU)
void widgetUpdated(const QString &id)
void addFiles(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())
void replaceAndPlay(const QStringList &paths)
void playFiles(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())
void widgetAdded(const QString &id)
void registerMenu(MenuType type, QMenu *menu, bool autoHide=false, QAction *before=nullptr)
void jumpToTrack(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())
QList< QAction * > actions(MenuType type=TOOLS_MENU)
void addDirectory(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())
void toggleVisibilityCalled()
MenuType
Definition uihelper.h:60
@ ADD_MENU
Definition uihelper.h:63
@ TOOLS_MENU
Definition uihelper.h:61
@ PLAYLIST_MENU
Definition uihelper.h:62
bool visibilityControl()
void loadPlayList(QWidget *parent=qApp->activeWindow(), PlayListModel *model=PlayListManager::instance() ->selectedPlayList())