ViewerToolbar::ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort)
: QToolBar(theParent), myVPort(thePort), myResize(false)
{
- setBackgroundRole(QPalette::NoRole);
- setAttribute(Qt::WA_NoSystemBackground);
- //setAttribute(Qt::WA_PaintOnScreen);
- setAutoFillBackground(false);
connect(myVPort, SIGNAL(resized()), this, SLOT(onViewPortResized()));
}
void ViewerToolbar::paintEvent(QPaintEvent* theEvent)
{
+ //QToolBar::paintEvent(theEvent);
// Paint background
QPainter aPainter(this);
QRect aRect = rect();
style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &aOpt, &aPainter, this);
}
+
+
//**************************************************************************
ViewerLabel::ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort)
: QLabel(theParent), myVPort(thePort), myResize(false)
{
- setBackgroundRole(QPalette::NoRole);
- setAttribute(Qt::WA_NoSystemBackground);
- //setAttribute(Qt::WA_PaintOnScreen);
- setAutoFillBackground(false);
connect(myVPort, SIGNAL(resized()), this, SLOT(onViewPortResized()));
}
QImage aImg = myVPort->dumpView(aImgRect, myResize);
if (!aImg.isNull())
QPainter(this).drawImage(aRect, aImg);
+ myResize = false;
QLabel::paintEvent(theEvent);
}
myRotationPointSelection(false),
myClosable(true),
myStartX(0), myStartY(0), myCurrX(0), myCurrY(0), myCurScale(0.0), myCurSketch(0),
- myDrawRect(false), myEnableDrawMode(true), myCursorIsHand(false), myEventStarted(false),
+ myDrawRect(false), myEnableDrawMode(false), myCursorIsHand(false), myEventStarted(false),
myIsActive(false),
myLastState(WindowNormalState), myOperation(NOTHING)
{
QHBoxLayout* aToolLay = new QHBoxLayout();
aToolLay->setMargin(0);
aToolLay->setSpacing(0);
- aVPLay->setContentsMargins(0,0,0,0);
+ aToolLay->setContentsMargins(0,0,0,0);
aVPLay->addLayout(aToolLay);
aVPLay->addStretch();
connect(myViewPort, SIGNAL(vpUpdated()), this, SLOT(updateToolBar()));
connect(this, SIGNAL(vpTransformationFinished(XGUI_ViewWindow::OperationType)),
this, SLOT(updateToolBar()));
-
}
//****************************************************************
}
myViewBar->show();
myWindowBar->show();
- myGripWgt->setVisible(!(isMaximized() || isMinimized()));
+ myGripWgt->setVisible(!(isMaximized() || isMinimized() ||
+ parentWidget()->isMaximized() || parentWidget()->isMinimized()));
} else
myIsActive = false;
}
}
parentWidget()->activateWindow();
myMinimizeBtn->setIcon(MinimizeIco);
+
+ // In order to avoid frosen background in toolbars when it shown as a second view
+ QTimer::singleShot(50, parentWidget(), SLOT(setFocus()));
}
//****************************************************************
} else {
showNormal();
}
- raise();
myViewer->onWindowActivated((QMdiSubWindow*)parentWidget());
+
+ // In order to avoid frosen background in toolbars when it shown as a second view
+ QTimer::singleShot(20, parentWidget(), SLOT(setFocus()));
+
return true;
}
}
if (processViewPort(theEvent)) {
return true;
}
+ if (theEvent->type() == QEvent::KeyRelease) {
+ emit keyReleased(this, (QKeyEvent*) theEvent);
+ return true;
+ }
}
return QFrame::eventFilter(theObj, theEvent);
}
l_mbPressEvent = new QMouseEvent( *theEvent );*/
}
+//****************************************************************
+void XGUI_ViewWindow::contextMenuEvent(QContextMenuEvent* theEvent)
+{
+ if (theEvent->modifiers() == Qt::NoModifier) {
+ // Temporary: has to be removed when viewer popup will be defined
+ //QFrame::contextMenuEvent(theEvent);
+ emit contextMenuRequested(theEvent);
+ }
+}
+
//****************************************************************
void XGUI_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent)
{
}
*/
emit mouseReleased(this, theEvent);
- if (theEvent->button() == Qt::RightButton && prevState == -1) {
- QContextMenuEvent aEvent(QContextMenuEvent::Mouse, theEvent->pos(), theEvent->globalPos());
- emit contextMenuRequested(&aEvent);
- }
}
break;
case ROTATE:
QMdiSubWindow* vw = myViewer->createView();
XGUI_ViewWindow* aNewWnd = static_cast<XGUI_ViewWindow*>(vw->widget());
aNewWnd->viewPort()->syncronizeWith(myViewPort);
+
emit viewCloned( vw );
+
+ // In order to avoid frosen background in toolbars when it shown as a second view
+ QTimer::singleShot(20, vw, SLOT(setFocus()));
}
void XGUI_ViewWindow::dumpView()
myGripWgt->update();
myViewBar->update();
myWindowBar->update();
- //QTimer::singleShot(50, Qt::VeryCoarseTimer, this, SLOT(repaintToolBar()));
}
-/*void XGUI_ViewWindow::repaintToolBar()
+/*!
+ \brief Update state of enable draw mode state.
+*/
+void XGUI_ViewWindow::updateEnabledDrawMode()
{
- QApplication::sync();
- myGripWgt->repaint();
- myViewBar->repaint();
- myWindowBar->repaint();
-}*/
+ myEnableDrawMode = myViewer->isSelectionEnabled() &&
+ myViewer->isMultiSelectionEnabled();
+}