ChatView triggers now a backlogrequest even if there is no scrollbar
visible. (MouseWheel, Page_Up/_Down, Shift Key_Up/_Down)
switch(keyEvent->key()) {
switch(keyEvent->key()) {
- case Qt::Key_PageUp:
- case Qt::Key_PageDown:
- // static cast to access public qobject::event
- return static_cast<QObject*>(ui.stackedWidget->currentWidget())->event(event);
-
- case Qt::Key_Up:
- direction = -1;
- case Qt::Key_Down:
- if(keyEvent->modifiers() == Qt::ShiftModifier) {
- QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(ui.stackedWidget->currentWidget());
- if(!scrollArea)
- return false;
- int sliderPosition = scrollArea->verticalScrollBar()->value();
- scrollArea->verticalScrollBar()->setValue(sliderPosition + (direction * 12));
- return true;
- }
- default:
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ if(!(keyEvent->modifiers() & Qt::ShiftModifier))
+ case Qt::Key_PageUp:
+ case Qt::Key_PageDown:
+ // static cast to access public qobject::event
+ return static_cast<QObject*>(ui.stackedWidget->currentWidget())->event(event);
+ default:
+ return false;
connect(_scene, SIGNAL(lastLineChanged(QGraphicsItem *, qreal)), this, SLOT(lastLineChanged(QGraphicsItem *, qreal)));
connect(_scene, SIGNAL(mouseMoveWhileSelecting(const QPointF &)), this, SLOT(mouseMoveWhileSelecting(const QPointF &)));
setScene(_scene);
connect(_scene, SIGNAL(lastLineChanged(QGraphicsItem *, qreal)), this, SLOT(lastLineChanged(QGraphicsItem *, qreal)));
connect(_scene, SIGNAL(mouseMoveWhileSelecting(const QPointF &)), this, SLOT(mouseMoveWhileSelecting(const QPointF &)));
setScene(_scene);
- // installEventFilter(_scene);
connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(verticalScrollbarChanged(int)));
}
connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(verticalScrollbarChanged(int)));
}
+bool ChatView::event(QEvent *event) {
+ if(event->type() == QEvent::KeyPress) {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
+ switch(keyEvent->key()) {
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ case Qt::Key_PageUp:
+ case Qt::Key_PageDown:
+ if(!verticalScrollBar()->isVisible()) {
+ scene()->requestBacklog();
+ return true;
+ }
+ default:
+ break;
+ }
+ }
+
+ if(event->type() == QEvent::Wheel) {
+ if(!verticalScrollBar()->isVisible()) {
+ scene()->requestBacklog();
+ return true;
+ }
+ }
+
+ return QGraphicsView::event(event);
+}
+
void ChatView::resizeEvent(QResizeEvent *event) {
QGraphicsView::resizeEvent(event);
void ChatView::resizeEvent(QResizeEvent *event) {
QGraphicsView::resizeEvent(event);
virtual void addActionsToMenu(QMenu *, const QPointF &pos);
virtual void addActionsToMenu(QMenu *, const QPointF &pos);
+ virtual bool event(QEvent *event);
+
public slots:
inline virtual void clear() {}
void zoomIn();
public slots:
inline virtual void clear() {}
void zoomIn();
<item>
<widget class="QStackedWidget" name="stackedWidget" >
<property name="currentIndex" >
<item>
<widget class="QStackedWidget" name="stackedWidget" >
<property name="currentIndex" >
</property>
<widget class="QWidget" name="page" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
</property>
<widget class="QWidget" name="page" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
- <width>481</width>
- <height>259</height>
+ <width>415</width>
+ <height>216</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
- <width>100</width>
- <height>30</height>
+ <width>415</width>
+ <height>216</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" >
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4" >