Skip to content

Commit

Permalink
Refs #8942 - Fix link.
Browse files Browse the repository at this point in the history
* Use QUrl::fromLocalFile to construct QUrl.
* Add error logging.
  • Loading branch information
PeterParker authored and Harry Jeffery committed Aug 22, 2014
1 parent 3fa9249 commit a92d0ac
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Code/Mantid/MantidQt/API/src/ScriptRepositoryView.cpp
Expand Up @@ -520,8 +520,26 @@ bool ScriptRepositoryView::RemoveEntryDelegate::editorEvent(QEvent *event,
}
}

/**
* Attempt to open the given folder link using an appropriate application.
*
* @param link :: the folder link to open.
*/
void ScriptRepositoryView::openFolderLink(QString link){
QDesktopServices::openUrl(QUrl(link));
const std::string error_msg = "Unable to open \"" + link.toStdString() + "\". Reason: ";

// QUrl::fromLocalFile seems to be the most robust way of constructing QUrls on
// the local file system for all platforms.
const QUrl url = QUrl::fromLocalFile(link);
if( !url.isValid() )
{
g_log.error() << error_msg << "Invalid (malformed) URL." << std::endl;
return;
}

const bool openSuccessful = QDesktopServices::openUrl(url);
if( !openSuccessful )
g_log.error() << error_msg << "Could not find directory." << std::endl;
}

} // namespace API
Expand Down

0 comments on commit a92d0ac

Please sign in to comment.