diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 4f218d5b0..9d3d4efd4 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -997,12 +997,15 @@ MainWindow::importPerspective() // import and select it pactive = true; - current->importPerspective(fileName); - current->setPerspectives(perspectiveSelector); + if (current->importPerspective(fileName)) { - // and select remember pactive is true, so we do the heavy lifting here - perspectiveSelector->setCurrentIndex(current->perspectives_.count()-1); - current->perspectiveSelected(perspectiveSelector->currentIndex()); + // on success we select the new one + current->setPerspectives(perspectiveSelector); + + // and select remember pactive is true, so we do the heavy lifting here + perspectiveSelector->setCurrentIndex(current->perspectives_.count()-1); + current->perspectiveSelected(perspectiveSelector->currentIndex()); + } pactive = false; } diff --git a/src/Gui/Perspective.cpp b/src/Gui/Perspective.cpp index bb023e629..d99716260 100644 --- a/src/Gui/Perspective.cpp +++ b/src/Gui/Perspective.cpp @@ -1443,11 +1443,15 @@ Perspective *Perspective::fromFile(Context *context, QString filename, int type) // none loaded ? if (handler.perspectives.count() == 0) return returning; - // return the first one (if there are multiple) - returning = handler.perspectives[0]; + // return the first one with the right type (if there are multiple) + for(int i=0; itype == type) + returning = handler.perspectives[i]; // delete any further perspectives - for(int i=1; i\n"; + out<<"\n"; // iterate over charts foreach (GcChartWindow *chart, charts) { diff --git a/src/Gui/PerspectiveDialog.cpp b/src/Gui/PerspectiveDialog.cpp index e039de2db..1c0077945 100644 --- a/src/Gui/PerspectiveDialog.cpp +++ b/src/Gui/PerspectiveDialog.cpp @@ -268,13 +268,14 @@ PerspectiveDialog::importPerspectiveClicked() } else { // import and select it - tabView->importPerspective(fileName); + if (tabView->importPerspective(fileName)) { - // update the table - setTables(); + // update the table + setTables(); - // new one added - emit perspectivesChanged(); + // new one added + emit perspectivesChanged(); + } } } diff --git a/src/Gui/TabView.cpp b/src/Gui/TabView.cpp index d320b6b22..24221a349 100644 --- a/src/Gui/TabView.cpp +++ b/src/Gui/TabView.cpp @@ -441,11 +441,18 @@ TabView::appendPerspective(Perspective *page) page->configChanged(0); // set colors correctly- will have missed from startup } -void +bool TabView::importPerspective(QString filename) { Perspective *newone = Perspective::fromFile(context, filename, type); - if (newone) appendPerspective(newone); + if (newone) { + appendPerspective(newone); + return true; + } else { + // no valid perspective found for this view... (maybe its for another type of view) + QMessageBox::information(this, tr("Perspective Import"), tr("No perspectives found that are appropriate for the current view.")); + return false; + } } void @@ -907,6 +914,7 @@ bool ViewParser::startElement( const QString&, const QString&, const QString &na if (name == "layout") { QString name="General"; + int typetouse=type; for(int i=0; iproperties, bool select) { perspective_->importChart(properties, select); } - void importPerspective(QString filename); + bool importPerspective(QString filename); void exportPerspective(Perspective *, QString filename); signals: