#include "settings.h"
#include "client.h"
+#include "action.h"
+#include "actioncollection.h"
+#include "qtui.h"
+
#include <QLayout>
+#include <QKeyEvent>
BufferWidget::BufferWidget(QWidget *parent)
: AbstractBufferContainer(parent),
connect(_chatViewSearchController, SIGNAL(newCurrentHighlight(QGraphicsItem *)),
this, SLOT(scrollToHighlight(QGraphicsItem *)));
+
+ ActionCollection *coll = QtUi::actionCollection();
+
+ Action *zoomChatview = coll->add<Action>("ZoomChatView");
+ connect(zoomChatview, SIGNAL(triggered()), SLOT(zoomIn()));
+ zoomChatview->setText(tr("Enlarge Chat View"));
+ zoomChatview->setShortcut(tr("Ctrl++"));
+
+ Action *zoomOutChatview = coll->add<Action>("ZoomOutChatView");
+ connect(zoomOutChatview, SIGNAL(triggered()), SLOT(zoomOut()));
+ zoomOutChatview->setText(tr("Demagnify Chat View"));
+ zoomOutChatview->setShortcut(tr("Ctrl+-"));
+
+ Action *zoomNormalChatview = coll->add<Action>("ZoomNormalChatView");
+ connect(zoomNormalChatview, SIGNAL(triggered()), SLOT(zoomNormal()));
+ zoomNormalChatview->setText(tr("Normalize zoom of Chat View"));
+ zoomNormalChatview->setShortcut(tr("Ctrl+0"));
}
BufferWidget::~BufferWidget() {
view->centerOn(highlightItem);
}
}
+
+
+void BufferWidget::zoomIn() {
+ ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ if(!view) return;
+ view->zoomIn();
+}
+
+void BufferWidget::zoomOut() {
+ ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ if(!view) return;
+ view->zoomOut();
+}
+
+void BufferWidget::zoomNormal() {
+ ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ if(!view) return;
+ view->zoomNormal();
+}
+
+bool BufferWidget::eventFilter(QObject *watched, QEvent *event) {
+ Q_UNUSED(watched);
+ if(event->type() != QEvent::KeyPress)
+ return false;
+
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
+ 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);
+ default:
+ return false;
+ }
+}
BufferWidget(QWidget *parent);
~BufferWidget();
+ virtual bool eventFilter(QObject *watched, QEvent *event);
+
inline ChatViewSearchBar *searchBar() const { return ui.searchBar; }
protected:
private slots:
void scrollToHighlight(QGraphicsItem *highlightItem);
+ void zoomIn();
+ void zoomOut();
+ void zoomNormal();
private:
Ui::BufferWidget ui;
ChatView::ChatView(BufferId bufferId, QWidget *parent)
: QGraphicsView(parent),
- AbstractChatView()
+ AbstractChatView(),
+ _currentScaleFactor(1)
{
QList<BufferId> filterList;
filterList.append(bufferId);
ChatView::ChatView(MessageFilter *filter, QWidget *parent)
: QGraphicsView(parent),
- AbstractChatView()
+ AbstractChatView(),
+ _currentScaleFactor(1)
{
init(filter);
}
//setOptimizationFlags(QGraphicsView::DontClipPainter | QGraphicsView::DontAdjustForAntialiasing);
// setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing);
setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
- setTransformationAnchor(QGraphicsView::NoAnchor);
+ // setTransformationAnchor(QGraphicsView::NoAnchor);
+ setTransformationAnchor(QGraphicsView::AnchorViewCenter);
_scene = new ChatScene(filter, filter->idString(), viewport()->width() - 2, this); // see below: resizeEvent()
connect(_scene, SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(sceneRectChanged(const QRectF &)));
return model->data(model->index(model->rowCount() - 1, 0), MessageModel::MsgIdRole).value<MsgId>();
}
+
+void ChatView::zoomIn() {
+ _currentScaleFactor *= 1.2;
+ scale(1.2, 1.2);
+ scene()->setWidth(viewport()->width() / _currentScaleFactor - 2);
+}
+
+void ChatView::zoomOut() {
+ _currentScaleFactor /= 1.2;
+ scale(1 / 1.2, 1 / 1.2);
+ scene()->setWidth(viewport()->width() / _currentScaleFactor - 2);
+}
+
+void ChatView::zoomNormal() {
+ scale(1/_currentScaleFactor, 1/_currentScaleFactor);
+ _currentScaleFactor = 1;
+ scene()->setWidth(viewport()->width() - 2);
+}
public slots:
inline virtual void clear() {}
+ void zoomIn();
+ void zoomOut();
+ void zoomNormal();
protected:
virtual void resizeEvent(QResizeEvent *event);
ChatScene *_scene;
int _lastScrollbarPos;
+ qreal _currentScaleFactor;
};
connect(activateInputline, SIGNAL(triggered()), SLOT(setFocus()));
activateInputline->setText(tr("Focus Input Line"));
activateInputline->setShortcut(tr("Ctrl+L"));
-
}
InputWidget::~InputWidget() {
#include "identity.h"
#include "network.h"
+class InputLine;
+
class InputWidget : public AbstractItemView {
Q_OBJECT
const Network *currentNetwork() const;
+ inline InputLine* inputLine() const { return ui.inputEdit; }
+
protected slots:
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
const int key = keyEvent->key();
- if(key < Qt::Key_0 || Qt::Key_9 < key)
+ if(key < Qt::Key_1 || Qt::Key_9 < key)
return QObject::eventFilter(obj, event);
if(keyEvent->modifiers() == bindModifier) {
#include "coreconnectdlg.h"
#include "iconloader.h"
#include "inputwidget.h"
+#include "inputline.h"
#include "irclistmodel.h"
#include "jumpkeyhandler.h"
#include "msgprocessorstatuswidget.h"
inputWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
_bufferWidget->setFocusProxy(inputWidget);
+
+ inputWidget->inputLine()->installEventFilter(_bufferWidget);
}
void MainWin::setupTopicWidget() {