1 /*
2  * %kadu copyright begin%
3  * Copyright 2016 Rafał Przemysław Malinowski (rafal.przemyslaw.malinowski@gmail.com)
4  * %kadu copyright end%
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #pragma once
21 
22 #include <QtCore/QMap>
23 #include <QtCore/QObject>
24 #include <QtCore/QPointer>
25 #include <injeqt/injeqt.h>
26 
27 class Configuration;
28 class InjectedFactory;
29 class StatusContainer;
30 class StatusWindow;
31 
32 class StatusWindowService : public QObject
33 {
34 	Q_OBJECT
35 
36 public:
37 	Q_INVOKABLE explicit StatusWindowService(QObject *parent = nullptr);
38 	virtual ~StatusWindowService();
39 
40 	/**
41 	 * @short Shows new status window.
42 	 * @param statusContainer status container
43 	 * @param parent dialog's parent widget, null by default
44 	 * @return Pointer to the created StatusWindow dialog.
45 	 *
46 	 * Creates and shows new status window.
47 	 */
48 	StatusWindow * showDialog(StatusContainer *statusContainer, QWidget *parent = nullptr);
49 
50 private:
51 	QPointer<Configuration> m_configuration;
52 	QPointer<InjectedFactory> m_injectedFactory;
53 	QMap<StatusContainer *, StatusWindow *> m_dialogs;
54 
55 	StatusWindow * getDialog(StatusContainer *statusContainer, QWidget *parent = nullptr);
56 
57 private slots:
58 	INJEQT_SET void setConfiguration(Configuration *configuration);
59 	INJEQT_SET void setInjectedFactory(InjectedFactory *injectedFactory);
60 
61 	void statusWindowClosed(StatusContainer *statusContainer);
62 
63 };
64