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