bool Brewtarget::ensureDirectoriesExist() { bool success; QDir dir; QString errTitle(QObject::tr("Directory Problem")); QString errText(QObject::tr("\"%1\" cannot be read.")); // Check data dir dir.setPath(getDataDir()); if( ! dir.exists() || ! dir.isReadable() ) { QMessageBox::information( 0, errTitle, errText.arg(dir.path()) ); return false; } // Check doc dir dir.setPath(getDocDir()); if( ! dir.exists() || ! dir.isReadable() ) { QMessageBox::information( 0, errTitle, errText.arg(dir.path()) ); return false; } // Check config dir dir.setPath(getConfigDir(&success)); if( !success || ! dir.exists() || ! dir.isReadable() ) { QMessageBox::information( 0, errTitle, errText.arg(dir.path()) ); return false; } // Check/create user data directory dir.setPath(getUserDataDir()); if( !dir.exists() && !dir.mkpath(".") ) { QMessageBox::information( 0, errTitle, errText.arg(dir.path()) ); return false; } return true; }
bool CommonData::checkIni() { bool ret = true; if (ret) ret = this->checkFileExists(getBinDir()); if (!ret) { qFatal("Bin Dir not found"); exit(INIFILE_WRONG); //questo errore e' fatale } if (ret) ret = this->checkFileExists(getImgDir()); if (!ret) { qFatal("Img Dir not found"); exit(INIFILE_WRONG); //questo errore e' fatale } if (ret) ret = this->checkFileExists(getDocDir()); if (!ret) { qFatal("Doc Dir not found"); exit(INIFILE_WRONG); //questo errore e' fatale } if (ret) ret = this->checkFileExists(getReportDir()); if (!ret) { qFatal("Reports Dir not found"); exit(INIFILE_WRONG); //questo errore e' fatale } if (ret) ret = this->checkFileExists(getQrDir()); if (ret) ret = this->checkFileExists(getBiblioDir()); if (ret) ret = this->checkFileExists(getHtmlDir()); if (ret) ret = this->checkFileExists(getBlocknotesDir()); if (ret) ret = this->checkFileExists(getTexDir()); if (ret) ret = this->checkFileExists(getCollezione()); if (ret) ret = this->checkFileExists(getContenitori()); if (ret) ret = this->checkFileExists(getContatti()); if (ret) ret = this->checkFileExists(getBiblioteca()); if (ret) ret = this->checkFileExists(getLinks()); if (ret) ret = this->checkFileExists(getBackupDir()); return ret; }
void MainWindow::help() { QDialog *h = new QDialog(this, 0); QString path, uri; Ui::Help ui; ui.setupUi(h); path = QString("file://"); #ifdef WIN32 path += "/"; #endif path += getDocDir() + "/"; #ifdef WIN32 path = path.replace("\\","/"); #endif uri = path + "xca.html"; ui.textbox->setSource(QUrl(uri)); ui.textbox->setSearchPaths(QStringList(path)); h->setWindowTitle(tr(XCA_TITLE)); h->show(); }