comparison src/AboutDialogGraphicsView.cpp @ 751:ac165b6ae67e

Done some refactoring: - Moved includes into the cpp files where possible and using class pre-declarations if possible - Made class member variable names begin with an underscore - Made by uic created header files be used as class members instead of inherting them - Renamed some variables to reflect their purpose better - Added some NULL initializations and added some comments - Rearranged some include and declaration code parts to be consistent and better readable - Updated for QScintilla 2.4.5 - Made UiGuiSettings be accessed via a shared pointer only git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@1028 59b1889a-e5ac-428c-b0c7-476e01d41282
author thomas_-_s <thomas_-_s@59b1889a-e5ac-428c-b0c7-476e01d41282>
date Thu, 14 Oct 2010 19:52:47 +0000
parents 850c647d857d
children f3631db17328
comparison
equal deleted inserted replaced
750:a884b5861e93 751:ac165b6ae67e
14 * You should have received a copy of the GNU General Public License * 14 * You should have received a copy of the GNU General Public License *
15 * along with this program in the file LICENSE.GPL; if not, write to the * 15 * along with this program in the file LICENSE.GPL; if not, write to the *
16 * Free Software Foundation, Inc., * 16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/ 18 ***************************************************************************/
19
20 #include "AboutDialogGraphicsView.h"
21
22 #include "AboutDialog.h"
23
19 #include <QtGui> 24 #include <QtGui>
20 #include "AboutDialogGraphicsView.h" 25 #include <QDesktopWidget>
26 #include <QDate>
27 #include <QTimeLine>
28 #include <QSplashScreen>
21 29
22 /*! 30 /*!
23 \class AboutDialogGraphicsView 31 \class AboutDialogGraphicsView
24 \brief A container for the real \a AboutDialog. Makes the 3D animation possible. 32 \brief A container for the real \a AboutDialog. Makes the 3D animation possible.
25 33
29 */ 37 */
30 38
31 /*! 39 /*!
32 \brief The constructor initializes everything needed for the 3D animation. 40 \brief The constructor initializes everything needed for the 3D animation.
33 */ 41 */
34 AboutDialogGraphicsView::AboutDialogGraphicsView(AboutDialog *aboutDialog, QWidget *parent) : QGraphicsView(parent) { 42 AboutDialogGraphicsView::AboutDialogGraphicsView(AboutDialog *aboutDialog, QWidget *parentWindow) : QGraphicsView(parentWindow)
35 this->parent = parent; 43 , _aboutDialog(NULL)
44 , _graphicsProxyWidget(NULL)
45 , _parentWindow(NULL)
46 , _timeLine(NULL)
47 , _aboutDialogAsSplashScreen(NULL)
48 {
49 _parentWindow = parentWindow;
36 setWindowFlags(Qt::SplashScreen); 50 setWindowFlags(Qt::SplashScreen);
37 51
38 #ifdef Q_OS_LINUX 52 #ifdef Q_OS_LINUX
39 QRect availableGeometry = QApplication::desktop()->availableGeometry(); 53 QRect availableGeometry = QApplication::desktop()->availableGeometry();
40 QRect newGeometry = QRect( availableGeometry.x(), availableGeometry.y(), availableGeometry.width(), availableGeometry.height() ); 54 QRect newGeometry = QRect( availableGeometry.x(), availableGeometry.y(), availableGeometry.width(), availableGeometry.height() );
41 #else 55 #else
42 QRect newGeometry = QRect( -1,-1, QApplication::desktop()->rect().width()+2, QApplication::desktop()->rect().height()+2 ); 56 QRect newGeometry = QRect( -1,-1, QApplication::desktop()->rect().width()+2, QApplication::desktop()->rect().height()+2 );
43 #endif 57 #endif
44 setGeometry( newGeometry ); 58 setGeometry( newGeometry );
45 59
46 this->aboutDialog = aboutDialog; 60 _aboutDialog = aboutDialog;
47 61
48 windowTitleBarWidth = 0; 62 _windowTitleBarWidth = 0;
49 windowPosOffset = 0; 63 _windowPosOffset = 0;
50 64
51 scene = new QGraphicsScene(this); 65 QGraphicsScene *scene = new QGraphicsScene(this);
52 setSceneRect( newGeometry ); 66 setSceneRect( newGeometry );
53 aboutDialogAsSplashScreen = new QSplashScreen(this); 67 _aboutDialogAsSplashScreen = new QSplashScreen(this);
54 //aboutDialogAsSplashScreen->setPixmap( QPixmap::grabWidget(aboutDialog) ); 68 _graphicsProxyWidget = scene->addWidget(_aboutDialogAsSplashScreen);
55 graphicsProxyWidget = scene->addWidget(aboutDialogAsSplashScreen); 69 _graphicsProxyWidget->setWindowFlags( Qt::ToolTip );
56 graphicsProxyWidget->setWindowFlags( Qt::ToolTip );
57 70
58 setScene( scene ); 71 setScene( scene );
59 setRenderHint(QPainter::Antialiasing); 72 setRenderHint(QPainter::Antialiasing);
60 73
61 setCacheMode(QGraphicsView::CacheBackground); 74 setCacheMode(QGraphicsView::CacheBackground);
62 setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); 75 setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
63 76
64 connect(aboutDialog, SIGNAL(finished(int)), this, SLOT(hide())); 77 connect(_aboutDialog, SIGNAL(finished(int)), this, SLOT(hide()));
65 78
66 //setWindowOpacity(0.9); 79 //setWindowOpacity(0.9);
67 80
68 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 81 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
69 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 82 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
70 setStyleSheet("AboutDialogGraphicsView { border: 0px; }"); 83 setStyleSheet("AboutDialogGraphicsView { border: 0px; }");
71 84
72 timeLine = new QTimeLine(1000, this); 85 _timeLine = new QTimeLine(1000, this);
73 timeLine->setFrameRange(270, 0); 86 _timeLine->setFrameRange(270, 0);
74 //timeLine->setUpdateInterval(10); 87 //_timeLine->setUpdateInterval(10);
75 //timeLine->setCurveShape(QTimeLine::EaseInCurve); 88 //_timeLine->setCurveShape(QTimeLine::EaseInCurve);
76 connect(timeLine, SIGNAL(frameChanged(int)), this, SLOT(updateStep(int))); 89 connect(_timeLine, SIGNAL(frameChanged(int)), this, SLOT(updateStep(int)));
77 } 90 }
78 91
79 92
80 AboutDialogGraphicsView::~AboutDialogGraphicsView(void) { 93 AboutDialogGraphicsView::~AboutDialogGraphicsView(void) {
81 } 94 }
85 \brief Grabs a screenshot of the full desktop and shows that as background. Above that background the 98 \brief Grabs a screenshot of the full desktop and shows that as background. Above that background the
86 AboutDialog 3D animation is shown. Also grabs the content of the AboutDialog itself. 99 AboutDialog 3D animation is shown. Also grabs the content of the AboutDialog itself.
87 */ 100 */
88 void AboutDialogGraphicsView::show() { 101 void AboutDialogGraphicsView::show() {
89 // Because on X11 system the window decoration is only available after a widget has been shown once, 102 // Because on X11 system the window decoration is only available after a widget has been shown once,
90 // we can detect windowTitleBarWidth here for the first time. 103 // we can detect _windowTitleBarWidth here for the first time.
91 windowTitleBarWidth = parent->geometry().y() - parent->y(); 104 _windowTitleBarWidth = _parentWindow->geometry().y() - _parentWindow->y();
92 // If the windowTitleBarWidth could not be determined, try it a second way. Even the chances are low to get good results. 105 // If the _windowTitleBarWidth could not be determined, try it a second way. Even the chances are low to get good results.
93 if ( windowTitleBarWidth == 0 ) 106 if ( _windowTitleBarWidth == 0 )
94 windowTitleBarWidth = parent->frameGeometry().height() - parent->geometry().height(); 107 _windowTitleBarWidth = _parentWindow->frameGeometry().height() - _parentWindow->geometry().height();
95 #ifdef Q_OS_LINUX 108 #ifdef Q_OS_LINUX
96 if ( windowTitleBarWidth == 0 ) { 109 if ( _windowTitleBarWidth == 0 ) {
97 //TODO: 27 pixel is a fix value for the Ubuntu 10.4 default window theme and so just a workaround for that specific case. 110 //TODO: 27 pixel is a fix value for the Ubuntu 10.4 default window theme and so just a workaround for that specific case.
98 windowPosOffset = 27; 111 _windowPosOffset = 27;
99 windowTitleBarWidth = 27; 112 _windowTitleBarWidth = 27;
100 } 113 }
101 #endif 114 #endif
102 QPixmap originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), QApplication::desktop()->availableGeometry().x(), QApplication::desktop()->availableGeometry().y(), geometry().width(), geometry().height() ); 115 QPixmap originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), QApplication::desktop()->availableGeometry().x(), QApplication::desktop()->availableGeometry().y(), geometry().width(), geometry().height() );
103 QBrush brush(originalPixmap); 116 QBrush brush(originalPixmap);
104 QTransform transform; 117 QTransform transform;
105 transform.translate(0, QApplication::desktop()->availableGeometry().y()); 118 transform.translate(0, QApplication::desktop()->availableGeometry().y());
106 brush.setTransform(transform); 119 brush.setTransform(transform);
107 120
108 setBackgroundBrush(brush); 121 setBackgroundBrush(brush);
109 122
110 aboutDialogAsSplashScreen->setPixmap( QPixmap::grabWidget(aboutDialog) ); 123 _aboutDialogAsSplashScreen->setPixmap( QPixmap::grabWidget(_aboutDialog) );
111 graphicsProxyWidget->setGeometry( aboutDialog->geometry() ); 124 _graphicsProxyWidget->setGeometry( _aboutDialog->geometry() );
112 aboutDialog->hide(); 125 _aboutDialog->hide();
113 graphicsProxyWidget->setPos( parent->geometry().x()+(parent->geometry().width()-graphicsProxyWidget->geometry().width()) / 2, parent->y()+windowTitleBarWidth-windowPosOffset); 126 _graphicsProxyWidget->setPos( _parentWindow->geometry().x()+(_parentWindow->geometry().width()-_graphicsProxyWidget->geometry().width()) / 2, _parentWindow->y()+_windowTitleBarWidth-_windowPosOffset);
114 127
115 QRectF r = graphicsProxyWidget->boundingRect(); 128 QRectF r = _graphicsProxyWidget->boundingRect();
116 graphicsProxyWidget->setTransform(QTransform() 129 _graphicsProxyWidget->setTransform(QTransform()
117 .translate(r.width() / 2, -windowTitleBarWidth) 130 .translate(r.width() / 2, -_windowTitleBarWidth)
118 .rotate(270, Qt::XAxis) 131 .rotate(270, Qt::XAxis)
119 //.rotate(90, Qt::YAxis) 132 //.rotate(90, Qt::YAxis)
120 //.rotate(5, Qt::ZAxis) 133 //.rotate(5, Qt::ZAxis)
121 //.scale(1 + 1.5 * step, 1 + 1.5 * step) 134 //.scale(1 + 1.5 * step, 1 + 1.5 * step)
122 .translate(-r.width() / 2, windowTitleBarWidth)); 135 .translate(-r.width() / 2, _windowTitleBarWidth));
123 136
124 graphicsProxyWidget->show(); 137 _graphicsProxyWidget->show();
125 //aboutDialogAsSplashScreen->show(); 138 //_aboutDialogAsSplashScreen->show();
126 QGraphicsView::show(); 139 QGraphicsView::show();
127 140
128 connect(timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog())); 141 connect(_timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog()));
129 timeLine->setDirection(QTimeLine::Forward); 142 _timeLine->setDirection(QTimeLine::Forward);
130 timeLine->start(); 143 _timeLine->start();
131 } 144 }
132 145
133 146
134 /*! 147 /*!
135 \brief Does the next calculation/transformation step. 148 \brief Does the next calculation/transformation step.
136 */ 149 */
137 void AboutDialogGraphicsView::updateStep(int step) { 150 void AboutDialogGraphicsView::updateStep(int step) {
138 QRectF r = graphicsProxyWidget->boundingRect(); 151 QRectF r = _graphicsProxyWidget->boundingRect();
139 graphicsProxyWidget->setTransform(QTransform() 152 _graphicsProxyWidget->setTransform(QTransform()
140 .translate(r.width() / 2, -windowTitleBarWidth) 153 .translate(r.width() / 2, -_windowTitleBarWidth)
141 .rotate(step, Qt::XAxis) 154 .rotate(step, Qt::XAxis)
142 //.rotate(step, Qt::YAxis) 155 //.rotate(step, Qt::YAxis)
143 //.rotate(step * 5, Qt::ZAxis) 156 //.rotate(step * 5, Qt::ZAxis)
144 //.scale(1 + 1.5 * step, 1 + 1.5 * step) 157 //.scale(1 + 1.5 * step, 1 + 1.5 * step)
145 .translate(-r.width() / 2, windowTitleBarWidth)); 158 .translate(-r.width() / 2, _windowTitleBarWidth));
146 //update(); 159 //update();
147 } 160 }
148 161
149 162
150 /*! 163 /*!
151 \brief Stops the 3D animation, moves the AboutDialog to the correct place and really shows it. 164 \brief Stops the 3D animation, moves the AboutDialog to the correct place and really shows it.
152 */ 165 */
153 void AboutDialogGraphicsView::showAboutDialog() { 166 void AboutDialogGraphicsView::showAboutDialog() {
154 //hide(); 167 //hide();
155 disconnect(timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog())); 168 disconnect(_timeLine, SIGNAL(finished()), this, SLOT(showAboutDialog()));
156 aboutDialog->move( int(parent->geometry().x()+(parent->geometry().width()-graphicsProxyWidget->geometry().width()) / 2), parent->y()+windowTitleBarWidth-windowPosOffset ); 169 _aboutDialog->move( int(_parentWindow->geometry().x()+(_parentWindow->geometry().width()-_graphicsProxyWidget->geometry().width()) / 2), _parentWindow->y()+_windowTitleBarWidth-_windowPosOffset );
157 aboutDialog->exec(); 170 _aboutDialog->exec();
158 } 171 }
159 172
160 173
161 /*! 174 /*!
162 \brief Does not directly hide the AboutDialog but instead starts the "fade out" 3D animation. 175 \brief Does not directly hide the AboutDialog but instead starts the "fade out" 3D animation.
163 */ 176 */
164 void AboutDialogGraphicsView::hide() { 177 void AboutDialogGraphicsView::hide() {
165 //aboutDialogAsSplashScreen->setPixmap( QPixmap::grabWidget(aboutDialog) ); 178 _graphicsProxyWidget->setPos( _parentWindow->geometry().x()+(_parentWindow->geometry().width()-_graphicsProxyWidget->geometry().width()) / 2, _parentWindow->y()+_windowTitleBarWidth-_windowPosOffset);
166 //graphicsProxyWidget->setGeometry( aboutDialog->geometry() ); 179
167 graphicsProxyWidget->setPos( parent->geometry().x()+(parent->geometry().width()-graphicsProxyWidget->geometry().width()) / 2, parent->y()+windowTitleBarWidth-windowPosOffset); 180 QRectF r = _graphicsProxyWidget->boundingRect();
168 181 _graphicsProxyWidget->setTransform(QTransform()
169 QRectF r = graphicsProxyWidget->boundingRect(); 182 .translate(r.width() / 2, -_windowTitleBarWidth)
170 graphicsProxyWidget->setTransform(QTransform()
171 .translate(r.width() / 2, -windowTitleBarWidth)
172 .rotate(0, Qt::XAxis) 183 .rotate(0, Qt::XAxis)
173 //.rotate(90, Qt::YAxis) 184 //.rotate(90, Qt::YAxis)
174 //.rotate(5, Qt::ZAxis) 185 //.rotate(5, Qt::ZAxis)
175 //.scale(1 + 1.5 * step, 1 + 1.5 * step) 186 //.scale(1 + 1.5 * step, 1 + 1.5 * step)
176 .translate(-r.width() / 2, windowTitleBarWidth)); 187 .translate(-r.width() / 2, _windowTitleBarWidth));
177 188
178 graphicsProxyWidget->show(); 189 _graphicsProxyWidget->show();
179 //aboutDialogAsSplashScreen->show(); 190 //_aboutDialogAsSplashScreen->show();
180 QGraphicsView::show(); 191 QGraphicsView::show();
181 192
182 connect(timeLine, SIGNAL(finished()), this, SLOT(hideReally())); 193 connect(_timeLine, SIGNAL(finished()), this, SLOT(hideReally()));
183 timeLine->setDirection(QTimeLine::Backward); 194 _timeLine->setDirection(QTimeLine::Backward);
184 timeLine->start(); 195 _timeLine->start();
185 } 196 }
186 197
187 198
188 /*! 199 /*!
189 \brief This slot really hides this AboutDialog container. 200 \brief This slot really hides this AboutDialog container.
190 */ 201 */
191 void AboutDialogGraphicsView::hideReally() { 202 void AboutDialogGraphicsView::hideReally() {
192 disconnect(timeLine, SIGNAL(finished()), this, SLOT(hideReally())); 203 disconnect(_timeLine, SIGNAL(finished()), this, SLOT(hideReally()));
193 QGraphicsView::hide(); 204 QGraphicsView::hide();
194 parent->activateWindow(); 205 _parentWindow->activateWindow();
195 } 206 }
196
197
198 /*!
199 \brief Makes it possible to set the screen shot used for the animation.
200 */
201 //TODO: Test whether this function is really still needed. Not only for debug.
202 void AboutDialogGraphicsView::setScreenshotPixmap(const QPixmap &screenShot) {
203 originalPixmap = screenShot;
204 }