Main Page   Compound List   File List   Compound Members   File Members  

main.cpp

Go to the documentation of this file.
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 <qapplication.h>
00019 #include <qlayout.h>
00020 
00021 //Projectwide includes
00022 #include "gui/window.h"
00023 #include "config.h"
00024 
00025 #include <iostream.h>
00026 
00027 
00033 #define DEFAULT_WIDTH 875
00034 #define DEFAULT_HEIGHT 620 
00035 
00036 int main( int argc, char **argv)
00037 { 
00038   //set image path
00039   if(argc > 1)
00040     IMAGE_PATH = QString(argv[1]).replace("/usr/local/bin", "/usr/local/share/albumshaper") + "/images/";
00041   else
00042     IMAGE_PATH = "images/";
00043   
00044   QApplication a(argc, argv);
00045 
00046   Window window;
00047   a.setMainWidget( &window );
00048   window.show();
00049 
00050   //determine default window size
00051   
00052   //set defaults
00053   int width = DEFAULT_WIDTH;
00054   int height = DEFAULT_HEIGHT;
00055   
00056   //if window size greater than desktop available then decrease
00057   QDesktopWidget *desktop = QApplication::desktop();
00058   if(width > desktop->width())
00059   { width = desktop->width(); }
00060   if(height > desktop->height())
00061   { height = desktop->height(); }
00062   
00063   //if window already must be larger than defaults then enlarge
00064   if(width < window.geometry().width())
00065   { width = window.geometry().width(); }
00066   if(height < window.geometry().height())
00067   { height = window.geometry().height(); }
00068   
00069   //compute offsets such that window centered on screen
00070   int xOffset = (desktop->width() - width) / 2;
00071   int yOffset = (desktop->height() - height) / 2;
00072   
00073   //set size and offset and show window
00074   window.setGeometry(xOffset, yOffset, width, height);
00075   window.repaint();
00076   a.exec();
00077 }

Generated on Tue Jun 10 23:41:20 2003 for AlbumShaper by doxygen 1.3.1