summaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp634
1 files changed, 373 insertions, 261 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index d3c14d85..28c7dff1 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -2,9 +2,10 @@
*
* This file is a part of the rekonq project
*
-* Copyright (C) 2008-2009 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2008-2010 by Andrea Diamantini <adjam7 at gmail dot com>
* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
-* Copyright (C) 2009 by Lionel Chauvin <megabigbug@yahoo.fr>
+* Copyright (C) 2009-2010 by Lionel Chauvin <megabigbug@yahoo.fr>
+* Copyright (C) 2010 by Matthieu Gicquel <matgic78 at gmail dot com>
*
*
* This program is free software; you can redistribute it and/or
@@ -51,7 +52,6 @@
#include "ui_cleardata.h"
// KDE Includes
-#include <KUrl>
#include <KShortcut>
#include <KStandardAction>
#include <KAction>
@@ -64,23 +64,21 @@
#include <KTemporaryFile>
#include <KPassivePopup>
#include <KMenuBar>
-#include <KToolBar>
#include <KJobUiDelegate>
#include <kdeprintdialog.h>
#include <KToggleAction>
#include <KStandardDirs>
#include <KActionCategory>
+#include <KProcess>
// Qt Includes
#include <QtCore/QTimer>
#include <QtCore/QRect>
#include <QtCore/QSize>
#include <QtCore/QList>
-#include <QtCore/QPointer>
+#include <QtCore/QWeakPointer>
-#include <QtGui/QWidget>
#include <QtGui/QVBoxLayout>
-#include <QtGui/QAction>
#include <QtGui/QFont>
#include <QtGui/QDesktopWidget>
#include <QtGui/QPrinter>
@@ -95,25 +93,23 @@
MainWindow::MainWindow()
- : KMainWindow()
- , m_view( new MainView(this) )
- , m_findBar( new FindBar(this) )
- , m_historyPanel(0)
- , m_bookmarksPanel(0)
- , m_webInspectorPanel(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) )
- , m_popup( new KPassivePopup(this) )
- , m_hidePopup( new QTimer(this) )
- , m_ac( new KActionCollection(this) )
+ : KMainWindow()
+ , m_view(new MainView(this))
+ , m_findBar(new FindBar(this))
+ , m_historyPanel(0)
+ , m_bookmarksPanel(0)
+ , m_webInspectorPanel(0)
+ , m_historyBackMenu(0)
+ , m_encodingMenu(new KMenu(this))
+ , m_mainBar(new KToolBar(QString("MainToolBar"), this, Qt::TopToolBarArea, true, true, true))
+ , m_bmBar(new KToolBar(QString("BookmarkToolBar"), this, Qt::TopToolBarArea, true, false, true))
+ , m_popup(new KPassivePopup(this))
+ , m_hidePopup(new QTimer(this))
+ , m_ac(new KActionCollection(this))
{
// enable window size "auto-save"
setAutoSaveSettings();
- // updating rekonq configuration
- updateConfiguration();
-
// creating a centralWidget containing panel, m_view and the hidden findbar
QWidget *centralWidget = new QWidget;
centralWidget->setContentsMargins(0, 0, 0, 0);
@@ -148,7 +144,7 @@ MainWindow::MainWindow()
// setting popup notification
m_popup->setAutoDelete(false);
- connect(Application::instance(), SIGNAL(focusChanged(QWidget*,QWidget*)), m_popup, SLOT(hide()));
+ connect(Application::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), m_popup, SLOT(hide()));
m_popup->setFrameShape(QFrame::NoFrame);
m_popup->setLineWidth(0);
connect(m_hidePopup, SIGNAL(timeout()), m_popup, SLOT(hide()));
@@ -159,36 +155,49 @@ MainWindow::MainWindow()
MainWindow::~MainWindow()
{
+ Application::bookmarkProvider()->removeToolBar(m_bmBar);
Application::instance()->removeMainWindow(this);
delete m_popup;
+ delete m_encodingMenu;
}
void MainWindow::setupToolbars()
{
// ============ Main ToolBar ================================
- m_mainBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
-
- m_mainBar->addAction( actionByName(KStandardAction::name(KStandardAction::Back)) );
- m_mainBar->addAction( actionByName(KStandardAction::name(KStandardAction::Forward)) );
+ m_mainBar->addAction(actionByName(KStandardAction::name(KStandardAction::Back)));
+ m_mainBar->addAction(actionByName(KStandardAction::name(KStandardAction::Forward)));
m_mainBar->addSeparator();
- m_mainBar->addAction( actionByName("stop_reload") );
- m_mainBar->addAction( actionByName(KStandardAction::name(KStandardAction::Home)) );
+ m_mainBar->addAction(actionByName("stop_reload"));
+ m_mainBar->addAction(actionByName(KStandardAction::name(KStandardAction::Home)));
// location bar
KAction *urlBarAction = new KAction(this);
- urlBarAction->setDefaultWidget(m_view->urlBar());
- m_mainBar->addAction( urlBarAction );
+ urlBarAction->setDefaultWidget(m_view->urlBarWidget());
+ m_mainBar->addAction(urlBarAction);
- m_mainBar->addAction( actionByName("bookmarksActionMenu") );
- m_mainBar->addAction( actionByName("rekonq_tools") );
+ m_mainBar->addAction(actionByName("bookmarksActionMenu"));
+ m_mainBar->addAction(actionByName("rekonq_tools"));
+
+ m_mainBar->show(); // this just to fix reopening rekonq after fullscreen close
// =========== Bookmarks ToolBar ================================
- m_bmBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
m_bmBar->setAcceptDrops(true);
- m_bmBar->setContextMenuPolicy(Qt::CustomContextMenu);
- m_bmBar->setIconDimensions(16);
Application::bookmarkProvider()->setupBookmarkBar(m_bmBar);
+
+ if (ReKonfig::firstExecution())
+ {
+ m_mainBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
+
+ m_bmBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ m_bmBar->setIconDimensions(16);
+ m_bmBar->hide();
+
+ KToolBar::setToolBarsEditable(false);
+ KToolBar::setToolBarsLocked(true);
+
+ ReKonfig::setFirstExecution(false);
+ }
}
@@ -196,13 +205,13 @@ void MainWindow::postLaunch()
{
// KActionCollection read settings
m_ac->readSettings();
-
+
// notification system
connect(m_view, SIGNAL(showStatusBarMessage(const QString&, Rekonq::Notify)), this, SLOT(notifyMessage(const QString&, Rekonq::Notify)));
connect(m_view, SIGNAL(linkHovered(const QString&)), this, SLOT(notifyMessage(const QString&)));
// --------- connect signals and slots
- connect(m_view, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(updateWindowTitle(const QString &)));
+ connect(m_view, SIGNAL(currentTitle(const QString &)), this, SLOT(updateWindowTitle(const QString &)));
connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *)));
// (shift +) ctrl + tab switching
@@ -251,8 +260,8 @@ void MainWindow::setupActions()
// new window action
a = new KAction(KIcon("window-new"), i18n("&New Window"), this);
a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_N));
- actionCollection()->addAction(QLatin1String("new_window"), a);
- connect(a, SIGNAL(triggered(bool)), Application::instance(), SLOT(newMainWindow()));
+ actionCollection()->addAction(QL1S("new_window"), a);
+ connect(a, SIGNAL(triggered(bool)), Application::instance(), SLOT(newWindow()));
// Standard Actions
KStandardAction::open(this, SLOT(fileOpen()), actionCollection());
@@ -261,142 +270,157 @@ void MainWindow::setupActions()
KStandardAction::quit(this , SLOT(close()), actionCollection());
a = KStandardAction::find(m_findBar, SLOT(show()), actionCollection());
- QList<QKeySequence> shortcutFindList;
- shortcutFindList << KStandardShortcut::find() << QKeySequence( Qt::Key_Slash );
- a->setShortcuts( shortcutFindList );
+ KShortcut findShortcut = KStandardShortcut::find();
+ findShortcut.setAlternate(Qt::Key_Slash);
+ a->setShortcut(findShortcut);
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 );
- a->setShortcuts( shortcutFullScreenList );
+ KShortcut fullScreenShortcut = KStandardShortcut::fullScreen();
+ fullScreenShortcut.setAlternate(Qt::Key_F11);
+ a->setShortcut(fullScreenShortcut);
- KStandardAction::home(this, SLOT(homePage()), actionCollection());
+ a = actionCollection()->addAction(KStandardAction::Home);
+ connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(homePage(Qt::MouseButtons, Qt::KeyboardModifiers)));
KStandardAction::preferences(this, SLOT(preferences()), actionCollection());
a = KStandardAction::redisplay(m_view, SLOT(webReload()), actionCollection());
a->setText(i18n("Reload"));
+ KShortcut reloadShortcut = KStandardShortcut::reload();
+ reloadShortcut.setAlternate(Qt::CTRL + Qt::Key_R);
+ a->setShortcut(reloadShortcut);
a = new KAction(KIcon("process-stop"), i18n("&Stop"), this);
a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_Period));
- actionCollection()->addAction(QLatin1String("stop"), a);
+ actionCollection()->addAction(QL1S("stop"), a);
connect(a, SIGNAL(triggered(bool)), m_view, SLOT(webStop()));
// stop reload Action
m_stopReloadAction = new KAction(this);
- actionCollection()->addAction(QLatin1String("stop_reload") , m_stopReloadAction);
+ actionCollection()->addAction(QL1S("stop_reload") , m_stopReloadAction);
m_stopReloadAction->setShortcutConfigurable(false);
connect(m_view, SIGNAL(browserTabLoading(bool)), this, SLOT(browserLoading(bool)));
browserLoading(false); //first init for blank start page
a = new KAction(i18n("Open Location"), this);
a->setShortcut(Qt::CTRL + Qt::Key_L);
- actionCollection()->addAction(QLatin1String("open_location"), a);
+ actionCollection()->addAction(QL1S("open_location"), a);
connect(a, SIGNAL(triggered(bool)) , this, SLOT(openLocation()));
// ============================= Zoom Actions ===================================
- a = new KAction(KIcon("zoom-in"), i18n("&Enlarge Font"), this);
+ a = new KAction(KIcon("zoom-in"), i18n("&Zoom In"), this);
a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_Plus));
- actionCollection()->addAction(QLatin1String("bigger_font"), a);
- connect(a, SIGNAL(triggered(bool)), this, SLOT(viewTextBigger()));
+ actionCollection()->addAction(QL1S("zoom_in"), a);
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(zoomIn()));
- a = new KAction(KIcon("zoom-original"), i18n("&Normal Font"), this);
+ a = new KAction(KIcon("zoom-original"), i18n("&Normal Zoom"), this);
a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_0));
- actionCollection()->addAction(QLatin1String("normal_font"), a);
- connect(a, SIGNAL(triggered(bool)), this, SLOT(viewTextNormal()));
+ actionCollection()->addAction(QL1S("zoom_normal"), a);
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(zoomNormal()));
- a = new KAction(KIcon("zoom-out"), i18n("&Shrink Font"), this);
+ a = new KAction(KIcon("zoom-out"), i18n("&Zoom Out"), this);
a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_Minus));
- actionCollection()->addAction(QLatin1String("smaller_font"), a);
- connect(a, SIGNAL(triggered(bool)), this, SLOT(viewTextSmaller()));
+ actionCollection()->addAction(QL1S("zoom_out"), a);
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(zoomOut()));
// =============================== Tools Actions =================================
a = new KAction(i18n("Page S&ource"), this);
a->setIcon(KIcon("application-xhtml+xml"));
- actionCollection()->addAction(QLatin1String("page_source"), a);
+ actionCollection()->addAction(QL1S("page_source"), a);
connect(a, SIGNAL(triggered(bool)), this, SLOT(viewPageSource()));
a = new KAction(KIcon("view-media-artist"), i18n("Private &Browsing"), this);
a->setCheckable(true);
- actionCollection()->addAction(QLatin1String("private_browsing"), a);
+ actionCollection()->addAction(QL1S("private_browsing"), a);
connect(a, SIGNAL(triggered(bool)), this, SLOT(privateBrowsing(bool)));
a = new KAction(KIcon("edit-clear"), i18n("Clear Private Data..."), this);
- actionCollection()->addAction(QLatin1String("clear_private_data"), a);
+ actionCollection()->addAction(QL1S("clear_private_data"), a);
connect(a, SIGNAL(triggered(bool)), this, SLOT(clearPrivateData()));
// ========================= History related actions ==============================
- a = KStandardAction::back(this, SLOT(openPrevious()) , actionCollection());
+ a = actionCollection()->addAction(KStandardAction::Back);
+ connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(openPrevious(Qt::MouseButtons, Qt::KeyboardModifiers)));
m_historyBackMenu = new KMenu(this);
a->setMenu(m_historyBackMenu);
connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowBackMenu()));
connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(openActionUrl(QAction *)));
- KStandardAction::forward(this, SLOT(openNext()) , actionCollection());
+ a = actionCollection()->addAction(KStandardAction::Forward);
+ connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(openNext(Qt::MouseButtons, Qt::KeyboardModifiers)));
// ============================== General Tab Actions ====================================
a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this);
a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_T));
- actionCollection()->addAction(QLatin1String("new_tab"), a);
+ actionCollection()->addAction(QL1S("new_tab"), a);
connect(a, SIGNAL(triggered(bool)), m_view, SLOT(newTab()));
a = new KAction(KIcon("view-refresh"), i18n("Reload All Tabs"), this);
- actionCollection()->addAction( QLatin1String("reload_all_tabs"), a);
- connect(a, SIGNAL(triggered(bool)), m_view, SLOT(reloadAllTabs()) );
+ actionCollection()->addAction(QL1S("reload_all_tabs"), a);
+ connect(a, SIGNAL(triggered(bool)), m_view, SLOT(reloadAllTabs()));
a = new KAction(i18n("Show Next Tab"), this);
a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext());
- actionCollection()->addAction(QLatin1String("show_next_tab"), a);
+ actionCollection()->addAction(QL1S("show_next_tab"), a);
connect(a, SIGNAL(triggered(bool)), m_view, SLOT(nextTab()));
a = new KAction(i18n("Show Previous Tab"), this);
a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev());
- actionCollection()->addAction(QLatin1String("show_prev_tab"), a);
+ actionCollection()->addAction(QL1S("show_prev_tab"), a);
connect(a, SIGNAL(triggered(bool)), m_view, SLOT(previousTab()));
// ============================== Indexed Tab Actions ====================================
a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this);
- actionCollection()->addAction(QLatin1String("close_tab"), a);
+ actionCollection()->addAction(QL1S("close_tab"), a);
connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(closeTab()));
a = new KAction(KIcon("tab-duplicate"), i18n("Clone Tab"), this);
- actionCollection()->addAction(QLatin1String("clone_tab"), a);
- connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(cloneTab()) );
+ actionCollection()->addAction(QL1S("clone_tab"), a);
+ connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(cloneTab()));
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()) );
+ actionCollection()->addAction(QL1S("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()) );
+ actionCollection()->addAction(QL1S("reload_tab"), a);
+ connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(reloadTab()));
a = new KAction(KIcon("tab-detach"), i18n("Detach Tab"), this);
- actionCollection()->addAction( QLatin1String("detach_tab"), a);
- connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(detachTab()) );
-
+ actionCollection()->addAction(QL1S("detach_tab"), a);
+ connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(detachTab()));
+
+
// ----------------------- Bookmarks ToolBar Action --------------------------------------
QAction *qa;
-
+
qa = m_mainBar->toggleViewAction();
- qa->setText( i18n("Main Toolbar") );
- qa->setIcon( KIcon("bookmark-toolbar") );
- actionCollection()->addAction(QLatin1String("main_bar"), qa);
-
+ qa->setText(i18n("Main Toolbar"));
+ qa->setIcon(KIcon("bookmark-toolbar"));
+ actionCollection()->addAction(QL1S("main_bar"), qa);
+
qa = m_bmBar->toggleViewAction();
- qa->setText( i18n("Bookmarks Toolbar") );
- qa->setIcon( KIcon("bookmark-toolbar") );
- actionCollection()->addAction(QLatin1String("bm_bar"), qa);
+ qa->setText(i18n("Bookmarks Toolbar"));
+ qa->setIcon(KIcon("bookmark-toolbar"));
+ actionCollection()->addAction(QL1S("bm_bar"), qa);
// Bookmark Menu
KActionMenu *bmMenu = Application::bookmarkProvider()->bookmarkActionMenu(this);
bmMenu->setIcon(KIcon("bookmarks"));
bmMenu->setDelayed(false);
- actionCollection()->addAction(QLatin1String("bookmarksActionMenu"), bmMenu);
+ actionCollection()->addAction(QL1S("bookmarksActionMenu"), bmMenu);
+
+
+ // ---------------- Encodings -----------------------------------
+ a = new KAction(KIcon("character-set"), i18n("Set Encoding"), this);
+ actionCollection()->addAction(QL1S("encodings"), a);
+ a->setMenu(m_encodingMenu);
+ connect(m_encodingMenu, SIGNAL(aboutToShow()), this, SLOT(populateEncodingMenu()));
+ connect(m_encodingMenu, SIGNAL(triggered(QAction *)), this, SLOT(setEncoding(QAction *)));
}
@@ -410,162 +434,121 @@ void MainWindow::setupTools()
toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Print)));
toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Find)));
- KActionMenu *fontMenu = new KActionMenu(KIcon("page-zoom"), i18n("Zoom"), this);
- fontMenu->addAction(actionByName(QLatin1String("smaller_font")));
- fontMenu->addAction(actionByName(QLatin1String("normal_font")));
- fontMenu->addAction(actionByName(QLatin1String("bigger_font")));
- toolsMenu->addAction(fontMenu);
+ // setup zoom widget
+ QWidget *zoomWidget = new QWidget(this);
+
+ QToolButton *zoomOut = new QToolButton(zoomWidget);
+ zoomOut->setDefaultAction(actionByName(QL1S("zoom_out")));
+ zoomOut->setAutoRaise(true);
+
+ m_zoomSlider = new QSlider(Qt::Horizontal, zoomWidget);
+ m_zoomSlider->setTracking(true);
+ m_zoomSlider->setRange(1, 19); // divide by 10 to obtain a qreal for zoomFactor()
+ m_zoomSlider->setValue(10);
+ m_zoomSlider->setPageStep(3);
+ connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setZoomFactor(int)));
+
+ QToolButton *zoomIn = new QToolButton(zoomWidget);
+ zoomIn->setDefaultAction(actionByName(QL1S("zoom_in")));
+ zoomIn->setAutoRaise(true);
+
+ QToolButton *zoomNormal = new QToolButton(zoomWidget);
+ zoomNormal->setDefaultAction(actionByName(QL1S("zoom_normal")));
+ zoomNormal->setAutoRaise(true);
+
+ QHBoxLayout* zoomWidgetLayout = new QHBoxLayout(zoomWidget);
+ zoomWidgetLayout->setSpacing(0);
+ zoomWidgetLayout->setMargin(0);
+ zoomWidgetLayout->addWidget(zoomOut);
+ zoomWidgetLayout->addWidget(m_zoomSlider);
+ zoomWidgetLayout->addWidget(zoomIn);
+ zoomWidgetLayout->addWidget(zoomNormal);
+
+ QWidgetAction *zoomAction = new QWidgetAction(this);
+ zoomAction->setDefaultWidget(zoomWidget);
+ toolsMenu->addAction(zoomAction);
toolsMenu->addSeparator();
- toolsMenu->addAction(actionByName(QLatin1String("private_browsing")));
- toolsMenu->addAction(actionByName(QLatin1String("clear_private_data")));
+ toolsMenu->addAction(actionByName(QL1S("private_browsing")));
+ toolsMenu->addAction(actionByName(QL1S("clear_private_data")));
toolsMenu->addSeparator();
KActionMenu *webMenu = new KActionMenu(KIcon("applications-development-web"), i18n("Web Development"), this);
- webMenu->addAction(actionByName(QLatin1String("web_inspector")));
- webMenu->addAction(actionByName(QLatin1String("page_source")));
+ webMenu->addAction(actionByName(QL1S("web_inspector")));
+ webMenu->addAction(actionByName(QL1S("page_source")));
toolsMenu->addAction(webMenu);
toolsMenu->addSeparator();
- toolsMenu->addAction(actionByName(QLatin1String("bm_bar")));
- toolsMenu->addAction(actionByName(QLatin1String("show_history_panel")));
- toolsMenu->addAction(actionByName(QLatin1String("show_bookmarks_panel")));
+ toolsMenu->addAction(actionByName(QL1S("bm_bar")));
+ toolsMenu->addAction(actionByName(QL1S("show_history_panel")));
+ toolsMenu->addAction(actionByName(QL1S("show_bookmarks_panel")));
toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::FullScreen)));
toolsMenu->addSeparator();
+ toolsMenu->addAction(actionByName(QL1S("encodings")));
+
helpMenu()->setIcon(KIcon("help-browser"));
toolsMenu->addAction(helpMenu()->menuAction());
toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Preferences)));
// adding rekonq_tools to rekonq actionCollection
- actionCollection()->addAction(QLatin1String("rekonq_tools"), toolsMenu);
+ actionCollection()->addAction(QL1S("rekonq_tools"), toolsMenu);
}
void MainWindow::setupPanels()
{
KAction* a;
-
+
// STEP 1
// Setup history panel
m_historyPanel = new HistoryPanel(i18n("History Panel"), this);
- connect(m_historyPanel, SIGNAL(openUrl(const KUrl&)), Application::instance(), SLOT(loadUrl(const KUrl&)));
+ connect(m_historyPanel, SIGNAL(openUrl(const KUrl&, const Rekonq::OpenType &)), Application::instance(), SLOT(loadUrl(const KUrl&, const Rekonq::OpenType &)));
+ connect(m_historyPanel, SIGNAL(itemHovered(QString)), this, SLOT(notifyMessage(QString)));
connect(m_historyPanel, SIGNAL(destroyed()), Application::instance(), SLOT(saveConfiguration()));
addDockWidget(Qt::LeftDockWidgetArea, m_historyPanel);
// setup history panel action
a = (KAction *) m_historyPanel->toggleViewAction();
- a->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_H) );
+ a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_H));
a->setIcon(KIcon("view-history"));
- actionCollection()->addAction(QLatin1String("show_history_panel"), a);
+ actionCollection()->addAction(QL1S("show_history_panel"), a);
// STEP 2
// Setup bookmarks panel
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(openUrl(const KUrl&, const Rekonq::OpenType &)), Application::instance(), SLOT(loadUrl(const KUrl&, const Rekonq::OpenType &)));
+ connect(m_bookmarksPanel, SIGNAL(itemHovered(QString)), this, SLOT(notifyMessage(QString)));
connect(m_bookmarksPanel, SIGNAL(destroyed()), Application::instance(), SLOT(saveConfiguration()));
addDockWidget(Qt::LeftDockWidgetArea, m_bookmarksPanel);
// setup bookmarks panel action
a = (KAction *) m_bookmarksPanel->toggleViewAction();
- a->setShortcut( QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B) );
+ a->setShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_B));
a->setIcon(KIcon("bookmarks-organize"));
- actionCollection()->addAction(QLatin1String("show_bookmarks_panel"), a);
+ actionCollection()->addAction(QL1S("show_bookmarks_panel"), a);
// STEP 3
// Setup webinspector panel
m_webInspectorPanel = new WebInspectorPanel(i18n("Web Inspector"), this);
connect(mainView(), SIGNAL(currentChanged(int)), m_webInspectorPanel, SLOT(changeCurrentPage()));
-
+
a = new KAction(KIcon("tools-report-bug"), i18n("Web &Inspector"), this);
a->setCheckable(true);
- actionCollection()->addAction(QLatin1String("web_inspector"), a);
+ actionCollection()->addAction(QL1S("web_inspector"), a);
connect(a, SIGNAL(triggered(bool)), m_webInspectorPanel, SLOT(toggle(bool)));
-
+
addDockWidget(Qt::BottomDockWidgetArea, m_webInspectorPanel);
m_webInspectorPanel->hide();
}
-
-void MainWindow::updateConfiguration()
-{
- // ============== General ==================
- m_view->updateTabBar();
-
- // ============== Tabs ==================
- if (ReKonfig::closeTabSelectPrevious())
- m_view->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
- else
- m_view->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectRightTab);
-
- // =========== Fonts ==============
- QWebSettings *defaultSettings = QWebSettings::globalSettings();
-
- int fnSize = ReKonfig::fontSize();
- int minFnSize = ReKonfig::minFontSize();
-
- QFont standardFont = ReKonfig::standardFont();
- defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family());
- defaultSettings->setFontSize(QWebSettings::DefaultFontSize, fnSize);
- defaultSettings->setFontSize(QWebSettings::MinimumFontSize, minFnSize);
-
- QFont fixedFont = ReKonfig::fixedFont();
- defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family());
- defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fnSize);
-
- // ================ WebKit ============================
- defaultSettings->setAttribute(QWebSettings::AutoLoadImages, ReKonfig::autoLoadImages());
- defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, ReKonfig::javascriptEnabled());
- defaultSettings->setAttribute(QWebSettings::JavaEnabled, ReKonfig::javaEnabled());
- defaultSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, ReKonfig::javascriptCanOpenWindows());
- defaultSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, ReKonfig::javascriptCanAccessClipboard());
- defaultSettings->setAttribute(QWebSettings::LinksIncludedInFocusChain, ReKonfig::linksIncludedInFocusChain());
- defaultSettings->setAttribute(QWebSettings::ZoomTextOnly, ReKonfig::zoomTextOnly());
- defaultSettings->setAttribute(QWebSettings::PrintElementBackgrounds, ReKonfig::printElementBackgrounds());
-
- if(ReKonfig::pluginsEnabled() == 2)
- defaultSettings->setAttribute(QWebSettings::PluginsEnabled, false);
- else
- defaultSettings->setAttribute(QWebSettings::PluginsEnabled, true);
-
- // ===== HTML 5 features WebKit support ======
- defaultSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, ReKonfig::offlineStorageDatabaseEnabled());
- defaultSettings->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, ReKonfig::offlineWebApplicationCacheEnabled());
- defaultSettings->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, ReKonfig::localStorageDatabaseEnabled());
- if(ReKonfig::localStorageDatabaseEnabled())
- {
- QString path = KStandardDirs::locateLocal("cache", QString("WebkitLocalStorage/rekonq"), true);
- path.remove("rekonq");
- 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());
-
- // ====== load Settings on main classes
- Application::historyManager()->loadSettings();
- Application::adblockManager()->loadSettings();
-
- defaultSettings = 0;
-}
-
-
-void MainWindow::updateBrowser()
-{
- updateConfiguration();
- mainView()->reloadAllTabs();
-}
-
-
void MainWindow::openLocation()
{
m_view->urlBar()->selectAll();
@@ -578,7 +561,7 @@ void MainWindow::fileSaveAs()
KUrl srcUrl = currentTab()->url();
QString name = srcUrl.fileName();
- if(name.isNull())
+ if (name.isNull())
{
name = srcUrl.host() + QString(".html");
}
@@ -602,7 +585,7 @@ void MainWindow::preferences()
QPointer<SettingsDialog> s = new SettingsDialog(this);
// keep us informed when the user changes settings
- connect(s, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateBrowser()));
+ connect(s, SIGNAL(settingsChanged(const QString&)), Application::instance(), SLOT(updateConfiguration()));
s->exec();
delete s;
@@ -624,9 +607,9 @@ void MainWindow::updateWindowTitle(const QString &title)
QWebSettings *settings = QWebSettings::globalSettings();
if (title.isEmpty())
{
- if(settings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ if (settings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
{
- setWindowTitle("rekonq (" + i18n("Private Browsing") + ")");
+ setWindowTitle(i18nc("Window title when private browsing is activated", "rekonq (Private Browsing)"));
}
else
{
@@ -635,13 +618,13 @@ void MainWindow::updateWindowTitle(const QString &title)
}
else
{
- if(settings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
+ if (settings->testAttribute(QWebSettings::PrivateBrowsingEnabled))
{
- setWindowTitle(title + " - rekonq (" + i18n("Private Browsing") + ")");
+ setWindowTitle(i18nc("window title, %1 = title of the active website", "%1 – rekonq (Private Browsing)", title));
}
else
{
- setWindowTitle(title + " - rekonq");
+ setWindowTitle(i18nc("window title, %1 = title of the active website", "%1 – rekonq", title));
}
}
}
@@ -651,7 +634,7 @@ void MainWindow::fileOpen()
{
QString filePath = KFileDialog::getOpenFileName(KUrl(),
i18n("*.html *.htm *.svg *.png *.gif *.svgz|Web Resources (*.html *.htm *.svg *.png *.gif *.svgz)\n"
- "*.*|All files (*.*)"),
+ "*.*|All files (*.*)"),
this,
i18n("Open Web Resource"));
@@ -668,7 +651,7 @@ void MainWindow::printRequested(QWebFrame *frame)
return;
QWebFrame *printFrame = 0;
- if(frame == 0)
+ if (frame == 0)
{
printFrame = currentTab()->page()->mainFrame();
}
@@ -696,16 +679,15 @@ void MainWindow::privateBrowsing(bool enable)
"<p>When private browsing is turned on,"
" web pages are not added to the history,"
" new cookies are not stored, current cookies cannot be accessed,"
- " site icons will not be stored, the session will not be saved, "
- " and searches are not added to the pop-up menu in the Google search box."
- " Until you close the window, you can still click the Back and Forward buttons"
+ " site icons will not be stored, the session will not be saved."
+ " Until you close the window, you can still click the Back and Forward buttons"
" to return to the web pages you have opened.</p>", title);
- int button = KMessageBox::questionYesNo(this, text, title);
- if (button == KMessageBox::Yes)
+ int button = KMessageBox::warningContinueCancel(this, text, title);
+ if (button == KMessageBox::Continue)
{
settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
- m_view->urlBar()->setBackgroundColor(Qt::lightGray); // palette().color(QPalette::Active, QPalette::Background));
+ m_view->urlBar()->setPrivateMode(true);
}
else
{
@@ -715,10 +697,9 @@ void MainWindow::privateBrowsing(bool enable)
else
{
settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
- m_view->urlBar()->setBackgroundColor(palette().color(QPalette::Active, QPalette::Base));
+ m_view->urlBar()->setPrivateMode(false);
m_lastSearch.clear();
- m_view->clear();
m_view->reloadAllTabs();
}
}
@@ -729,57 +710,111 @@ void MainWindow::find(const QString & search)
if (!currentTab())
return;
m_lastSearch = search;
+
+ findNext();
+}
+
+
+void MainWindow::matchCaseUpdate()
+{
+ if (!currentTab())
+ return;
+
+ currentTab()->view()->findText(m_lastSearch, QWebPage::FindBackward);
findNext();
}
void MainWindow::findNext()
{
- if (!currentTab() && m_lastSearch.isEmpty())
+ if (!currentTab())
+ return;
+
+ highlightAll();
+
+ if (m_findBar->isHidden())
+ {
+ QPoint previous_position = currentTab()->view()->page()->currentFrame()->scrollPosition();
+ currentTab()->view()->page()->focusNextPrevChild(true);
+ currentTab()->view()->page()->currentFrame()->setScrollPosition(previous_position);
return;
+ }
+
+ highlightAll();
QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
if (m_findBar->matchCase())
options |= QWebPage::FindCaseSensitively;
- m_findBar->notifyMatch(currentTab()->view()->findText(m_lastSearch, options));
+ bool found = currentTab()->view()->findText(m_lastSearch, options);
+ m_findBar->notifyMatch(found);
+
+ if (!found)
+ {
+ QPoint previous_position = currentTab()->view()->page()->currentFrame()->scrollPosition();
+ currentTab()->view()->page()->focusNextPrevChild(true);
+ currentTab()->view()->page()->currentFrame()->setScrollPosition(previous_position);
+ }
}
void MainWindow::findPrevious()
{
- if (!currentTab() && m_lastSearch.isEmpty())
+ if (!currentTab())
return;
QWebPage::FindFlags options = QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument;
if (m_findBar->matchCase())
options |= QWebPage::FindCaseSensitively;
- m_findBar->notifyMatch(currentTab()->view()->findText(m_lastSearch, options));
+ bool found = currentTab()->view()->findText(m_lastSearch, options);
+ m_findBar->notifyMatch(found);
}
-
-void MainWindow::viewTextBigger()
+void MainWindow::highlightAll()
{
if (!currentTab())
return;
- currentTab()->view()->setTextSizeMultiplier(currentTab()->view()->textSizeMultiplier() + 0.1);
+
+ QWebPage::FindFlags options = QWebPage::HighlightAllOccurrences;
+
+ currentTab()->view()->findText("", options); //Clear an existing highlight
+
+ if (m_findBar->highlightAllState() && !m_findBar->isHidden())
+ {
+ if (m_findBar->matchCase())
+ options |= QWebPage::FindCaseSensitively;
+
+ currentTab()->view()->findText(m_lastSearch, options);
+ }
}
-void MainWindow::viewTextNormal()
+void MainWindow::zoomIn()
{
- if (!currentTab())
- return;
- currentTab()->view()->setTextSizeMultiplier(1.0);
+ m_zoomSlider->setValue(m_zoomSlider->value() + 1);
+}
+
+void MainWindow::zoomNormal()
+{
+ m_zoomSlider->setValue(10);
}
+void MainWindow::zoomOut()
+{
+ m_zoomSlider->setValue(m_zoomSlider->value() - 1);
+}
-void MainWindow::viewTextSmaller()
+void MainWindow::setZoomFactor(int factor)
{
if (!currentTab())
return;
- currentTab()->view()->setTextSizeMultiplier(currentTab()->view()->textSizeMultiplier() - 0.1);
+ currentTab()->view()->setZoomFactor(QVariant(factor).toReal() / 10);
+}
+
+void MainWindow::setZoomSliderFactor(qreal factor)
+{
+ m_zoomSlider->setValue(factor*10);
}
@@ -806,10 +841,10 @@ void MainWindow::setWidgetsVisible(bool makeVisible)
historyPanelFlag = m_historyPanel->isHidden();
bookmarksPanelFlag = m_bookmarksPanel->isHidden();
}
-
- m_bmBar->hide();
+
+ m_bmBar->hide();
m_view->setTabBarHidden(true);
- m_historyPanel->hide();
+ m_historyPanel->hide();
m_bookmarksPanel->hide();
// hide main toolbar
@@ -828,7 +863,7 @@ void MainWindow::setWidgetsVisible(bool makeVisible)
m_historyPanel->show();
if (!bookmarksPanelFlag)
m_bookmarksPanel->show();
- }
+ }
}
@@ -856,13 +891,16 @@ void MainWindow::viewPageSource()
isTempFile = true;
}
}
- KRun::runUrl(url, QLatin1String("text/plain"), this, isTempFile);
+ KRun::runUrl(url, QL1S("text/plain"), this, isTempFile);
}
-void MainWindow::homePage()
+void MainWindow::homePage(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers keyboardModifiers)
{
- currentTab()->view()->load( QUrl(ReKonfig::homePage()) );
+ if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier)
+ Application::instance()->loadUrl(KUrl(ReKonfig::homePage()), Rekonq::SettingOpenTab);
+ else
+ currentTab()->view()->load(QUrl(ReKonfig::homePage()));
}
@@ -903,19 +941,41 @@ void MainWindow::browserLoading(bool v)
}
-void MainWindow::openPrevious()
+void MainWindow::openPrevious(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers keyboardModifiers)
{
QWebHistory *history = currentTab()->view()->history();
if (history->canGoBack())
- history->goToItem(history->backItem());
+ {
+ if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier)
+ {
+ Application::instance()->loadUrl(history->backItem().url(), Rekonq::SettingOpenTab);
+ }
+ else
+ {
+ history->goToItem(history->backItem());
+ }
+
+ updateActions();
+ }
+
}
-void MainWindow::openNext()
+void MainWindow::openNext(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers keyboardModifiers)
{
QWebHistory *history = currentTab()->view()->history();
if (history->canGoForward())
- history->goToItem(history->forwardItem());
+ {
+ if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier)
+ {
+ Application::instance()->loadUrl(history->forwardItem().url(), Rekonq::SettingOpenTab);
+ }
+ else
+ {
+ history->goToItem(history->forwardItem());
+ }
+ updateActions();
+ }
}
@@ -925,6 +985,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
if (event->key() == Qt::Key_Escape)
{
m_findBar->hide();
+ currentTab()->setFocus(); // give focus to web pages
return;
}
@@ -961,7 +1022,7 @@ QAction *MainWindow::actionByName(const QString name)
return ret;
/* else */
- kWarning() << "Action named: " << name << " not found, returning empty action.";
+ kDebug() << "Action named: " << name << " not found, returning empty action.";
return new QAction(this); // return empty object instead of NULL pointer
}
@@ -975,7 +1036,7 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)
}
// deleting popus if empty msgs
- if(msg.isEmpty())
+ if (msg.isEmpty())
{
m_hidePopup->start(250);
return;
@@ -984,7 +1045,7 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)
m_hidePopup->stop();
- switch(status)
+ switch (status)
{
case Rekonq::Info:
break;
@@ -1003,78 +1064,95 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)
// setting the popup
QLabel *label = new QLabel(msg);
m_popup->setView(label);
- QSize labelSize(label->fontMetrics().width(msg)+2*margin, label->fontMetrics().height()+2*margin);
+ QSize labelSize(label->fontMetrics().width(msg) + 2*margin, label->fontMetrics().height() + 2*margin);
if (labelSize.width() > width()) labelSize.setWidth(width());
m_popup->setFixedSize(labelSize);
m_popup->layout()->setAlignment(Qt::AlignTop);
m_popup->layout()->setMargin(margin);
// useful values
-
+ WebTab *tab = m_view->currentWebTab();
+
+ // fix crash on window close
+ if (!tab)
+ return;
+
// fix crash on window close
- if(!m_view->currentWebTab()->page()->currentFrame())
+ if (!tab->page())
return;
-
- bool scrollbarIsVisible = m_view->currentWebTab()->page()->currentFrame()->scrollBarMaximum(Qt::Horizontal);
+
+ bool scrollbarIsVisible = tab->page()->currentFrame()->scrollBarMaximum(Qt::Horizontal);
int scrollbarSize = 0;
if (scrollbarIsVisible)
{
//TODO: detect QStyle size
scrollbarSize = 17;
}
- QPoint webViewOrigin = m_view->currentWebTab()->mapToGlobal(QPoint(0,0));
- int bottomLeftY=webViewOrigin.y() + m_view->currentWebTab()->page()->viewportSize().height() - labelSize.height() - scrollbarSize;
+
+ QPoint webViewOrigin = tab->view()->mapToGlobal(QPoint(0, 0));
+ int bottomLeftY = webViewOrigin.y() + tab->page()->viewportSize().height() - labelSize.height() - scrollbarSize;
// setting popup in bottom-left position
int x = geometry().x();
int y = bottomLeftY;
- QPoint mousePos = m_view->currentWebTab()->mapToGlobal(m_view->currentWebTab()->view()->mousePos());
- if(QRect(webViewOrigin.x(),bottomLeftY,labelSize.width(),labelSize.height()).contains(mousePos))
+ QPoint mousePos = tab->mapToGlobal(tab->view()->mousePos());
+ if (QRect(webViewOrigin.x() , bottomLeftY , labelSize.width() , labelSize.height()).contains(mousePos))
{
// setting popup above the mouse
y = bottomLeftY - labelSize.height();
}
- m_popup->show(QPoint(x,y));
+ m_popup->show(QPoint(x, y));
}
void MainWindow::clearPrivateData()
{
- QPointer<KDialog> dialog = new KDialog(this, Qt::Sheet);
+ QPointer<KDialog> dialog = new KDialog(this);
+ dialog->setCaption(i18n("Clear Private Data"));
dialog->setButtons(KDialog::Ok | KDialog::Cancel);
+ dialog->button(KDialog::Ok)->setIcon(KIcon("edit-clear"));
+ dialog->button(KDialog::Ok)->setText(i18n("Clear"));
+
Ui::ClearDataWidget clearWidget;
QWidget widget;
clearWidget.setupUi(&widget);
dialog->setMainWidget(&widget);
+ dialog->exec();
- if (dialog->exec() == KDialog::Accepted)
+ if (dialog->result() == QDialog::Accepted)
{
- if(clearWidget.clearHistory->isChecked())
+ if (clearWidget.clearHistory->isChecked())
{
Application::historyManager()->clear();
}
- if(clearWidget.clearCookies->isChecked())
+ if (clearWidget.clearDownloads->isChecked())
+ {
+ Application::historyManager()->clearDownloadsHistory();
+ }
+
+ if (clearWidget.clearCookies->isChecked())
{
QDBusInterface kcookiejar("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer");
- QDBusReply<void> reply = kcookiejar.call( "deleteAllCookies" );
+ QDBusReply<void> reply = kcookiejar.call("deleteAllCookies");
}
- if(clearWidget.clearCachedPages->isChecked())
+ if (clearWidget.clearCachedPages->isChecked())
{
- // TODO implement me!
+ KProcess::startDetached(KStandardDirs::findExe("kio_http_cache_cleaner"),
+ QStringList(QL1S("--clear-all")));
}
- if(clearWidget.clearWebIcons->isChecked())
+ if (clearWidget.clearWebIcons->isChecked())
{
QWebSettings::clearIconDatabase();
}
- if(clearWidget.homePageThumbs->isChecked())
+ if (clearWidget.homePageThumbs->isChecked())
{
QString path = KStandardDirs::locateLocal("cache", QString("thumbs/rekonq"), true);
path.remove("rekonq");
@@ -1087,6 +1165,8 @@ void MainWindow::clearPrivateData()
}
}
}
+
+ dialog->deleteLater();
}
@@ -1100,19 +1180,17 @@ void MainWindow::aboutToShowBackMenu()
int offset = 0;
QList<QWebHistoryItem> historyList = history->backItems(8); //no more than 8 elements!
int listCount = historyList.count();
- if(pivot >= 8)
- offset = pivot - 8;
-
-
+ if (pivot >= 8)
+ offset = pivot - 8;
- for(int i = listCount - 1; i>=0; --i)
+ for (int i = listCount - 1; i >= 0; --i)
{
QWebHistoryItem item = historyList.at(i);
KAction *action = new KAction(this);
action->setData(i + offset);
- QIcon icon = Application::icon( item.url() );
- action->setIcon( icon );
- action->setText( item.title() );
+ KIcon icon = Application::icon(item.url());
+ action->setIcon(icon);
+ action->setText(item.title());
m_historyBackMenu->addAction(action);
}
}
@@ -1121,13 +1199,47 @@ void MainWindow::aboutToShowBackMenu()
void MainWindow::openActionUrl(QAction *action)
{
int index = action->data().toInt();
-
- QWebHistory *history = currentTab()->view()->history();
- if(!history->itemAt(index).isValid())
+
+ QWebHistory *history = currentTab()->view()->history();
+ if (!history->itemAt(index).isValid())
{
- kDebug() << "Invalid Index!: "<< index;
+ kDebug() << "Invalid Index!: " << index;
return;
}
- history->goToItem( history->itemAt(index) );
+ history->goToItem(history->itemAt(index));
+}
+
+
+void MainWindow::setEncoding(QAction *qa)
+{
+ QString currentCodec = qa->text().toLatin1();
+ currentCodec = currentCodec.remove('&');
+ kDebug() << currentCodec;
+ QWebSettings::globalSettings()->setDefaultTextEncoding(currentCodec);
+ ReKonfig::setDefaultEncoding(currentCodec);
+}
+
+
+void MainWindow::populateEncodingMenu()
+{
+ QList<QByteArray> byteCodecs = QTextCodec::availableCodecs();
+ QStringList codecs;
+ Q_FOREACH(const QByteArray &b, byteCodecs)
+ {
+ codecs << QString(b);
+ }
+ codecs.sort();
+
+ QString currentCodec = ReKonfig::defaultEncoding();
+ kDebug() << "Current Codec: " << currentCodec;
+
+ m_encodingMenu->clear();
+ Q_FOREACH(const QString &codec, codecs)
+ {
+ QAction *action = m_encodingMenu->addAction(codec);
+ action->setCheckable(true);
+ if (currentCodec == codec)
+ action->setChecked(true);
+ }
}