diff --git a/src/adaptors/publishing/UBDocumentPublisher.cpp b/src/adaptors/publishing/UBDocumentPublisher.cpp index 87e78ad4..39174dba 100644 --- a/src/adaptors/publishing/UBDocumentPublisher.cpp +++ b/src/adaptors/publishing/UBDocumentPublisher.cpp @@ -77,19 +77,15 @@ 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()) { @@ -655,73 +651,6 @@ 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) diff --git a/src/adaptors/publishing/UBDocumentPublisher.h b/src/adaptors/publishing/UBDocumentPublisher.h index b9578eef..4babbec8 100644 --- a/src/adaptors/publishing/UBDocumentPublisher.h +++ b/src/adaptors/publishing/UBDocumentPublisher.h @@ -33,35 +33,6 @@ 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