"Fossies" - the Fresh Open Source Software Archive

Member "seafile-client-7.0.4/src/ui/logout-view.cpp" (19 Nov 2019, 1775 Bytes) of package /linux/www/seafile-client-7.0.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "logout-view.cpp" see the Fossies "Dox" file reference documentation.

    1 #include <QtGlobal>
    2 
    3 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
    4 #include <QtWidgets>
    5 #else
    6 #include <QtGui>
    7 #endif
    8 #include "seafile-applet.h"
    9 #include "account-mgr.h"
   10 
   11 #include "logout-view.h"
   12 
   13 LogoutView::LogoutView(QWidget *parent)
   14     : QWidget(parent)
   15 {
   16     setObjectName("LogoutView");
   17 
   18     QVBoxLayout *layout = new QVBoxLayout;
   19     setLayout(layout);
   20 
   21     label_ = new QLabel;
   22     label_->setAlignment(Qt::AlignCenter);
   23 
   24     layout->addWidget(label_);
   25     layout->setContentsMargins(0, 0, 0, 0);
   26 
   27     connect(seafApplet->accountManager(), SIGNAL(accountsChanged()),
   28             this, SLOT(onAccountChanged()));
   29 
   30     onAccountChanged();
   31 }
   32 
   33 void LogoutView::setQssStyleForTab()
   34 {
   35     static const char *kLogoutViewQss = "border: 0; margin: 0;"
   36                               "border-top: 1px solid #DCDCDE;"
   37                               "background-color: #F5F5F7;";
   38 
   39     setStyleSheet(kLogoutViewQss);
   40 }
   41 
   42 void LogoutView::onAccountChanged()
   43 {
   44     // disconnect current signal
   45     disconnect(label_, SIGNAL(linkActivated(const QString&)), 0, 0);
   46 
   47     QString link = QString("<a style=\"color:#777\" href=\"#\">%1</a>");
   48 
   49     if (seafApplet->accountManager()->hasAccount()) {
   50         connect(label_, SIGNAL(linkActivated(const QString&)),
   51                 this, SLOT(reloginCurrentAccount()));
   52         label_->setText(tr("You are logout. Please ") + link.arg(tr("login")));
   53     } else {
   54         connect(label_, SIGNAL(linkActivated(const QString&)),
   55                 seafApplet->accountManager(), SIGNAL(requireAddAccount()));
   56         label_->setText(link.arg(tr("Add an account")));
   57     }
   58 }
   59 
   60 void LogoutView::reloginCurrentAccount()
   61 {
   62     Account account = seafApplet->accountManager()->accounts().front();
   63     seafApplet->accountManager()->reloginAccount(account);
   64 }