00001 //============================================== 00002 // copyright : (C) 2003 by Will Stokes 00003 //============================================== 00004 // This program is free software; you can redistribute it 00005 // and/or modify it under the terms of the GNU General 00006 // Public License as published by the Free Software 00007 // Foundation; either version 2 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // As a special exception, Will Stokes gives permission to 00011 // link this program with Qt non-commercial edition, and 00012 // distribute the resulting executable, without including the 00013 // source code for the Qt non-commercial edition in the 00014 // source distribution. 00015 //============================================== 00016 00017 //Systemwide includes 00018 #include <qwidget.h> 00019 #include <qapplication.h> 00020 #include <qstring.h> 00021 #include <qstringlist.h> 00022 #include <qpixmap.h> 00023 00024 //Projectwide includes 00025 #include "guiTools.h" 00026 00027 //============================================== 00028 //centers window on screen 00029 void centerWindow(QWidget* window) 00030 { 00031 //get size and location of application window 00032 QRect appRec = qApp->mainWidget()->geometry(); 00033 QRect windowRec = window->geometry(); 00034 00035 //center this dialoag within application window 00036 int x, y; 00037 if(windowRec.width() < appRec.width()) 00038 { x = appRec.x() + ((appRec.width() - windowRec.width())/2); } 00039 else 00040 { x = appRec.x(); } 00041 if(windowRec.height() < appRec.height()) 00042 { y = appRec.y() + ((appRec.height() - windowRec.height())/2); } 00043 else 00044 { y = appRec.y(); } 00045 00046 window->move( QPoint( x, y) ); 00047 } 00048 //============================================== 00049 00050 00051
1.3.4