void RepoTreeView::toggleRepoAutoSync() { LocalRepo repo = qvariant_cast<LocalRepo>(toggle_auto_sync_action_->data()); seafApplet->rpcClient()->setRepoAutoSync(repo.id, !repo.auto_sync); updateRepoActions(); }
void RepoTreeView::downloadRepo() { ServerRepo repo = qvariant_cast<ServerRepo>(download_action_->data()); DownloadRepoDialog dialog(seafApplet->accountManager()->accounts()[0], repo, this); dialog.exec(); updateRepoActions(); }
void RepoTreeView::downloadRepo() { ServerRepo repo = qvariant_cast<ServerRepo>(download_action_->data()); DownloadRepoDialog dialog(cloud_view_->currentAccount(), repo, this); dialog.exec(); updateRepoActions(); }
std::vector<QAction*> RepoTreeView::getToolBarActions() { std::vector<QAction*> actions; updateRepoActions(); actions.push_back(download_toolbar_action_); actions.push_back(open_local_folder_toolbar_action_); return actions; }
void RepoTreeView::downloadRepo() { ServerRepo repo = qvariant_cast<ServerRepo>(download_action_->data()); DownloadRepoDialog dialog(cloud_view_->currentAccount(), repo, this); if (dialog.exec() == QDialog::Accepted) { CloneTasksDialog tasks_dialog(this); tasks_dialog.exec(); } updateRepoActions(); }
void RepoTreeView::resyncRepo() { LocalRepo local_repo = qvariant_cast<LocalRepo>(unsync_action_->data()); ServerRepo server_repo = RepoService::instance()->getRepo(local_repo.id); SeafileRpcClient *rpc = seafApplet->rpcClient(); if (!seafApplet->yesOrNoBox( tr("Are you sure to unsync and resync library \"%1\"?").arg(server_repo.name), this)) { return; } // must read these before unsync QString token = getRepoProperty(local_repo.id, "token"); QString relay_addr = getRepoProperty(local_repo.id, "relay-address"); QString relay_port = getRepoProperty(local_repo.id, "relay-port"); if (rpc->unsync(server_repo.id) < 0) { seafApplet->warningBox(tr("Failed to unsync library \"%1\"").arg(server_repo.name)); return; } if (server_repo.encrypted) { DownloadRepoDialog dialog(seafApplet->accountManager()->currentAccount(), RepoService::instance()->getRepo(server_repo.id), this); dialog.setMergeWithExisting(local_repo.worktree); dialog.exec(); return; } else { QString more_info = buildMoreInfo(server_repo); QString email = seafApplet->accountManager()->currentAccount().username; QString error; // unused fields QString magic, passwd, random_key; // all null int enc_version = 0; if (rpc->cloneRepo(local_repo.id, local_repo.version, local_repo.relay_id, server_repo.name, local_repo.worktree, token, passwd, magic, relay_addr, relay_port, email, random_key, enc_version, more_info, &error) < 0) { seafApplet->warningBox(tr("Failed to add download task:\n %1").arg(error)); } } updateRepoActions(); }
void RepoTreeView::contextMenuEvent(QContextMenuEvent *event) { QPoint pos = event->pos(); QModelIndex index = indexAt(pos); if (!index.isValid()) { // Not clicked at a repo item return; } QStandardItem *item = getRepoItem(index); if (!item || item->type() != REPO_ITEM_TYPE) { return; } updateRepoActions(); QMenu *menu = prepareContextMenu((RepoItem *)item); pos = viewport()->mapToGlobal(pos); menu->exec(pos); }
void RepoTreeView::unsyncRepo() { LocalRepo repo = qvariant_cast<LocalRepo>(toggle_auto_sync_action_->data()); QString question = tr("Are you sure to unsync library \"%1\"?").arg(repo.name); if (QMessageBox::question(this, getBrand(), question, QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel) != QMessageBox::Ok) { return; } if (seafApplet->rpcClient()->unsync(repo.id) < 0) { QMessageBox::warning(this, getBrand(), tr("Failed to unsync library \"%1\"").arg(repo.name), QMessageBox::Ok); } updateRepoActions(); }
void RepoTreeView::showEvent(QShowEvent *event) { updateRepoActions(); }
void RepoTreeView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) { updateRepoActions(); }