Beispiel #1
0
bool MainWindowList::openFile (const File& file)
{
    for (int i = windows.size(); --i >= 0;)
    {
        MainWindow* const w = windows.getUnchecked(i);

        if (w->getProject() != nullptr && w->getProject()->getFile() == file)
        {
            w->toFront (true);
            return true;
        }
    }

    if (file.hasFileExtension (Project::projectFileExtension))
    {
        MainWindow* const w = getOrCreateEmptyWindow();
        bool ok = w->openFile (file);

        w->makeVisible();
        avoidSuperimposedWindows (w);

        return ok;
    }

    if (file.exists())
        return getFrontmostWindow()->openFile (file);

    return false;
}
Beispiel #2
0
bool MainWindowList::openFile (const File& file, bool openInBackground)
{
    for (auto* w : windows)
    {
        if (w->getProject() != nullptr && w->getProject()->getFile() == file)
        {
            w->toFront (true);
            return true;
        }
    }

    if (file.hasFileExtension (Project::projectFileExtension))
    {
        WeakReference<Component> previousFrontWindow (getFrontmostWindow());

        auto* w = getOrCreateEmptyWindow();
        bool ok = w->openFile (file);

        if (ok)
        {
            w->makeVisible();
            avoidSuperimposedWindows (w);
        }
        else
        {
            closeWindow (w);
        }

        if (openInBackground && previousFrontWindow != nullptr)
            previousFrontWindow->toFront (true);

        return ok;
    }

    if (getFrontmostWindow()->tryToOpenPIP (file))
        return true;

    if (! isPIPFile (file) && file.exists())
        return getFrontmostWindow()->openFile (file);

    return false;
}
Beispiel #3
0
void MainWindowList::openDocument (OpenDocumentManager::Document* doc, bool grabFocus)
{
    Desktop& desktop = Desktop::getInstance();

    for (int i = desktop.getNumComponents(); --i >= 0;)
    {
        if (MainWindow* const mw = dynamic_cast<MainWindow*> (desktop.getComponent(i)))
        {
            if (ProjectContentComponent* pcc = mw->getProjectContentComponent())
            {
                if (pcc->hasFileInRecentList (doc->getFile()))
                {
                    mw->toFront (true);
                    mw->getProjectContentComponent()->showDocument (doc, grabFocus);
                    return;
                }
            }
        }
    }

    getFrontmostWindow()->getProjectContentComponent()->showDocument (doc, grabFocus);
}