comparison src/AboutDialogGraphicsView.cpp @ 745:b30f03c1a40d

Changed the positioning of the about dialog background to work on Linux properly. git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@1022 59b1889a-e5ac-428c-b0c7-476e01d41282
author thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
date Mon, 27 Sep 2010 18:53:48 +0000
parents 9b37def27afe
children 850c647d857d
comparison
equal deleted inserted replaced
744:d510c7117cd3 745:b30f03c1a40d
34 AboutDialogGraphicsView::AboutDialogGraphicsView(AboutDialog *aboutDialog, QWidget *parent) : QGraphicsView(parent) { 34 AboutDialogGraphicsView::AboutDialogGraphicsView(AboutDialog *aboutDialog, QWidget *parent) : QGraphicsView(parent) {
35 this->parent = parent; 35 this->parent = parent;
36 setWindowFlags(Qt::SplashScreen); 36 setWindowFlags(Qt::SplashScreen);
37 37
38 #ifdef Q_OS_LINUX 38 #ifdef Q_OS_LINUX
39 QRect newGeometry = QRect( QApplication::desktop()->availableGeometry().x(), QApplication::desktop()->availableGeometry().y(), QApplication::desktop()->availableGeometry().width(), QApplication::desktop()->availableGeometry().height() ); 39 QRect availableGeometry = QApplication::desktop()->availableGeometry();
40 QRect newGeometry = QRect( availableGeometry.x(), availableGeometry.y(), availableGeometry.width(), availableGeometry.height() );
41 windowPosOffset = 27;
40 #else 42 #else
41 QRect newGeometry = QRect( -1,-1, QApplication::desktop()->rect().width()+2, QApplication::desktop()->rect().height()+2 ); 43 QRect newGeometry = QRect( -1,-1, QApplication::desktop()->rect().width()+2, QApplication::desktop()->rect().height()+2 );
44 windowPosOffset = 0;
42 #endif 45 #endif
43 setGeometry( newGeometry ); 46 setGeometry( newGeometry );
44 47
45 this->aboutDialog = aboutDialog; 48 this->aboutDialog = aboutDialog;
46 49
47 firstRunOfAnimation = true;
48 windowTitleBarWidth = 0; 50 windowTitleBarWidth = 0;
49 51
50 scene = new QGraphicsScene(this); 52 scene = new QGraphicsScene(this);
51 setSceneRect( newGeometry ); 53 setSceneRect( newGeometry );
52 aboutDialogAsSplashScreen = new QSplashScreen(this); 54 aboutDialogAsSplashScreen = new QSplashScreen(this);
86 */ 88 */
87 void AboutDialogGraphicsView::show() { 89 void AboutDialogGraphicsView::show() {
88 // Because on X11 system the window decoration is only available after a widget has been shown once, 90 // Because on X11 system the window decoration is only available after a widget has been shown once,
89 // we can detect windowTitleBarWidth here for the first time. 91 // we can detect windowTitleBarWidth here for the first time.
90 windowTitleBarWidth = parent->geometry().y() - parent->y(); 92 windowTitleBarWidth = parent->geometry().y() - parent->y();
91 #ifdef Q_OS_LINUX 93 QPixmap originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), QApplication::desktop()->availableGeometry().x(), QApplication::desktop()->availableGeometry().y(), geometry().width(), geometry().height() );
92 QPixmap originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), 0, 0, QApplication::desktop()->availableGeometry().width(), QApplication::desktop()->availableGeometry().height()+windowTitleBarWidth+1 ); 94 QBrush brush(originalPixmap);
93 #else 95 QTransform transform;
94 QPixmap originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), 0, 0, geometry().width(), geometry().height() ); 96 transform.translate(0, QApplication::desktop()->availableGeometry().y());
95 #endif 97 brush.setTransform(transform);
96 98
97 setBackgroundBrush(originalPixmap); 99 setBackgroundBrush(brush);
98 100
99 aboutDialogAsSplashScreen->setPixmap( QPixmap::grabWidget(aboutDialog) ); 101 aboutDialogAsSplashScreen->setPixmap( QPixmap::grabWidget(aboutDialog) );
100 graphicsProxyWidget->setGeometry( aboutDialog->geometry() ); 102 graphicsProxyWidget->setGeometry( aboutDialog->geometry() );
101 aboutDialog->hide(); 103 aboutDialog->hide();
102 if ( firstRunOfAnimation ) { 104 graphicsProxyWidget->setPos( parent->geometry().x()+(parent->geometry().width()-graphicsProxyWidget->geometry().width()) / 2, parent->y()+windowTitleBarWidth-windowPosOffset);
103 graphicsProxyWidget->setPos( parent->geometry().x()+(parent->geometry().width()-graphicsProxyWidget->geometry().width()) / 2, parent->y()+windowTitleBarWidth);
104 }
105 else {
106 graphicsProxyWidget->setPos( parent->geometry().x()+(parent->geometry().width()-graphicsProxyWidget->geometry().width()) / 2, parent->y()+windowTitleBarWidth);
107 }
108 105
109 QRectF r = graphicsProxyWidget->boundingRect(); 106 QRectF r = graphicsProxyWidget->boundingRect();
110 graphicsProxyWidget->setTransform(QTransform() 107 graphicsProxyWidget->setTransform(QTransform()
111 .translate(r.width() / 2, -windowTitleBarWidth) 108 .translate(r.width() / 2, -windowTitleBarWidth)
112 .rotate(270, Qt::XAxis) 109 .rotate(270, Qt::XAxis)
145 \brief Stops the 3D animation, moves the AboutDialog to the correct place and really shows it. 142 \brief Stops the 3D animation, moves the AboutDialog to the correct place and really shows it.
146 */ 143 */
147 void AboutDialogGraphicsView::showAboutDialog() { 144 void AboutDialogGraphicsView::showAboutDialog() {
148 //hide(); 145 //hide();
149 disconnect(timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog())); 146 disconnect(timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog()));
150 aboutDialog->move( int(parent->geometry().x()+(parent->geometry().width()-graphicsProxyWidget->geometry().width()) / 2), parent->y()+windowTitleBarWidth ); 147 aboutDialog->move( int(parent->geometry().x()+(parent->geometry().width()-graphicsProxyWidget->geometry().width()) / 2), parent->y()+windowTitleBarWidth-windowPosOffset );
151 aboutDialog->exec(); 148 aboutDialog->exec();
152 } 149 }
153 150
154 151
155 /*! 152 /*!
156 \brief Does not directly hide the AboutDialog but instead starts the "fade out" 3D animation. 153 \brief Does not directly hide the AboutDialog but instead starts the "fade out" 3D animation.
157 */ 154 */
158 void AboutDialogGraphicsView::hide() { 155 void AboutDialogGraphicsView::hide() {
159 //aboutDialogAsSplashScreen->setPixmap( QPixmap::grabWidget(aboutDialog) ); 156 //aboutDialogAsSplashScreen->setPixmap( QPixmap::grabWidget(aboutDialog) );
160 //graphicsProxyWidget->setGeometry( aboutDialog->geometry() ); 157 //graphicsProxyWidget->setGeometry( aboutDialog->geometry() );
161 //if ( firstRunOfAnimation ) { 158 graphicsProxyWidget->setPos( parent->geometry().x()+(parent->geometry().width()-graphicsProxyWidget->geometry().width()) / 2, parent->y()+windowTitleBarWidth-windowPosOffset);
162 firstRunOfAnimation = false;
163 // graphicsProxyWidget->setPos( parent->geometry().x()+(parent->geometry().width()-graphicsProxyWidget->geometry().width()) / 2, parent->y());
164 //}
165 //else {
166 graphicsProxyWidget->setPos( parent->geometry().x()+(parent->geometry().width()-graphicsProxyWidget->geometry().width()) / 2, parent->y()+windowTitleBarWidth);
167 //}
168 159
169 QRectF r = graphicsProxyWidget->boundingRect(); 160 QRectF r = graphicsProxyWidget->boundingRect();
170 graphicsProxyWidget->setTransform(QTransform() 161 graphicsProxyWidget->setTransform(QTransform()
171 .translate(r.width() / 2, -windowTitleBarWidth) 162 .translate(r.width() / 2, -windowTitleBarWidth)
172 .rotate(0, Qt::XAxis) 163 .rotate(0, Qt::XAxis)