52{
53
54 QApplication a(argc, argv);
55
56
57
58
59
60
61
62 #if defined(Q_OS_MACX)
63 CFURLRef pluginRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
64 CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef, kCFURLPOSIXPathStyle);
65 MATERIAL_DIR = QString( CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding())) +
"/Contents/Resources";
66
67
68 #elif defined(Q_OS_WIN)
70
71
72 #else
73 if( argc > 1 )
74 {
75
76
77 if( QString(argv[1]).contains(QString(BIN_DIR)) != 0 )
79
80
81
82
83 else
85 }
86
87
88 else
90 #endif
91
92
93
95
96
99 if(!handbookDir.exists())
101
102
105 if(!textDir.exists())
107
108
110
111
113
114
115
117 {
118 std::cout << "Error! Unable to make configurations directory!\n";
119 return -1;
120 }
121
122
123
124
125
126 bool tempDirMade = true;
127 QDir homeDir;
128
129
130 #if defined(Q_OS_MACX)
131 homeDir = QDir::homeDirPath();
132 homeDir.cd("Library");
133 homeDir.cd("Application Support");
134 if(!homeDir.exists("Album Shaper"))
135 { tempDirMade = homeDir.mkdir("Album Shaper"); }
136 TEMP_DIR = QDir::convertSeparators( QDir::homeDirPath() + QString(
"/Library/Application Support/Album Shaper") );
137
138
139 #elif defined(Q_OS_WIN)
140 QString folderLoc;
141 if( !getWindowsFolderLocation(APPLICATION_DATA, folderLoc) )
142 {
143 std::cout << "Error! Unable to identify Application Data folder!\n";
144 return -1;
145 }
146
147 QDir applicationDataDir( folderLoc );
148 if(!applicationDataDir.exists("Album Shaper"))
149 { tempDirMade = applicationDataDir.mkdir("Album Shaper"); }
150 TEMP_DIR = QDir::convertSeparators ( folderLoc + QString(
"/Album Shaper") );
151
152
153 #else
154 homeDir = QDir::homeDirPath();
155 if(!homeDir.exists(".albumShaper")) { tempDirMade = homeDir.mkdir(".albumShaper"); }
156 TEMP_DIR = QDir::homeDirPath() + QString(
"/.albumShaper");
157 #endif
158
159
160 if(!tempDirMade)
161 {
162 std::cout << "Error! Unable to make temp files directory!\n";
163 return -1;
164 }
165
166
167 QTranslator translator( 0 );
168 translator.load( QString("AlbumShaper_") +
169
170 QTextCodec::locale(),
172
173 a.installTranslator( &translator );
174
175
177 a.setMainWidget( &window );
178
179
181 if( config->
getBool(
"layout",
"restoreWindowPlacementSize") )
182 {
183 window.resize( config->
getInt(
"layout",
"windowWidth" ),
184 config->
getInt(
"layout",
"windowHeight" ) );
185
186 window.move( config->
getInt(
"layout",
"windowPosX" ),
187 config->
getInt(
"layout",
"windowPosY" ) );
188 }
189 else
190 {
191 QDesktopWidget *desktop = QApplication::desktop();
192 int size = config->
getInt(
"layout",
"defaultWindowSize" );
193 int placement = config->
getInt(
"layout",
"defaultWindowPlacement" );
194
195 QRect availRect = desktop->availableGeometry();
196 int width = (size*availRect.width()) / 100;
197 int height = (size*availRect.height()) / 100;
198
200 width = window.frameGeometry().width();
201 height = window.frameGeometry().height();
202
203 int x, y;
204
206 {
207 x = availRect.left();
208 y = availRect.top();
209 }
210
212 {
213 x = availRect.right() -
width;
214 y = availRect.top();
215 }
216
218 {
219 x = availRect.left();
220 y = availRect.bottom() -
height;
221 }
222
224 {
225 x = availRect.right() -
width;
226 y = availRect.bottom() -
height;
227 }
228
229 else
230 {
231 x = availRect.left() + (availRect.width() -
width) / 2;
232 y = availRect.top() + (availRect.height() -
height) / 2;
233 }
234
235
236 window.move( x, y );
237 }
238 window.show();
239
240
242
243
244
245
246 #ifdef CVS_CODE
247 if( config->
getBool (
"misc",
"cvsWarn" ) )
248 {
250 QString("Warning! You are running a potentially unstable (CVS) build of Album Shaper! It is strongly suggested you only use this copy for testing and evaluation purposes. Data loss may occur!"),
251 "alertIcons/warning.png", &window );
252 alert.exec();
253 }
254 #endif
255
256
258 if(config->
getBool(
"misc",
"firstRun" ) )
259 {
261 welcome->show();
263 config->
setBool(
"misc",
"firstRun",
false );
264 }
265
266 return a.exec();
267}
A configurable alert dialog that displays an alert/error message.
Configuration object manages all user-specific application settings.
bool getBool(QString group, QString key)
Fetch bool setting.
void setBool(QString group, QString key, bool val)
Set bool setting.
static bool constructSettingsDirectory()
Constructs any necessary directories for loading and saving user settings, returns false if unsuccess...
int getInt(QString group, QString key)
Fetch int setting.
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget.
Configuration * getConfig()
get setting object
QString XMLCONVERSION_PATH