void CloudView::createTabs() { tabs_ = new SeafileTabWidget; // tabs_ = new QTabWidget; repos_tab_ = new ReposTab; QString base_icon_path = ":/images/tabs/"; tabs_->addTab(repos_tab_, tr("Libraries"), base_icon_path + "files.png"); starred_files_tab_ = new StarredFilesTab; tabs_->addTab(starred_files_tab_, tr("Starred"), base_icon_path + "starred.png"); activities_tab_ = new ActivitiesTab; search_tab_ = new SearchTab; connect(tabs_, SIGNAL(currentTabChanged(int)), this, SLOT(onTabChanged(int))); bool has_pro_account = hasAccount() && seafApplet->accountManager()->accounts().front().isPro(); if (has_pro_account) { addActivitiesTab(); } }
void CloudView::createToolBar() { tool_bar_ = new QToolBar; tool_bar_->setIconSize(QSize(24, 24)); std::vector<QAction*> repo_actions = repos_tab_->getToolBarActions(); for (size_t i = 0, n = repo_actions.size(); i < n; i++) { QAction *action = repo_actions[i]; tool_bar_->addAction(action); } QWidget *spacer = new QWidget; spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); tool_bar_->addWidget(spacer); refresh_action_ = new QAction(tr("Refresh"), this); refresh_action_->setIcon(QIcon(":/images/toolbar/refresh.png")); refresh_action_->setEnabled(hasAccount()); connect(refresh_action_, SIGNAL(triggered()), this, SLOT(onRefreshClicked())); tool_bar_->addAction(refresh_action_); QWidget *spacer_right = new QWidget; spacer_right->setObjectName("spacerWidget"); spacer_right->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); tool_bar_->addWidget(spacer_right); }
void CloudView::onRefreshClicked() { if (hasAccount()) { showLoadingView(); refreshRepos(); } }
void TWS_TLServer::updateAccountValue( const CString &key, const CString &val, const CString ¤cy, const CString &accountName) { // make sure we don't have this account already if (!hasAccount(accountName)) { accts.push_back(accountName); // save the account name } }
void CloudView::onAccountChanged() { refresh_action_->setEnabled(hasAccount()); repos_tab_->refresh(); starred_files_tab_->refresh(); activities_tab_->refresh(); account_view_->onAccountChanged(); }
/** * 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::onTabChanged(int index) { bool enable_sync_with_any_folder = hasAccount() && !seafApplet->accountManager()->accounts().front().hasDisableSyncWithAnyFolder(); bool drop_area_visible = index == 0; if (enable_sync_with_any_folder && drop_area_visible) { mDropArea->setVisible(true); mFooter->setStyleSheet(""); } else { mDropArea->setVisible(false); mFooter->setStyleSheet("QFrame#mFooter { border-top: 1px solid #DCDCDE; }"); } }
void CloudView::onAccountChanged() { refresh_action_->setEnabled(hasAccount()); bool was_pro_account = tabs_->count() > 2; bool has_pro_account = hasAccount() && seafApplet->accountManager()->accounts().front().isPro(); if (has_pro_account && !was_pro_account) { addActivitiesTab(); } else if (!has_pro_account && was_pro_account) { tabs_->removeTab(TAB_INDEX_SEARCH, search_tab_); tabs_->removeTab(TAB_INDEX_ACTIVITIES, activities_tab_); } tabs_->adjustTabsWidth(rect().width()); repos_tab_->refresh(); starred_files_tab_->refresh(); activities_tab_->refresh(); search_tab_->reset(); account_view_->onAccountChanged(); }
void CloudView::updateAccountInfoDisplay() { mAccountBtn->setIcon(QIcon(":/images/account.png")); mAccountBtn->setIconSize(QSize(32, 32)); if (hasAccount()) { mEmail->setText(current_account_.username); mServerAddr->setText(current_account_.serverUrl.host()); } else { mEmail->setText(tr("No account")); mServerAddr->setText(QString()); } }
void CloudView::createToolBar() { tool_bar_ = new QToolBar; QVBoxLayout *vlayout = (QVBoxLayout *)layout(); vlayout->insertWidget(2, tool_bar_); std::vector<QAction*> repo_actions = repos_tree_->getToolBarActions(); for (int i = 0, n = repo_actions.size(); i < n; i++) { QAction *action = repo_actions[i]; tool_bar_->addAction(action); action->setEnabled(hasAccount()); } QWidget *spacerWidget = new QWidget; spacerWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); tool_bar_->addWidget(spacerWidget); refresh_action_ = new QAction(tr("Refresh"), this); refresh_action_->setIcon(QIcon(":/images/refresh.png")); refresh_action_->setEnabled(hasAccount()); connect(refresh_action_, SIGNAL(triggered()), this, SLOT(onRefreshClicked())); tool_bar_->addAction(refresh_action_); }
void CloudView::refreshRepos() { if (in_refresh_) { return; } if (!hasAccount()) { return; } in_refresh_ = true; if (list_repo_req_) { delete list_repo_req_; } list_repo_req_ = new ListReposRequest(current_account_); connect(list_repo_req_, SIGNAL(success(const std::vector<ServerRepo>&)), this, SLOT(refreshRepos(const std::vector<ServerRepo>&))); connect(list_repo_req_, SIGNAL(failed(int)), this, SLOT(refreshReposFailed())); list_repo_req_->send(); }
void AccountManager::invalidateCurrentLogin() { // make sure we have accounts there if (!hasAccount()) return; const Account &account = accounts_.front(); // if the token is already invalidated, ignore if (account.token.isEmpty()) return; QString error; if (seafApplet->rpcClient()->removeSyncTokensByAccount(account.serverUrl.host(), account.username, &error) < 0) { qWarning("Failed to remove local repos sync token %s", error.toUtf8().data()); } clearAccountToken(account); seafApplet->warningBox(tr("Authorization expired, please re-login")); emit accountRequireRelogin(account); }
void CloudView::updateAccountInfoDisplay() { mAccountBtn->setIcon(QIcon(":/images/account.png")); mAccountBtn->setIconSize(QSize(32, 32)); if (hasAccount()) { mEmail->setText(current_account_.username); mServerAddr->setOpenExternalLinks(true); mServerAddr->setToolTip(tr("click to open the website")); QString host = current_account_.serverUrl.host(); QString href = current_account_.serverUrl.toString(); QString text = QString("<a style=" "\"color:#A4A4A4; text-decoration: none;\" " "href=\"%1\">%2</a>").arg(href).arg(host); mServerAddr->setText(text); } else { mEmail->setText(tr("No account")); mServerAddr->setText(QString()); } }
std::shared_ptr<Account> AccountFactory::createAccount(const char* const accountType, const std::string& id) { if (hasAccount(id)) { RING_ERR("Existing account %s", id.c_str()); return nullptr; } std::shared_ptr<Account> account; { const auto& it = generators_.find(accountType); if (it != generators_.cend()) account = it->second(id); } { std::lock_guard<std::recursive_mutex> lock(mutex_); accountMaps_[accountType].insert(std::make_pair(id, account)); } return account; }