Browse Source

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

QGC4.4
John Tapsell 12 years ago
parent
commit
f6ae5ed8fc
  1. 12
      src/ui/MainWindow.cc
  2. 6
      src/ui/designer/QGCToolWidget.cc
  3. 9
      src/ui/menuactionhelper.cpp

12
src/ui/MainWindow.cc

@ -860,8 +860,16 @@ void MainWindow::createCustomWidget() @@ -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);

6
src/ui/designer/QGCToolWidget.cc

@ -27,12 +27,6 @@ QGCToolWidget::QGCToolWidget(const QString& objectName, const QString& title, QW @@ -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);

9
src/ui/menuactionhelper.cpp

@ -165,15 +165,6 @@ bool MenuActionHelper::eventFilter(QObject *object,QEvent *event) @@ -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)
{

Loading…
Cancel
Save