forked from qt-creator/qt-creator
NavigationWidget: Avoid using sender()
Change-Id: I6fd8935a9394f0b6ac3c435535f32796b26346d2 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -335,10 +335,16 @@ Internal::NavigationSubWidget *NavigationWidget::insertSubItem(int position, int
|
|||||||
d->m_subWidgets.at(0)->setCloseIcon(Utils::Icons::CLOSE_SPLIT_BOTTOM.icon());
|
d->m_subWidgets.at(0)->setCloseIcon(Utils::Icons::CLOSE_SPLIT_BOTTOM.icon());
|
||||||
|
|
||||||
auto nsw = new Internal::NavigationSubWidget(this, position, factoryIndex);
|
auto nsw = new Internal::NavigationSubWidget(this, position, factoryIndex);
|
||||||
connect(nsw, &Internal::NavigationSubWidget::splitMe, this, &NavigationWidget::splitSubWidget);
|
connect(nsw, &Internal::NavigationSubWidget::splitMe, this, [this, nsw](int factoryIndex) {
|
||||||
connect(nsw, &Internal::NavigationSubWidget::closeMe, this, &NavigationWidget::closeSubWidget);
|
insertSubItem(indexOf(nsw) + 1, factoryIndex);
|
||||||
connect(nsw, &Internal::NavigationSubWidget::factoryIndexChanged,
|
});
|
||||||
this, &NavigationWidget::onSubWidgetFactoryIndexChanged);
|
connect(nsw, &Internal::NavigationSubWidget::closeMe, this, [this, nsw] {
|
||||||
|
closeSubWidget(nsw);
|
||||||
|
});
|
||||||
|
connect(nsw, &Internal::NavigationSubWidget::factoryIndexChanged, this, [this, nsw] {
|
||||||
|
const Id factoryId = nsw->factory()->id();
|
||||||
|
NavigationWidgetPrivate::updateActivationsMap(factoryId, {d->m_side, nsw->position()});
|
||||||
|
});
|
||||||
insertWidget(position, nsw);
|
insertWidget(position, nsw);
|
||||||
|
|
||||||
d->m_subWidgets.insert(position, nsw);
|
d->m_subWidgets.insert(position, nsw);
|
||||||
@@ -371,17 +377,9 @@ QWidget *NavigationWidget::activateSubWidget(Id factoryId, int preferredPosition
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::splitSubWidget(int factoryIndex)
|
void NavigationWidget::closeSubWidget(Internal::NavigationSubWidget *subWidget)
|
||||||
{
|
|
||||||
auto original = qobject_cast<Internal::NavigationSubWidget *>(sender());
|
|
||||||
int pos = indexOf(original) + 1;
|
|
||||||
insertSubItem(pos, factoryIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NavigationWidget::closeSubWidget()
|
|
||||||
{
|
{
|
||||||
if (d->m_subWidgets.count() != 1) {
|
if (d->m_subWidgets.count() != 1) {
|
||||||
auto subWidget = qobject_cast<Internal::NavigationSubWidget *>(sender());
|
|
||||||
subWidget->saveSettings();
|
subWidget->saveSettings();
|
||||||
|
|
||||||
int position = d->m_subWidgets.indexOf(subWidget);
|
int position = d->m_subWidgets.indexOf(subWidget);
|
||||||
@@ -553,15 +551,6 @@ QString NavigationWidget::settingsKey(const QString &key) const
|
|||||||
return QStringLiteral("%1/%2").arg(settingsGroup(), key);
|
return QStringLiteral("%1/%2").arg(settingsGroup(), key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::onSubWidgetFactoryIndexChanged(int factoryIndex)
|
|
||||||
{
|
|
||||||
Q_UNUSED(factoryIndex)
|
|
||||||
auto subWidget = qobject_cast<Internal::NavigationSubWidget *>(sender());
|
|
||||||
QTC_ASSERT(subWidget, return);
|
|
||||||
Id factoryId = subWidget->factory()->id();
|
|
||||||
NavigationWidgetPrivate::updateActivationsMap(factoryId, {d->m_side, subWidget->position()});
|
|
||||||
}
|
|
||||||
|
|
||||||
QHash<Id, Command *> NavigationWidget::commandMap() const
|
QHash<Id, Command *> NavigationWidget::commandMap() const
|
||||||
{
|
{
|
||||||
return d->m_commandMap;
|
return d->m_commandMap;
|
||||||
|
|||||||
@@ -116,13 +116,11 @@ protected:
|
|||||||
void resizeEvent(QResizeEvent *) override;
|
void resizeEvent(QResizeEvent *) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void splitSubWidget(int factoryIndex);
|
void closeSubWidget(Internal::NavigationSubWidget *subWidget);
|
||||||
void closeSubWidget();
|
|
||||||
void updateToggleText();
|
void updateToggleText();
|
||||||
Internal::NavigationSubWidget *insertSubItem(int position, int factoryIndex);
|
Internal::NavigationSubWidget *insertSubItem(int position, int factoryIndex);
|
||||||
int factoryIndex(Utils::Id id);
|
int factoryIndex(Utils::Id id);
|
||||||
QString settingsKey(const QString &key) const;
|
QString settingsKey(const QString &key) const;
|
||||||
void onSubWidgetFactoryIndexChanged(int factoryIndex);
|
|
||||||
|
|
||||||
NavigationWidgetPrivate *d;
|
NavigationWidgetPrivate *d;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user