Skip to content
Browse files

quickflick: first cut

  • Loading branch information...
1 parent f63d6c6 commit b44f73b30867b14c4b95abdf080d5cca3ca3aa5b @mwenge mwenge committed with Sep 14, 2009
Showing with 234 additions and 0 deletions.
  1. +19 −0 README
  2. +48 −0 src/browsermainwindow.cpp
  3. +11 −0 src/browsermainwindow.h
  4. +17 −0 src/tabwidget.cpp
  5. +14 −0 src/webpage.cpp
  6. +111 −0 src/webview.cpp
  7. +14 −0 src/webview.h
View
19 README
@@ -1,3 +1,22 @@
+Quickflick
+
+This feature proposal allows the user to flick quickly back and forth through their
+browsing history. The action of flicking is performed using CTRL+ALT and the left and right
+arrow buttons.
+
+A 'flick' consists of the item in history sliding in from the left of the screen (back) or
+the right of the screen (forward). Once the user has found the page in their history they
+wish to nagivate to, they release the CTRL+ALT keys and Arora loads that page.
+
+The approach has a number of advantages over conventional history navigation:
+
+ - The user can visually identify the page they are loading from history before nagivating to it.
+ This is more intuitive and reliable than identifying the page from the url/title.
+ - Navigating several pages back in the history is less time-consuming.
+ - When completing multi-page forms the user can review their input on previous pages without interrupting work
+ on the current page.
+
+---------------------
Arora web browser
http://www.arora-browser.org
View
48 src/browsermainwindow.cpp
@@ -89,6 +89,7 @@
#include "webview.h"
#include "webviewsearch.h"
+#include <qdesktopservices.h>
#include <qdesktopwidget.h>
#include <qevent.h>
#include <qfiledialog.h>
@@ -735,13 +736,25 @@ void BrowserMainWindow::setupMenu()
m_historyBackAction->setIconVisibleInMenu(false);
#endif
+ m_historyQuickBackAction = new QAction(this);
+ m_historyQuickBackAction->setShortcut(QKeySequence(Qt::AltModifier | Qt::ControlModifier | Qt::Key_Left));
+ m_historyQuickBackAction->setIconVisibleInMenu(false);
+ connect(m_historyQuickBackAction, SIGNAL(triggered()),
+ this, SLOT(quickBack()));
+
m_historyForwardAction = new QAction(this);
m_tabWidget->addWebAction(m_historyForwardAction, QWebPage::Forward);
m_historyForwardAction->setShortcuts(QKeySequence::Forward);
#if QT_VERSION < 0x040600 || (QT_VERSION >= 0x040600 && !defined(Q_WS_X11))
m_historyForwardAction->setIconVisibleInMenu(false);
#endif
+ m_historyQuickForwardAction = new QAction(this);
+ m_historyQuickForwardAction->setShortcut(QKeySequence(Qt::AltModifier | Qt::ControlModifier | Qt::Key_Right));
+ m_historyQuickForwardAction->setIconVisibleInMenu(false);
+ connect(m_historyQuickForwardAction, SIGNAL(triggered()),
+ this, SLOT(quickForward()));
+
m_historyHomeAction = new QAction(this);
connect(m_historyHomeAction, SIGNAL(triggered()), this, SLOT(goHome()));
m_historyHomeAction->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_H));
@@ -752,7 +765,9 @@ void BrowserMainWindow::setupMenu()
m_historyRestoreLastSessionAction->setEnabled(BrowserApplication::instance()->canRestoreSession());
historyActions.append(m_historyBackAction);
+ historyActions.append(m_historyQuickBackAction);
historyActions.append(m_historyForwardAction);
+ historyActions.append(m_historyQuickForwardAction);
historyActions.append(m_historyHomeAction);
historyActions.append(m_tabWidget->recentlyClosedTabsAction());
historyActions.append(m_historyRestoreLastSessionAction);
@@ -1589,3 +1604,36 @@ void BrowserMainWindow::geometryChangeRequested(const QRect &geometry)
setGeometry(geometry);
}
+void BrowserMainWindow::quickBack()
+{
+ if (!currentTab())
+ return;
+
+ m_lookback = true;
+ currentTab()->quickBack();
+
+}
+
+void BrowserMainWindow::quickForward()
+{
+ if (!currentTab())
+ return;
+ m_lookback = true;
+ currentTab()->quickForward();
+}
+
+void BrowserMainWindow::keyReleaseEvent ( QKeyEvent * event ) {
+ if ((event->key() == Qt::Key_Alt) && m_lookback) {
+ qDebug() << "improper key release event " << endl;
+ qDebug() << currentTab()->lookBackItem() << endl;
+ m_lookback = false;
+ QWebHistory *history = currentTab()->history();
+ currentTab()->clearScreenShot();
+ if (currentTab()->lookBackItem() != history->currentItemIndex())
+ history->goToItem(history->items().at(currentTab()->lookBackItem()));
+ event->accept();
+ return;
+ }
+ event->ignore();
+};
+
View
11 src/browsermainwindow.h
@@ -64,6 +64,10 @@
#define BROWSERMAINWINDOW_H
#include <qmainwindow.h>
+#include <qicon.h>
+#include <qurl.h>
+#include <QKeyEvent>
+#include <qdebug.h>
class AutoSaver;
class BookmarksToolBar;
@@ -76,6 +80,7 @@ class QFrame;
class HistoryMenu;
class BookmarksMenuBarMenu;
class UserAgentMenu;
+class QKeyEvent;
/*!
The MainWindow of the Browser Application.
@@ -167,12 +172,15 @@ private slots:
void printRequested(QWebFrame *frame);
void geometryChangeRequested(const QRect &geometry);
+ void quickBack();
+ void quickForward();
private:
void retranslate();
void loadDefaultState();
void setupMenu();
void setupToolBar();
void updateStopReloadActionText(bool loading);
+ void keyReleaseEvent ( QKeyEvent * event );
private:
QMenu *m_fileMenu;
@@ -217,7 +225,9 @@ private slots:
HistoryMenu *m_historyMenu;
QAction *m_historyBackAction;
+ QAction *m_historyQuickBackAction;
QAction *m_historyForwardAction;
+ QAction *m_historyQuickForwardAction;
QAction *m_historyHomeAction;
QAction *m_historyRestoreLastSessionAction;
@@ -264,6 +274,7 @@ private slots:
// used to determine if these bars should be reshown when leaving fullscreen.
bool m_menuBarVisible;
bool m_statusBarVisible;
+ bool m_lookback;
friend class BrowserApplication;
};
View
17 src/tabwidget.cpp
@@ -83,16 +83,19 @@
#include <qcompleter.h>
#include <qdir.h>
+#include <qdesktopservices.h>
#include <qevent.h>
#include <qlistview.h>
#include <qmenu.h>
#include <qmessagebox.h>
#include <qmovie.h>
+#include <qpainter.h>
#include <qsettings.h>
#include <qstackedwidget.h>
#include <qstyle.h>
#include <qtoolbutton.h>
#include <qwebhistory.h>
+#include <qwebframe.h>
#include <qdebug.h>
@@ -678,6 +681,20 @@ void TabWidget::webViewLoadFinished(bool ok)
emit showStatusBarMessage(tr("Finished loading"));
else
emit showStatusBarMessage(tr("Failed to load"));
+
+
+ QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+ QWebPage *page = webView->page();
+ QImage image(page->viewportSize(), QImage::Format_ARGB32);
+ QPainter painter(&image);
+ page->mainFrame()->render(&painter);
+ painter.end();
+ QString filename = QString(QLatin1String("%1/%2.png"))
+ .arg(directory)
+ .arg(webView->page()->mainFrame()->url().toString().replace(QLatin1String("/"),QLatin1String("")));
+ image.save(filename);
+ webView->addScreenShot(filename);
+
}
void TabWidget::webViewIconChanged()
View
14 src/webpage.cpp
@@ -36,6 +36,7 @@
#include <qmessagebox.h>
#include <qnetworkreply.h>
#include <qnetworkrequest.h>
+#include <qpainter.h>
#include <qsettings.h>
#include <qwebframe.h>
@@ -298,6 +299,19 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
bool accepted = QWebPage::acceptNavigationRequest(frame, request, type);
if (accepted && frame == mainFrame()) {
+ QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+ QImage image(viewportSize(), QImage::Format_ARGB32);
+ QPainter painter(&image);
+ mainFrame()->render(&painter);
+ painter.end();
+
+ QString filename = QString(QLatin1String("%1/%2.png"))
+ .arg(directory)
+ .arg(mainFrame()->url().toString().replace(QLatin1String("/"),QLatin1String("")));
+ image.save(filename);
+ WebView *webView = qobject_cast<WebView*>(view());
+ webView->addScreenShot(filename);
+
m_requestedUrl = request.url();
emit aboutToLoadUrl(request.url());
}
View
111 src/webview.cpp
@@ -81,10 +81,13 @@
#include <qclipboard.h>
#include <qdebug.h>
+#include <qdesktopservices.h>
#include <qevent.h>
#include <qmenubar.h>
+#include <qpainter.h>
#include <qtimer.h>
#include <qwebframe.h>
+#include <qwebhistory.h>
#if QT_VERSION >= 0x040600 || defined(WEBKIT_TRUNK)
#if !defined(QTWEBKIT_VERSION) || QTWEBKIT_VERSION < 0x020000
@@ -110,6 +113,7 @@ WebView::WebView(QWidget *parent)
, m_enableAccessKeys(true)
, m_accessKeysPressed(false)
#endif
+ , m_screenshot()
{
setPage(m_page);
#if QT_VERSION >= 0x040600
@@ -148,6 +152,15 @@ WebView::WebView(QWidget *parent)
loadSettings();
}
+WebView::~WebView()
+{
+ QStringListIterator iter(m_screenshotfiles);
+ while (iter.hasNext()) {
+ QFile file(iter.next());
+ file.remove();
+ }
+}
+
void WebView::loadSettings()
{
#if QT_VERSION >= 0x040600 || defined(WEBKIT_TRUNK)
@@ -575,6 +588,8 @@ void WebView::loadFinished()
m_progress = 0;
AdBlockManager::instance()->page()->applyRulesToPage(page());
BrowserApplication::instance()->autoFillManager()->fill(page());
+
+ m_quickhistorycurrentitem = history()->currentItemIndex();
}
void WebView::loadUrl(const QUrl &url, const QString &title)
@@ -908,3 +923,99 @@ void WebView::makeAccessKeyLabel(const QChar &accessKey, const QWebElement &elem
}
#endif
+
+void WebView::displayScreenShot(const QPixmap &screenshot)
+{
+ m_screenshot = screenshot;
+ update();
+}
+
+void WebView::paintEvent(QPaintEvent *event)
+{
+ if (!m_screenshot.isNull()) {
+ QPixmap toaster;
+ m_width += 100;
+ QPainter painter(this);
+
+ int tx = x();
+ if (m_width < width()) {
+ tx = (width() - m_width);
+ if (m_forward)
+ toaster = m_screenshot.copy(QRect(x(), y(), m_width, height()));
+ else
+ toaster = m_screenshot.copy(QRect(tx, y(), m_width, height()));
+ QTimer::singleShot(20, this, SLOT(update()));
+ } else
+ toaster = m_screenshot;
+ if (m_forward)
+ painter.drawPixmap(QPoint(tx,y()), toaster);
+ else
+ painter.drawPixmap(QPoint(x(),y()), toaster);
+ if (m_quickhistorycurrentitem >= (history()->count() - 1) && (toaster.width() == m_screenshot.width())) {
+ m_screenshot = 0L;
+ m_quickhistorycurrentitem = history()->count() - 1;
+ return;
+ }
+
+ return;
+ }
+
+ QWebView::paintEvent(event);
+}
+
+void WebView::quickBack()
+{
+ if (m_quickhistorycurrentitem == 0)
+ return;
+
+ m_quickhistorycurrentitem--;
+ m_width = 0;
+ m_forward = false;
+
+ QString urlString = history()->items().at(m_quickhistorycurrentitem).url().toString();
+ QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+ QString filename = QString(QLatin1String("%1/%2.png"))
+ .arg(directory)
+ .arg(urlString.replace(QLatin1String("/"),QLatin1String("")));
+
+ QPixmap screenshot;
+ bool loaded = screenshot.load(filename);
+
+ displayScreenShot(screenshot);
+
+ qDebug() << "quick screenshot " << filename;
+ qDebug() << "loaded " << loaded;
+
+}
+
+void WebView::quickForward()
+{
+ qDebug() << "m_quickhistorycurrentitem " << m_quickhistorycurrentitem;
+ qDebug() << "history()->items().count() " << history()->items().count();
+ if (m_quickhistorycurrentitem >= (history()->items().count() - 1)) {
+ return;
+ }
+
+ m_width = 0;
+ m_forward = true;
+ m_quickhistorycurrentitem++;
+
+ QString urlString = history()->items().at(m_quickhistorycurrentitem).url().toString();
+ QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
+ QString filename = QString(QLatin1String("%1/%2.png"))
+ .arg(directory)
+ .arg(urlString.replace(QLatin1String("/"),QLatin1String("")));
+
+ QPixmap screenshot;
+ bool loaded = screenshot.load(filename);
+
+ displayScreenShot(screenshot);
+
+ qDebug() << "quick screenshot " << filename;
+ qDebug() << "loaded " << loaded;
+}
+
+int WebView::lookBackItem()
+{
+ return m_quickhistorycurrentitem;
+}
View
14 src/webview.h
@@ -82,6 +82,7 @@ class WebView : public QWebView
public:
WebView(QWidget *parent = 0);
+ ~WebView();
WebPage *webPage() const { return m_page; }
#if !(QT_VERSION >= 0x040600)
@@ -101,6 +102,10 @@ class WebView : public QWebView
inline int progress() const { return m_progress; }
TabWidget *tabWidget() const;
+ void displayScreenShot(const QPixmap &screenshot);
+ int lookBackItem();
+ void clearScreenShot() { m_screenshot = 0L; }
+ void addScreenShot(const QString &filename) { m_screenshotfiles << filename; }
signals:
void search(const QUrl &searchUrl, TabWidget::OpenUrlIn openIn);
@@ -109,6 +114,8 @@ public slots:
void zoomOut();
void resetZoom();
void applyZoom();
+ void quickBack();
+ void quickForward();
protected:
void mousePressEvent(QMouseEvent *event);
@@ -154,6 +161,11 @@ private slots:
QList<int> m_zoomLevels;
WebPage *m_page;
+ void paintEvent(QPaintEvent *event);
+ QPixmap m_screenshot;
+ int m_width;
+ bool m_forward;
+
#if QT_VERSION >= 0x040600 || defined(WEBKIT_TRUNK)
bool m_enableAccessKeys;
bool checkForAccessKey(QKeyEvent *event);
@@ -163,6 +175,8 @@ private slots:
QHash<QChar, QWebElement> m_accessKeyNodes;
bool m_accessKeysPressed;
#endif
+ int m_quickhistorycurrentitem;
+ QStringList m_screenshotfiles;
};
#endif

0 comments on commit b44f73b

Please sign in to comment.
Something went wrong with that request. Please try again.