From c4feb4a5b3e770f892f763eaaab3193ac2431ccb Mon Sep 17 00:00:00 2001 From: Mirko Lindner Date: Wed, 7 Apr 2010 19:36:17 +0200 Subject: [PATCH] add mouse movement Signed-off-by: Mirko Lindner --- htmlarea.cpp | 39 ++++++++++++++++++++++++++++++++++++++- htmlarea.h | 3 +++ moc_htmlarea.cpp | 2 +- moc_qmain.cpp | 2 +- qmain.cpp | 15 +++++++++++++-- 5 files changed, 56 insertions(+), 5 deletions(-) diff --git a/htmlarea.cpp b/htmlarea.cpp index 81f9b4a..a45b050 100644 --- a/htmlarea.cpp +++ b/htmlarea.cpp @@ -115,9 +115,9 @@ void HtmlArea::setNewContent( int method, QString str = "" ){ log_debug("Text set"); // log_debug("index: " << article.getIndex()); // log_debug("enabled: " << this->isEnabled()); - log_debug("string: " << str.toUtf8().data()); qApp->processEvents(); qobject_cast(this->parentWidget())->setEnabled(true); + log_debug("string: " << str.toUtf8().data()); }else{ this->setText(current); @@ -324,3 +324,40 @@ zim::Search::Results HtmlArea::searchArticleFromTitle(QString phrase) log_debug("term :" << phrase.toUtf8().data()); return result; } + +/////////////////////////////////// +// functions related to navigation + +void HtmlArea::keyPressEvent(QKeyEvent *e){ + log_debug("key pressed"); + switch (e->key()) { + case Qt::Key_Right: + { + QPoint pos = qApp->overrideCursor()->pos(); + qApp->overrideCursor()->setPos(pos.x() + 5, pos.y()); + } + return; + + case Qt::Key_Left: + { + QPoint pos = qApp->overrideCursor()->pos(); + qApp->overrideCursor()->setPos(pos.x() - 5, pos.y()); + } + return; + + case Qt::Key_Down: + { + QPoint pos = qApp->overrideCursor()->pos(); + qApp->overrideCursor()->setPos(pos.x(), pos.y() + 5); + } + return; + + case Qt::Key_Up: + { + QPoint pos = qApp->overrideCursor()->pos(); + qApp->overrideCursor()->setPos(pos.x(), pos.y() - 5); + } + return; + } + QTextBrowser::keyPressEvent(e); +} \ No newline at end of file diff --git a/htmlarea.h b/htmlarea.h index dcea3f8..2be3771 100644 --- a/htmlarea.h +++ b/htmlarea.h @@ -52,6 +52,9 @@ class HtmlArea : public QTextBrowser void setNewContent( int method, QString str ); QVariant loadResource(int type, const QUrl &name); + protected: + virtual void keyPressEvent(QKeyEvent *e); + public Q_SLOTS: void linking( const QUrl &txt ); void sourceChange( const QUrl &txt ); diff --git a/moc_htmlarea.cpp b/moc_htmlarea.cpp index 02afd2f..5a04017 100644 --- a/moc_htmlarea.cpp +++ b/moc_htmlarea.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Meta object code from reading C++ file 'htmlarea.h' ** -** Created: Wed Apr 7 18:36:22 2010 +** Created: Wed Apr 7 19:01:42 2010 ** by: The Qt Meta Object Compiler version 61 (Qt 4.5.2) ** ** WARNING! All changes made in this file will be lost! diff --git a/moc_qmain.cpp b/moc_qmain.cpp index b460288..40cce16 100644 --- a/moc_qmain.cpp +++ b/moc_qmain.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** Meta object code from reading C++ file 'qmain.h' ** -** Created: Wed Apr 7 18:36:22 2010 +** Created: Wed Apr 7 19:01:42 2010 ** by: The Qt Meta Object Compiler version 61 (Qt 4.5.2) ** ** WARNING! All changes made in this file will be lost! diff --git a/qmain.cpp b/qmain.cpp index 15c435d..bfa0fe7 100644 --- a/qmain.cpp +++ b/qmain.cpp @@ -23,6 +23,10 @@ #include #include "qmain.h" +#include + +log_define("qvido.qmain"); + QMain::QMain(std::string File) { @@ -39,7 +43,14 @@ QMain::QMain(std::string File) centralWidget,SLOT(linking(const QUrl&))); QObject::connect(centralWidget,SIGNAL(sourceChanged(const QUrl &)), centralWidget,SLOT(sourceChange(const QUrl&))); - + + QCursor cursor; + + if (qApp->overrideCursor() == false){ + qApp->setOverrideCursor(cursor); + log_debug("no cursor"); + } + } QMain::~QMain(){} @@ -84,7 +95,7 @@ void QMain::registerCommands() connect(goToTopAct, SIGNAL(triggered()), this->centralWidget, SLOT(goToTop())); this->addAction(goToTopAct); - // quit qvid0 + // quit qvido quitAct = new QAction(tr("Quit QVido"), this); quitAct->setShortcut(tr("Ctrl+Q")); quitAct->setStatusTip(tr("Quit"));