mainwnd.h 2.06 KB
Newer Older
Tobias WEBER's avatar
Tobias WEBER committed
1
2
/**
 * in20 data analysis tool
Tobias WEBER's avatar
Tobias WEBER committed
3
 * @author Tobias Weber <tweber@ill.fr>
Tobias WEBER's avatar
Tobias WEBER committed
4
5
6
7
8
9
10
 * @date 6-Apr-2018
 * @license see 'LICENSE' file
 */

#ifndef __IN20MAINWND_H__
#define __IN20MAINWND_H__

Tobias WEBER's avatar
Tobias WEBER committed
11
12
13
14
#include <QtCore/QSettings>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMdiArea>
#include <QtWidgets/QMenuBar>
15
#include <QtWidgets/QMenu>
Tobias WEBER's avatar
Tobias WEBER committed
16
17
18
#include <QtWidgets/QStatusBar>

#include "filebrowser.h"
Tobias WEBER's avatar
Tobias WEBER committed
19
#include "workspace.h"
20
#include "command.h"
Tobias WEBER's avatar
Tobias WEBER committed
21
#include "plot.h"
Tobias WEBER's avatar
Tobias WEBER committed
22

Tobias WEBER's avatar
Tobias WEBER committed
23
24
25
#include <boost/dll/shared_library.hpp>
#include <memory>

Tobias WEBER's avatar
Tobias WEBER committed
26

Tobias WEBER's avatar
Tobias WEBER committed
27
28
29
30
31
32

/**
 * dialog plugins
 */
struct PluginDlg
{
Tobias WEBER's avatar
Tobias WEBER committed
33
	std::shared_ptr<boost::dll::shared_library> dll;
Tobias WEBER's avatar
Tobias WEBER committed
34
	std::string ty, name, descr;
Tobias WEBER's avatar
Tobias WEBER committed
35
	bool inited = false;
Tobias WEBER's avatar
Tobias WEBER committed
36
37
38
39
40
41
42
43
44
45

	using t_descr = const char*(*)();
	using t_init = bool(*)();
	using t_create = QDialog*(*)(QWidget*);
	using t_destroy = void(*)(QDialog*);

	t_descr f_descr = nullptr;
	t_init f_init = nullptr;
	t_create f_create = nullptr;
	t_destroy f_destroy = nullptr;
Tobias WEBER's avatar
Tobias WEBER committed
46
47

	QDialog *dlg = nullptr;
Tobias WEBER's avatar
Tobias WEBER committed
48
49
50
51
52
53
54
};



/**
 * main dialog
 */
Tobias WEBER's avatar
Tobias WEBER committed
55
56
57
58
class MainWnd : public QMainWindow
{
private:
	QSettings *m_pSettings = nullptr;
Tobias WEBER's avatar
Tobias WEBER committed
59

Tobias WEBER's avatar
Tobias WEBER committed
60
	QMenuBar *m_pMenu = new QMenuBar(this);
Tobias WEBER's avatar
Tobias WEBER committed
61
	QMenu *m_pmenuPluginTools = nullptr;
Tobias WEBER's avatar
Tobias WEBER committed
62
	//QStatusBar *m_pStatus = new QStatusBar(this);
Tobias WEBER's avatar
Tobias WEBER committed
63
	QMdiArea *m_pMDI = new QMdiArea(this);
Tobias WEBER's avatar
Tobias WEBER committed
64

Tobias WEBER's avatar
Tobias WEBER committed
65
	FileBrowser *m_pBrowser = nullptr;
Tobias WEBER's avatar
Tobias WEBER committed
66
	WorkSpace *m_pWS = nullptr;
67
	CommandLine *m_pCLI = nullptr;
Tobias WEBER's avatar
Tobias WEBER committed
68
	PlotterDock *m_pCurPlot = nullptr;
Tobias WEBER's avatar
Tobias WEBER committed
69

70
71
72
73
	QMenu *m_menuOpenRecent = nullptr;
	QStringList m_recentFiles;
	QString m_curFile;

Tobias WEBER's avatar
Tobias WEBER committed
74
75
	std::vector<PluginDlg> m_plugin_dlgs;

Tobias WEBER's avatar
Tobias WEBER committed
76
protected:
Tobias WEBER's avatar
Tobias WEBER committed
77
	virtual void showEvent(QShowEvent *pEvt) override;
Tobias WEBER's avatar
Tobias WEBER committed
78
79
	virtual void closeEvent(QCloseEvent *pEvt) override;

80
81
82
83
84
	void SetCurrentFile(const QString &file);
	void SetRecentFiles(const QStringList &files);
	void AddRecentFile(const QString &file);
	void RebuildRecentFiles();

Tobias WEBER's avatar
Tobias WEBER committed
85
	void LoadPlugins();
Tobias WEBER's avatar
Tobias WEBER committed
86
	void UnloadPlugins();
Tobias WEBER's avatar
Tobias WEBER committed
87

Tobias WEBER's avatar
Tobias WEBER committed
88
89
90
public:
	MainWnd(QSettings* pSettings = nullptr);
	virtual ~MainWnd();
Tobias WEBER's avatar
Tobias WEBER committed
91

92
93
94
95
96
97
98
99
100
	// session file menu operations
	void NewFile();
	void OpenFile();
	void SaveFile();
	void SaveFileAs();

	// actual session file operations
	bool OpenFile(const QString &file);
	bool SaveFile(const QString &file);
Tobias WEBER's avatar
Tobias WEBER committed
101
102
103
};

#endif