]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QLMenubar.C
Sane ordering of the files #included in the Qt frontend.
[lyx.git] / src / frontends / qt2 / QLMenubar.C
1 /**
2  * \file qt2/QLMenubar.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 // Qt defines a macro 'signals' that clashes with a boost namespace.
14 // All is well if the namespace is visible first.
15 #include "QtView.h"
16
17 #include "QLMenubar.h"
18 #include "QLPopupMenu.h"
19
20 #include "MenuBackend.h"
21
22 #include <qmenubar.h>
23 #include <qcursor.h>
24
25
26 using std::pair;
27 using std::string;
28
29 namespace lyx {
30 namespace frontend {
31
32 QLMenubar::QLMenubar(LyXView * view, MenuBackend const & mbe)
33         : owner_(static_cast<QtView*>(view)), menubackend_(mbe)
34 {
35         Menu::const_iterator m = mbe.getMenubar().begin();
36         Menu::const_iterator end = mbe.getMenubar().end();
37         for (; m != end; ++m) {
38                 pair<int, QLPopupMenu *> menu =
39                         createMenu(owner_->menuBar(), &(*m), this, true);
40                 name_map_[m->submenuname()] = menu.second;
41 #ifdef Q_WS_MACX
42                 /* The qt/mac menu code has a very silly hack that
43                    moves some menu entries that it recognizes by name
44                    (ex: "Preferences...") to the "LyX" menu. This
45                    feature can only work if the menu entries are
46                    always available. Since we build menus on demand,
47                    we have to have a reasonable default value before
48                    the menus have been explicitely opened. (JMarc)
49                 */
50                 menu.second->showing();
51 #endif
52         }
53 }
54
55
56 void QLMenubar::openByName(string const & name)
57 {
58         NameMap::const_iterator const cit = name_map_.find(name);
59         if (cit == name_map_.end())
60                 return;
61
62         // this will have to do I'm afraid.
63         cit->second->exec(QCursor::pos());
64 }
65
66
67 void QLMenubar::update()
68 {}
69
70
71 QtView * QLMenubar::view()
72 {
73         return owner_;
74 }
75
76
77 MenuBackend const & QLMenubar::backend()
78 {
79         return menubackend_;
80 }
81
82 } // namespace frontend
83 } // namespace lyx