# HG changeset patch # User thomas_-_s # Date 1286020570 0 # Node ID 850c647d857df589e204617b0b1f9462cfce323d # Parent ab871460c30083e407730c24cd68e153ebf46dd7 AboutDialogGraphicsView: Improved the about dialog positioning on Linux. git-svn-id: svn://svn.code.sf.net/p/universalindent/code/trunk@1024 59b1889a-e5ac-428c-b0c7-476e01d41282 diff -r ab871460c300 -r 850c647d857d src/AboutDialogGraphicsView.cpp --- a/src/AboutDialogGraphicsView.cpp Thu Sep 30 20:58:43 2010 +0000 +++ b/src/AboutDialogGraphicsView.cpp Sat Oct 02 11:56:10 2010 +0000 @@ -38,16 +38,15 @@ #ifdef Q_OS_LINUX QRect availableGeometry = QApplication::desktop()->availableGeometry(); QRect newGeometry = QRect( availableGeometry.x(), availableGeometry.y(), availableGeometry.width(), availableGeometry.height() ); - windowPosOffset = 27; #else QRect newGeometry = QRect( -1,-1, QApplication::desktop()->rect().width()+2, QApplication::desktop()->rect().height()+2 ); - windowPosOffset = 0; #endif setGeometry( newGeometry ); this->aboutDialog = aboutDialog; windowTitleBarWidth = 0; + windowPosOffset = 0; scene = new QGraphicsScene(this); setSceneRect( newGeometry ); @@ -90,6 +89,16 @@ // 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 = parent->geometry().y() - parent->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 = parent->frameGeometry().height() - parent->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; + } +#endif QPixmap originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), QApplication::desktop()->availableGeometry().x(), QApplication::desktop()->availableGeometry().y(), geometry().width(), geometry().height() ); QBrush brush(originalPixmap); QTransform transform;