QTfrontend/main.cpp.in
changeset 148 c0355acf07c8
parent 146 458f4f58c1b6
child 187 96c3154efee5
equal deleted inserted replaced
147:52a3c431db8a 148:c0355acf07c8
    42 
    42 
    43 QDir * bindir;
    43 QDir * bindir;
    44 QDir * cfgdir;
    44 QDir * cfgdir;
    45 QDir * datadir;
    45 QDir * datadir;
    46 
    46 
       
    47 bool checkForDir(const QString & dir)
       
    48 {
       
    49 	QDir tmpdir;
       
    50 	if (!tmpdir.exists(dir))
       
    51 		if (!tmpdir.mkdir(dir))
       
    52 		{
       
    53 			QMessageBox::critical(0,
       
    54 					QObject::tr("Error"),
       
    55 					QObject::tr("Cannot create directory %1").arg(dir),
       
    56 					QObject::tr("OK"));
       
    57 			return false;
       
    58 		}
       
    59 	return true;
       
    60 }
       
    61 
    47 int main(int argc, char *argv[])
    62 int main(int argc, char *argv[])
    48 {
    63 {
    49 	QApplication app(argc, argv);
    64 	QApplication app(argc, argv);
    50 
    65 
    51 	QDateTime now = QDateTime::currentDateTime();
    66 	QDateTime now = QDateTime::currentDateTime();
    58 	Translator.load(":/translations/hedgewars_" + QLocale::system().name());
    73 	Translator.load(":/translations/hedgewars_" + QLocale::system().name());
    59 	app.installTranslator(&Translator);
    74 	app.installTranslator(&Translator);
    60 
    75 
    61 	QDir mydir("${HEDGEWARS_BINDIR}");
    76 	QDir mydir("${HEDGEWARS_BINDIR}");
    62 	mydir.cd("bin");
    77 	mydir.cd("bin");
    63 	
    78 
    64 	bindir = new QDir(mydir);
    79 	bindir = new QDir(mydir);
    65 	cfgdir = new QDir();
    80 	cfgdir = new QDir();
    66 
    81 
    67 	cfgdir->setPath(cfgdir->homePath());
    82 	cfgdir->setPath(cfgdir->homePath());
    68 	if (!cfgdir->exists(".hedgewars"))
    83 	if (checkForDir(cfgdir->absolutePath() + "/.hedgewars"))
    69 	{
    84 	{
    70 		if (!cfgdir->mkdir(".hedgewars"))
    85 		checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos");
    71 		{
       
    72 			QMessageBox::critical(0,
       
    73 					QObject::tr("Error"),
       
    74 					QObject::tr("Cannot create directory %1").arg("/.hedgewars"),
       
    75 					QObject::tr("Quit"));
       
    76 		}
       
    77 	}
    86 	}
    78 	cfgdir->cd(".hedgewars");
    87 	cfgdir->cd(".hedgewars");
    79 
    88 
    80 	datadir = new QDir(mydir);
    89 	datadir = new QDir(mydir);
    81 	datadir->cd("../share/hedgewars/Data");
    90 	datadir->cd("../share/hedgewars/Data");