Пример #1
0
bool EditWidget::eventFilter(QObject *AWatched, QEvent *AEvent)
{
	bool hooked = false;
	if (AWatched==ui.medEditor && AEvent->type()==QEvent::KeyPress)
	{
		QKeyEvent *keyEvent = static_cast<QKeyEvent *>(AEvent);
		emit keyEventReceived(keyEvent, hooked);

		if (!hooked && keyEvent->modifiers()==Qt::CTRL && keyEvent->key()==Qt::Key_Up)
		{
			hooked = true;
			showNextBufferedMessage();
		}
		else if (!hooked && keyEvent->modifiers()==Qt::CTRL && keyEvent->key() == Qt::Key_Down)
		{
			hooked = true;
			showPrevBufferedMessage();
		}
	}
	else if (AWatched==ui.medEditor && AEvent->type()==QEvent::ShortcutOverride)
	{
		hooked = true;
	}
	else if (AWatched==ui.medEditor && AEvent->type()==QEvent::Resize)
	{
		static const int rightMargin = StyleStorage::staticStorage(RSR_STORAGE_STYLESHEETS)->getStyleInt(SV_MW_EDIT_RIGHT_MARGIN);
		QResizeEvent * resEvent = (QResizeEvent*)AEvent;
		ui.medEditor->setLineWrapColumnOrWidth(resEvent->size().width() - rightMargin);
	}
	return hooked || QWidget::eventFilter(AWatched,AEvent);
}
Пример #2
0
void EditWidget::onShortcutActivated(const QString &AId, QWidget *AWidget)
{
	if (AId==FSendShortcutId && AWidget==ui.medEditor)
	{
		sendMessage();
	}
	else if (AId==SCT_MESSAGEWINDOWS_EDITNEXTMESSAGE && AWidget==ui.medEditor)
	{
		showPrevBufferedMessage();
	}
	else if (AId==SCT_MESSAGEWINDOWS_EDITPREVMESSAGE && AWidget==ui.medEditor)
	{
		showNextBufferedMessage();
	}
}