Beispiel #1
0
bool EditWidget::eventFilter(QObject *AWatched, QEvent *AEvent)
{
	bool hooked = false;
	if (AWatched == ui.medEditor)
	{
		if (AEvent->type() == QEvent::KeyPress)
		{
			QKeyEvent *keyEvent = static_cast<QKeyEvent *>(AEvent);
			if (FSendShortcut[0] == keyEvent->key()+keyEvent->modifiers())
			{
				hooked = true;
				onShortcutActivated(FSendShortcutId,ui.medEditor);
			}
			else
			{
				emit keyEventReceived(keyEvent,hooked);
			}
		}
		else if (AEvent->type() == QEvent::ShortcutOverride)
		{
			hooked = true;
		}
	}
	return hooked || QWidget::eventFilter(AWatched,AEvent);
}
Beispiel #2
0
StyleViewer::StyleViewer(QWidget *AParent) : QWebView(AParent)
{
    setPage(new WebPage(this));
    setAcceptDrops(false);
    setContextMenuPolicy(Qt::CustomContextMenu);
    setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    QShortcut *shortcut = new QShortcut(QKeySequence::Copy,this,NULL,NULL,Qt::WidgetShortcut);
    connect(shortcut, SIGNAL(activated()), SLOT(onShortcutActivated()));
}
EditWidget::EditWidget(IMessageWidgets *AMessageWidgets, const Jid& AStreamJid, const Jid &AContactJid)
{
	ui.setupUi(this);
	ui.medEditor->setAcceptRichText(true);
	ui.medEditor->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
	
	QVBoxLayout *vlayout = new QVBoxLayout;
	vlayout->setMargin(1);
	vlayout->addWidget(ui.tlbSend,0,Qt::AlignBottom);

	QHBoxLayout *hlayout = new QHBoxLayout;
	hlayout->addStretch();
	hlayout->setContentsMargins(2, 2, 20, 2);
	hlayout->addLayout(vlayout);

	ui.medEditor->setLayout(hlayout);
	ui.medEditor->setAcceptRichText(false);
	ui.medEditor->installEventFilter(this);
	ui.medEditor->setLineWrapMode(QTextEdit::FixedPixelWidth);

	FMessageWidgets = AMessageWidgets;
	FStreamJid = AStreamJid;
	FContactJid = AContactJid;
	FBufferPos = -1;

	FSendShortcut = new QShortcut(ui.medEditor);
	FSendShortcut->setContext(Qt::WidgetShortcut);
	connect(FSendShortcut,SIGNAL(activated()),SLOT(onShortcutActivated()));

	connect(ui.tlbSend,SIGNAL(clicked(bool)),SLOT(onSendButtonCliked(bool)));

	onOptionsChanged(Options::node(OPV_MESSAGES_EDITORAUTORESIZE));
	onOptionsChanged(Options::node(OPV_MESSAGES_EDITORMINIMUMLINES));
	onOptionsChanged(Options::node(OPV_MESSAGES_EDITORMAXIMUMLINES));
	onOptionsChanged(Options::node(OPV_MESSAGES_EDITORSENDKEY));
	connect(Options::instance(),SIGNAL(optionsChanged(const OptionsNode &)),SLOT(onOptionsChanged(const OptionsNode &)));
}