Allow configuring a callback to create tool windows on-demand

* This means we can start with an empty manager, load a layout, and just
  create the needed windows as we go according to what the layout needs.
This commit is contained in:
baldurk
2016-10-07 15:53:16 +02:00
parent f8b7f0ca87
commit e64c666883
3 changed files with 27 additions and 0 deletions
@@ -66,6 +66,7 @@ ToolWindowManager::ToolWindowManager(QWidget *parent) :
m_dropSuggestionSwitchTimer.setInterval(1000);
m_dropCurrentSuggestionIndex = 0;
m_allowFloatingWindow = true;
m_createCallback = NULL;
m_rectRubberBand = new QRubberBand(QRubberBand::Rectangle, this);
m_lineRubberBand = new QRubberBand(QRubberBand::Line, this);
@@ -271,6 +272,21 @@ void ToolWindowManager::removeToolWindow(QWidget *toolWindow) {
m_toolWindowProperties.remove(toolWindow);
}
QWidget* ToolWindowManager::createToolWindow(const QString& objectName)
{
if (m_createCallback) {
QWidget *toolWindow = m_createCallback(objectName);
if(toolWindow) {
m_toolWindows << toolWindow;
m_toolWindowProperties[toolWindow] = ToolWindowProperty(0);
QObject::connect(toolWindow, &QWidget::windowTitleChanged, this, &ToolWindowManager::windowTitleChanged);
return toolWindow;
}
}
return NULL;
}
void ToolWindowManager::setSuggestionSwitchInterval(int msec) {
m_dropSuggestionSwitchTimer.setInterval(msec);
}