mainwnd.cpp 1.83 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
 * @date 6-Apr-2018
 * @license see 'LICENSE' file
 */

#include "mainwnd.h"
Tobias WEBER's avatar
Tobias WEBER committed
9
//#include <iostream>
Tobias WEBER's avatar
Tobias WEBER committed
10
11
12
13


MainWnd::MainWnd(QSettings* pSettings)
	: QMainWindow(), m_pSettings(pSettings), 
Tobias WEBER's avatar
Tobias WEBER committed
14
15
	m_pBrowser(new FileBrowser(this, pSettings)
)
Tobias WEBER's avatar
Tobias WEBER committed
16
{
Tobias WEBER's avatar
Tobias WEBER committed
17
	this->setObjectName("in20");
Tobias WEBER's avatar
Tobias WEBER committed
18
19
20
	this->setWindowTitle("IN20 Tool");
	this->resize(800, 600);

Tobias WEBER's avatar
Tobias WEBER committed
21
22
23
24
25
26
27

	// ------------------------------------------------------------------------
	// Menu Bar
	QMenu *pMenuView = new QMenu("View", m_pMenu);

	QAction *pShowFileBrowser = new QAction("Show File Browser", pMenuView);
	pShowFileBrowser->setChecked(m_pBrowser->isVisible());
Tobias WEBER's avatar
Tobias WEBER committed
28
	connect(pShowFileBrowser, &QAction::triggered, m_pBrowser, &FileBrowser::show);
Tobias WEBER's avatar
Tobias WEBER committed
29
30
31
	pMenuView->addAction(pShowFileBrowser);

	m_pMenu->addMenu(pMenuView);
Tobias WEBER's avatar
Tobias WEBER committed
32
	this->setMenuBar(m_pMenu);
Tobias WEBER's avatar
Tobias WEBER committed
33
34
35
	// ------------------------------------------------------------------------


Tobias WEBER's avatar
Tobias WEBER committed
36
	this->setStatusBar(m_pStatus);
Tobias WEBER's avatar
Tobias WEBER committed
37
38
39
	this->setCentralWidget(m_pMDI);
	this->addDockWidget(Qt::LeftDockWidgetArea, m_pBrowser);

Tobias WEBER's avatar
Tobias WEBER committed
40

Tobias WEBER's avatar
Tobias WEBER committed
41
42
	// ------------------------------------------------------------------------
	// restore settings
Tobias WEBER's avatar
Tobias WEBER committed
43
44
45
46
47
48
49
50
	if(m_pSettings)
	{
		// restore window state
		if(m_pSettings->contains("mainwnd/geo"))
			this->restoreGeometry(m_pSettings->value("mainwnd/geo").toByteArray());
		if(m_pSettings->contains("mainwnd/state"))
			this->restoreState(m_pSettings->value("mainwnd/state").toByteArray());
	}
Tobias WEBER's avatar
Tobias WEBER committed
51
	// ------------------------------------------------------------------------
Tobias WEBER's avatar
Tobias WEBER committed
52
53
54
55
}


MainWnd::~MainWnd()
Tobias WEBER's avatar
Tobias WEBER committed
56
57
58
59
{}


void MainWnd::showEvent(QShowEvent *pEvt)
Tobias WEBER's avatar
Tobias WEBER committed
60
{
Tobias WEBER's avatar
Tobias WEBER committed
61
	QMainWindow::showEvent(pEvt);
Tobias WEBER's avatar
Tobias WEBER committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
}


void MainWnd::closeEvent(QCloseEvent *pEvt)
{
	if(m_pSettings)
	{
		// save window state
		m_pSettings->setValue("mainwnd/geo", this->saveGeometry());
		m_pSettings->setValue("mainwnd/state", this->saveState());
	}

	QMainWindow::closeEvent(pEvt);
}