diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index e2081e98e46a38d5995e1140214e8b2536694f4e..f38ca9b284592896e58e98e389fb5eaa24db8856 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -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); diff --git a/src/ui/designer/QGCToolWidget.cc b/src/ui/designer/QGCToolWidget.cc index 6610e03d509c9219eac0182084de3df48205e05f..f394ca1ffaef05873c66234af97c371fa1ccfa49 100644 --- a/src/ui/designer/QGCToolWidget.cc +++ b/src/ui/designer/QGCToolWidget.cc @@ -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); diff --git a/src/ui/menuactionhelper.cpp b/src/ui/menuactionhelper.cpp index a9b3a8d766adade0551a099972b3400889fee488..459ebaade3b6604c54b8ad7aff3d0ac89f44f867 100644 --- a/src/ui/menuactionhelper.cpp +++ b/src/ui/menuactionhelper.cpp @@ -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 >::iterator it; - for (it = m_centralWidgetToDockWidgetsMap.begin(); it != m_centralWidgetToDockWidgetsMap.end(); ++it) { - QMap &map = it.value(); - map[newObjectName] = map[oldObjectName]; - map.remove(oldObjectName); - }*/ } } else if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease) {