00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <qapplication.h>
00019 #include <qlayout.h>
00020 #include <qtranslator.h>
00021 #include <qtextcodec.h>
00022 #include <qdir.h>
00023
00024 #if defined(Q_OS_MACX)
00025 #include <CoreFoundation/CFURL.h>
00026 #include <CoreFoundation/CFBundle.h>
00027 #endif
00028
00029
00030 #include "gui/window.h"
00031 #include "config.h"
00032
00038 #define DEFAULT_WIDTH 875
00039 #define DEFAULT_HEIGHT 620
00040
00041 int main( int argc, char **argv)
00042 {
00043
00044
00045
00046
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
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
00060 IMAGE_PATH = MATERIAL_DIR + "/images/";
00061
00062
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
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
00075 THEMES_PATH = MATERIAL_DIR + "/themes/";
00076
00077
00078 XMLCONVERSION_PATH = MATERIAL_DIR + "/xmlConversion/";
00079
00080
00081 EASTER_PATH = MATERIAL_DIR + "/easter/";
00082
00083
00084 QApplication a(argc, argv);
00085
00086
00087 QTranslator translator( 0 );
00088 translator.load( QString("AlbumShaper_") + QTextCodec::locale(), MATERIAL_DIR + "/translations");
00089 a.installTranslator( &translator );
00090
00091
00092 Window window;
00093 a.setMainWidget( &window );
00094 window.show();
00095
00096
00097
00098
00099
00100 int width = DEFAULT_WIDTH;
00101 int height = DEFAULT_HEIGHT;
00102
00103
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
00111 if(width < window.geometry().width())
00112 { width = window.geometry().width(); }
00113 if(height < window.geometry().height())
00114 { height = window.geometry().height(); }
00115
00116
00117 int xOffset = (desktop->width() - width) / 2;
00118 int yOffset = (desktop->height() - height) / 2;
00119
00120
00121 window.setGeometry(xOffset, yOffset, width, height);
00122 window.repaint();
00123 return a.exec();
00124 }