StelDialog.cpp   StelDialog.cpp 
skipping to change at line 58 skipping to change at line 58
if (event->type()==QEvent::WindowDeactivate) if (event->type()==QEvent::WindowDeactivate)
{ {
widget()->setWindowOpacity(0.4); widget()->setWindowOpacity(0.4);
} }
if (event->type()==QEvent::WindowActivate) if (event->type()==QEvent::WindowActivate)
{ {
widget()->setWindowOpacity(0.9); widget()->setWindowOpacity(0.9);
} }
return QGraphicsProxyWidget::event(event); return QGraphicsProxyWidget::event(event);
} }
// Avoid blocking the program when hovering over an inactive
window
virtual bool sceneEvent(QEvent* event)
{
if (!(isActiveWindow() || event->type()==QEvent::Win
dowActivate || event->type()==QEvent::GraphicsSceneMousePress))
{
event->setAccepted(false);
return false;
}
return QGraphicsProxyWidget::sceneEvent(event);
}
}; };
StelDialog::StelDialog() : dialog(NULL) StelDialog::StelDialog() : dialog(NULL)
{ {
} }
StelDialog::~StelDialog() StelDialog::~StelDialog()
{ {
} }
void StelDialog::close() void StelDialog::close()
{ {
emit visibleChanged(false); setVisible(false);
StelMainGraphicsView::getInstance().scene()->setActiveWindow(0); StelMainGraphicsView::getInstance().scene()->setActiveWindow(0);
((QGraphicsWidget*)StelMainGraphicsView::getInstance().getStelAppGra phicsWidget())->setFocus(Qt::OtherFocusReason);
} }
void StelDialog::setVisible(bool v) void StelDialog::setVisible(bool v)
{ {
if (v) if (v)
{ {
QSize screenSize = StelMainGraphicsView::getInstance().size( );
if (dialog) if (dialog)
{ {
dialog->show(); dialog->show();
StelMainGraphicsView::getInstance().scene()->setActi veWindow(proxy); StelMainGraphicsView::getInstance().scene()->setActi veWindow(proxy);
// If the main window has been resized, it is possib
le the dialog
// will be off screen. Check for this and move it t
o a visible
// position if necessary
QPointF newPos = proxy->pos();
if (newPos.x()>=screenSize.width())
newPos.setX(screenSize.width() - dialog->siz
e().width());
if (newPos.y()>=screenSize.height())
newPos.setY(screenSize.height() - dialog->si
ze().height());
if (newPos != dialog->pos())
proxy->setPos(newPos);
proxy->setFocus(); proxy->setFocus();
return; return;
} }
dialog = new QDialog(NULL); dialog = new QDialog(NULL);
//dialog->setAttribute(Qt::WA_OpaquePaintEvent, true);
connect(dialog, SIGNAL(rejected()), this, SLOT(close())); connect(dialog, SIGNAL(rejected()), this, SLOT(close()));
createDialogContent(); createDialogContent();
proxy = new CustomProxy(NULL, Qt::Tool); proxy = new CustomProxy(NULL, Qt::Tool);
proxy->setWidget(dialog); proxy->setWidget(dialog);
QRectF bound = proxy->boundingRect();
// centre with dialog according to current window size.
proxy->setPos((int)((screenSize.width()-bound.width())/2), (
int)((screenSize.height()-bound.height())/2));
StelMainGraphicsView::getInstance().scene()->addItem(proxy); StelMainGraphicsView::getInstance().scene()->addItem(proxy);
proxy->setWindowFrameMargins(2,0,2,2); proxy->setWindowFrameMargins(2,0,2,2);
proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache); /
/ , QSize(proxy->boundingRect().width()/2, proxy->boundingRect().height()/2 // The caching is buggy on all plateforms with Qt 4.5.2
) proxy->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
proxy->setZValue(100); proxy->setZValue(100);
StelMainGraphicsView::getInstance().scene()->setActiveWindow (proxy); StelMainGraphicsView::getInstance().scene()->setActiveWindow (proxy);
proxy->setFocus(); proxy->setFocus();
} }
else else
{ {
dialog->hide(); dialog->hide();
emit visibleChanged(false); emit visibleChanged(false);
//proxy->clearFocus(); //proxy->clearFocus();
StelMainGraphicsView::getInstance().scene()->setActiveWindow (0); StelMainGraphicsView::getInstance().scene()->setActiveWindow (0);
 End of changes. 8 change blocks. 
17 lines changed or deleted 28 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/