示例#1
0
void NativeViewerPhonon::show()
{
	if(state() != NativeViewer::Running)
		return;

	QRect rect = containerWidget()->geometry();
	QPoint abs = WidgetUtil::absoluteWidgetPosition(containerWidget());
	//qDebug() << "NativeViewerPhonon::show: Showing at "<<abs<<", size:"<<rect.size();
#ifdef PHONON_ENABLED
	if(m_autoPlay)
		m_media->play();
	if(!m_widget->parentWidget())
	{
		m_widget->resize(rect.size());
		m_widget->move(abs);
	}
	m_widget->show();
	// the second 'move' is required to move it to an 'odd' 
	// place, at least on X11 systems that I've tested.
	// For example, over a task bar or halfway off screen, etc.
	// And yes, 2 moves are required - before AND after the show()
	// - I have no idea why both are required, but it doesn't 
	// work without both.
	if(!m_widget->parentWidget())
		m_widget->move(abs);
#endif

	//qDebug() << "NativeViewerPhonon::show: done.";
}
示例#2
0
void tst_QLayout::setLayoutBugs()
{
    QWidget widget(0);
    QHBoxLayout *hBoxLayout = new QHBoxLayout(&widget);

    for(int i = 0; i < 6; ++i) {
        QPushButton *pushButton = new QPushButton("Press me!", &widget);
        hBoxLayout->addWidget(pushButton);
    }

    widget.setLayout(hBoxLayout);
    QVERIFY(widget.layout() == hBoxLayout);

    QWidget containerWidget(0);
    containerWidget.setLayout(widget.layout());
    QVERIFY(widget.layout() == 0);
    QVERIFY(containerWidget.layout() == hBoxLayout);
}
示例#3
0
QPixmap NativeViewerWin32PPT::snapshot()
{
	QRect rect = containerWidget()->geometry();
	QPoint abs = WidgetUtil::absoluteWidgetPosition(containerWidget());
	return QPixmap::grabWindow(qApp->desktop()->winId(), abs.x(), abs.y(), rect.width(), rect.height());
}
示例#4
0
void NativeViewerWin32PPT::embedHwnd()
{
	// adjust parent window
	//NativeViewerWin32::embedHwnd();
#ifdef Q_OS_WIN32
	QRect rect = containerWidget()->geometry();
	QPoint abs = WidgetUtil::absoluteWidgetPosition(containerWidget());
	m_ppt->runShow();
	m_ppt->setWindowRect(abs.x(), abs.y(), rect.width(), rect.height());

	HWND ptr = NULL;
	int count = 0;
	int max = 1000;
	while(!ptr && count++ < max)
	{
		//qApp->processEvents();
		ptr = FindWindow(L"screenClass",  NULL);
	}

	//HWND hwnd = FindWindowEx(hwnd(), NULL, L"paneClassDC", NULL);
	setHwnd(ptr);
	//qDebug() << "NativeViewerWin32PPT::embedHwnd: hwnd:"<<hwnd()<<", count:"<<count;
	//m_numSlides = m_ppt->numSlides();

	//qDebug() << "NativeViewerWin32PPT::embedHwnd: Num slides:"<<m_numSlides;
	NativeViewerWin32::embedHwnd();
	BringWindowToTop(hwnd());
//
	/*

	// now find the actual widget that holds the show and stretch it out
	HWND hwnd2 = FindWindowEx(hwnd(), NULL, L"paneClassDC", NULL);
	setHwnd(FindWindow(L"screenClass",  NULL));

	if(hwnd2)
	{

		//QPoint abs = absoluteWidgetPosition(containerWidget());

		// This is a "magic forumla" for the proper stretch amount -
		// just found through trial and error. Its NOT perfect, and
		// gets more and more inaccurate the further away from 1024x768 or 320x240
		// the size is. But, it's "good enough" for now.
		int xa = ((int)(8.0/1024.0 * ((double)rect.width())));
		int ya = ((int)(67.0/768.0 * ((double)rect.height())));

		// override for known rectangle size
		if(rect.width() == 320 && rect.height() == 240)
		{
			xa = 8;
			ya = 25;
		}

		//MoveWindow(hwnd(), rect.x(), rect.x(), rect.width(), rect.height(), 1);
		qDebug() << "NativeViewerWin32PPT::embedHwnd(): hwnd2:"<<hwnd2<<", orig size:"<<rect.size()<<", xa:"<<xa<<",ya:"<<ya;


		SetWindowPos(hwnd2, 0,
				-xa, -ya,
				rect.width()  + xa*2,
				rect.height() + ya*2,
				SWP_SHOWWINDOW);
		BringWindowToTop(hwnd());
	}
*/
#endif
}