Added DockWidget::isInMainWindow()

For task #69.
A signal would be nice too, though.
This commit is contained in:
Sergio Martins
2020-09-07 15:27:54 +01:00
parent 03e58c7443
commit b510c2fd5f
3 changed files with 43 additions and 0 deletions

View File

@@ -77,6 +77,20 @@ public:
return qobject_cast<FloatingWindow*>(q->window());
}
MainWindowBase *mainWindow() const
{
// Note: Don't simply use window(), as the MainWindow might be embedded into something else
QObject *p = q->parent();
while (p) {
if (auto window = qobject_cast<MainWindowBase*>(p))
return window;
p = p->parent();
}
return nullptr;
}
QPoint defaultCenterPosForFloating();
void updateTitle();
@@ -430,6 +444,11 @@ bool DockWidgetBase::isMainWindow() const
return qobject_cast<MainWindowBase*>(widget());
}
bool DockWidgetBase::isInMainWindow() const
{
return d->mainWindow() != nullptr;
}
bool DockWidgetBase::isFocused() const
{
auto f = this->frame();