0000920: Hide turntable dialog when in fullscreen mode

This commit is contained in:
wmayer 2013-06-30 19:07:41 +02:00
parent c6d23d1598
commit 9e546120bc
2 changed files with 50 additions and 0 deletions

View File

@ -26,6 +26,7 @@
# include <cmath>
# include <float.h>
# include <climits>
# include <QCursor>
# include <QTimer>
#include <Inventor/nodes/SoCamera.h>
#endif
@ -53,6 +54,11 @@ DemoMode::DemoMode(QWidget* parent, Qt::WFlags fl)
timer->setInterval(1000 * ui->timeout->value());
connect(timer, SIGNAL(timeout()), this, SLOT(onAutoPlay()));
oldvalue = ui->angleSlider->value();
wasHidden = false;
showHideTimer = new QTimer(this);
showHideTimer->setInterval(5000);
connect(showHideTimer, SIGNAL(timeout()), this, SLOT(hide()));
}
/** Destroys the object and frees any allocated resources */
@ -82,6 +88,35 @@ void DemoMode::reject()
QDialog::reject();
}
bool DemoMode::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::MouseMove) {
if (ui->fullscreen->isChecked()) {
QPoint point = QCursor::pos() - oldPos;
if (point.manhattanLength() > 10) {
show();
showHideTimer->start();
}
}
}
return QDialog::eventFilter(obj, event);
}
void DemoMode::showEvent(QShowEvent *)
{
if (this->wasHidden)
this->move(this->pnt);
this->wasHidden = false;
}
void DemoMode::hideEvent(QHideEvent *)
{
this->pnt = this->pos();
this->wasHidden = true;
this->oldPos = QCursor::pos();
showHideTimer->stop();
}
Gui::View3DInventor* DemoMode::activeView() const
{
Document* doc = Application::Instance->activeDocument();
@ -186,6 +221,14 @@ void DemoMode::on_fullscreen_toggled(bool on)
view->setCurrentViewMode(on ? MDIView::/*TopLevel*/FullScreen : MDIView::Child);
this->activateWindow();
}
if (on) {
qApp->installEventFilter(this);
showHideTimer->start();
}
else {
qApp->removeEventFilter(this);
showHideTimer->stop();
}
}
void DemoMode::on_timeout_valueChanged(int v)

View File

@ -68,12 +68,19 @@ private:
Gui::View3DInventor* activeView() const;
void startAnimation(Gui::View3DInventor*);
void changeEvent(QEvent *e);
bool eventFilter(QObject *, QEvent *);
void showEvent(QShowEvent *);
void hideEvent(QHideEvent *);
private:
int oldvalue;
SbVec3f viewAxis;
bool wasHidden;
QPoint pnt;
QPoint oldPos;
Ui_DemoMode* ui;
QTimer* timer;
QTimer* showHideTimer;
};
} // namespace Dialog