VPTissue Reference Manual
ViewerWindow.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 Universiteit Antwerpen
3  *
4  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
5  * the European Commission - subsequent versions of the EUPL (the "Licence");
6  * You may not use this work except in compliance with the Licence.
7  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the Licence is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the Licence for the specific language governing
13  * permissions and limitations under the Licence.
14  */
20 #include "ViewerWindow.h"
21 
22 #include <QAction>
23 #include <QCloseEvent>
24 
25 using namespace std;
26 
27 namespace SimShell {
28 namespace Gui {
29 
30 ViewerWindow::ViewerWindow(const shared_ptr<Ws::MergedPreferences>& p, QWidget* parent, std::function<void()> on_close)
31  : QMainWindow(parent, Qt::Dialog), m_preferences(p), m_on_close(on_close)
32 {
33  setWindowModality(Qt::NonModal);
34 
35  auto pos_x = m_preferences->Get<int>("position.x");
36  auto pos_y = m_preferences->Get<int>("position.y");
37  auto size_x = m_preferences->Get<int>("size.x");
38  auto size_y = m_preferences->Get<int>("size.y");
39  setGeometry(pos_x, pos_y, size_x, size_y);
40 }
41 
42 ViewerWindow::~ViewerWindow()
43 {
44  auto g = geometry();
45  m_preferences->Put("position.x", g.x());
46  m_preferences->Put("position.y", g.y());
47  m_preferences->Put("size.x", g.width());
48  m_preferences->Put("size.y", g.height());
49 }
50 
51 void ViewerWindow::closeEvent(QCloseEvent* )
52 {
53  if (m_on_close)
54  m_on_close();
55 }
56 
57 } // end namespace Gui
58 } // end namespace SimShell
STL namespace.
Interface for ViewerWindow.
see the online Qt documentation
see the online Qt documentation
virtual void closeEvent(QCloseEvent *)
overrides QWidget::closeEvent
Namespace for generic graphical shell for simulators.
Definition: SimSession.h:32