1 // -*- C++ -*-
2 /**
3  * \file DockView.cpp
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Abdelrazak Younes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11 
12 #include <config.h>
13 
14 #include "DockView.h"
15 
16 
17 namespace lyx {
18 namespace frontend {
19 
20 
DockView(GuiView & parent,QString const & name,QString const & title,Qt::DockWidgetArea area,Qt::WindowFlags flags)21 DockView::DockView(GuiView & parent, QString const & name,
22                    QString const & title, Qt::DockWidgetArea area,
23                    Qt::WindowFlags flags)
24 	: QDockWidget(&parent, flags), Dialog(parent, name, title)
25 {
26 	setObjectName(name);
27 	parent.addDockWidget(area, this);
28 	hide();
29 	connect(&parent, SIGNAL(bufferViewChanged()),
30 	        this, SLOT(onBufferViewChanged()));
31 }
32 
33 
keyPressEvent(QKeyEvent * ev)34 void DockView::keyPressEvent(QKeyEvent * ev)
35 {
36 	if (ev->key() == Qt::Key_Escape) {
37 		QMainWindow * mw = static_cast<QMainWindow *>(parent());
38 		if (!mw) {
39 			ev->ignore();
40 			return;
41 		}
42 		mw->activateWindow();
43 		mw->setFocus();
44 		if (isFloating())
45 			hide();
46 		ev->accept();
47 	}
48 }
49 
50 
51 } // namespace frontend
52 } // namespace lyx
53 
54 #include "moc_DockView.cpp"
55