diff options
Diffstat (limited to 'src/webwindow')
-rw-r--r-- | src/webwindow/maintoolbar.cpp | 73 | ||||
-rw-r--r-- | src/webwindow/maintoolbar.h | 53 | ||||
-rw-r--r-- | src/webwindow/rekonqfactory.cpp | 46 | ||||
-rw-r--r-- | src/webwindow/rekonqfactory.h | 2 | ||||
-rw-r--r-- | src/webwindow/webwindow.cpp | 33 | ||||
-rw-r--r-- | src/webwindow/webwindow.h | 6 |
6 files changed, 207 insertions, 6 deletions
diff --git a/src/webwindow/maintoolbar.cpp b/src/webwindow/maintoolbar.cpp new file mode 100644 index 00000000..ee667ec1 --- /dev/null +++ b/src/webwindow/maintoolbar.cpp @@ -0,0 +1,73 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2003 by Andrea Diamantini <adjam7 at gmail dot com> +* +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* +* ============================================================ */ + + +#include "maintoolbar.h" +#include "maintoolbar.moc" + + +#include <KAction> +#include <KActionCollection> +#include <KMenu> + +#include <QPoint> + + +MainToolBar::MainToolBar(QWidget *parent) + : KToolBar (parent, true, true) +{ + setContextMenuPolicy(Qt::CustomContextMenu); + + connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showCustomContextMenu(QPoint))); +} + + +void MainToolBar::showCustomContextMenu(QPoint p) +{ + KMenu menu(this); + + QList<KActionCollection *> lac = KActionCollection::allCollections(); + + int lac_count = lac.count(); + for (int i = lac_count - 1; i >= 0; i--) + { + KActionCollection *ac = lac.at(i); + + QAction *a = ac->action("show_bookmarks_toolbar"); + if (a) + { + menu.addAction(a); + } + + QAction *b = ac->action("configure_main_toolbar"); + if (b) + { + menu.addAction(b); + } + } + + // finally launch the menu... + menu.exec(mapToGlobal(p)); +} diff --git a/src/webwindow/maintoolbar.h b/src/webwindow/maintoolbar.h new file mode 100644 index 00000000..903c7567 --- /dev/null +++ b/src/webwindow/maintoolbar.h @@ -0,0 +1,53 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2003 by Andrea Diamantini <adjam7 at gmail dot com> +* +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* +* ============================================================ */ + + +#ifndef MAIN_TOOLBAR_H +#define MAIN_TOOLBAR_H + + +// Rekonq Includes +#include "rekonq_defines.h" + +// KDE Includes +#include <KToolBar> + +// Forward Declarations +class QPoint; + + +class MainToolBar : public KToolBar +{ + Q_OBJECT + +public: + explicit MainToolBar(QWidget *parent = 0); + +private Q_SLOTS: + void showCustomContextMenu(QPoint); + +}; + +#endif // MAIN_TOOLBAR_H 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 <KActionCollection> @@ -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<MainToolBar *>(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")) diff --git a/src/webwindow/rekonqfactory.h b/src/webwindow/rekonqfactory.h index 4a4f46dd..450adc88 100644 --- a/src/webwindow/rekonqfactory.h +++ b/src/webwindow/rekonqfactory.h @@ -42,6 +42,8 @@ namespace RekonqFactory { QWidget *createWidget(const QString &name, QWidget *parent); +void updateWidget(QWidget *widg, const QString &name); + void fillToolbar(KToolBar *, QDomNode); void fillMenu(KMenu *, QDomNode); diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp index f5f0896d..d512620d 100644 --- a/src/webwindow/webwindow.cpp +++ b/src/webwindow/webwindow.cpp @@ -53,6 +53,7 @@ // KDE Includes #include <KIO/Job> +#include <KEditToolBar> #include <KFileDialog> #include <KJobUiDelegate> #include <KMimeTypeTrader> @@ -76,7 +77,6 @@ WebWindow::WebWindow(QWidget *parent, bool isPrivateBrowsing, WebPage *pg) : QWidget(parent) , _tab(new WebTab(this, isPrivateBrowsing)) , _bar(new UrlBar(_tab)) - , _mainToolBar(0) , m_findBar(new FindBar(this)) , m_loadStopReloadAction(0) , m_rekonqMenu(0) @@ -101,7 +101,7 @@ WebWindow::WebWindow(QWidget *parent, bool isPrivateBrowsing, WebPage *pg) // main toolbar _mainToolBar = qobject_cast<KToolBar *>(RekonqFactory::createWidget(QL1S("mainToolBar"), this)); - l->addWidget(_mainToolBar); + l->addWidget(_mainToolBar.data()); if (ReKonfig::showBookmarksToolbar()) { @@ -212,6 +212,11 @@ void WebWindow::setupActions() KStandardAction::keyBindings(this, SLOT(keyBindings()), actionCollection()); KStandardAction::quit(rApp, SLOT(queryQuit()), actionCollection()); + // Configure Main Toolbar + a = new KAction(KIcon("configure-toolbars"), i18n("Configure Main ToolBar"), this); + actionCollection()->addAction(QL1S("configure_main_toolbar"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(showToolbarEditor())); + // Bookmark Toolbar a = new KAction(KIcon("bookmark-toolbar"), i18n("Bookmarks Toolbar"), this); a->setCheckable(true); @@ -821,12 +826,12 @@ void WebWindow::setWidgetsHidden(bool hide) } // hide main toolbar - _mainToolBar->hide(); + _mainToolBar.data()->hide(); } else { // show main toolbar - _mainToolBar->show(); + _mainToolBar.data()->show(); // restore state of windowed mode if (!_bookmarksBar.isNull() && bookmarksToolBarFlag) @@ -1000,3 +1005,23 @@ void WebWindow::keyBindings() dialog->deleteLater(); } + + +// Main Toolbar methods ---------- + + +void WebWindow::setupMainToolBar() +{ + RekonqFactory::updateWidget(_mainToolBar.data(), QL1S("mainToolBar")); +} + + +void WebWindow::showToolbarEditor() +{ + QPointer<KEditToolBar> ed = new KEditToolBar(actionCollection(), this); + ed->setResourceFile( "rekonqui.rc" ); + connect(ed, SIGNAL(newToolBarConfig()),this, SLOT(setupMainToolBar())); + + ed->exec(); + ed->deleteLater(); +} diff --git a/src/webwindow/webwindow.h b/src/webwindow/webwindow.h index 85c9395f..e8e77dd7 100644 --- a/src/webwindow/webwindow.h +++ b/src/webwindow/webwindow.h @@ -139,6 +139,10 @@ private Q_SLOTS: void preferences(); void keyBindings(); + // Main ToolBar Settings slots + void setupMainToolBar(); + void showToolbarEditor(); + Q_SIGNALS: void titleChanged(QString); @@ -159,7 +163,7 @@ private: WebTab *_tab; UrlBar *_bar; - KToolBar *_mainToolBar; + QWeakPointer<KToolBar> _mainToolBar; QWeakPointer<BookmarkToolBar> _bookmarksBar; FindBar *m_findBar; |