mirror of
https://github.com/YACReader/yacreader
synced 2025-07-20 14:04:40 -04:00
fixed key events in goToFlow
TODO: add eventFilter to goToFlow edit...
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QMutex>
|
||||
#include <QCoreApplication>
|
||||
#include <QApplication>
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
@ -71,6 +71,20 @@ GoToFlow::~GoToFlow()
|
||||
worker->deleteLater();
|
||||
}
|
||||
|
||||
void GoToFlow::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Left: case Qt::Key_Right: case Qt::Key_Up:
|
||||
QApplication::sendEvent(flow,event);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
GoToFlowWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void GoToFlow::centerSlide(int slide)
|
||||
{
|
||||
if(flow->centerIndex()!=slide)
|
||||
@ -188,23 +202,6 @@ void GoToFlow::updateImageData()
|
||||
updateTimer->stop();
|
||||
}
|
||||
|
||||
bool GoToFlow::eventFilter(QObject *target, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress)
|
||||
{
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
int key = keyEvent->key();
|
||||
if((key==Qt::Key_Return)||
|
||||
(key==Qt::Key_Enter)||
|
||||
(key==Qt::Key_Space)||
|
||||
(key==Qt::Key_Left)||
|
||||
(key==Qt::Key_Right)||
|
||||
(key==Qt::Key_S))
|
||||
this->keyPressEvent(keyEvent);
|
||||
}
|
||||
return QWidget::eventFilter(target, event);
|
||||
}
|
||||
|
||||
void GoToFlow::wheelEvent(QWheelEvent * event)
|
||||
{
|
||||
if(event->delta()<0)
|
||||
|
@ -23,6 +23,7 @@ class SlideInitializer;
|
||||
class PageLoader;
|
||||
class YACReaderFlow;
|
||||
class PictureFlow;
|
||||
class QKeyEvent;
|
||||
|
||||
class GoToFlow : public GoToFlowWidget
|
||||
{
|
||||
@ -31,9 +32,9 @@ public:
|
||||
GoToFlow(QWidget* parent = 0,FlowType flowType = CoverFlowLike);
|
||||
~GoToFlow();
|
||||
bool ready; //comic is ready for read.
|
||||
bool eventFilter(QObject *target, QEvent *event);
|
||||
private:
|
||||
YACReaderFlow * flow;
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
//Comic * comic;
|
||||
QSize imageSize;
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QPushButton>
|
||||
#include <QPushButton>
|
||||
#include <QSize>
|
||||
#include <QApplication>
|
||||
|
||||
#include "configuration.h"
|
||||
|
||||
@ -32,12 +33,6 @@ GoToFlowGL::GoToFlowGL(QWidget* parent, FlowType flowType)
|
||||
|
||||
resize(static_cast<int>(5*imageSize.width()),static_cast<int>(imageSize.height()*1.7));
|
||||
|
||||
//install eventFilter
|
||||
//flow->installEventFilter(this);
|
||||
//edit->installEventFilter(this);
|
||||
//centerButton->installEventFilter(this);
|
||||
//goToButton->installEventFilter(this);
|
||||
|
||||
this->setCursor(QCursor(Qt::ArrowCursor));
|
||||
}
|
||||
|
||||
@ -46,25 +41,6 @@ GoToFlowGL::~GoToFlowGL()
|
||||
delete flow;
|
||||
}
|
||||
|
||||
bool GoToFlowGL::eventFilter(QObject *target, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress)
|
||||
{
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
int key = keyEvent->key();
|
||||
if((key==Qt::Key_Return)||
|
||||
(key==Qt::Key_Enter)||
|
||||
(key==Qt::Key_Space)||
|
||||
(key==Qt::Key_Left)||
|
||||
(key==Qt::Key_Right)||
|
||||
(key==Qt::Key_S))
|
||||
this->keyPressEvent(keyEvent);
|
||||
}
|
||||
return QWidget::eventFilter(target, event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GoToFlowGL::reset()
|
||||
{
|
||||
flow->reset();
|
||||
@ -167,3 +143,16 @@ void GoToFlowGL::updateConfig(QSettings * settings)
|
||||
|
||||
}
|
||||
|
||||
void GoToFlowGL::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Left: case Qt::Key_Right: case Qt::Key_Up:
|
||||
QApplication::sendEvent(flow,event);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
GoToFlowWidget::keyPressEvent(event);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ class QIntValidator;
|
||||
class QPushButton;
|
||||
class QPushButton;
|
||||
class QSize;
|
||||
class QKeyEvent;
|
||||
|
||||
class GoToFlowGL : public GoToFlowWidget
|
||||
{
|
||||
@ -23,7 +24,6 @@ public:
|
||||
void setNumSlides(unsigned int slides);
|
||||
void setImageReady(int index,const QByteArray & image);
|
||||
void updateSize();
|
||||
bool eventFilter(QObject *target, QEvent *event);
|
||||
|
||||
void updateConfig(QSettings * settings);
|
||||
|
||||
@ -31,8 +31,7 @@ signals:
|
||||
void goToPage(unsigned int page);
|
||||
private:
|
||||
YACReaderPageFlowGL * flow;
|
||||
|
||||
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
//Comic * comic;
|
||||
QSize imageSize;
|
||||
};
|
||||
|
@ -26,6 +26,8 @@ GoToFlowWidget::GoToFlowWidget(QWidget * parent)
|
||||
mainLayout->setSpacing(0);
|
||||
|
||||
setLayout(mainLayout);
|
||||
|
||||
//toolBar->installEventFilter(this);
|
||||
}
|
||||
|
||||
GoToFlowWidget::~GoToFlowWidget() {
|
||||
@ -53,12 +55,21 @@ void GoToFlowWidget::keyPressEvent(QKeyEvent* event)
|
||||
case Qt::Key_S:
|
||||
QCoreApplication::sendEvent(this->parent(),event);
|
||||
break;
|
||||
case Qt::Key_Left: case Qt::Key_Right:
|
||||
//if(event->modifiers() == Qt::ControlModifier)
|
||||
//flow->keyPressEvent(event);
|
||||
//QCoreApplication::sendEvent(flow,event);
|
||||
break;
|
||||
}
|
||||
|
||||
event->accept();
|
||||
}
|
||||
|
||||
/*bool GoToFlowWidget::eventFilter(QObject * target, QEvent * event)
|
||||
{
|
||||
if(event->type() == QEvent::KeyPress)
|
||||
{
|
||||
QKeyEvent * e = static_cast<QKeyEvent *>(event);
|
||||
if(e->key()==Qt::Key_S || e->key() == Qt::Key_Space)
|
||||
{
|
||||
this->keyPressEvent(e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(target,event);
|
||||
}*/
|
||||
|
@ -34,6 +34,7 @@ public slots:
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
//bool eventFilter(QObject *, QEvent *);
|
||||
|
||||
};
|
||||
|
||||
|
@ -273,6 +273,7 @@ void MainWindowViewer::createActions()
|
||||
prevAction = new QAction(tr("&Previous"),this);
|
||||
prevAction->setIcon(QIcon(":/images/viewer_toolbar/previous.png"));
|
||||
prevAction->setShortcut(Qt::Key_Left);
|
||||
prevAction->setShortcutContext(Qt::WidgetShortcut);
|
||||
prevAction->setToolTip(tr("Go to previous page"));
|
||||
prevAction->setDisabled(true);
|
||||
connect(prevAction, SIGNAL(triggered()),viewer,SLOT(prev()));
|
||||
@ -280,6 +281,7 @@ void MainWindowViewer::createActions()
|
||||
nextAction = new QAction(tr("&Next"),this);
|
||||
nextAction->setIcon(QIcon(":/images/viewer_toolbar/next.png"));
|
||||
nextAction->setShortcut(Qt::Key_Right);
|
||||
nextAction->setShortcutContext(Qt::WidgetShortcut);
|
||||
nextAction->setToolTip(tr("Go to next page"));
|
||||
nextAction->setDisabled(true);
|
||||
connect(nextAction, SIGNAL(triggered()),viewer,SLOT(next()));
|
||||
|
@ -82,6 +82,7 @@ shouldOpenPrevious(false)
|
||||
else
|
||||
goToFlow = new GoToFlow(this,Configuration::getConfiguration().getFlowType());
|
||||
|
||||
goToFlow->setFocusPolicy(Qt::StrongFocus);
|
||||
goToFlow->hide();
|
||||
showGoToFlowAnimation = new QPropertyAnimation(goToFlow,"pos");
|
||||
showGoToFlowAnimation->setDuration(150);
|
||||
@ -255,7 +256,10 @@ void Viewer::updatePage()
|
||||
emit backgroundChanges();
|
||||
emit(pageAvailable(true));
|
||||
|
||||
if(goToFlow->isHidden())
|
||||
setFocus(Qt::ShortcutFocusReason);
|
||||
else
|
||||
goToFlow->setFocus(Qt::OtherFocusReason);
|
||||
delete previousPage;
|
||||
|
||||
if(currentPage->isNull())
|
||||
|
@ -1244,6 +1244,12 @@ void PictureFlow::keyPressEvent(QKeyEvent* event)
|
||||
return;
|
||||
}
|
||||
|
||||
if(event->key() == Qt::Key_Up)
|
||||
{
|
||||
//TODO emit selected signal
|
||||
return;
|
||||
}
|
||||
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
|
@ -952,6 +952,12 @@ void YACReaderFlowGL::keyPressEvent(QKeyEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
if(event->key() == Qt::Key_Up)
|
||||
{
|
||||
emit selected(centerIndex());
|
||||
return;
|
||||
}
|
||||
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user