VPTissue Reference Manual
ViewerDockWidget.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 "ViewerDockWidget.h"
21 
22 #include <QAction>
23 #include <QCloseEvent>
24 #include <QMainWindow>
25 
26 using namespace std;
27 
28 namespace SimShell {
29 namespace Gui {
30 
31 ViewerDockWidget::ViewerDockWidget(Qt::DockWidgetArea area, const shared_ptr<Ws::MergedPreferences>& p,
32  QWidget* parent, std::function<void()> on_close)
33  : QDockWidget(parent), m_preferences(p), m_on_close(on_close)
34 {
35  setWindowModality(Qt::NonModal);
36  static_cast<QMainWindow*>(parent)->addDockWidget(area, this);
37 
38  const auto pos_x = m_preferences->Get<int>("position.x");
39  const auto pos_y = m_preferences->Get<int>("position.y");
40  const auto size_x = m_preferences->Get<int>("size.x");
41  const auto size_y = m_preferences->Get<int>("size.y");
42  setGeometry(pos_x, pos_y, size_x, size_y);
43 }
44 
45 ViewerDockWidget::~ViewerDockWidget()
46 {
47  auto g = geometry();
48  m_preferences->Put("position.x", g.x());
49  m_preferences->Put("position.y", g.y());
50  m_preferences->Put("size.x", g.width());
51  m_preferences->Put("size.y", g.height());
52 }
53 
54 void ViewerDockWidget::closeEvent(QCloseEvent* )
55 {
56  if (m_on_close) {
57  m_on_close();
58  }
59 }
60 
61 } // end namespace Gui
62 } // end namespace SimShell
STL namespace.
Interface for ViewerDockWidget.
see the online Qt documentation
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