Refactoring of feed editing forms, re-introduced support for adding tt-rss feeds.
This commit is contained in:
parent
db92b9d27b
commit
59e546a8cd
16 changed files with 355 additions and 72 deletions
|
@ -160,7 +160,7 @@ HEADERS += core/feeddownloader.h \
|
|||
services/owncloud/owncloudserviceroot.h \
|
||||
services/standard/atomparser.h \
|
||||
services/standard/feedparser.h \
|
||||
services/standard/gui/authenticationdetails.h \
|
||||
services/abstract/gui/authenticationdetails.h \
|
||||
services/standard/gui/formstandardcategorydetails.h \
|
||||
services/standard/gui/formstandardfeeddetails.h \
|
||||
services/standard/gui/formstandardimportexport.h \
|
||||
|
@ -175,6 +175,8 @@ HEADERS += core/feeddownloader.h \
|
|||
services/standard/standardserviceroot.h \
|
||||
services/tt-rss/definitions.h \
|
||||
services/tt-rss/gui/formeditttrssaccount.h \
|
||||
services/tt-rss/gui/formttrssfeeddetails.h \
|
||||
services/tt-rss/gui/ttrssfeeddetails.h \
|
||||
services/tt-rss/network/ttrssnetworkfactory.h \
|
||||
services/tt-rss/ttrssfeed.h \
|
||||
services/tt-rss/ttrssserviceentrypoint.h \
|
||||
|
@ -308,7 +310,7 @@ SOURCES += core/feeddownloader.cpp \
|
|||
services/owncloud/owncloudserviceroot.cpp \
|
||||
services/standard/atomparser.cpp \
|
||||
services/standard/feedparser.cpp \
|
||||
services/standard/gui/authenticationdetails.cpp \
|
||||
services/abstract/gui/authenticationdetails.cpp \
|
||||
services/standard/gui/formstandardcategorydetails.cpp \
|
||||
services/standard/gui/formstandardfeeddetails.cpp \
|
||||
services/standard/gui/formstandardimportexport.cpp \
|
||||
|
@ -322,6 +324,8 @@ SOURCES += core/feeddownloader.cpp \
|
|||
services/standard/standardserviceentrypoint.cpp \
|
||||
services/standard/standardserviceroot.cpp \
|
||||
services/tt-rss/gui/formeditttrssaccount.cpp \
|
||||
services/tt-rss/gui/formttrssfeeddetails.cpp \
|
||||
services/tt-rss/gui/ttrssfeeddetails.cpp \
|
||||
services/tt-rss/network/ttrssnetworkfactory.cpp \
|
||||
services/tt-rss/ttrssfeed.cpp \
|
||||
services/tt-rss/ttrssserviceentrypoint.cpp \
|
||||
|
@ -363,7 +367,7 @@ FORMS += gui/dialogs/formabout.ui \
|
|||
services/gmail/gui/formeditgmailaccount.ui \
|
||||
services/inoreader/gui/formeditinoreaderaccount.ui \
|
||||
services/owncloud/gui/formeditowncloudaccount.ui \
|
||||
services/standard/gui/authenticationdetails.ui \
|
||||
services/abstract/gui/authenticationdetails.ui \
|
||||
services/standard/gui/formstandardcategorydetails.ui \
|
||||
services/standard/gui/formstandardimportexport.ui \
|
||||
services/standard/gui/standardfeeddetails.ui \
|
||||
|
@ -371,7 +375,8 @@ FORMS += gui/dialogs/formabout.ui \
|
|||
services/gmail/gui/formdownloadattachment.ui \
|
||||
services/gmail/gui/formaddeditemail.ui \
|
||||
gui/searchtextwidget.ui \
|
||||
gui/newspaperpreviewer.ui
|
||||
gui/newspaperpreviewer.ui \
|
||||
services/tt-rss/gui/ttrssfeeddetails.ui
|
||||
|
||||
equals(USE_WEBENGINE, true) {
|
||||
HEADERS += gui/locationlineedit.h \
|
||||
|
|
47
src/librssguard/services/abstract/gui/authenticationdetails.cpp
Executable file
47
src/librssguard/services/abstract/gui/authenticationdetails.cpp
Executable file
|
@ -0,0 +1,47 @@
|
|||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
#include "services/abstract/gui/authenticationdetails.h"
|
||||
|
||||
AuthenticationDetails::AuthenticationDetails(QWidget* parent) : QWidget(parent) {
|
||||
setupUi(this);
|
||||
|
||||
// Set text boxes.
|
||||
m_txtUsername->lineEdit()->setPlaceholderText(tr("Username"));
|
||||
m_txtUsername->lineEdit()->setToolTip(tr("Set username to access the feed."));
|
||||
m_txtPassword->lineEdit()->setPlaceholderText(tr("Password"));
|
||||
m_txtPassword->lineEdit()->setToolTip(tr("Set password to access the feed."));
|
||||
|
||||
connect(m_txtUsername->lineEdit(), &BaseLineEdit::textChanged, this, &AuthenticationDetails::onUsernameChanged);
|
||||
connect(m_txtPassword->lineEdit(), &BaseLineEdit::textChanged, this, &AuthenticationDetails::onPasswordChanged);
|
||||
connect(m_gbAuthentication, &QGroupBox::toggled, this, &AuthenticationDetails::onAuthenticationSwitched);
|
||||
|
||||
onUsernameChanged(QString());
|
||||
onPasswordChanged(QString());
|
||||
}
|
||||
|
||||
void AuthenticationDetails::onUsernameChanged(const QString& new_username) {
|
||||
bool is_username_ok = !m_gbAuthentication->isChecked() || !new_username.simplified().isEmpty();
|
||||
|
||||
m_txtUsername->setStatus(is_username_ok ?
|
||||
LineEditWithStatus::StatusType::Ok :
|
||||
LineEditWithStatus::StatusType::Warning,
|
||||
is_username_ok ?
|
||||
tr("Username is ok or it is not needed.") :
|
||||
tr("Username is empty."));
|
||||
}
|
||||
|
||||
void AuthenticationDetails::onPasswordChanged(const QString& new_password) {
|
||||
bool is_password_ok = !m_gbAuthentication->isChecked() || !new_password.simplified().isEmpty();
|
||||
|
||||
m_txtPassword->setStatus(is_password_ok ?
|
||||
LineEditWithStatus::StatusType::Ok :
|
||||
LineEditWithStatus::StatusType::Warning,
|
||||
is_password_ok ?
|
||||
tr("Password is ok or it is not needed.") :
|
||||
tr("Password is empty."));
|
||||
}
|
||||
|
||||
void AuthenticationDetails::onAuthenticationSwitched() {
|
||||
onUsernameChanged(m_txtUsername->lineEdit()->text());
|
||||
onPasswordChanged(m_txtPassword->lineEdit()->text());
|
||||
}
|
|
@ -7,11 +7,9 @@
|
|||
|
||||
#include "ui_authenticationdetails.h"
|
||||
|
||||
class AuthenticationDetails : public QWidget {
|
||||
class AuthenticationDetails : public QWidget, public Ui::AuthenticationDetails {
|
||||
Q_OBJECT
|
||||
|
||||
friend class FormStandardFeedDetails;
|
||||
|
||||
public:
|
||||
explicit AuthenticationDetails(QWidget* parent = nullptr);
|
||||
|
||||
|
@ -19,9 +17,6 @@ class AuthenticationDetails : public QWidget {
|
|||
void onUsernameChanged(const QString& new_username);
|
||||
void onPasswordChanged(const QString& new_password);
|
||||
void onAuthenticationSwitched();
|
||||
|
||||
private:
|
||||
Ui::AuthenticationDetails m_ui;
|
||||
};
|
||||
|
||||
#endif // AUTHENTICATIONDETAILS_H
|
|
@ -37,6 +37,10 @@ void FormFeedDetails::activateTab(int index) {
|
|||
m_ui->m_tabWidget->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void FormFeedDetails::clearTabs() {
|
||||
m_ui->m_tabWidget->clear();
|
||||
}
|
||||
|
||||
void FormFeedDetails::insertCustomTab(QWidget* custom_tab, const QString& title, int index) {
|
||||
m_ui->m_tabWidget->insertTab(index, custom_tab, title);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ class FormFeedDetails : public QDialog {
|
|||
|
||||
protected slots:
|
||||
void activateTab(int index);
|
||||
void clearTabs();
|
||||
void insertCustomTab(QWidget* custom_tab, const QString& title, int index);
|
||||
|
||||
// Applies changes.
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
#include "services/standard/gui/authenticationdetails.h"
|
||||
|
||||
AuthenticationDetails::AuthenticationDetails(QWidget* parent) : QWidget(parent) {
|
||||
m_ui.setupUi(this);
|
||||
|
||||
// Set text boxes.
|
||||
m_ui.m_txtUsername->lineEdit()->setPlaceholderText(tr("Username"));
|
||||
m_ui.m_txtUsername->lineEdit()->setToolTip(tr("Set username to access the feed."));
|
||||
m_ui.m_txtPassword->lineEdit()->setPlaceholderText(tr("Password"));
|
||||
m_ui.m_txtPassword->lineEdit()->setToolTip(tr("Set password to access the feed."));
|
||||
|
||||
connect(m_ui.m_txtUsername->lineEdit(), &BaseLineEdit::textChanged, this, &AuthenticationDetails::onUsernameChanged);
|
||||
connect(m_ui.m_txtPassword->lineEdit(), &BaseLineEdit::textChanged, this, &AuthenticationDetails::onPasswordChanged);
|
||||
connect(m_ui.m_gbAuthentication, &QGroupBox::toggled, this, &AuthenticationDetails::onAuthenticationSwitched);
|
||||
|
||||
onUsernameChanged(QString());
|
||||
onPasswordChanged(QString());
|
||||
}
|
||||
|
||||
void AuthenticationDetails::onUsernameChanged(const QString& new_username) {
|
||||
bool is_username_ok = !m_ui.m_gbAuthentication->isChecked() || !new_username.simplified().isEmpty();
|
||||
|
||||
m_ui.m_txtUsername->setStatus(is_username_ok ?
|
||||
LineEditWithStatus::StatusType::Ok :
|
||||
LineEditWithStatus::StatusType::Warning,
|
||||
is_username_ok ?
|
||||
tr("Username is ok or it is not needed.") :
|
||||
tr("Username is empty."));
|
||||
}
|
||||
|
||||
void AuthenticationDetails::onPasswordChanged(const QString& new_password) {
|
||||
bool is_password_ok = !m_ui.m_gbAuthentication->isChecked() || !new_password.simplified().isEmpty();
|
||||
|
||||
m_ui.m_txtPassword->setStatus(is_password_ok ?
|
||||
LineEditWithStatus::StatusType::Ok :
|
||||
LineEditWithStatus::StatusType::Warning,
|
||||
is_password_ok ?
|
||||
tr("Password is ok or it is not needed.") :
|
||||
tr("Password is empty."));
|
||||
}
|
||||
|
||||
void AuthenticationDetails::onAuthenticationSwitched() {
|
||||
onUsernameChanged(m_ui.m_txtUsername->lineEdit()->text());
|
||||
onPasswordChanged(m_ui.m_txtPassword->lineEdit()->text());
|
||||
}
|
|
@ -6,8 +6,8 @@
|
|||
#include "miscellaneous/iconfactory.h"
|
||||
#include "network-web/networkfactory.h"
|
||||
#include "services/abstract/category.h"
|
||||
#include "services/abstract/gui/authenticationdetails.h"
|
||||
#include "services/abstract/serviceroot.h"
|
||||
#include "services/standard/gui/authenticationdetails.h"
|
||||
#include "services/standard/gui/standardfeeddetails.h"
|
||||
#include "services/standard/standardfeed.h"
|
||||
|
||||
|
@ -39,19 +39,19 @@ int FormStandardFeedDetails::addEditFeed(StandardFeed* input_feed, RootItem* par
|
|||
}
|
||||
|
||||
// Run the dialog.
|
||||
return QDialog::exec();
|
||||
return exec();
|
||||
}
|
||||
|
||||
void FormStandardFeedDetails::guessFeed() {
|
||||
m_standardFeedDetails->guessFeed(m_standardFeedDetails->ui.m_txtUrl->lineEdit()->text(),
|
||||
m_authDetails->m_ui.m_txtUsername->lineEdit()->text(),
|
||||
m_authDetails->m_ui.m_txtPassword->lineEdit()->text());
|
||||
m_authDetails->m_txtUsername->lineEdit()->text(),
|
||||
m_authDetails->m_txtPassword->lineEdit()->text());
|
||||
}
|
||||
|
||||
void FormStandardFeedDetails::guessIconOnly() {
|
||||
m_standardFeedDetails->guessIconOnly(m_standardFeedDetails->ui.m_txtUrl->lineEdit()->text(),
|
||||
m_authDetails->m_ui.m_txtUsername->lineEdit()->text(),
|
||||
m_authDetails->m_ui.m_txtPassword->lineEdit()->text());
|
||||
m_authDetails->m_txtUsername->lineEdit()->text(),
|
||||
m_authDetails->m_txtPassword->lineEdit()->text());
|
||||
}
|
||||
|
||||
void FormStandardFeedDetails::apply() {
|
||||
|
@ -71,9 +71,9 @@ void FormStandardFeedDetails::apply() {
|
|||
new_feed->setEncoding(m_standardFeedDetails->ui.m_cmbEncoding->currentText());
|
||||
new_feed->setType(type);
|
||||
new_feed->setUrl(m_standardFeedDetails->ui.m_txtUrl->lineEdit()->text());
|
||||
new_feed->setPasswordProtected(m_authDetails->m_ui.m_gbAuthentication->isChecked());
|
||||
new_feed->setUsername(m_authDetails->m_ui.m_txtUsername->lineEdit()->text());
|
||||
new_feed->setPassword(m_authDetails->m_ui.m_txtPassword->lineEdit()->text());
|
||||
new_feed->setPasswordProtected(m_authDetails->m_gbAuthentication->isChecked());
|
||||
new_feed->setUsername(m_authDetails->m_txtUsername->lineEdit()->text());
|
||||
new_feed->setPassword(m_authDetails->m_txtPassword->lineEdit()->text());
|
||||
new_feed->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(
|
||||
m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
|
||||
new_feed->setAutoUpdateInitialInterval(int(m_ui->m_spinAutoUpdateInterval->value()));
|
||||
|
@ -115,7 +115,7 @@ void FormStandardFeedDetails::setEditableFeed(Feed* editable_feed) {
|
|||
FormFeedDetails::setEditableFeed(editable_feed);
|
||||
|
||||
m_standardFeedDetails->setExistingFeed(qobject_cast<StandardFeed*>(editable_feed));
|
||||
m_authDetails->m_ui.m_gbAuthentication->setChecked(editable_feed->passwordProtected());
|
||||
m_authDetails->m_ui.m_txtUsername->lineEdit()->setText(editable_feed->username());
|
||||
m_authDetails->m_ui.m_txtPassword->lineEdit()->setText(editable_feed->password());
|
||||
m_authDetails->m_gbAuthentication->setChecked(editable_feed->passwordProtected());
|
||||
m_authDetails->m_txtUsername->lineEdit()->setText(editable_feed->username());
|
||||
m_authDetails->m_txtPassword->lineEdit()->setText(editable_feed->password());
|
||||
}
|
||||
|
|
|
@ -113,9 +113,8 @@ void StandardServiceRoot::addNewFeed(RootItem* selected_item, const QString& url
|
|||
// is quitting.
|
||||
qApp->showGuiMessage(tr("Cannot add item"),
|
||||
tr("Cannot add feed because another critical operation is ongoing."),
|
||||
QSystemTrayIcon::Warning, qApp->mainFormWidget(), true);
|
||||
QSystemTrayIcon::MessageIcon::Warning, qApp->mainFormWidget(), true);
|
||||
|
||||
// Thus, cannot delete and quit the method.
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
79
src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp
Executable file
79
src/librssguard/services/tt-rss/gui/formttrssfeeddetails.cpp
Executable file
|
@ -0,0 +1,79 @@
|
|||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
#include "services/tt-rss/gui/formttrssfeeddetails.h"
|
||||
|
||||
#include "miscellaneous/application.h"
|
||||
#include "services/abstract/feed.h"
|
||||
#include "services/abstract/gui/authenticationdetails.h"
|
||||
#include "services/tt-rss/definitions.h"
|
||||
#include "services/tt-rss/gui/ttrssfeeddetails.h"
|
||||
#include "services/tt-rss/network/ttrssnetworkfactory.h"
|
||||
#include "services/tt-rss/ttrssfeed.h"
|
||||
#include "services/tt-rss/ttrssserviceroot.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QMimeData>
|
||||
#include <QTimer>
|
||||
|
||||
FormTtRssFeedDetails::FormTtRssFeedDetails(ServiceRoot* service_root, QWidget* parent)
|
||||
: FormFeedDetails(service_root, parent), m_feedDetails(new TtRssFeedDetails(this)),
|
||||
m_authDetails(new AuthenticationDetails(this)) {}
|
||||
|
||||
int FormTtRssFeedDetails::addFeed(RootItem* parent_to_select, const QString& url) {
|
||||
clearTabs();
|
||||
insertCustomTab(m_feedDetails, tr("General"), 0);
|
||||
insertCustomTab(m_authDetails, tr("Network"), 1);
|
||||
activateTab(0);
|
||||
|
||||
setWindowTitle(tr("Add new feed"));
|
||||
m_feedDetails->loadCategories(m_serviceRoot->getSubTreeCategories(), m_serviceRoot, parent_to_select);
|
||||
|
||||
if (!url.isEmpty()) {
|
||||
m_feedDetails->ui.m_txtUrl->lineEdit()->setText(url);
|
||||
}
|
||||
else if (Application::clipboard()->mimeData()->hasText()) {
|
||||
m_feedDetails->ui.m_txtUrl->lineEdit()->setText(Application::clipboard()->text());
|
||||
}
|
||||
|
||||
m_feedDetails->ui.m_txtUrl->lineEdit()->selectAll();
|
||||
m_feedDetails->ui.m_txtUrl->setFocus();
|
||||
|
||||
return exec();
|
||||
}
|
||||
|
||||
void FormTtRssFeedDetails::apply() {
|
||||
if (m_editableFeed != nullptr) {
|
||||
// NOTE: We can only edit base properties, therefore
|
||||
// base method is fine.
|
||||
FormFeedDetails::apply();
|
||||
}
|
||||
else {
|
||||
RootItem* parent = static_cast<RootItem*>(m_feedDetails->ui.m_cmbParentCategory->itemData(
|
||||
m_feedDetails->ui.m_cmbParentCategory->currentIndex()).value<void*>());
|
||||
auto* root = qobject_cast<TtRssServiceRoot*>(parent->getParentServiceRoot());
|
||||
const int category_id = parent->kind() == RootItem::Kind::ServiceRoot ?
|
||||
0 :
|
||||
parent->customId().toInt();
|
||||
const TtRssSubscribeToFeedResponse response = root->network()->subscribeToFeed(m_feedDetails->ui.m_txtUrl->lineEdit()->text(),
|
||||
category_id,
|
||||
m_authDetails->m_gbAuthentication->isChecked(),
|
||||
m_authDetails->m_txtUsername->lineEdit()->text(),
|
||||
m_authDetails->m_txtPassword->lineEdit()->text());
|
||||
|
||||
if (response.code() == STF_INSERTED) {
|
||||
// Feed was added online.
|
||||
accept();
|
||||
qApp->showGuiMessage(tr("Feed added"),
|
||||
tr("Feed was added, triggering sync in now."),
|
||||
QSystemTrayIcon::MessageIcon::Information);
|
||||
QTimer::singleShot(300, root, &TtRssServiceRoot::syncIn);
|
||||
}
|
||||
else {
|
||||
qApp->showGuiMessage(tr("Cannot add feed"),
|
||||
tr("Feed was not added due to error."),
|
||||
QSystemTrayIcon::MessageIcon::Critical,
|
||||
qApp->mainFormWidget(),
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
27
src/librssguard/services/tt-rss/gui/formttrssfeeddetails.h
Executable file
27
src/librssguard/services/tt-rss/gui/formttrssfeeddetails.h
Executable file
|
@ -0,0 +1,27 @@
|
|||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
#ifndef FORMTTRSSFEEDDETAILS_H
|
||||
#define FORMTTRSSFEEDDETAILS_H
|
||||
|
||||
#include "services/abstract/gui/formfeeddetails.h"
|
||||
|
||||
class TtRssFeed;
|
||||
class TtRssFeedDetails;
|
||||
class AuthenticationDetails;
|
||||
|
||||
class FormTtRssFeedDetails : public FormFeedDetails {
|
||||
public:
|
||||
explicit FormTtRssFeedDetails(ServiceRoot* service_root, QWidget* parent = nullptr);
|
||||
|
||||
public slots:
|
||||
int addFeed(RootItem* parent_to_select, const QString& url = QString());
|
||||
|
||||
protected slots:
|
||||
virtual void apply();
|
||||
|
||||
private:
|
||||
TtRssFeedDetails* m_feedDetails;
|
||||
AuthenticationDetails* m_authDetails;
|
||||
};
|
||||
|
||||
#endif // FORMTTRSSFEEDDETAILS_H
|
52
src/librssguard/services/tt-rss/gui/ttrssfeeddetails.cpp
Executable file
52
src/librssguard/services/tt-rss/gui/ttrssfeeddetails.cpp
Executable file
|
@ -0,0 +1,52 @@
|
|||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
#include "services/tt-rss/gui/ttrssfeeddetails.h"
|
||||
|
||||
#include "services/abstract/category.h"
|
||||
|
||||
TtRssFeedDetails::TtRssFeedDetails(QWidget* parent) : QWidget(parent) {
|
||||
ui.setupUi(this);
|
||||
|
||||
ui.m_txtUrl->lineEdit()->setPlaceholderText(tr("Full feed URL including scheme"));
|
||||
ui.m_txtUrl->lineEdit()->setToolTip(tr("Provide URL for your feed."));
|
||||
|
||||
connect(ui.m_txtUrl->lineEdit(), &BaseLineEdit::textChanged, this, &TtRssFeedDetails::onUrlChanged);
|
||||
onUrlChanged(QString());
|
||||
}
|
||||
|
||||
void TtRssFeedDetails::onUrlChanged(const QString& new_url) {
|
||||
if (QRegularExpression(URL_REGEXP).match(new_url).hasMatch()) {
|
||||
// New url is well-formed.
|
||||
ui.m_txtUrl->setStatus(LineEditWithStatus::StatusType::Ok, tr("The URL is ok."));
|
||||
}
|
||||
else if (!new_url.simplified().isEmpty()) {
|
||||
// New url is not well-formed but is not empty on the other hand.
|
||||
ui.m_txtUrl->setStatus(LineEditWithStatus::StatusType::Warning,
|
||||
tr(R"(The URL does not meet standard pattern. Does your URL start with "http://" or "https://" prefix.)"));
|
||||
}
|
||||
else {
|
||||
// New url is empty.
|
||||
ui.m_txtUrl->setStatus(LineEditWithStatus::StatusType::Error, tr("The URL is empty."));
|
||||
}
|
||||
}
|
||||
|
||||
void TtRssFeedDetails::loadCategories(const QList<Category*>& categories, RootItem* root_item, RootItem* parent_to_select) {
|
||||
ui.m_cmbParentCategory->addItem(root_item->fullIcon(), root_item->title(), QVariant::fromValue((void*) root_item));
|
||||
|
||||
for (Category* category : categories) {
|
||||
ui.m_cmbParentCategory->addItem(category->fullIcon(), category->title(), QVariant::fromValue((void*) category));
|
||||
}
|
||||
|
||||
if (parent_to_select != nullptr) {
|
||||
if (parent_to_select->kind() == RootItem::Kind::Category) {
|
||||
ui.m_cmbParentCategory->setCurrentIndex(ui.m_cmbParentCategory->findData(QVariant::fromValue((void*)parent_to_select)));
|
||||
}
|
||||
else if (parent_to_select->kind() == RootItem::Kind::Feed) {
|
||||
int target_item = ui.m_cmbParentCategory->findData(QVariant::fromValue((void*)parent_to_select->parent()));
|
||||
|
||||
if (target_item >= 0) {
|
||||
ui.m_cmbParentCategory->setCurrentIndex(target_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
31
src/librssguard/services/tt-rss/gui/ttrssfeeddetails.h
Executable file
31
src/librssguard/services/tt-rss/gui/ttrssfeeddetails.h
Executable file
|
@ -0,0 +1,31 @@
|
|||
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||
|
||||
#ifndef TTRSSFEEDDETAILS_H
|
||||
#define TTRSSFEEDDETAILS_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "ui_ttrssfeeddetails.h"
|
||||
|
||||
class Category;
|
||||
class RootItem;
|
||||
|
||||
class TtRssFeedDetails : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
friend class FormTtRssFeedDetails;
|
||||
|
||||
public:
|
||||
explicit TtRssFeedDetails(QWidget* parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void onUrlChanged(const QString& new_url);
|
||||
|
||||
private:
|
||||
void loadCategories(const QList<Category*>& categories, RootItem* root_item, RootItem* parent_to_select = nullptr);
|
||||
|
||||
private:
|
||||
Ui::TtRssFeedDetails ui;
|
||||
};
|
||||
|
||||
#endif // TTRSSFEEDDETAILS_H
|
68
src/librssguard/services/tt-rss/gui/ttrssfeeddetails.ui
Executable file
68
src/librssguard/services/tt-rss/gui/ttrssfeeddetails.ui
Executable file
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TtRssFeedDetails</class>
|
||||
<widget class="QWidget" name="TtRssFeedDetails">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>367</width>
|
||||
<height>202</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_lblParentCategory">
|
||||
<property name="text">
|
||||
<string>Parent category</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_cmbParentCategory</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="m_cmbParentCategory">
|
||||
<property name="toolTip">
|
||||
<string>Select parent item for your feed.</string>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>12</width>
|
||||
<height>12</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>URL</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_txtUrl</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="LineEditWithStatus" name="m_txtUrl" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEditWithStatus</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>lineeditwithstatus.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -14,6 +14,7 @@
|
|||
#include "services/abstract/recyclebin.h"
|
||||
#include "services/tt-rss/definitions.h"
|
||||
#include "services/tt-rss/gui/formeditttrssaccount.h"
|
||||
#include "services/tt-rss/gui/formttrssfeeddetails.h"
|
||||
#include "services/tt-rss/network/ttrssnetworkfactory.h"
|
||||
#include "services/tt-rss/ttrssfeed.h"
|
||||
#include "services/tt-rss/ttrssserviceentrypoint.h"
|
||||
|
@ -83,13 +84,33 @@ bool TtRssServiceRoot::deleteViaGui() {
|
|||
}
|
||||
|
||||
bool TtRssServiceRoot::supportsFeedAdding() const {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TtRssServiceRoot::supportsCategoryAdding() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void TtRssServiceRoot::addNewFeed(RootItem* selected_item, const QString& url) {
|
||||
if (!qApp->feedUpdateLock()->tryLock()) {
|
||||
// Lock was not obtained because
|
||||
// it is used probably by feed updater or application
|
||||
// is quitting.
|
||||
qApp->showGuiMessage(tr("Cannot add item"),
|
||||
tr("Cannot add feed because another critical operation is ongoing."),
|
||||
QSystemTrayIcon::MessageIcon::Warning,
|
||||
qApp->mainFormWidget(),
|
||||
true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QScopedPointer<FormTtRssFeedDetails> form_pointer(new FormTtRssFeedDetails(this, qApp->mainFormWidget()));
|
||||
|
||||
form_pointer->addFeed(selected_item, url);
|
||||
qApp->feedUpdateLock()->unlock();
|
||||
}
|
||||
|
||||
bool TtRssServiceRoot::canBeEdited() const {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ class TtRssServiceRoot : public ServiceRoot, public CacheForServiceRoot {
|
|||
virtual bool deleteViaGui();
|
||||
virtual bool supportsFeedAdding() const;
|
||||
virtual bool supportsCategoryAdding() const;
|
||||
virtual void addNewFeed(RootItem* selected_item, const QString& url = QString());
|
||||
virtual QString additionalTooltip() const;
|
||||
virtual void saveAllCachedData(bool async = true);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue