From 072490b92b33bd37672e4ac34d3b7df0705c84ae Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 25 Apr 2013 08:59:47 +0200 Subject: appmenu-qt support :) BUG: 309148 --- src/tabwindow/rekonqwindow.cpp | 6 ++++ src/webwindow/rekonqfactory.cpp | 42 ++++++++++++++++++++++++++ src/webwindow/rekonqui.rc | 66 ++++++++++++++++++++++------------------- src/webwindow/webwindow.cpp | 14 +++++++++ 4 files changed, 98 insertions(+), 30 deletions(-) diff --git a/src/tabwindow/rekonqwindow.cpp b/src/tabwindow/rekonqwindow.cpp index e67e21c8..c0785b67 100644 --- a/src/tabwindow/rekonqwindow.cpp +++ b/src/tabwindow/rekonqwindow.cpp @@ -36,6 +36,7 @@ #include "tabwidget.h" #include "tabbar.h" +#include "rekonqfactory.h" #include "webpage.h" #include "webwindow.h" @@ -47,6 +48,7 @@ // Qt Includes #include #include +#include RekonqWindow::RekonqWindow(bool withTab, bool privateBrowsingMode, QWidget *parent) @@ -97,6 +99,10 @@ void RekonqWindow::init() // signals connect(_tabWidget, SIGNAL(closeWindow()), this, SLOT(close())); connect(_tabWidget, SIGNAL(windowTitleChanged(QString)), this, SLOT(setWindowTitle(QString))); + + // This is needed to properly support appmenu-qt feature + RekonqFactory::createWidget(QL1S("menuBar"), this); + QDBusConnection::sessionBus().registerObject(QL1S("rekonq"), this); } // -------------------------------------------------------------------------------------------------- diff --git a/src/webwindow/rekonqfactory.cpp b/src/webwindow/rekonqfactory.cpp index 75fd0baa..03711464 100644 --- a/src/webwindow/rekonqfactory.cpp +++ b/src/webwindow/rekonqfactory.cpp @@ -38,6 +38,7 @@ #include #include +#include #include #include @@ -177,6 +178,47 @@ QWidget *RekonqFactory::createWidget(const QString &name, QWidget *parent) } + // MenuBar ---------------------------------------------------------------------- + QDomNodeList elementMenuBarList = document.elementsByTagName(QL1S("MenuBar")); + if (elementMenuBarList.isEmpty()) + { + kDebug() << "ELEMENT MENUBAR LIST EMPTY. RETURNING NULL"; + return 0; + } + + if (name == QL1S("menuBar")) + { + QDomNode node = elementMenuBarList.at(0); + QDomNodeList menuNodes = node.childNodes(); + + QMenuBar *menuBar = new QMenuBar(parent); + for (unsigned int i = 0; i < menuNodes.length(); ++i) + { + QDomNode node = menuNodes.at(i); + if (node.isComment()) + continue; + + QDomElement element = node.toElement(); + + if (element.attribute("deleted").toLower() == "true") + continue; + + if (element.attribute("name") == QL1S("help")) + { + KHelpMenu *m = new KHelpMenu(parent, KCmdLineArgs::aboutData()); + menuBar->addMenu(m->menu()); + continue; + } + + KMenu *m = new KMenu(parent); + fillMenu(m, node); + menuBar->addMenu(m); + } + + menuBar->hide(); + return menuBar; + } + kDebug() << "NO WIDGET RETURNED"; return 0; } diff --git a/src/webwindow/rekonqui.rc b/src/webwindow/rekonqui.rc index 6e23416f..cefdb96b 100644 --- a/src/webwindow/rekonqui.rc +++ b/src/webwindow/rekonqui.rc @@ -1,6 +1,6 @@ - + @@ -75,17 +75,19 @@ + + - - + &File + @@ -93,8 +95,7 @@ - - + &Edit @@ -107,54 +108,59 @@ - - + &View - + - - - + + + - + + - - + &Go + + + + + + + + + - - Hi&story - - - - &Bookmarks - - - &Tools - - + + + + + - + &Settings - - - + + - + + + + + diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp index 5858ec6c..a2854460 100644 --- a/src/webwindow/webwindow.cpp +++ b/src/webwindow/webwindow.cpp @@ -219,6 +219,20 @@ void WebWindow::setupActions() KStandardAction::keyBindings(this, SLOT(keyBindings()), actionCollection()); KStandardAction::quit(rApp, SLOT(queryQuit()), actionCollection()); + // WebPage Actions + QAction *qa; + + qa = _tab->page()->action(QWebPage::Undo); + actionCollection()->addAction(QL1S("edit_undo"), qa); + qa = _tab->page()->action(QWebPage::Redo); + actionCollection()->addAction(QL1S("edit_redo"), qa); + qa = _tab->page()->action(QWebPage::Cut); + actionCollection()->addAction(QL1S("edit_cut"), qa); + qa = _tab->page()->action(QWebPage::Copy); + actionCollection()->addAction(QL1S("edit_copy"), qa); + qa = _tab->page()->action(QWebPage::Paste); + actionCollection()->addAction(QL1S("edit_paste"), qa); + // Configure Main Toolbar a = new KAction(KIcon("configure-toolbars"), i18n("Configure Main ToolBar"), this); actionCollection()->addAction(QL1S("configure_main_toolbar"), a); -- cgit v1.2.1