Add custom properties to ToolWindowManager toolwindows, update titles

* Two properties added - DisallowUserDocking which completely prevents
  a toolwindow from being dragged or docked other than programmatically.
* HideCloseButton also hides the close button that normally appears on
  the tabs created
* Also tabs now watch for title change signals and update the titles in
  tabs.
This commit is contained in:
baldurk
2015-07-10 16:38:44 +02:00
parent 227e6feddd
commit 4627ead8f2
4 changed files with 71 additions and 0 deletions
@@ -53,6 +53,9 @@ void ToolWindowManagerArea::addToolWindows(const QList<QWidget *> &toolWindows)
int index = 0;
foreach(QWidget* toolWindow, toolWindows) {
index = addTab(toolWindow, toolWindow->windowIcon(), toolWindow->windowTitle());
if(m_manager->toolWindowProperties(toolWindow) & ToolWindowManager::HideCloseButton) {
tabBar()->tabButton(index, QTabBar::RightSide)->resize(0, 0);
}
}
setCurrentIndex(index);
m_manager->m_lastUsedArea = this;
@@ -66,6 +69,18 @@ QList<QWidget *> ToolWindowManagerArea::toolWindows() {
return result;
}
void ToolWindowManagerArea::updateToolWindow(QWidget* toolWindow) {
int index = indexOf(toolWindow);
if(index >= 0) {
if(m_manager->toolWindowProperties(toolWindow) & ToolWindowManager::HideCloseButton) {
tabBar()->tabButton(index, QTabBar::RightSide)->resize(0, 0);
} else {
tabBar()->tabButton(index, QTabBar::RightSide)->resize(16, 16);
}
tabBar()->setTabText(index, toolWindow->windowTitle());
}
}
void ToolWindowManagerArea::mousePressEvent(QMouseEvent *) {
if (qApp->mouseButtons() == Qt::LeftButton) {
m_dragCanStart = true;