From 2d8de46ae55966ff00e1f89e2133024b5d70edef Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 14 Jan 2013 21:21:20 +0100 Subject: Reimplement (in 2.x way) the ability to edit toolbar BUG: 312340 --- src/webwindow/rekonqfactory.cpp | 46 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) (limited to 'src/webwindow/rekonqfactory.cpp') diff --git a/src/webwindow/rekonqfactory.cpp b/src/webwindow/rekonqfactory.cpp index 60ba3872..af15bf42 100644 --- a/src/webwindow/rekonqfactory.cpp +++ b/src/webwindow/rekonqfactory.cpp @@ -27,6 +27,7 @@ #include "rekonqfactory.h" #include "bookmarkstoolbar.h" +#include "maintoolbar.h" #include "rekonqmenu.h" #include @@ -129,7 +130,7 @@ QWidget *RekonqFactory::createWidget(const QString &name, QWidget *parent) } else { - KToolBar *b = new KToolBar(parent, false , false); + MainToolBar *b = new MainToolBar(parent); fillToolbar(b, node); return b; } @@ -181,8 +182,51 @@ QWidget *RekonqFactory::createWidget(const QString &name, QWidget *parent) } +void RekonqFactory::updateWidget(QWidget *widg, const QString &name) +{ + QDomDocument document("rekonqui.rc"); + QString xmlFilePath = KStandardDirs::locate("data", "rekonq/rekonqui.rc"); + + if (!readDocument(document, xmlFilePath)) + return; + + // Toolbars ---------------------------------------------------------------------- + QDomNodeList elementToolbarList = document.elementsByTagName(QL1S("ToolBar")); + if (elementToolbarList.isEmpty()) + { + kDebug() << "ELEMENT TOOLBAR LIST EMPTY. RETURNING NULL"; + return; + } + + for (unsigned int i = 0; i < elementToolbarList.length(); ++i) + { + QDomNode node = elementToolbarList.at(i); + QDomElement element = node.toElement(); + + if (element.attribute("name") != name) + continue; + + if (element.attribute("deleted").toLower() == "true") + { + return; + } + + if (name == QL1S("mainToolBar")) + { + fillToolbar(qobject_cast(widg), node); + return; + } + } + + kDebug() << "NO WIDGET RETURNED"; + return; +} + + void RekonqFactory::fillToolbar(KToolBar *b, QDomNode node) { + b->clear(); + QDomElement element = node.toElement(); if (element.hasAttribute("iconSize")) -- cgit v1.2.1