summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp68
1 files changed, 51 insertions, 17 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 8caa6fbc..9b95f052 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -42,6 +42,7 @@
#include "mainview.h"
#include "findbar.h"
#include "sidepanel.h"
+#include "bookmarkspanel/bookmarkspanel.h"
#include "urlbar.h"
#include "tabbar.h"
#include "newtabpage.h"
@@ -98,6 +99,7 @@ MainWindow::MainWindow()
, m_view(new MainView(this))
, m_findBar(new FindBar(this))
, m_sidePanel(0)
+ , m_bookmarksPanel(0)
, m_historyBackMenu(0)
, m_mainBar( new KToolBar( QString("MainToolBar"), this, Qt::TopToolBarArea, true, false, false) )
, m_bmBar( new KToolBar( QString("BookmarkToolBar"), this, Qt::TopToolBarArea, true, false, false) )
@@ -134,6 +136,7 @@ MainWindow::MainWindow()
// setting Side Panel
setupSidePanel();
+ setupBookmarksPanel();
// setting up rekonq tools
setupTools();
@@ -167,6 +170,11 @@ SidePanel *MainWindow::sidePanel()
return m_sidePanel;
}
+BookmarksPanel *MainWindow::bookmarksPanel()
+{
+ return m_bookmarksPanel;
+}
+
void MainWindow::setupToolbars()
{
@@ -186,7 +194,7 @@ void MainWindow::setupToolbars()
KAction *urlBarAction = new KAction(this);
urlBarAction->setDefaultWidget(m_view->urlBar());
m_mainBar->addAction( urlBarAction );
-
+
m_mainBar->addAction( actionByName("bookmarksActionMenu") );
m_mainBar->addAction( actionByName("rekonq_tools") );
@@ -211,7 +219,7 @@ void MainWindow::postLaunch()
connect(m_view, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(updateWindowTitle(const QString &)));
connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *)));
- // (shift +) ctrl + tab switching
+ // (shift +) ctrl + tab switching
connect(this, SIGNAL(ctrlTabPressed()), m_view, SLOT(nextTab()));
connect(this, SIGNAL(shiftCtrlTabPressed()), m_view, SLOT(previousTab()));
@@ -221,7 +229,7 @@ void MainWindow::postLaunch()
// launch it manually. Just the first time...
updateActions();
-
+
// Find Bar signal
connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(find(const QString &)));
@@ -256,7 +264,7 @@ void MainWindow::setupActions()
actionCollection()->addAssociatedWidget(this);
KAction *a;
-
+
// new window action
a = new KAction(KIcon("window-new"), i18n("&New Window"), this);
a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_N));
@@ -269,10 +277,14 @@ void MainWindow::setupActions()
KStandardAction::print(this, SLOT(printRequested()), actionCollection());
KStandardAction::quit(this , SLOT(close()), actionCollection());
- KStandardAction::find(m_findBar, SLOT(show()) , actionCollection());
+ a = KStandardAction::find(m_findBar, SLOT(show()), actionCollection());
+ QList<QKeySequence> shortcutFindList;
+ shortcutFindList << KStandardShortcut::find() << QKeySequence( Qt::Key_Slash );
+ a->setShortcuts( shortcutFindList );
+
KStandardAction::findNext(this, SLOT(findNext()) , actionCollection());
KStandardAction::findPrev(this, SLOT(findPrevious()) , actionCollection());
-
+
a = KStandardAction::fullScreen(this, SLOT(viewFullScreen(bool)), this, actionCollection());
QList<QKeySequence> shortcutFullScreenList;
shortcutFullScreenList << KStandardShortcut::fullScreen() << QKeySequence( Qt::Key_F11 );
@@ -380,11 +392,11 @@ void MainWindow::setupActions()
a = new KAction(KIcon("tab-close-other"), i18n("Close &Other Tabs"), this);
actionCollection()->addAction( QLatin1String("close_other_tabs"), a);
connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(closeOtherTabs()) );
-
+
a = new KAction(KIcon("view-refresh"), i18n("Reload Tab"), this);
actionCollection()->addAction( QLatin1String("reload_tab"), a);
connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(reloadTab()) );
-
+
// ----------------------- Bookmarks ToolBar Action --------------------------------------
QAction *qa = m_bmBar->toggleViewAction();
qa->setText( i18n("Bookmarks Toolbar") );
@@ -431,6 +443,7 @@ void MainWindow::setupTools()
toolsMenu->addAction(actionByName(QLatin1String("bm_bar")));
toolsMenu->addAction(actionByName(QLatin1String("show_history_panel")));
+ toolsMenu->addAction(actionByName(QLatin1String("show_bookmarks_panel")));
toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::FullScreen)));
toolsMenu->addSeparator();
@@ -460,6 +473,21 @@ void MainWindow::setupSidePanel()
actionCollection()->addAction(QLatin1String("show_history_panel"), a);
}
+void MainWindow::setupBookmarksPanel()
+{
+ m_bookmarksPanel = new BookmarksPanel(i18n("Bookmarks Panel"), this);
+ connect(m_bookmarksPanel, SIGNAL(openUrl(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&)));
+ connect(m_bookmarksPanel, SIGNAL(destroyed()), Application::instance(), SLOT(saveConfiguration()));
+
+ addDockWidget(Qt::LeftDockWidgetArea, m_bookmarksPanel);
+
+ // setup side panel actions
+ KAction* a = (KAction *) m_bookmarksPanel->toggleViewAction();
+ a->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B)); // FIXME: this shortcut should be configurable !
+ a->setIcon(KIcon("bookmarks-organize"));
+ actionCollection()->addAction(QLatin1String("show_bookmarks_panel"), a);
+}
+
void MainWindow::updateConfiguration()
{
@@ -501,7 +529,7 @@ void MainWindow::updateConfiguration()
QWebSettings::setOfflineStoragePath(path);
QWebSettings::setOfflineStorageDefaultQuota(50000);
}
-
+
// Applies user defined CSS to all open webpages. If there no longer is a
// user defined CSS removes it from all open webpages.
defaultSettings->setUserStyleSheetUrl(ReKonfig::userCSS());
@@ -589,7 +617,7 @@ void MainWindow::updateWindowTitle(const QString &title)
void MainWindow::fileOpen()
{
QString filePath = KFileDialog::getOpenFileName(KUrl(),
- i18n("*.html *.htm *.svg *.png *.gif *.svgz|Web Resources (*.html *.htm *.svg *.png *.gif *.svgz)\n"
+ i18n("*.html *.htm *.svg *.png *.gif *.svgz|Web Resources (*.html *.htm *.svg *.png *.gif *.svgz)\n"
"*.*|All files (*.*)"),
this,
i18n("Open Web Resource"));
@@ -727,6 +755,7 @@ void MainWindow::viewFullScreen(bool makeFullScreen)
// state flags
static bool bookmarksToolBarFlag;
static bool sidePanelFlag;
+ static bool bookmarksPanelFlag;
if (makeFullScreen == true)
{
@@ -737,6 +766,9 @@ void MainWindow::viewFullScreen(bool makeFullScreen)
sidePanelFlag = sidePanel()->isHidden();
sidePanel()->hide();
+ bookmarksPanelFlag = bookmarksPanel()->isHidden();
+ bookmarksPanel()->hide();
+
// hide main toolbar
m_mainBar->hide();
}
@@ -750,6 +782,8 @@ void MainWindow::viewFullScreen(bool makeFullScreen)
m_bmBar->show();
if (!sidePanelFlag)
sidePanel()->show();
+ if (!bookmarksPanelFlag)
+ bookmarksPanel()->show();
}
KToggleFullScreenAction::setFullScreen(this, makeFullScreen);
@@ -927,7 +961,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
m_view->closeTab(m_view->currentIndex());
return;
}
-
+
KMainWindow::keyPressEvent(event);
}
@@ -961,7 +995,7 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)
}
m_hidePopup->stop();
-
+
switch(status)
{
@@ -1081,7 +1115,7 @@ void MainWindow::aboutToShowBackMenu()
QWebHistoryItem item = history->backItems(history->count()).at(i);
KAction *action = new KAction(this);
action->setData( i - history->currentItemIndex() );
- QIcon icon = Application::icon(item.url());
+ QIcon icon = Application::icon(item.url());
action->setIcon(icon);
action->setText(item.title());
m_historyBackMenu->addAction(action);
@@ -1093,7 +1127,7 @@ void MainWindow::openActionUrl(QAction *action)
{
int offset = action->data().toInt();
QWebHistory *history = currentTab()->history();
-
+
if(!history->itemAt(offset).isValid())
{
kDebug() << "Invalid Offset!";
@@ -1118,9 +1152,9 @@ bool MainWindow::newTabPage(const KUrl &url)
{
if(m_loadingNewTabPage)
return false;
-
- if ( url == KUrl("about:closedTabs")
- || url == KUrl("about:history")
+
+ if ( url == KUrl("about:closedTabs")
+ || url == KUrl("about:history")
|| url == KUrl("about:bookmarks")
|| url == KUrl("about:favorites")
|| url == KUrl("about:home")