Qt: Create directories if they should be opened

In the about dialog, create directories within the folders tab
if the user wants them to open and they do not exist yet

Change-Id: Ia95692dabef92392714c329c868abc78e3bcec6e
Reviewed-on: https://code.wireshark.org/review/29782
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
Roland Knall 2018-09-21 15:43:29 +02:00 committed by Roland Knall
parent 5507d1b344
commit 70e340aaaf
1 changed files with 15 additions and 2 deletions

View File

@ -61,6 +61,7 @@
#include <QClipboard>
#include <QMenu>
#include <QFileInfo>
#include <QMessageBox>
AuthorListModel::AuthorListModel(QObject * parent) :
AStringListListModel(parent)
@ -455,8 +456,20 @@ void AboutDialog::urlDoubleClicked(const QModelIndex &idx)
if ( urlText.isEmpty() )
return;
QFileInfo fi (urlText);
if ( fi.isDir() && fi.exists() )
if ( ! QDir(urlText).exists() )
{
if ( QMessageBox::question(this, tr("The directory does not exist"),
QString(tr("Should the directory %1 be created?").arg(urlText)) ) == QMessageBox::Yes )
{
if ( ! QDir().mkdir(urlText) )
{
QMessageBox::warning(this, tr("The directory could not be created"),
QString(tr("The directory %1 could not be created!").arg(urlText)));
}
}
}
if ( QDir(urlText).exists() )
{
QUrl url = QUrl::fromLocalFile(urlText);
if ( url.isValid() )