source: trunk/FACT++/gui/DockWindow.cc @ 10394

Last change on this file since 10394 was 10394, checked in by tbretz, 9 years ago
First version of the GUI.
File size: 1.1 KB
Line 
1#include "DockWindow.h"
2
3#include <QtGui/QDockWidget>
4
5#include <stdexcept>
6
7using namespace std;
8
9DockWindow::DockWindow(QDockWidget *d, const QString &name)
10    : fDockWidget(d), fGeometry(d->geometry())
11{
12    QObject *w0 = d->parent();   // QWidget
13    if (!w0)
14        throw runtime_error("1st parent of QDockWidget is NULL");
15
16    QObject *w1 = w0->parent();  // QWidget
17    if (!w1)
18        throw runtime_error("2nd parent of QDockWidget is NULL");
19
20    QObject *w2 = w1->parent();  // QWidget
21    if (!w2)
22            throw runtime_error("3rd parent of QDockWidget is NULL");
23
24    fTabWidget = dynamic_cast<QTabWidget*>(w2);
25    if (!fTabWidget)
26        throw runtime_error("3rd parent of QDockWidget is not a QTabWidget");
27
28    setGeometry(fGeometry);
29    addDockWidget(Qt::LeftDockWidgetArea, fDockWidget);
30    setWindowTitle(name);
31}
32
33void DockWindow::closeEvent(QCloseEvent *)
34{
35    QWidget *w = new QWidget;
36
37    fTabWidget->addTab(w, windowTitle());
38
39    fDockWidget->setParent(w);
40    fDockWidget->setGeometry(fGeometry);
41
42    fTabWidget->setTabsClosable(true);
43}
Note: See TracBrowser for help on using the repository browser.