#include <qapplication.h>
#include <qlayout.h>
#include <qtranslator.h>
#include <qtextcodec.h>
#include <qdir.h>
#include "gui/window.h"
#include "config.h"
Include dependency graph for main.cpp:

Go to the source code of this file.
Defines | |
| #define | DEFAULT_WIDTH 875 |
| #define | DEFAULT_HEIGHT 620 |
Functions | |
| int | main (int argc, char **argv) |
|
|
|
|
|
|
|
||||||||||||
|
Definition at line 41 of file main.cpp. References DEFAULT_HEIGHT, DEFAULT_WIDTH, EASTER_PATH, HANDBOOK_PATH, IMAGE_PATH, MATERIAL_DIR, TEXT_PATH, THEMES_PATH, and XMLCONVERSION_PATH.
00042 {
00043 //----------------------------------------------
00044 //set material path
00045
00046 //if using mac os x material dir in bundle
00047 #if defined(Q_OS_MACX)
00048 CFURLRef pluginRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
00049 CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef, kCFURLPOSIXPathStyle);
00050 MATERIAL_DIR = QString( CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding())) + "/Contents/Resources";
00051 //otherwise material path can be passed in or assumed to be the local path
00052 #else
00053 if(argc > 1)
00054 MATERIAL_DIR = QString(argv[1]).replace("/usr/local/bin", "/usr/local/share/albumshaper");
00055 else
00056 MATERIAL_DIR = "./";
00057 #endif
00058 //----------------------------------------------
00059 //set image path
00060 IMAGE_PATH = MATERIAL_DIR + "/images/";
00061 //----------------------------------------------
00062 //set handbook path, attempt to use locale specific directory, otherwise fall back on english default
00063 HANDBOOK_PATH = MATERIAL_DIR + "/handbook_" + QTextCodec::locale() + "/";
00064 QDir handbookDir( HANDBOOK_PATH );
00065 if(!handbookDir.exists())
00066 HANDBOOK_PATH = MATERIAL_DIR + "/handbook/";
00067 //----------------------------------------------
00068 //set text path, attempt to use locale specific directory, otherwise fall back on english default
00069 TEXT_PATH = MATERIAL_DIR + "/text_" + QTextCodec::locale() + "/";
00070 QDir textDir( TEXT_PATH );
00071 if(!textDir.exists())
00072 TEXT_PATH = MATERIAL_DIR + "/text/";
00073 //----------------------------------------------
00074 //set themes path
00075 THEMES_PATH = MATERIAL_DIR + "/themes/";
00076 //----------------------------------------------
00077 //set xml conversion path
00078 XMLCONVERSION_PATH = MATERIAL_DIR + "/xmlConversion/";
00079 //----------------------------------------------
00080 //set easter eggs path
00081 EASTER_PATH = MATERIAL_DIR + "/easter/";
00082 //----------------------------------------------
00083 //create app
00084 QApplication a(argc, argv);
00085
00086 //create translator for current locale and attempt to install
00087 QTranslator translator( 0 );
00088 translator.load( QString("AlbumShaper_") + QTextCodec::locale(), MATERIAL_DIR + "/translations");
00089 a.installTranslator( &translator );
00090
00091 //create main window and show
00092 Window window;
00093 a.setMainWidget( &window );
00094 window.show();
00095
00096 //----------------------------------------------
00097 //determine default window size
00098
00099 //set defaults
00100 int width = DEFAULT_WIDTH;
00101 int height = DEFAULT_HEIGHT;
00102
00103 //if window size greater than desktop available then decrease
00104 QDesktopWidget *desktop = QApplication::desktop();
00105 if(width > desktop->width())
00106 { width = desktop->width(); }
00107 if(height > desktop->height())
00108 { height = desktop->height(); }
00109
00110 //if window already must be larger than defaults then enlarge
00111 if(width < window.geometry().width())
00112 { width = window.geometry().width(); }
00113 if(height < window.geometry().height())
00114 { height = window.geometry().height(); }
00115
00116 //compute offsets such that window centered on screen
00117 int xOffset = (desktop->width() - width) / 2;
00118 int yOffset = (desktop->height() - height) / 2;
00119
00120 //set size and offset and show window
00121 window.setGeometry(xOffset, yOffset, width, height);
00122 window.repaint();
00123 return a.exec();
00124 }
|
1.3.4