]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/DockView.cpp
Few string fixes from Dan.
[lyx.git] / src / frontends / qt / DockView.cpp
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 #include "GuiView.h"
16
17 #include <QKeyEvent>
18
19
20 namespace lyx {
21 namespace frontend {
22
23
24 DockView::DockView(GuiView & parent, QString const & name,
25                    QString const & title, Qt::DockWidgetArea area,
26                    Qt::WindowFlags flags)
27         : QDockWidget(&parent, flags), Dialog(parent, name, title)
28 {
29         setObjectName(name);
30         parent.addDockWidget(area, this);
31         hide();
32         connect(&parent, SIGNAL(bufferViewChanged()),
33                 this, SLOT(onBufferViewChanged()));
34
35         // Make dock widgets sub windows to prevent focusNextPrevChild
36         // (Tab key) switching to the parent rather than to the next
37         // widget in the pane (#12170)
38         setWindowFlags(Qt::SubWindow);
39 }
40
41
42 void DockView::keyPressEvent(QKeyEvent * ev)
43 {
44         if (ev->key() == Qt::Key_Escape) {
45                 QMainWindow * mw = static_cast<QMainWindow *>(parent());
46                 if (!mw) {
47                         ev->ignore();
48                         return;
49                 }
50                 mw->activateWindow();
51                 mw->setFocus();
52                 Qt::KeyboardModifiers mod = ev->modifiers();
53                 if (mod & Qt::AltModifier) {
54                         (setFloating(!isFloating()));
55                         ev->accept();
56                         return;
57                 }
58                 if (isFloating())
59                         hide();
60                 ev->accept();
61         }
62 }
63
64
65 } // namespace frontend
66 } // namespace lyx
67
68 #include "moc_DockView.cpp"