summaryrefslogtreecommitdiff
path: root/src/webwindow
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-08-09 15:36:39 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:05 +0100
commitb3526c84a15e91b05ee1ea0c6052be3fd73a6044 (patch)
treed587600753d9f22e36670f2ddf7a3808dc26ce94 /src/webwindow
parentRestore rekonq settings (diff)
downloadrekonq-b3526c84a15e91b05ee1ea0c6052be3fd73a6044.tar.xz
Moved the bookmark toolbar to be a... toolbar!!!
Diffstat (limited to 'src/webwindow')
-rw-r--r--src/webwindow/rekonqfactory.cpp105
-rw-r--r--src/webwindow/rekonqfactory.h2
-rw-r--r--src/webwindow/webwindow.cpp13
3 files changed, 91 insertions, 29 deletions
diff --git a/src/webwindow/rekonqfactory.cpp b/src/webwindow/rekonqfactory.cpp
index e3f62f9f..c8aaeb09 100644
--- a/src/webwindow/rekonqfactory.cpp
+++ b/src/webwindow/rekonqfactory.cpp
@@ -26,6 +26,7 @@
#include "rekonqfactory.h"
+#include "bookmarkstoolbar.h"
#include "rekonqmenu.h"
#include <KActionCollection>
@@ -45,7 +46,6 @@ QWidget *RekonqFactory::createWidget(const QString &name, QWidget *parent, KActi
{
QString xmlFilePath;
xmlFilePath = KStandardDirs::locateLocal( "data", "rekonq/rekonqui.rc");
- kDebug() << "local xmlfile: " << xmlFilePath;
if (!QFile::exists(xmlFilePath))
{
xmlFilePath = KStandardDirs::locate( "data", "rekonq/rekonqui.rc");
@@ -58,42 +58,46 @@ QWidget *RekonqFactory::createWidget(const QString &name, QWidget *parent, KActi
document.setContent(&xmlFile, false);
// Toolbars ----------------------------------------------------------------------
- QDomNodeList elementList = document.elementsByTagName(QL1S("ToolBar"));
- if (elementList.isEmpty())
+ QDomNodeList elementToolbarList = document.elementsByTagName(QL1S("ToolBar"));
+ if (elementToolbarList.isEmpty())
{
+ kDebug() << "ELEMENT TOOLBAR LIST EMPTY. RETURNING NULL";
return 0;
}
- for(unsigned int i = 0; i < elementList.length(); ++i)
+ for(unsigned int i = 0; i < elementToolbarList.length(); ++i)
{
- QDomElement element = elementList.at(i).toElement();
+ QDomNode node = elementToolbarList.at(i);
+ QDomElement element = node.toElement();
if (element.attribute("name") != name)
continue;
if (element.attribute("deleted").toLower() == "true")
{
+ kDebug() << "ELEMENT DELETED. RETURNING NULL";
return 0;
}
- KToolBar *bar = new KToolBar(parent, false, false);
- QDomNodeList actionList = element.elementsByTagName(QL1S("Action"));
-
- for(unsigned int j = 0; j < actionList.length(); ++j)
+
+ if (name == QL1S("bookmarkToolBar"))
{
- QDomElement actionElement = actionList.at(j).toElement();
- const QString actionName = actionElement.attribute("name");
- QAction *a = ac->action(actionName);
- if (a)
- bar->addAction(a);
+ BookmarkToolBar *b = new BookmarkToolBar(parent);
+ fillToolbar(b, node, ac);
+ return b;
+ }
+ else
+ {
+ KToolBar *b = new KToolBar(parent, false , false);
+ fillToolbar(b, node, ac);
+ return b;
}
-
- return bar;
}
// Rekonq Menu ----------------------------------------------------------------------
QDomNodeList elementMenuList = document.elementsByTagName(QL1S("Menu"));
if (elementMenuList.isEmpty())
{
+ kDebug() << "ELEMENT MENU LIST EMPTY. RETURNING NULL";
return 0;
}
@@ -106,13 +110,13 @@ QWidget *RekonqFactory::createWidget(const QString &name, QWidget *parent, KActi
if (element.attribute("deleted").toLower() == "true")
{
+ kDebug() << "ELEMENT DELETED. RETURNING NULL";
return 0;
}
if (name == QL1S("rekonqMenu"))
{
RekonqMenu *m = new RekonqMenu(parent);
- kDebug() << "filling menu...";
fillMenu(m, node, ac);
return m;
}
@@ -130,6 +134,70 @@ QWidget *RekonqFactory::createWidget(const QString &name, QWidget *parent, KActi
}
+void RekonqFactory::fillToolbar(KToolBar *b, QDomNode node, KActionCollection *ac)
+{
+ QDomElement element = node.toElement();
+
+ if (element.hasAttribute("iconSize"))
+ {
+ int iconSize = element.attribute("iconSize").toInt();
+ b->setIconDimensions(iconSize);
+ }
+
+ if (element.hasAttribute("iconText"))
+ {
+ if(element.attribute("iconText").toLower() == QL1S("icononly"))
+ {
+ b->setToolButtonStyle(Qt::ToolButtonIconOnly);
+ }
+
+ if(element.attribute("iconText").toLower() == QL1S("textonly"))
+ {
+ b->setToolButtonStyle(Qt::ToolButtonTextOnly);
+ }
+
+ if(element.attribute("iconText").toLower() == QL1S("icontextright"))
+ {
+ b->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ }
+
+ if(element.attribute("iconText").toLower() == QL1S("textundericon"))
+ {
+ b->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ }
+
+ if(element.attribute("iconText").toLower() == QL1S("followstyle"))
+ {
+ b->setToolButtonStyle(Qt::ToolButtonFollowStyle);
+ }
+ }
+
+ QDomNodeList childrenList = node.childNodes();
+
+ for(unsigned int i = 0; i < childrenList.length(); ++i)
+ {
+ QDomElement el = childrenList.at(i).toElement();
+
+ if (el.tagName() == QL1S("Action"))
+ {
+ const QString actionName = el.attribute("name");
+ QAction *a = ac->action(actionName);
+ if (a)
+ {
+ b->addAction(a);
+ }
+
+ }
+
+ if (el.tagName() == QL1S("Separator"))
+ {
+ b->addSeparator();
+ }
+
+ }
+}
+
+
void RekonqFactory::fillMenu(KMenu *m, QDomNode node, KActionCollection *ac)
{
QDomNodeList childrenList = node.childNodes();
@@ -144,10 +212,9 @@ void RekonqFactory::fillMenu(KMenu *m, QDomNode node, KActionCollection *ac)
QAction *a = ac->action(actionName);
if (a)
{
- kDebug() << "ADDING ACTION " << actionName << " to menu " << m;
m->addAction(a);
}
-
+
}
if (el.tagName() == QL1S("Separator"))
diff --git a/src/webwindow/rekonqfactory.h b/src/webwindow/rekonqfactory.h
index 6a59adcd..cf8bc2ee 100644
--- a/src/webwindow/rekonqfactory.h
+++ b/src/webwindow/rekonqfactory.h
@@ -32,6 +32,7 @@
class KActionCollection;
class KMenu;
+class KToolBar;
class QDomNode;
class QString;
@@ -42,6 +43,7 @@ namespace RekonqFactory
{
QWidget *createWidget(const QString &name, QWidget *parent, KActionCollection *);
+ void fillToolbar(KToolBar *, QDomNode, KActionCollection *);
void fillMenu(KMenu *, QDomNode, KActionCollection *);
};
diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp
index 4d350d71..87006bf8 100644
--- a/src/webwindow/webwindow.cpp
+++ b/src/webwindow/webwindow.cpp
@@ -92,21 +92,14 @@ WebWindow::WebWindow(QWidget *parent, WebPage *pg)
// main toolbar
_mainToolBar = qobject_cast<KToolBar *>(RekonqFactory::createWidget(QL1S("mainToolBar"), this, actionCollection()));
-
- // bookmarks toolbar
- if (_bookmarksBar)
- {
- BookmarkManager::self()->removeBookmarkBar(_bookmarksBar);
- delete _bookmarksBar;
- }
- KToolBar *XMLGUIBkBar = new KToolBar(this);
- _bookmarksBar = new BookmarkToolBar(XMLGUIBkBar, this);
+
+ _bookmarksBar = qobject_cast<BookmarkToolBar *>(RekonqFactory::createWidget(QL1S("bookmarkToolBar"), this, actionCollection()));
BookmarkManager::self()->registerBookmarkBar(_bookmarksBar);
// layout
QVBoxLayout *l = new QVBoxLayout(this);
l->addWidget(_mainToolBar);
- l->addWidget(XMLGUIBkBar);
+ l->addWidget(_bookmarksBar);
l->addWidget(_tab);
l->setContentsMargins(0, 0, 0, 0);