From e4358722a6dd1abfc14e3a94335d72f52a2d6776 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 1 Dec 2015 08:22:22 +0100 Subject: [PATCH] Added initial add/edit TT-RSS account dialog. --- CMakeLists.txt | 5 + src/gui/dialogs/formsettings.ui | 4 +- .../gui/formstandardcategorydetails.ui | 2 +- src/services/tt-rss/gui/formeditaccount.cpp | 122 +++++++++++++++++ src/services/tt-rss/gui/formeditaccount.h | 59 ++++++++ src/services/tt-rss/gui/formeditaccount.ui | 129 ++++++++++++++++++ .../tt-rss/ttrssserviceentrypoint.cpp | 11 +- 7 files changed, 328 insertions(+), 4 deletions(-) create mode 100755 src/services/tt-rss/gui/formeditaccount.cpp create mode 100755 src/services/tt-rss/gui/formeditaccount.h create mode 100755 src/services/tt-rss/gui/formeditaccount.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d04f27b3..b6a65dec1 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -439,6 +439,7 @@ set(APP_SOURCES # TT-RSS feed service sources. src/services/tt-rss/ttrssserviceentrypoint.cpp src/services/tt-rss/ttrssserviceroot.cpp + src/services/tt-rss/gui/formeditaccount.cpp # NETWORK-WEB sources. src/network-web/basenetworkaccessmanager.cpp @@ -555,6 +556,7 @@ set(APP_HEADERS # TT-RSS service headers. src/services/tt-rss/ttrssserviceroot.h + src/services/tt-rss/gui/formeditaccount.h # NETWORK-WEB headers. src/network-web/webpage.h @@ -595,6 +597,9 @@ set(APP_FORMS src/services/standard/gui/formstandardfeeddetails.ui src/services/standard/gui/formstandardimportexport.ui + # TT-RSS service forms. + src/services/tt-rss/gui/formeditaccount.ui + # NETWORK forms. src/network-web/downloadmanager.ui src/network-web/downloaditem.ui diff --git a/src/gui/dialogs/formsettings.ui b/src/gui/dialogs/formsettings.ui index b92abf5bc..d4f2f5e96 100755 --- a/src/gui/dialogs/formsettings.ui +++ b/src/gui/dialogs/formsettings.ui @@ -88,7 +88,7 @@ - 3 + 1 @@ -463,7 +463,7 @@ Authors of this application are NOT responsible for lost data. QTabWidget::North - 1 + 0 diff --git a/src/services/standard/gui/formstandardcategorydetails.ui b/src/services/standard/gui/formstandardcategorydetails.ui index 101ac40e6..d68dedfe4 100755 --- a/src/services/standard/gui/formstandardcategorydetails.ui +++ b/src/services/standard/gui/formstandardcategorydetails.ui @@ -7,7 +7,7 @@ 0 0 397 - 205 + 209 diff --git a/src/services/tt-rss/gui/formeditaccount.cpp b/src/services/tt-rss/gui/formeditaccount.cpp new file mode 100755 index 000000000..5d840ffce --- /dev/null +++ b/src/services/tt-rss/gui/formeditaccount.cpp @@ -0,0 +1,122 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// RSS Guard is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with RSS Guard. If not, see . + + +#include "services/tt-rss/gui/formeditaccount.h" + +#include "services/tt-rss/ttrssserviceroot.h" + + +FormEditAccount::FormEditAccount(QWidget *parent) + : QDialog(parent), m_ui(new Ui::FormEditAccount), m_editableRoot(NULL) { + m_ui->setupUi(this); + m_btnOk = m_ui->m_buttonBox->button(QDialogButtonBox::Ok); + + m_ui->m_txtPassword->lineEdit()->setPlaceholderText(tr("Password for your TT-RSS account.")); + m_ui->m_txtUsername->lineEdit()->setPlaceholderText(tr("Username for your TT-RSS account.")); + m_ui->m_txtUrl->lineEdit()->setPlaceholderText(tr("URL of your TT-RSS instance WITHOUT trailing \"/api/\" string.")); + m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Information, + tr("No test done yet."), + tr("Here, results of connection test are shown.")); + + connect(m_ui->m_buttonBox, SIGNAL(accepted()), this, SLOT(onClickedOk())); + connect(m_ui->m_buttonBox, SIGNAL(rejected()), this, SLOT(onClickedCancel())); + connect(m_ui->m_txtPassword->lineEdit(), SIGNAL(textEdited(QString)), this, SLOT(onPasswordChanged())); + connect(m_ui->m_txtUsername->lineEdit(), SIGNAL(textEdited(QString)), this, SLOT(onUsernameChanged())); + connect(m_ui->m_txtUrl->lineEdit(), SIGNAL(textEdited(QString)), this, SLOT(onUrlChanged())); + connect(m_ui->m_txtPassword->lineEdit(), SIGNAL(textEdited(QString)), this, SLOT(checkOkButton())); + connect(m_ui->m_txtUsername->lineEdit(), SIGNAL(textEdited(QString)), this, SLOT(checkOkButton())); + connect(m_ui->m_txtUrl->lineEdit(), SIGNAL(textEdited(QString)), this, SLOT(checkOkButton())); + connect(m_ui->m_btnTestSetup, SIGNAL(clicked()), this, SLOT(performTest())); + + onPasswordChanged(); + onUsernameChanged(); + onUrlChanged(); + checkOkButton(); +} + +FormEditAccount::~FormEditAccount() { + delete m_ui; +} + +TtRssServiceRoot *FormEditAccount::execForCreate() { + setWindowTitle(tr("Add new Tiny Tiny RSS account")); + exec(); + return m_editableRoot; +} + +void FormEditAccount::execForEdit(TtRssServiceRoot *existing_root) { + setWindowTitle(tr("Edit existing Tiny Tiny RSS account")); + m_editableRoot = existing_root; + exec(); +} + +void FormEditAccount::performTest() { + +} + +void FormEditAccount::onClickedOk() { + if (m_editableRoot == NULL) { + // We want to confirm newly created account. + } + else { + // We want to edit existing account. + } +} + +void FormEditAccount::onClickedCancel() { + reject(); +} + +void FormEditAccount::onUsernameChanged() { + QString username = m_ui->m_txtUsername->lineEdit()->text(); + + if (username.isEmpty()) { + m_ui->m_txtUsername->setStatus(WidgetWithStatus::Error, tr("Username cannot be empty.")); + } + else { + m_ui->m_txtUsername->setStatus(WidgetWithStatus::Ok, tr("Username is okay.")); + } +} + +void FormEditAccount::onPasswordChanged() { + QString password = m_ui->m_txtPassword->lineEdit()->text(); + + if (password.isEmpty()) { + m_ui->m_txtPassword->setStatus(WidgetWithStatus::Error, tr("Password cannot be empty.")); + } + else { + m_ui->m_txtPassword->setStatus(WidgetWithStatus::Ok, tr("Password is okay.")); + } +} + +void FormEditAccount::onUrlChanged() { + QString url = m_ui->m_txtUrl->lineEdit()->text(); + + if (url.isEmpty()) { + m_ui->m_txtUrl->setStatus(WidgetWithStatus::Error, tr("URL cannot be empty.")); + } + else { + m_ui->m_txtUrl->setStatus(WidgetWithStatus::Ok, tr("URL is okay.")); + } +} + +void FormEditAccount::checkOkButton() { + m_btnOk->setEnabled(!m_ui->m_txtUsername->lineEdit()->text().isEmpty() && + !m_ui->m_txtPassword->lineEdit()->text().isEmpty() && + !m_ui->m_txtUrl->lineEdit()->text().isEmpty()); +} diff --git a/src/services/tt-rss/gui/formeditaccount.h b/src/services/tt-rss/gui/formeditaccount.h new file mode 100755 index 000000000..6de37e3db --- /dev/null +++ b/src/services/tt-rss/gui/formeditaccount.h @@ -0,0 +1,59 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// RSS Guard is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with RSS Guard. If not, see . + + +#ifndef FORMEDITACCOUNT_H +#define FORMEDITACCOUNT_H + +#include + +#include "ui_formeditaccount.h" + + +namespace Ui { + class FormEditAccount; +} + +class TtRssServiceRoot; + +class FormEditAccount : public QDialog { + Q_OBJECT + + public: + explicit FormEditAccount(QWidget *parent = 0); + virtual ~FormEditAccount(); + + TtRssServiceRoot *execForCreate(); + void execForEdit(TtRssServiceRoot *existing_root); + + private slots: + void performTest(); + void onClickedOk(); + void onClickedCancel(); + + void onUsernameChanged(); + void onPasswordChanged(); + void onUrlChanged(); + void checkOkButton(); + + private: + Ui::FormEditAccount *m_ui; + TtRssServiceRoot *m_editableRoot; + QPushButton *m_btnOk; +}; + +#endif // FORMEDITACCOUNT_H diff --git a/src/services/tt-rss/gui/formeditaccount.ui b/src/services/tt-rss/gui/formeditaccount.ui new file mode 100755 index 000000000..76da5638e --- /dev/null +++ b/src/services/tt-rss/gui/formeditaccount.ui @@ -0,0 +1,129 @@ + + + FormEditAccount + + + + 0 + 0 + 400 + 235 + + + + Dialog + + + + + + + + URL + + + m_txtUrl + + + + + + + + + + &Test setup + + + + + + + Some feeds require authentication, including GMail feeds. BASIC, NTLM-2 and DIGEST-MD5 authentication schemes are supported. + + + Authentication + + + false + + + false + + + + + + Username + + + m_txtUsername + + + + + + + Password + + + m_txtPassword + + + + + + + + + + + + + + + + + 0 + 0 + + + + Qt::RightToLeft + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + LineEditWithStatus + QWidget +
lineeditwithstatus.h
+ 1 +
+ + LabelWithStatus + QWidget +
labelwithstatus.h
+ 1 +
+
+ + m_btnTestSetup + + + +
diff --git a/src/services/tt-rss/ttrssserviceentrypoint.cpp b/src/services/tt-rss/ttrssserviceentrypoint.cpp index e497d30d3..3b02f255e 100755 --- a/src/services/tt-rss/ttrssserviceentrypoint.cpp +++ b/src/services/tt-rss/ttrssserviceentrypoint.cpp @@ -20,6 +20,11 @@ #include "definitions/definitions.h" #include "miscellaneous/application.h" #include "miscellaneous/iconfactory.h" +#include "gui/dialogs/formmain.h" +#include "services/tt-rss/gui/formeditaccount.h" +#include "services/tt-rss/ttrssserviceroot.h" + +#include TtRssServiceEntryPoint::TtRssServiceEntryPoint(){ @@ -59,7 +64,11 @@ QString TtRssServiceEntryPoint::code() { } ServiceRoot *TtRssServiceEntryPoint::createNewRoot() { - return NULL; + QPointer form_acc = new FormEditAccount(qApp->mainForm()); + TtRssServiceRoot *new_root = form_acc.data()->execForCreate(); + delete form_acc.data(); + + return new_root; } QList TtRssServiceEntryPoint::initializeSubtree() {