]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/DockView.cpp
Url errors 37 & 38 correction
[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         connect(this, SIGNAL(visibilityChanged(bool)),
35                 &parent, SLOT(onDockWidgetVisibilityChanged()));
36
37
38         // Make dock widgets sub windows to prevent focusNextPrevChild
39         // (Tab key) switching to the parent rather than to the next
40         // widget in the pane (#12170)
41         setWindowFlags(Qt::SubWindow);
42 }
43
44
45 void DockView::keyPressEvent(QKeyEvent * ev)
46 {
47         if (ev->key() == Qt::Key_Escape) {
48                 QMainWindow * mw = static_cast<QMainWindow *>(parent());
49                 if (!mw) {
50                         ev->ignore();
51                         return;
52                 }
53                 mw->activateWindow();
54                 mw->setFocus();
55                 Qt::KeyboardModifiers mod = ev->modifiers();
56                 if (mod & Qt::AltModifier) {
57                         (setFloating(!isFloating()));
58                         ev->accept();
59                         return;
60                 }
61                 if (isFloating())
62                         hide();
63                 ev->accept();
64         }
65 }
66
67
68 } // namespace frontend
69 } // namespace lyx
70
71 #include "moc_DockView.cpp"