X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffrontends%2Fqt4%2FGuiPopupMenu.cpp;h=6a37dc896f7c2a7226f2a646f4431fe3d0eee6d6;hb=3ffd3f51a12470c7805f3b99385658b9eebd846d;hp=9b479fc7d4d405d3f4a9e27830eb867fae01c792;hpb=a1cec91afaca91968b46e695533c10ad2a3f73d3;p=lyx.git diff --git a/src/frontends/qt4/GuiPopupMenu.cpp b/src/frontends/qt4/GuiPopupMenu.cpp index 9b479fc7d4..6a37dc896f 100644 --- a/src/frontends/qt4/GuiPopupMenu.cpp +++ b/src/frontends/qt4/GuiPopupMenu.cpp @@ -11,48 +11,39 @@ #include -#include - -// Qt defines a macro 'signals' that clashes with a boost namespace. -// All is well if the namespace is visible first. #include "GuiView.h" #include "Action.h" #include "GuiPopupMenu.h" -#include "GuiMenubar.h" #include "qt_helpers.h" +#include "LyXFunc.h" #include "MenuBackend.h" #include "support/lstrings.h" -#include "debug.h" - - -using std::make_pair; -using std::string; -using std::pair; -using std::endl; +#include "support/debug.h" +#include namespace lyx { namespace frontend { -GuiPopupMenu::GuiPopupMenu(GuiMenubar * owner, - MenuItem const & mi, bool topLevelMenu) - : owner_(owner) +GuiPopupMenu::GuiPopupMenu(GuiView * owner, MenuItem const & mi, + bool topLevelMenu) + : QMenu(owner), owner_(owner) { name_ = mi.submenuname(); setTitle(toqstr(getLabel(mi))); if (topLevelMenu) - connect(this, SIGNAL(aboutToShow()), this, SLOT(update())); + connect(this, SIGNAL(aboutToShow()), this, SLOT(updateView())); } -void GuiPopupMenu::update() +void GuiPopupMenu::updateView() { - LYXERR(Debug::GUI) << BOOST_CURRENT_FUNCTION << endl; - LYXERR(Debug::GUI) << "\tTriggered menu: " << to_utf8(name_) << endl; + LYXERR(Debug::GUI, "GuiPopupMenu::updateView()" + << "\tTriggered menu: " << to_utf8(name_)); clear(); @@ -60,14 +51,14 @@ void GuiPopupMenu::update() return; // Here, We make sure that theLyXFunc points to the correct LyXView. - theLyXFunc().setLyXView(owner_->view()); + theLyXFunc().setLyXView(owner_); - Menu const & fromLyxMenu = owner_->backend().getMenu(name_); - owner_->backend().expand(fromLyxMenu, topLevelMenu_, owner_->view()->buffer()); + Menu const & fromLyxMenu = menubackend.getMenu(name_); + menubackend.expand(fromLyxMenu, topLevelMenu_, owner_->buffer()); - if (!owner_->backend().hasMenu(topLevelMenu_.name())) { - LYXERR(Debug::GUI) << "\tWARNING: menu seems empty" - << to_utf8(topLevelMenu_.name()) << endl; + if (!menubackend.hasMenu(topLevelMenu_.name())) { + LYXERR(Debug::GUI, "\tWARNING: menu seems empty" + << to_utf8(topLevelMenu_.name())); } populate(this, &topLevelMenu_); } @@ -75,15 +66,12 @@ void GuiPopupMenu::update() void GuiPopupMenu::populate(QMenu * qMenu, Menu * menu) { - LYXERR(Debug::GUI) << "populating menu " << to_utf8(menu->name()) ; + LYXERR(Debug::GUI, "populating menu " << to_utf8(menu->name())); if (menu->size() == 0) { - LYXERR(Debug::GUI) << "\tERROR: empty menu " - << to_utf8(menu->name()) << endl; + LYXERR(Debug::GUI, "\tERROR: empty menu " << to_utf8(menu->name())); return; } - else { - LYXERR(Debug::GUI) << " ***** menu entries " << menu->size() << endl; - } + LYXERR(Debug::GUI, " ***** menu entries " << menu->size()); Menu::const_iterator m = menu->begin(); Menu::const_iterator end = menu->end(); @@ -93,25 +81,25 @@ void GuiPopupMenu::populate(QMenu * qMenu, Menu * menu) if (m->kind() == MenuItem::Separator) { qMenu->addSeparator(); - LYXERR(Debug::GUI) << "adding Menubar Separator" << endl; + LYXERR(Debug::GUI, "adding Menubar Separator"); } else if (m->kind() == MenuItem::Submenu) { - LYXERR(Debug::GUI) << "** creating New Sub-Menu " - << to_utf8(getLabel(*m)) << endl; + LYXERR(Debug::GUI, "** creating New Sub-Menu " + << to_utf8(getLabel(*m))); QMenu * subMenu = qMenu->addMenu(toqstr(getLabel(*m))); populate(subMenu, m->submenu()); } else { // we have a MenuItem::Command - LYXERR(Debug::GUI) << "creating Menu Item " - << to_utf8(m->label()) << endl; + LYXERR(Debug::GUI, "creating Menu Item " + << to_utf8(m->label())); docstring label = getLabel(*m); addBinding(label, *m); - Action * action = new Action(*(owner_->view()), - label, m->func()); + Action * action = new Action(*(owner_), + QIcon(), toqstr(label), m->func(), QString()); qMenu->addAction(action); } } @@ -125,7 +113,7 @@ docstring const GuiPopupMenu::getLabel(MenuItem const & mi) from_ascii("&"), from_ascii("&&")); if (!shortcut.empty()) { - docstring::size_type pos = label.find(shortcut); + size_t pos = label.find(shortcut); if (pos != docstring::npos) label.insert(pos, 1, char_type('&')); }