Commit f6ae5ed8 authored by John Tapsell's avatar John Tapsell

Make sure that our custom widget doesn't reuse an object name

parent a6a5a65b
......@@ -860,8 +860,16 @@ void MainWindow::createCustomWidget()
// This is the first widget
ui.menuTools->addSeparator();
}
QString title = "Unnamed Tool " + QString::number(ui.menuTools->actions().size());
QString objectName = "UNNAMED_TOOL_" + QString::number(ui.menuTools->actions().size())+"DOCK";
QString objectName;
int customToolIndex = 0;
//Find the next unique object name that we can use
do {
++customToolIndex;
objectName = QString("CUSTOM_TOOL_%1").arg(customToolIndex) + "DOCK";
} while(QGCToolWidget::instances()->contains(objectName));
QString title = tr("Custom Tool %1").arg(customToolIndex );
QGCToolWidget* tool = new QGCToolWidget(objectName, title);
createDockWidget(centerStack->currentWidget(),tool,title,objectName,currentView,Qt::BottomDockWidgetArea);
......
......@@ -27,12 +27,6 @@ QGCToolWidget::QGCToolWidget(const QString& objectName, const QString& title, QW
ui->setupUi(this);
if (settings) loadSettings(*settings);
if (title == "Unnamed Tool")
{
widgetTitle = QString("%1 %2").arg(title).arg(QGCToolWidget::instances()->count());
}
//qDebug() << "WidgetTitle" << widgetTitle;
createActions();
toolLayout = ui->toolLayout;
toolLayout->setAlignment(Qt::AlignTop);
......
......@@ -165,15 +165,6 @@ bool MenuActionHelper::eventFilter(QObject *object,QEvent *event)
if(action)
action->setText(dock->windowTitle());
//Now modify the object name - it is a strange naming scheme..
/* QString newObjectName = widgetTitle+"DOCK";
dock->setObjectName(newObjectName);
m_menuToDockNameMap[action] = newObjectName;
QMap<MainWindow::VIEW_SECTIONS,QMap<QString,QDockWidget*> >::iterator it;
for (it = m_centralWidgetToDockWidgetsMap.begin(); it != m_centralWidgetToDockWidgetsMap.end(); ++it) {
QMap<QString,QDockWidget*> &map = it.value();
map[newObjectName] = map[oldObjectName];
map.remove(oldObjectName);
}*/
}
} else if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment