diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2009-04-21 23:44:58 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2009-04-21 23:44:58 +0200 |
commit | 2612c0c79ceeed46f432421ee09a45a466824ee7 (patch) | |
tree | 1ffaf4e80c5bd4c282b76ba99b4bc0698f009a9b | |
parent | Updating Application class with missing static functions (diff) | |
download | rekonq-2612c0c79ceeed46f432421ee09a45a466824ee7.tar.xz |
Fixing MainWindow code
-rw-r--r-- | src/mainwindow.cpp | 43 | ||||
-rw-r--r-- | src/mainwindow.h | 2 |
2 files changed, 37 insertions, 8 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8180b1e1..7b9139cc 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -64,7 +64,6 @@ MainWindow::MainWindow() : KXmlGuiWindow() , m_view(new MainView(this)) - , m_bookmarksProvider(new BookmarksProvider(this)) , m_findBar(new FindBar(this)) , m_searchBar(new SearchBar(this)) { @@ -120,10 +119,13 @@ MainWindow::MainWindow() setupToolBars(); // ----- BOOKMARKS MENU: this has to be done BEFORE setupGUI!! - KAction *a = new KActionMenu(i18n("B&ookmarks"), this); - actionCollection()->addAction(QLatin1String("bookmarks"), a); - KMenu *bmMenu = m_bookmarksProvider->bookmarksMenu(); - a->setMenu(bmMenu); +// KAction *a = new KActionMenu(i18n("B&ookmarks"), this); +// actionCollection()->addAction(QLatin1String("bookmarks"), a); +// KActionMenu *bmMenu = Application::bookmarkProvider()->bookmarkActionMenu(); +// a->setMenu(bmMenu); + + KActionMenu *bmMenu = Application::bookmarkProvider()->bookmarkActionMenu(); + actionCollection()->addAction(QLatin1String("bookmarks"), bmMenu); // a call to KXmlGuiWindow::setupGUI() populates the GUI // with actions, using KXMLGUI. @@ -136,8 +138,8 @@ MainWindow::MainWindow() setupHistoryMenu(); // bookmarks bar: this has to be done AFTER setupGUI!! - KToolBar *bmToolbar = toolBar("bookmarksToolBar"); - m_bookmarksProvider->provideBmToolbar(bmToolbar); +// KToolBar *bmToolbar = toolBar("bookmarksToolBar"); +// m_bookmarkProvider->provideBmToolbar(bmToolbar); // setting up toolbars to NOT have context menu enabled setContextMenuPolicy(Qt::DefaultContextMenu); @@ -174,6 +176,10 @@ void MainWindow::setupToolBars() a->setDefaultWidget(m_searchBar); connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); actionCollection()->addAction(QLatin1String("search_bar"), a); + + // bookmarks bar + KAction *bookmarkBarAction = Application::bookmarkProvider()->bookmarkToolBarAction(); + a = actionCollection()->addAction(QLatin1String("bookmarks_bar"), bookmarkBarAction); } @@ -304,7 +310,16 @@ void MainWindow::setupHistoryMenu() connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_view, SLOT(loadUrlInCurrentTab(const KUrl&))); connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); historyMenu->setTitle(i18n("&History")); + + // setting history menu position menuBar()->insertMenu(actionCollection()->action("bookmarks"), historyMenu); + + // setting initial actions + QList<QAction*> historyActions; + historyActions.append(actionCollection()->action("history_back")); + historyActions.append(actionCollection()->action("history_forward")); + historyActions.append(m_view->recentlyClosedTabsAction()); + historyMenu->setInitialActions(historyActions); } @@ -858,3 +873,17 @@ void MainWindow::slotClearLocationBar() lineEdit->setFocus(); } + +QAction *MainWindow::actionByName(const QString name) +{ + QAction *ret = actionCollection()->action(name); + + if (ret) + return ret; + + /* else */ + kWarning() << "Action named: " << name << " not found, returning empty action."; + + return new QAction(this); // return empty object instead of NULL pointer +} + diff --git a/src/mainwindow.h b/src/mainwindow.h index b9b90b5e..76f5431b 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -58,6 +58,7 @@ public: static KUrl guessUrlFromString(const QString &url); MainView *mainView() const; WebView *currentTab() const; + QAction *actionByName(const QString name); virtual QSize sizeHint() const; private: @@ -131,7 +132,6 @@ private: QString m_homePage; MainView *m_view; - BookmarksProvider *m_bookmarksProvider; FindBar *m_findBar; SearchBar *m_searchBar; }; |