void GPlainTextLogger::ChooseFolder(QString folderPath /*= ""*/) { if(folderPath.isEmpty()) { QFileDialog* pDialog = new QFileDialog(0, "Select folder", m_FolderPath); pDialog->setFileMode(QFileDialog::Directory); pDialog->setOption(QFileDialog::ShowDirsOnly); pDialog->show(); pDialog->setAttribute(Qt::WA_DeleteOnClose); connect(pDialog, SIGNAL(fileSelected(QString)), this, SLOT(ChooseFolder(QString))); return; } QDir theFolder(folderPath); // if the folder doesn't exists, offer to create it if(!theFolder.exists()) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Question); QString strMess("The folder %1 doesn't exist."); strMess = strMess.arg(folderPath); msgBox.setText(strMess); msgBox.setInformativeText("Do you want to create it?"); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Yes); int ret = msgBox.exec(); if(ret == QMessageBox::Yes) { theFolder.mkpath(folderPath); } } if(folderPath != m_FolderPath) if(theFolder.exists()) m_FolderPath = folderPath; }
void XWinProcessLauncher::SetDefaultDirectory(const VString &inDirectory) { delete [] fCurrentDirectory; fCurrentDirectory = NULL; if(!inDirectory.IsEmpty()) { VFolder theFolder(inDirectory); VString currentDirectoryPath = theFolder.GetPath().GetPath(); fCurrentDirectory = _CreateCString(currentDirectoryPath, true); } }