diff options
Diffstat (limited to 'src/AboutDialogGraphicsView.cpp')
-rw-r--r--[-rwxr-xr-x] | src/AboutDialogGraphicsView.cpp | 254 |
1 files changed, 134 insertions, 120 deletions
diff --git a/src/AboutDialogGraphicsView.cpp b/src/AboutDialogGraphicsView.cpp index 8c868ef..3c031f2 100755..100644 --- a/src/AboutDialogGraphicsView.cpp +++ b/src/AboutDialogGraphicsView.cpp @@ -39,168 +39,182 @@ /*! \brief The constructor initializes everything needed for the 3D animation. */ -AboutDialogGraphicsView::AboutDialogGraphicsView(AboutDialog *aboutDialog, TQWidget *parentWindow) : TQGraphicsView(parentWindow) - , _aboutDialog(NULL) - , _graphicsProxyWidget(NULL) - , _parentWindow(NULL) - , _timeLine(NULL) - , _aboutDialogAsSplashScreen(NULL) +AboutDialogGraphicsView::AboutDialogGraphicsView(AboutDialog *aboutDialog, TQWidget *parentWindow) : + TQGraphicsView(parentWindow), _aboutDialog(NULL), _graphicsProxyWidget(NULL), + _parentWindow(NULL), _timeLine(NULL), _aboutDialogAsSplashScreen(NULL) { - _parentWindow = parentWindow; - setWindowFlags(TQt::SplashScreen); + _parentWindow = parentWindow; + setWindowFlags(TQt::SplashScreen); #ifdef Q_OS_LINUX - TQRect availableGeometry = TQApplication::desktop()->availableGeometry(); - TQRect newGeometry = TQRect( availableGeometry.x(), availableGeometry.y(), availableGeometry.width(), availableGeometry.height() ); + TQRect availableGeometry = TQApplication::desktop()->availableGeometry(); + TQRect newGeometry = TQRect(availableGeometry.x(), + availableGeometry.y(), availableGeometry.width(), availableGeometry.height()); #else - TQRect newGeometry = TQRect( -1,-1, TQApplication::desktop()->rect().width()+2, TQApplication::desktop()->rect().height()+2 ); + TQRect newGeometry = TQRect(-1, -1, + TQApplication::desktop()->rect().width() + 2, + TQApplication::desktop()->rect().height() + 2); #endif - setGeometry( newGeometry ); + setGeometry(newGeometry); - _aboutDialog = aboutDialog; + _aboutDialog = aboutDialog; - _windowTitleBarWidth = 0; - _windowPosOffset = 0; + _windowTitleBarWidth = 0; + _windowPosOffset = 0; - TQGraphicsScene *scene = new TQGraphicsScene(this); - setSceneRect( newGeometry ); - _aboutDialogAsSplashScreen = new TQSplashScreen(this); - _graphicsProxyWidget = scene->addWidget(_aboutDialogAsSplashScreen); - _graphicsProxyWidget->setWindowFlags( TQt::ToolTip ); + TQGraphicsScene *scene = new TQGraphicsScene(this); + setSceneRect(newGeometry); + _aboutDialogAsSplashScreen = new TQSplashScreen(this); + _graphicsProxyWidget = scene->addWidget(_aboutDialogAsSplashScreen); + _graphicsProxyWidget->setWindowFlags(TQt::ToolTip); - setScene( scene ); - setRenderHint(TQPainter::Antialiasing); + setScene(scene); + setRenderHint(TQPainter::Antialiasing); - setCacheMode(TQGraphicsView::CacheBackground); - setViewportUpdateMode(TQGraphicsView::BoundingRectViewportUpdate); + setCacheMode(TQGraphicsView::CacheBackground); + setViewportUpdateMode(TQGraphicsView::BoundingRectViewportUpdate); - connect(_aboutDialog, SIGNAL(finished(int)), this, SLOT(hide())); + connect(_aboutDialog, SIGNAL(finished(int)), this, SLOT(hide())); - //setWindowOpacity(0.9); + //setWindowOpacity(0.9); - setVerticalScrollBarPolicy(TQt::ScrollBarAlwaysOff); - setHorizontalScrollBarPolicy(TQt::ScrollBarAlwaysOff); - setStyleSheet("AboutDialogGraphicsView { border: 0px; }"); + setVerticalScrollBarPolicy(TQt::ScrollBarAlwaysOff); + setHorizontalScrollBarPolicy(TQt::ScrollBarAlwaysOff); + setStyleSheet("AboutDialogGraphicsView { border: 0px; }"); - _timeLine = new TQTimeLine(1000, this); - _timeLine->setFrameRange(270, 0); - //_timeLine->setUpdateInterval(10); - //_timeLine->setCurveShape(TQTimeLine::EaseInCurve); - connect(_timeLine, SIGNAL(frameChanged(int)), this, SLOT(updateStep(int))); + _timeLine = new TQTimeLine(1000, this); + _timeLine->setFrameRange(270, 0); + //_timeLine->setUpdateInterval(10); + //_timeLine->setCurveShape(TQTimeLine::EaseInCurve); + connect(_timeLine, SIGNAL(frameChanged(int)), this, SLOT(updateStep(int))); } - -AboutDialogGraphicsView::~AboutDialogGraphicsView(void) { +AboutDialogGraphicsView::~AboutDialogGraphicsView(void) +{ } - /*! \brief Grabs a screenshot of the full desktop and shows that as background. Above that background the AboutDialog 3D animation is shown. Also grabs the content of the AboutDialog itself. */ -void AboutDialogGraphicsView::show() { - // Because on X11 system the window decoration is only available after a widget has been shown once, - // we can detect _windowTitleBarWidth here for the first time. - _windowTitleBarWidth = _parentWindow->geometry().y() - _parentWindow->y(); - // If the _windowTitleBarWidth could not be determined, try it a second way. Even the chances are low to get good results. - if ( _windowTitleBarWidth == 0 ) - _windowTitleBarWidth = _parentWindow->frameGeometry().height() - _parentWindow->geometry().height(); +void AboutDialogGraphicsView::show() +{ + // Because on X11 system the window decoration is only available after a widget has been shown + // once, + // we can detect _windowTitleBarWidth here for the first time. + _windowTitleBarWidth = _parentWindow->geometry().y() - _parentWindow->y(); + // If the _windowTitleBarWidth could not be determined, try it a second way. Even the chances are + // low to get good results. + if (_windowTitleBarWidth == 0) + { + _windowTitleBarWidth = _parentWindow->frameGeometry().height() - + _parentWindow->geometry().height(); + } #ifdef Q_OS_LINUX - if ( _windowTitleBarWidth == 0 ) { - //TODO: 27 pixel is a fix value for the Ubuntu 10.4 default window theme and so just a workaround for that specific case. - _windowPosOffset = 27; - _windowTitleBarWidth = 27; - } + if (_windowTitleBarWidth == 0) + { + //TODO: 27 pixel is a fix value for the Ubuntu 10.4 default window theme and so just a + // workaround for that specific case. + _windowPosOffset = 27; + _windowTitleBarWidth = 27; + } #endif - TQPixmap originalPixmap = TQPixmap::grabWindow(TQApplication::desktop()->winId(), TQApplication::desktop()->availableGeometry().x(), TQApplication::desktop()->availableGeometry().y(), geometry().width(), geometry().height() ); - TQBrush brush(originalPixmap); - TQTransform transform; - transform.translate(0, TQApplication::desktop()->availableGeometry().y()); - brush.setTransform(transform); - - setBackgroundBrush(brush); - - _aboutDialogAsSplashScreen->setPixmap( TQPixmap::grabWidget(_aboutDialog) ); - _graphicsProxyWidget->setGeometry( _aboutDialog->geometry() ); - _aboutDialog->hide(); - _graphicsProxyWidget->setPos( _parentWindow->geometry().x()+(_parentWindow->geometry().width()-_graphicsProxyWidget->geometry().width()) / 2, _parentWindow->y()+_windowTitleBarWidth-_windowPosOffset); - - TQRectF r = _graphicsProxyWidget->boundingRect(); - _graphicsProxyWidget->setTransform(TQTransform() - .translate(r.width() / 2, -_windowTitleBarWidth) - .rotate(270, TQt::XAxis) - //.rotate(90, TQt::YAxis) - //.rotate(5, TQt::ZAxis) - //.scale(1 + 1.5 * step, 1 + 1.5 * step) - .translate(-r.width() / 2, _windowTitleBarWidth)); - - _graphicsProxyWidget->show(); - //_aboutDialogAsSplashScreen->show(); - TQGraphicsView::show(); - - connect(_timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog())); - _timeLine->setDirection(TQTimeLine::Forward); - _timeLine->start(); + TQPixmap originalPixmap = TQPixmap::grabWindow( + TQApplication::desktop()->winId(), + TQApplication::desktop()->availableGeometry().x(), + TQApplication::desktop()->availableGeometry().y(), geometry().width(), + geometry().height()); + TQBrush brush(originalPixmap); + TQTransform transform; + transform.translate(0, TQApplication::desktop()->availableGeometry().y()); + brush.setTransform(transform); + + setBackgroundBrush(brush); + + _aboutDialogAsSplashScreen->setPixmap(TQPixmap::grabWidget(_aboutDialog)); + _graphicsProxyWidget->setGeometry(_aboutDialog->geometry()); + _aboutDialog->hide(); + _graphicsProxyWidget->setPos(_parentWindow->geometry().x() + + (_parentWindow->geometry().width() - _graphicsProxyWidget->geometry().width()) / 2, + _parentWindow->y() + _windowTitleBarWidth - _windowPosOffset); + + TQRectF r = _graphicsProxyWidget->boundingRect(); + _graphicsProxyWidget->setTransform(TQTransform().translate( + r.width() / 2, -_windowTitleBarWidth).rotate(270, TQt::XAxis) + //.rotate(90, TQt::YAxis) + //.rotate(5, TQt::ZAxis) + //.scale(1 + 1.5 * step, 1 + 1.5 * step) + .translate(-r.width() / 2, _windowTitleBarWidth)); + + _graphicsProxyWidget->show(); + //_aboutDialogAsSplashScreen->show(); + TQGraphicsView::show(); + + connect(_timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog())); + _timeLine->setDirection(TQTimeLine::Forward); + _timeLine->start(); } - /*! \brief Does the next calculation/transformation step. */ -void AboutDialogGraphicsView::updateStep(int step) { - TQRectF r = _graphicsProxyWidget->boundingRect(); - _graphicsProxyWidget->setTransform(TQTransform() - .translate(r.width() / 2, -_windowTitleBarWidth) - .rotate(step, TQt::XAxis) - //.rotate(step, TQt::YAxis) - //.rotate(step * 5, TQt::ZAxis) - //.scale(1 + 1.5 * step, 1 + 1.5 * step) - .translate(-r.width() / 2, _windowTitleBarWidth)); - //update(); +void AboutDialogGraphicsView::updateStep(int step) +{ + TQRectF r = _graphicsProxyWidget->boundingRect(); + _graphicsProxyWidget->setTransform(TQTransform().translate( + r.width() / 2, -_windowTitleBarWidth).rotate(step, TQt::XAxis) + //.rotate(step, TQt::YAxis) + //.rotate(step * 5, TQt::ZAxis) + //.scale(1 + 1.5 * step, 1 + 1.5 * step) + .translate(-r.width() / 2, _windowTitleBarWidth)); + //update(); } - /*! \brief Stops the 3D animation, moves the AboutDialog to the correct place and really shows it. */ -void AboutDialogGraphicsView::showAboutDialog() { - //hide(); - disconnect(_timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog())); - _aboutDialog->move( int(_parentWindow->geometry().x()+(_parentWindow->geometry().width()-_graphicsProxyWidget->geometry().width()) / 2), _parentWindow->y()+_windowTitleBarWidth-_windowPosOffset ); - _aboutDialog->exec(); +void AboutDialogGraphicsView::showAboutDialog() +{ + //hide(); + disconnect(_timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog())); + _aboutDialog->move(int(_parentWindow->geometry().x() + + (_parentWindow->geometry().width() - _graphicsProxyWidget->geometry().width()) / 2), + _parentWindow->y() + _windowTitleBarWidth - _windowPosOffset); + _aboutDialog->exec(); } - /*! \brief Does not directly hide the AboutDialog but instead starts the "fade out" 3D animation. */ -void AboutDialogGraphicsView::hide() { - _graphicsProxyWidget->setPos( _parentWindow->geometry().x()+(_parentWindow->geometry().width()-_graphicsProxyWidget->geometry().width()) / 2, _parentWindow->y()+_windowTitleBarWidth-_windowPosOffset); - - TQRectF r = _graphicsProxyWidget->boundingRect(); - _graphicsProxyWidget->setTransform(TQTransform() - .translate(r.width() / 2, -_windowTitleBarWidth) - .rotate(0, TQt::XAxis) - //.rotate(90, TQt::YAxis) - //.rotate(5, TQt::ZAxis) - //.scale(1 + 1.5 * step, 1 + 1.5 * step) - .translate(-r.width() / 2, _windowTitleBarWidth)); - - _graphicsProxyWidget->show(); - //_aboutDialogAsSplashScreen->show(); - TQGraphicsView::show(); - - connect(_timeLine, SIGNAL(finished()), this, SLOT(hideReally())); - _timeLine->setDirection(TQTimeLine::Backward); - _timeLine->start(); +void AboutDialogGraphicsView::hide() +{ + _graphicsProxyWidget->setPos(_parentWindow->geometry().x() + + (_parentWindow->geometry().width() - _graphicsProxyWidget->geometry().width()) / 2, + _parentWindow->y() + _windowTitleBarWidth - _windowPosOffset); + + TQRectF r = _graphicsProxyWidget->boundingRect(); + _graphicsProxyWidget->setTransform(TQTransform().translate( + r.width() / 2, -_windowTitleBarWidth).rotate(0, TQt::XAxis) + //.rotate(90, TQt::YAxis) + //.rotate(5, TQt::ZAxis) + //.scale(1 + 1.5 * step, 1 + 1.5 * step) + .translate(-r.width() / 2, _windowTitleBarWidth)); + + _graphicsProxyWidget->show(); + //_aboutDialogAsSplashScreen->show(); + TQGraphicsView::show(); + + connect(_timeLine, SIGNAL(finished()), this, SLOT(hideReally())); + _timeLine->setDirection(TQTimeLine::Backward); + _timeLine->start(); } - /*! \brief This slot really hides this AboutDialog container. */ -void AboutDialogGraphicsView::hideReally() { - disconnect(_timeLine, SIGNAL(finished()), this, SLOT(hideReally())); - TQGraphicsView::hide(); - _parentWindow->activateWindow(); +void AboutDialogGraphicsView::hideReally() +{ + disconnect(_timeLine, SIGNAL(finished()), this, SLOT(hideReally())); + TQGraphicsView::hide(); + _parentWindow->activateWindow(); } |