FileBrowserDialog *FileBrowserManager::openOrActivateDialog(const Account &account, const ServerRepo &repo, const QString &path)
{
    FileBrowserDialog *dialog = getDialog(account, repo.id);
    QString fixed_path = path;
    if (!fixed_path.startsWith("/")) {
        fixed_path = "/" + fixed_path;
    }
    if (!fixed_path.endsWith("/")) {
        fixed_path += "/";
    }
    if (dialog == NULL) {
        dialog = new FileBrowserDialog(account, repo, fixed_path);
        QRect screen = QApplication::desktop()->screenGeometry();
        dialog->setAttribute(Qt::WA_DeleteOnClose, true);
        dialog->show();
        dialog->move(screen.center() - dialog->rect().center());
        dialogs_.push_back(dialog);
        connect(dialog, SIGNAL(aboutToClose()), this, SLOT(onAboutToClose()));
    } else if (!path.isEmpty()) {
        dialog->enterPath(fixed_path);
    }
    dialog->raise();
    dialog->activateWindow();
    return dialog;
}
Ejemplo n.º 2
0
void RepoTreeView::onItemDoubleClicked(const QModelIndex& index)
{
    QStandardItem *item = getRepoItem(index);
    if (!item) {
        return;
    }
    if (item->type() == REPO_ITEM_TYPE) {
        RepoItem *it = (RepoItem *)item;
        const LocalRepo& local_repo = it->localRepo();
        if (local_repo.isValid()) {
            // open local folder for downloaded repo
            QDesktopServices::openUrl(QUrl::fromLocalFile(local_repo.worktree));
        } else {
            // open seahub repo page for not downloaded repo
            // if (seafApplet->isPro()) {
            FileBrowserDialog* dialog = new FileBrowserDialog(it->repo(), this);
            const QRect screen = QApplication::desktop()->screenGeometry();
            dialog->setAttribute(Qt::WA_DeleteOnClose, true);
            dialog->show();
            dialog->move(screen.center() - dialog->rect().center());
            dialog->raise();
            // } else {
            //     const Account& account = seafApplet->accountManager()->accounts()[0];
            //     if (account.isValid()) {
            //         QUrl url = account.getAbsoluteUrl("repo/" + it->repo().id);
            //         QDesktopServices::openUrl(url);
            //     }
            // }
        }
    }
}
FileBrowserDialog *FileBrowserManager::openOrActivateDialog(const Account &account, const ServerRepo &repo)
{
    FileBrowserDialog *dialog = getDialog(account, repo.id);
    if (dialog == NULL) {
        dialog = new FileBrowserDialog(account, repo, seafApplet->mainWindow());
        QRect screen = QApplication::desktop()->screenGeometry();
        dialog->setAttribute(Qt::WA_DeleteOnClose, true);
        dialog->show();
        dialog->move(screen.center() - dialog->rect().center());
        dialogs_.push_back(dialog);
        connect(dialog, SIGNAL(aboutToClose()), this, SLOT(onAboutToClose()));
    }
    dialog->raise();
    dialog->activateWindow();
    return dialog;
}