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 "provider/default-provider.h"
23 #include "provider/simple-provider.h"
24 #include "exports.h"
25 
26 #include <QtCore/QObject>
27 #include <QtCore/QPointer>
28 #include <injeqt/injeqt.h>
29 
30 class InjectedFactory;
31 class KaduWindow;
32 
33 class KADUAPI KaduWindowService : public QObject
34 {
35 	Q_OBJECT
36 
37 public:
38 	Q_INVOKABLE explicit KaduWindowService(QObject *parent = nullptr);
39 	virtual ~KaduWindowService();
40 
41 	void createWindow();
42 
43 	KaduWindow * kaduWindow();
44 	void showMainWindow();
45 
46 	void setShowMainWindowOnStart(bool showMainWindowOnStart);
47 	std::shared_ptr<DefaultProvider<QWidget *>> mainWindowProvider() const;
48 
49 private:
50 	QPointer<InjectedFactory> m_injectedFactory;
51 
52 	KaduWindow *m_kaduWindow;
53 	std::shared_ptr<SimpleProvider<QWidget *>> m_kaduWindowProvider;
54 	std::shared_ptr<DefaultProvider<QWidget *>> m_mainWindowProvider;
55 	bool m_showMainWindowOnStart; // TODO: it is a hack for docking
56 
57 private slots:
58 	INJEQT_SET void setInjectedFactory(InjectedFactory *injectedFactory);
59 	INJEQT_DONE void done();
60 
61 	void kaduWindowDestroyed();
62 
63 };
64