Gui: fix several regressions caused by PR #12035
* fix hard crash in MainWindow::_updateActions() if no MDI view exists * in MDIView::buildWindowTitle() use the label of the document because this changes when saving it while the name is immutable * fix const correctness in MDIView::buildWindowTitle() * do not set the modified flag of the main window in MDIView::buildWindowTitle() but in the calling instance * move setting the main window title to Application::viewActivated to reduce code duplication * fix missing application name if FreeCADGui is loaded as Python module
This commit is contained in:
@@ -1260,6 +1260,10 @@ void Application::viewActivated(MDIView* pcView)
|
||||
#endif
|
||||
|
||||
signalActivateView(pcView);
|
||||
getMainWindow()->setWindowTitle(pcView->buildWindowTitle());
|
||||
if (auto document = pcView->getGuiDocument()) {
|
||||
getMainWindow()->setWindowModified(document->isModified());
|
||||
}
|
||||
|
||||
// Set the new active document which is taken of the activated view. If, however,
|
||||
// this view is passive we let the currently active document unchanged as we would
|
||||
|
||||
@@ -448,18 +448,11 @@ void MDIView::setCurrentViewMode(ViewMode mode)
|
||||
}
|
||||
}
|
||||
|
||||
QString MDIView::buildWindowTitle()
|
||||
QString MDIView::buildWindowTitle() const
|
||||
{
|
||||
QString windowTitle;
|
||||
if (Gui::Document* document = getGuiDocument()) {
|
||||
if (document->isModified()) {
|
||||
getMainWindow()->setWindowModified(TRUE);
|
||||
}
|
||||
else {
|
||||
getMainWindow()->setWindowModified(FALSE);
|
||||
}
|
||||
|
||||
windowTitle.append(QString::fromUtf8(getAppDocument()->getName()));
|
||||
windowTitle.append(QString::fromStdString(getAppDocument()->Label.getStrValue()));
|
||||
}
|
||||
|
||||
return windowTitle;
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
virtual void viewAll();
|
||||
|
||||
/// build window title
|
||||
QString buildWindowTitle();
|
||||
QString buildWindowTitle() const;
|
||||
|
||||
/// Message handler
|
||||
bool onMsg(const char* pMsg,const char** ppReturn) override;
|
||||
|
||||
@@ -1268,9 +1268,8 @@ void MainWindow::removeWindow(Gui::MDIView* view, bool close)
|
||||
|
||||
void MainWindow::tabChanged(MDIView* view)
|
||||
{
|
||||
Q_UNUSED(view);
|
||||
Q_UNUSED(view)
|
||||
updateActions();
|
||||
getMainWindow()->setWindowTitle(view->buildWindowTitle());
|
||||
}
|
||||
|
||||
void MainWindow::tabCloseRequested(int index)
|
||||
@@ -1665,8 +1664,15 @@ void MainWindow::_updateActions()
|
||||
d->activityTimer->stop();
|
||||
Application::Instance->commandManager().testActive();
|
||||
}
|
||||
|
||||
d->actionUpdateDelay = 0;
|
||||
getMainWindow()->setWindowTitle(activeWindow()->buildWindowTitle());
|
||||
|
||||
if (auto view = activeWindow()) {
|
||||
setWindowTitle(view->buildWindowTitle());
|
||||
if (auto document = view->getGuiDocument()) {
|
||||
setWindowModified(document->isModified());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateEditorActions()
|
||||
@@ -2370,7 +2376,6 @@ void MainWindow::changeEvent(QEvent *e)
|
||||
d->activeView = view;
|
||||
Application::Instance->viewActivated(view);
|
||||
}
|
||||
getMainWindow()->setWindowTitle(view->buildWindowTitle());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2515,8 +2520,10 @@ QMdiArea *MainWindow::getMdiArea() const
|
||||
void MainWindow::setWindowTitle(const QString& string)
|
||||
{
|
||||
QString title;
|
||||
QString appname =
|
||||
QString(static_cast<QApplication*>(QCoreApplication::instance())->applicationName());
|
||||
QString appname = QCoreApplication::applicationName();
|
||||
if (appname.isEmpty()) {
|
||||
appname = QString::fromLatin1(App::Application::Config()["ExeName"].c_str());
|
||||
}
|
||||
|
||||
// allow to disable version number
|
||||
ParameterGrp::handle hGen = +App::GetApplication().GetParameterGroupByPath(
|
||||
|
||||
Reference in New Issue
Block a user