Commit 5e2c369a authored by Stefan Brüns's avatar Stefan Brüns
Browse files

Dont open a MessageBox when a file fails to load from the library

As the filemanager is also used from non-interactive contexts, a message
box is a no-go.

Interactive applications can connect to the fileError signal. This is
done for both marble-qt and marble-kde.

BUG: 416925
CCBUG: 420089
parent 29e13621
......@@ -53,6 +53,7 @@
#include "BookmarkManagerDialog.h"
#include "CurrentLocationWidget.h"
#include "DownloadRegionDialog.h"
#include "FileManager.h"
#include "GeoDataCoordinates.h"
#include "GeoDataFolder.h"
#include "GeoDataLatLonAltBox.h"
......@@ -167,6 +168,13 @@ MarblePart::MarblePart( QWidget *parentWidget, QObject *parent, const QVariantLi
m_statusBarExtension = new KParts::StatusBarExtension( this );
m_statusBarExtension->statusBar()->setUpdatesEnabled( false );
connect(m_controlView->marbleModel()->fileManager(), &FileManager::fileError, this,
[this](const QString& path, const QString& error) {
KMessageBox::error( widget(),
i18n( "Sorry, unable to open '%1':\n'%2'", path, error),
i18n( "File not readable" ) );
});
// Load bookmark file. If it does not exist, a default one will be used.
m_controlView->marbleModel()->bookmarkManager()->loadFile( "bookmarks/bookmarks.kml" );
......
......@@ -54,6 +54,7 @@
#include "AbstractFloatItem.h"
#include "MarbleModel.h"
#include "MarbleClock.h"
#include "FileManager.h"
#include "HttpDownloadManager.h"
#include "BookmarkManager.h"
#include "NewBookmarkFolderDialog.h"
......@@ -194,6 +195,13 @@ MainWindow::MainWindow(const QString& marbleDataPath, const QVariantMap& cmdLine
connect(m_configDialog, SIGNAL(syncNowClicked()),
m_configDialog, SLOT(disableSyncNow()));
connect(m_controlView->marbleModel()->fileManager(), &FileManager::fileError, this,
[this](const QString& path, const QString& error) {
QMessageBox::warning(this, tr("Marble"), // krazy:exclude=qclasses
tr("Sorry, unable to open '%1':\n'%2'").arg(path).arg(error),
QMessageBox::Ok);
});
// Load bookmark file. If it does not exist, a default one will be used.
m_controlView->marbleModel()->bookmarkManager()->loadFile( "bookmarks/bookmarks.kml" );
......
......@@ -13,7 +13,6 @@
#include <QFileInfo>
#include <QElapsedTimer>
#include <QMessageBox>
#include "FileLoader.h"
#include "MarbleDebug.h"
......@@ -187,11 +186,6 @@ void FileManagerPrivate::cleanupLoader( FileLoader* loader )
}
}
if ( !loader->error().isEmpty() ) {
QMessageBox errorBox;
errorBox.setWindowTitle( QObject::tr("File Parsing Error"));
errorBox.setText( loader->error() );
errorBox.setIcon( QMessageBox::Warning );
errorBox.exec();
qWarning() << "Failed to parse" << loader->path() << loader->error();
emit q->fileError(loader->path(), loader->error());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment