void KeyCaptureTestApp::processEvent(const QString &prefix, QEvent *ev)
{
    TX_ENTRY_ARGS(reinterpret_cast<int>(ev));
    if (ev){
        if (ev->type() == QEvent::KeyPress){
           QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
           QString keyName = mappingPtr->name(static_cast<Qt::Key>(keyEvent->key())); 
           
           addTextLine(prefix + QString("KeyPress:%1\n").arg(keyName));
        } else if (ev->type() == QEvent::KeyRelease){
           QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
           QString keyName = mappingPtr->name(static_cast<Qt::Key>(keyEvent->key()));
           
           addTextLine(prefix + QString("KeyRelease:%1\n").arg(keyName));
        } else if (ev->type() == XQKeyCapture::remoteEventType_KeyPress()){
           QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
           QString keyName = mappingPtr->name(static_cast<Qt::Key>(keyEvent->key()));

           addTextLine(prefix + QString("KeyPress:%1 (native:%2)\n").arg(keyName).arg(static_cast<int>(keyEvent->nativeVirtualKey())));
        } else if (ev->type() == XQKeyCapture::remoteEventType_KeyRelease()){
           QKeyEvent *keyEvent = static_cast<QKeyEvent *>(ev);
           QString keyName = mappingPtr->name(static_cast<Qt::Key>(keyEvent->key()));
                      
           addTextLine(prefix + QString("KeyRelease:%1 (native:%2)\n").arg(keyName).arg(static_cast<int>(keyEvent->nativeVirtualKey())));
        }
    }
    TX_EXIT_ARGS(reinterpret_cast<int>(ev));
}
void KeyCaptureTestApp::enableRemoteExtEvents(bool enable)
{
    if (enable) {
        addTextLine("Remote Events Ext. enabled");
        QFlags<XQKeyCapture::CapturingFlag> flags = getFlags() | XQKeyCapture::CaptureEnableRemoteExtEvents;
        mKeyCapture->captureRemoteKeys(flags);
    } else {
        addTextLine("Remote Events Ext. disabled");
        mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureEnableRemoteExtEvents);
    }
}
void KeyCaptureTestApp::enableRemCallHandlingEx(bool enable)
{
    if (enable) {
        addTextLine("Remote Call Handling Ext. enabled");
        QFlags<XQKeyCapture::CapturingFlag> flags = getFlags() | XQKeyCapture::CaptureCallHandlingExt;
        mKeyCapture->captureRemoteKeys(flags);
    } else {
        addTextLine("Remote Call Handling Ext. disabled");
        mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureCallHandlingExt);
    }
}
void KeyCaptureTestApp::enableRemoteSideKeys(bool enable)
{
    if (enable) {
        addTextLine("Side Keys enabled");
        QFlags<XQKeyCapture::CapturingFlag> flags = getFlags() | XQKeyCapture::CaptureSideKeys;
        mKeyCapture->captureRemoteKeys(flags);
    } else {
        addTextLine("Side Keys disabled");
        mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureSideKeys);
    }
}
void KeyCaptureTestApp::enableRemBasic(bool enable)
{
    if (enable) {
        addTextLine("Remote Basic enabled");
        QFlags<XQKeyCapture::CapturingFlag> flags = getFlags() | XQKeyCapture::CaptureBasic;
        mKeyCapture->captureRemoteKeys(flags);
    } else {
        addTextLine("Remote Basic disabled");
        mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureBasic);
    }
}
void KeyCaptureTestApp::remoteNone(bool enable)
{
    Q_UNUSED(enable);
    toggleRemoteBasic->setChecked(false);
    toggleRemoteCallHandlingEx->setChecked(false);
    toggleRemoteExtEvents->setChecked(false);
    addTextLine("Remote: disable all");
    mKeyCapture->cancelCaptureRemoteKeys(XQKeyCapture::CaptureCallHandlingExt | XQKeyCapture::CaptureBasic | 
            XQKeyCapture::CaptureSideKeys | XQKeyCapture::CaptureEnableRemoteExtEvents);
}
예제 #7
0
	void MarkupBase::parseBBCodes()
	{
		clear();
		const float maxwidth = m_viewport.getWidth();
		float height = 0.f;
		
		float xpos = 0.f;
		size_t wordcount = 0;
		PTextLine currentLine;
		PText textChunk;
		PImg imgChunk;
		PTooltipArea tooltipChunk;
		PLinkArea urlChunk;
		float linespacing = m_textSpacing;

		const ActiveText::TextViewVector& v = m_parser.getFormattedOutput();
		ActiveText::TextViewVector::const_iterator i = v.begin();
		ActiveText::TextViewVector::const_iterator end = v.end();
		while(i != end)
		{
			const ActiveText::TextView* tv = (*i).get();
			size_t pos = tv->start;
			size_t len = tv->len;
			size_t last = pos + len;
			std::string text = m_text.substr(pos, len);
			
			if(tv->isNewLine)
			{
				height += addTextLine(currentLine);

				// new paragraph
				currentLine.reset(new TextLine());
				currentLine->area = m_viewport;
				currentLine->area.m_top = height;
				currentLine->area.setHeight(0.f);
				linespacing = tv->isList ? m_listSpacing : m_textSpacing;
				wordcount = 0;
				xpos = 0.f;
				
				xpos += m_font->getTextExtent("    ");
			}

			{
				textChunk.reset(new Text());
				textChunk->start = pos;
				textChunk->col = tv->col;
				textChunk->font = tv->font;
				textChunk->selcol = tv->col;
				textChunk->selcol.invertColour();
				textChunk->area.m_left = xpos;
				textChunk->area.setHeight(textChunk->font->getLineSpacing());
				textChunk->area.setWidth(0.f);
			}

			if(tv->isTooltip)
			{
				if(tooltipChunk)
				{
					if(tooltipChunk->parent != tv->tooltipnode)
					{
						m_tooltips.push_back(tooltipChunk);
						tooltipChunk.reset(new TooltipArea());
						tooltipChunk->parent = tv->tooltipnode;
						tooltipChunk->tooltip = tv->tooltip;
					}
				}
				else
				{
					tooltipChunk.reset(new TooltipArea());
					tooltipChunk->parent = tv->tooltipnode;
					tooltipChunk->tooltip = tv->tooltip;
				}
			}

			if(tv->isURL)
			{
				if(urlChunk)
				{
					if(urlChunk->parent != tv->urlnode)
					{
						m_links.push_back(urlChunk);
						urlChunk.reset(new LinkArea());
						urlChunk->parent = tv->urlnode;
						urlChunk->type = tv->type;
						urlChunk->id = tv->id;
					}
				}
				else
				{
					urlChunk.reset(new LinkArea());
					urlChunk->parent = tv->urlnode;
					urlChunk->type = tv->type;
					urlChunk->id = tv->id;
				}
			}

			if(!tv->isImage)
			{ // text
				while(pos < last)
				{
					bool white = false;
					size_t nextTokenLen = getNextTokenLength(m_text, pos, white);
					if(pos + nextTokenLen > last)
						nextTokenLen = last - pos;

					float xlen = tv->font->getTextExtent(m_text.substr(pos, nextTokenLen));

					// if text isn't fit anyway (and must be alone on a string)
					if(xlen > maxwidth && wordcount == 0)
						xlen = maxwidth - xpos;

					if(xpos + xlen > maxwidth)
					{
						textChunk->len = pos - textChunk->start;
						if(white)
						{
							// don't allow whitespace in new line
							pos += nextTokenLen;
						}

						currentLine->addChunk(textChunk, linespacing);
						if(tv->isTooltip)
							tooltipChunk->masked.push_back(textChunk);
						if(tv->isURL)
							urlChunk->masked.push_back(textChunk);

						height += addTextLine(currentLine);
						
						{
							// new line
							currentLine.reset(new TextLine());
							currentLine->area = m_viewport;
							currentLine->area.m_top = height;
							currentLine->area.setHeight(0.f);
							linespacing = tv->isList ? m_listSpacing : m_textSpacing;
							wordcount = 0;
							xpos = 0.f;
						}

						{
							textChunk.reset(new Text());
							textChunk->start = pos;
							textChunk->col = tv->col;
							textChunk->font = tv->font;
							textChunk->selcol = tv->col;
							textChunk->selcol.invertColour();
							textChunk->area.m_left = xpos;
							textChunk->area.setHeight(textChunk->font->getLineSpacing());
							textChunk->area.setWidth(0.f);
						}
					}
					else
					{
						// add next word until width or tag
						pos += nextTokenLen;
						xpos += xlen;
						wordcount++;
						textChunk->area.m_right = xpos;
					}
				}

				// end chunk
				textChunk->len = pos - textChunk->start;
				currentLine->addChunk(textChunk, linespacing);
				if(tv->isTooltip)
					tooltipChunk->masked.push_back(textChunk);
				if(tv->isURL)
					urlChunk->masked.push_back(textChunk);
			}
			else
			{ // image
				imgChunk.reset(new Img());
				const Image* img = tv->img;			
				imgChunk->img = img;
				
				if(img)
				{
					Size imgsize = img->GetSize();

					if(imgsize.width > maxwidth - xpos)
					{
						height += addTextLine(currentLine);
						
						{
							// new line
							currentLine.reset(new TextLine());
							currentLine->area = m_viewport;
							currentLine->area.m_top = height;
							currentLine->area.setHeight(0.f);
							linespacing = tv->isList ? m_listSpacing : m_textSpacing;
							wordcount = 0;
							xpos = 0.f;
						}					
					}

					imgChunk->area.m_left = m_viewport.m_left + xpos;
					imgChunk->area.m_top = /*m_viewport.m_top*/ + currentLine->area.m_top;
					imgChunk->area.m_bottom = imgChunk->area.m_top + imgsize.height;
					imgChunk->area.m_right = imgChunk->area.m_left + imgsize.width;
					xpos += imgsize.width;
					wordcount++;

					currentLine->addChunk(imgChunk);
					m_images.push_back(imgChunk);

					if(tv->isTooltip)
						tooltipChunk->maskedimg.push_back(imgChunk);
					if(tv->isURL)
						urlChunk->maskedimg.push_back(imgChunk);
				}			
			}

			++i;
		}
		
		if(currentLine && !currentLine->isEmpty())
			height += addTextLine(currentLine);
		if(tooltipChunk && !tooltipChunk->isEmpty())
			m_tooltips.push_back(tooltipChunk);
		if(urlChunk && !urlChunk->isEmpty())
			m_links.push_back(urlChunk);

		m_viewport.m_bottom = m_viewport.m_top + height;
		m_area.m_bottom = m_viewport.m_bottom + m_margin.m_bottom;
	}