OCCViewer_ViewFrame::OCCViewer_ViewFrame(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel)
- : OCCViewer_ViewWindow( theDesktop, theModel )
+ : OCCViewer_ViewWindow( theDesktop, theModel ), myPopupRequestedView(0)
{
QFrame* centralFrame = new QFrame( this );
setCentralWidget( centralFrame );
connect( theView, SIGNAL( mouseMoving(SUIT_ViewWindow*, QMouseEvent*) ),
this, SIGNAL( mouseMoving(SUIT_ViewWindow*, QMouseEvent*) ) );
+ // The signal is used to process get/set bacgrounf\d color from popup
+ connect( theView, SIGNAL( contextMenuRequested(QContextMenuEvent*) ),
+ this, SLOT( onContextMenuRequested(QContextMenuEvent*) ) );
+
connect( theView, SIGNAL( contextMenuRequested(QContextMenuEvent*) ),
this, SIGNAL( contextMenuRequested(QContextMenuEvent*) ) );
+
}
void OCCViewer_ViewFrame::setBackgroundColor( const QColor& theColor)
{
- foreach (OCCViewer_ViewWindow* aView, myViews) {
- aView->setBackgroundColor(theColor);
- }
+ if (myPopupRequestedView)
+ myPopupRequestedView->setBackgroundColor(theColor);
+ else
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ if (aView->isVisible())
+ aView->setBackgroundColor(theColor);
+ }
}
aView->onFitAll();
}
}
+
+QColor OCCViewer_ViewFrame::backgroundColor() const
+{
+ if (myPopupRequestedView)
+ return myPopupRequestedView->backgroundColor();
+
+ foreach (OCCViewer_ViewWindow* aView, myViews) {
+ if (aView->isVisible())
+ return aView->backgroundColor();
+ }
+ return getView(MAIN_VIEW)->backgroundColor();
+}
+
+void OCCViewer_ViewFrame::onContextMenuRequested(QContextMenuEvent*)
+{
+ myPopupRequestedView = dynamic_cast<OCCViewer_ViewWindow*>(sender());
+}
+
virtual bool eventFilter(QObject* watched, QEvent* e) { return SUIT_ViewWindow::eventFilter(watched, e); }
- virtual QColor backgroundColor() const { return getView(MAIN_VIEW)->backgroundColor(); }
+ virtual QColor backgroundColor() const;
virtual void setBackgroundColor( const QColor& );
+
public slots:
virtual void onFrontView() { getView(MAIN_VIEW)->onFrontView(); }
virtual void onViewFitAll();
virtual void onDumpView() { getView(MAIN_VIEW)->onDumpView(); }
+private slots:
+ void onContextMenuRequested(QContextMenuEvent*);
+
private:
void connectViewSignals(OCCViewer_ViewWindow* theView);
QList<OCCViewer_ViewWindow*> myViews;
QGridLayout* myLayout;
+
+ OCCViewer_ViewWindow* myPopupRequestedView;
};
#endif