Skip to content

Commit

Permalink
Use Page Label for Tab Text
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan authored and yorikvanhavre committed Oct 22, 2018
1 parent 8280d55 commit 3ca8eb0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/Mod/TechDraw/Gui/MDIViewPage.cpp
Expand Up @@ -559,13 +559,12 @@ bool MDIViewPage::onHasMsg(const char* pMsg) const
return false;
}


void MDIViewPage::onRelabel(Gui::Document *pDoc)
//called by ViewProvider when Page feature Label changes
void MDIViewPage::setTabText(std::string t)
{
if (!bIsPassive && pDoc) {
QString cap = QString::fromLatin1("%1 : %2[*]")
.arg(QString::fromUtf8(pDoc->getDocument()->Label.getValue()))
.arg(objectName());
if (!isPassive() && !t.empty()) {
QString cap = QString::fromLatin1("%1 [*]")
.arg(QString::fromUtf8(t.c_str()));
setWindowTitle(cap);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Mod/TechDraw/Gui/MDIViewPage.h
Expand Up @@ -72,7 +72,6 @@ class TechDrawGuiExport MDIViewPage : public Gui::MDIView, public Gui::Selection

bool onMsg(const char* pMsg,const char** ppReturn);
bool onHasMsg(const char* pMsg) const;
void onRelabel(Gui::Document *pDoc);

void print();
void print(QPrinter* printer);
Expand All @@ -98,6 +97,9 @@ class TechDrawGuiExport MDIViewPage : public Gui::MDIView, public Gui::Selection

void redrawAllViews(void);
void redraw1View(TechDraw::DrawView* dv);

void setTabText(std::string t);


public Q_SLOTS:
void setRenderer(QAction *action);
Expand Down
9 changes: 7 additions & 2 deletions src/Mod/TechDraw/Gui/ViewProviderPage.cpp
Expand Up @@ -154,8 +154,12 @@ void ViewProviderPage::updateData(const App::Property* prop)
m_mdiView->matchSceneRectToTemplate();
m_mdiView->updateTemplate();
}
} else if (prop == &(getDrawPage()->Label)) {
if(m_mdiView &&
!getDrawPage()->isUnsetting()) {
m_mdiView->setTabText(getDrawPage()->Label.getValue());
}
}

Gui::ViewProviderDocumentObject::updateData(prop);
}

Expand Down Expand Up @@ -214,7 +218,8 @@ bool ViewProviderPage::showMDIViewPage()
Gui::Document* doc = Gui::Application::Instance->getDocument
(pcObject->getDocument());
m_mdiView = new MDIViewPage(this, doc, Gui::getMainWindow());
QString tabTitle = QString::fromUtf8(getDrawPage()->getNameInDocument());
// QString tabTitle = QString::fromUtf8(getDrawPage()->getNameInDocument());
QString tabTitle = QString::fromUtf8(getDrawPage()->Label.getValue());

m_mdiView->setDocumentObject(getDrawPage()->getNameInDocument());
m_mdiView->setDocumentName(pcObject->getDocument()->getName());
Expand Down

0 comments on commit 3ca8eb0

Please sign in to comment.