subwindow.cpp
Go to the documentation of this file.
1 #include "subwindow.h"
2 #include <QDebug>
3 #include <QSettings>
4 #include <QMessageBox>
5 #include <QCloseEvent>
6 
7 SubWindow::SubWindow(QString name,
8  PlotMatrix *first_tab,
9  PlotDataMapRef &mapped_data,
10  QMainWindow *parent_window) :
11  QMainWindow(parent_window)
12 {
13  tabbed_widget_ = new TabbedPlotWidget( name, parent_window, first_tab, mapped_data, this );
14  this->setCentralWidget( tabbed_widget_ );
15 
16  Qt::WindowFlags flags = this->windowFlags();
17  this->setWindowFlags( flags | Qt::SubWindow );
18  this->setWindowTitle( tabbed_widget_->name() );
19 
20  QSettings settings;
21  restoreGeometry(settings.value( QString("SubWindow.%1.geometry").arg(name) ).toByteArray());
22 
23  this->setAttribute( Qt::WA_DeleteOnClose );
24 }
25 
27 {
28  QSettings settings;
29  settings.setValue(QString("SubWindow.%1.geometry").arg( tabbedWidget()->name() ), saveGeometry());
30  tabbed_widget_->close();
31 }
32 
33 void SubWindow::closeEvent(QCloseEvent *event)
34 {
35  QMessageBox::StandardButton reply;
36  reply = QMessageBox::question(this, tr("Warning"),
37  tr("Are you sure that you want to destroy this window?\n"),
38  QMessageBox::Yes | QMessageBox::No,
39  QMessageBox::Yes );
40 
41  if (reply != QMessageBox::Yes) {
42  event->ignore();
43  } else {
44  event->accept();
45  }
46 }
QString name() const
virtual void closeEvent(QCloseEvent *event) override
Definition: subwindow.cpp:33
SubWindow(QString name, PlotMatrix *first_tab, PlotDataMapRef &mapped_data, QMainWindow *parent_window)
Definition: subwindow.cpp:7
char name[1]
virtual ~SubWindow()
Definition: subwindow.cpp:26
void * arg
TabbedPlotWidget * tabbed_widget_
Definition: subwindow.h:24
TabbedPlotWidget * tabbedWidget()
Definition: subwindow.h:16
int flags


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:18