Added initial add/edit TT-RSS account dialog.

This commit is contained in:
Martin Rotter 2015-12-01 08:22:22 +01:00
parent f634857f6e
commit e4358722a6
7 changed files with 328 additions and 4 deletions

View File

@ -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

View File

@ -88,7 +88,7 @@
<item row="0" column="1">
<widget class="QStackedWidget" name="m_stackedSettings">
<property name="currentIndex">
<number>3</number>
<number>1</number>
</property>
<widget class="QWidget" name="m_pageGeneral">
<layout class="QFormLayout" name="formLayout_5">
@ -463,7 +463,7 @@ Authors of this application are NOT responsible for lost data.</string>
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="m_tabIconSkin">
<attribute name="title">

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>397</width>
<height>205</height>
<height>209</height>
</rect>
</property>
<property name="minimumSize">

View File

@ -0,0 +1,122 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
#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());
}

View File

@ -0,0 +1,59 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2015 by Martin Rotter <rotter.martinos@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
#ifndef FORMEDITACCOUNT_H
#define FORMEDITACCOUNT_H
#include <QDialog>
#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

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FormEditAccount</class>
<widget class="QDialog" name="FormEditAccount">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>235</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="m_lblTitle">
<property name="text">
<string>URL</string>
</property>
<property name="buddy">
<cstring>m_txtUrl</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="LineEditWithStatus" name="m_txtUrl" native="true"/>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="m_btnTestSetup">
<property name="text">
<string>&amp;Test setup</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="m_gbAuthentication">
<property name="toolTip">
<string>Some feeds require authentication, including GMail feeds. BASIC, NTLM-2 and DIGEST-MD5 authentication schemes are supported.</string>
</property>
<property name="title">
<string>Authentication</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Username</string>
</property>
<property name="buddy">
<cstring>m_txtUsername</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Password</string>
</property>
<property name="buddy">
<cstring>m_txtPassword</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="LineEditWithStatus" name="m_txtPassword" native="true"/>
</item>
<item row="0" column="1">
<widget class="LineEditWithStatus" name="m_txtUsername" native="true"/>
</item>
</layout>
</widget>
</item>
<item row="2" column="1">
<widget class="LabelWithStatus" name="m_lblTestResult" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="m_buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LineEditWithStatus</class>
<extends>QWidget</extends>
<header>lineeditwithstatus.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LabelWithStatus</class>
<extends>QWidget</extends>
<header>labelwithstatus.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>m_btnTestSetup</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -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 <QPointer>
TtRssServiceEntryPoint::TtRssServiceEntryPoint(){
@ -59,7 +64,11 @@ QString TtRssServiceEntryPoint::code() {
}
ServiceRoot *TtRssServiceEntryPoint::createNewRoot() {
return NULL;
QPointer<FormEditAccount> form_acc = new FormEditAccount(qApp->mainForm());
TtRssServiceRoot *new_root = form_acc.data()->execForCreate();
delete form_acc.data();
return new_root;
}
QList<ServiceRoot*> TtRssServiceEntryPoint::initializeSubtree() {