subwindow.cpp
Go to the documentation of this file.
00001 #include "subwindow.h"
00002 #include <QDebug>
00003 #include <QSettings>
00004 #include <QMessageBox>
00005 #include <QCloseEvent>
00006 
00007 SubWindow::SubWindow(QString name,
00008                      PlotMatrix *first_tab,
00009                      PlotDataMapRef &mapped_data,
00010                      QMainWindow *parent_window) :
00011   QMainWindow(parent_window)
00012 {
00013     tabbed_widget_ = new TabbedPlotWidget( name, parent_window, first_tab, mapped_data, this );
00014     this->setCentralWidget( tabbed_widget_ );
00015 
00016     Qt::WindowFlags flags = this->windowFlags();
00017     this->setWindowFlags( flags | Qt::SubWindow );
00018     this->setWindowTitle( tabbed_widget_->name() );
00019 
00020     QSettings settings;
00021     restoreGeometry(settings.value( QString("SubWindow.%1.geometry").arg(name) ).toByteArray());
00022 
00023     this->setAttribute( Qt::WA_DeleteOnClose );
00024 }
00025 
00026 SubWindow::~SubWindow()
00027 {
00028     QSettings settings;
00029     settings.setValue(QString("SubWindow.%1.geometry").arg( tabbedWidget()->name() ), saveGeometry());
00030     tabbed_widget_->close();
00031 }
00032 
00033 void SubWindow::closeEvent(QCloseEvent *event)
00034 {
00035     QMessageBox::StandardButton reply;
00036     reply = QMessageBox::question(this, tr("Warning"),
00037                                   tr("Are you sure that you want to destroy this window?\n"),
00038                                   QMessageBox::Yes | QMessageBox::No,
00039                                   QMessageBox::Yes );
00040 
00041     if (reply != QMessageBox::Yes) {
00042         event->ignore();
00043     } else {
00044         event->accept();
00045     }
00046 }


plotjuggler
Author(s): Davide Faconti
autogenerated on Wed Jul 3 2019 19:28:05