示例#1
0
Shell::Pointer Window::GetModalChild(const QList<Shell::Pointer>& toSearch)
{
  int modal = Constants::APPLICATION_MODAL | Constants::SYSTEM_MODAL | Constants::PRIMARY_MODAL;

  int size = toSearch.size();
  for (int i = size - 1; i < size; i--)
  {
    Shell::Pointer shell = toSearch[i];

    // Check if this shell has a modal child
    QList<Shell::Pointer> children = shell->GetShells();
    Shell::Pointer modalChild = GetModalChild(children);
    if (modalChild != 0)
    {
      return modalChild;
    }

    // If not, check if this shell is modal itself
    if (shell->IsVisible() && (shell->GetStyle() & modal) != 0)
    {
      return shell;
    }
  }

  return Shell::Pointer(nullptr);
}
示例#2
0
Shell::Pointer Window::DefaultModalParent::GetShell() const
{
  Shell::Pointer parent = Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetActiveShell();

  // Make sure we don't pick a parent that has a modal child (this can lock the app)
  if (parent == 0)
  {
    // If this is a top-level window, then there must not be any open modal windows.
    parent = Window::GetModalChild(Tweaklets::Get(GuiWidgetsTweaklet::KEY)->GetShells());
  }
  else
  {
    // If we picked a parent with a modal child, use the modal child instead
    Shell::Pointer modalChild = Window::GetModalChild(parent->GetShells());
    if (modalChild != 0)
    {
      parent = modalChild;
    }
  }

  return parent;
}