Implemented SANKORE-765.

User is aksed for a login+password couple if none of these have been filled in preferences.
He can allow Sankoré to store it in checking "Remember credentials".
preferencesAboutTextFull
Guillaume Burel 12 years ago
parent a17f31f3ce
commit 90c03c866c
  1. 83
      src/adaptors/publishing/UBDocumentPublisher.cpp
  2. 29
      src/adaptors/publishing/UBDocumentPublisher.h

@ -77,15 +77,19 @@ void UBDocumentPublisher::publish()
//check that the username and password are stored on preferences
UBSettings* settings = UBSettings::settings();
if(settings->communityUsername().isEmpty() || settings->communityPassword().isEmpty()){
UBApplication::showMessage(tr("Credentials has to not been filled out yet."));
qDebug() << "trying to connect to community without the required credentials";
return;
}
mUsername = settings->communityUsername();
mPassword = settings->communityPassword();
if (mUsername.isEmpty() || mPassword.isEmpty()){
UBLoginDlg dlg;
if (dlg.exec() == QDialog::Accepted) {
mUsername = dlg.username();
mPassword = dlg.password();
}
else
return;
}
UBPublicationDlg dlg;
if(QDialog::Accepted == dlg.exec())
{
@ -651,6 +655,73 @@ QString UBDocumentPublisher::getBase64Of(QString stringToEncode)
return stringToEncode.toAscii().toBase64();
}
UBLoginDlg::UBLoginDlg(QWidget *parent, const char *name)
: QDialog(parent)
, mUsernameLabel(tr("Username:"), this)
, mUsernameLineEdit(this)
, mPasswordLabel(tr("Password:"), this)
, mPasswordLineEdit(this)
, mRememberLabel(tr("Remember credentials"), this)
, mButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this)
{
setObjectName(name);
setFixedSize(400, 150);
setWindowTitle(tr("Login"));
setLayout(&mLayout);
mLayout.addLayout(&mUsernameLayout);
mLayout.addLayout(&mPasswordLayout);
mLayout.addLayout(&mRememberLayout);
mUsernameLayout.addWidget(&mUsernameLabel, 0);
mUsernameLayout.addWidget(&mUsernameLineEdit, 1);
mPasswordLayout.addWidget(&mPasswordLabel, 0);
mPasswordLineEdit.setEchoMode(QLineEdit::Password);
mPasswordLayout.addWidget(&mPasswordLineEdit, 1);
mRememberLayout.addWidget(&mRememberCheckBox, 0);
mRememberLayout.addWidget(&mRememberLabel, 1);
mLayout.addWidget(&mButtons);
connect(&mButtons, SIGNAL(accepted()), this, SLOT(onButtonsAccepted()));
connect(&mButtons, SIGNAL(rejected()), this, SLOT(reject()));
}
UBLoginDlg::~UBLoginDlg()
{
/* NOOP */
}
QString UBLoginDlg::username()
{
return mUsernameLineEdit.text();
}
QString UBLoginDlg::password()
{
return mPasswordLineEdit.text();
}
bool UBLoginDlg::hasToRemember()
{
return mRememberCheckBox.checkState() == Qt::Checked;
}
void UBLoginDlg::onButtonsAccepted()
{
if (username().isEmpty() || password().isEmpty())
return;
if (hasToRemember()) {
UBSettings* settings = UBSettings::settings();
settings->setCommunityUsername(username());
settings->setCommunityPassword(password());
}
accept();
}
// ---------------------------------------------------------
UBProxyLoginDlg::UBProxyLoginDlg(QWidget *parent, const char *name):QDialog(parent)
, mpLayout(NULL)

@ -33,6 +33,35 @@ class UBServerXMLHttpRequest;
class UBGraphicsW3CWidgetItem;
class QWebView;
class UBLoginDlg : public QDialog
{
Q_OBJECT
public:
UBLoginDlg(QWidget* parent = 0, const char* name = "LoginDlg");
~UBLoginDlg();
QString username();
QString password();
private slots:
void onButtonsAccepted();
private:
bool hasToRemember();
QVBoxLayout mLayout;
QHBoxLayout mUsernameLayout;
QHBoxLayout mPasswordLayout;
QHBoxLayout mRememberLayout;
QLabel mUsernameLabel;
QLineEdit mUsernameLineEdit;
QLabel mPasswordLabel;
QLineEdit mPasswordLineEdit;
QCheckBox mRememberCheckBox;
QLabel mRememberLabel;
QDialogButtonBox mButtons;
};
class UBProxyLoginDlg : public QDialog
{
Q_OBJECT

Loading…
Cancel
Save