// Switch to the clicked account in the account menu void CloudView::onAccountItemClicked() { QAction *action = (QAction *)(sender()); Account account = qvariant_cast<Account>(action->data()); if (account == current_account_) { return; } setCurrentAccount(account); updateAccountMenu(); }
bool kOnlineTransferForm::setOnlineJob(const onlineJob job) { QString name; try { name = job.task()->taskName(); } catch (const onlineJob::emptyTask&) { return false; } setCurrentAccount(job.responsibleAccount()); if (showEditWidget(name)) { IonlineJobEdit* widget = qobject_cast<IonlineJobEdit*>(ui->creditTransferEdit->widget()); if (widget != 0) { // This can happen if there are no widgets const bool ret = widget->setOnlineJob(job); setJobReadOnly(!job.isEditable()); return ret; } } return false; }
/** * Update the account menu when accounts changed */ void CloudView::updateAccountMenu() { // Remove all menu items account_menu_->clear(); // Add accounts again const std::vector<Account>& accounts = seafApplet->accountManager()->accounts(); if (!accounts.empty()) { if (!hasAccount()) { setCurrentAccount(accounts[0]); } for (int i = 0, n = accounts.size(); i < n; i++) { Account account = accounts[i]; QAction *action = makeAccountAction(accounts[i]); if (account == current_account_) { action->setChecked(true); } account_menu_->addAction(action); } account_menu_->addSeparator(); } // Add rest items add_account_action_ = new QAction(tr("Add an account"), this); add_account_action_->setIcon(awesome->icon(icon_plus)); add_account_action_->setIconVisibleInMenu(true); connect(add_account_action_, SIGNAL(triggered()), this, SLOT(showAddAccountDialog())); account_menu_->addAction(add_account_action_); if (hasAccount()) { add_account_action_->setVisible(false); // disk42 delete_account_action_ = new QAction(tr("Delete this account"), this); delete_account_action_->setIcon(awesome->icon(icon_remove)); delete_account_action_->setIconVisibleInMenu(true); connect(delete_account_action_, SIGNAL(triggered()), this, SLOT(deleteAccount())); account_menu_->addAction(delete_account_action_); } }
void CloudView::deleteAccount() { QString question = tr("Are you sure to remove this account?<br>" "<b>Warning: All libraries of this account would be unsynced!</b>"); if (QMessageBox::question(this, tr(SEAFILE_CLIENT_BRAND), question, QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Ok) { QString error, server_addr = current_account_.serverUrl.host(); if (seafApplet->rpcClient()->unsyncReposByAccount(server_addr, current_account_.username, &error) < 0) { QMessageBox::warning(this, tr(SEAFILE_CLIENT_BRAND), tr("Failed to unsync libraries of this account: %1").arg(error), QMessageBox::Ok); } Account account = current_account_; setCurrentAccount(Account()); seafApplet->accountManager()->removeAccount(account); } }