Unified account dialog for nextcloud.
This commit is contained in:
parent
abaadbafda
commit
1e2d677206
3 changed files with 370 additions and 0 deletions
128
src/librssguard/services/owncloud/gui/owncloudaccountdetails.cpp
Executable file
128
src/librssguard/services/owncloud/gui/owncloudaccountdetails.cpp
Executable file
|
@ -0,0 +1,128 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#include "services/owncloud/gui/owncloudaccountdetails.h"
|
||||||
|
|
||||||
|
#include "definitions/definitions.h"
|
||||||
|
#include "gui/guiutilities.h"
|
||||||
|
#include "miscellaneous/systemfactory.h"
|
||||||
|
#include "services/owncloud/definitions.h"
|
||||||
|
#include "services/owncloud/network/owncloudnetworkfactory.h"
|
||||||
|
|
||||||
|
OwnCloudAccountDetails::OwnCloudAccountDetails(QWidget* parent) : QWidget(parent) {
|
||||||
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
|
m_ui.m_lblTestResult->label()->setWordWrap(true);
|
||||||
|
m_ui.m_lblServerSideUpdateInformation->setText(tr("Leaving this option on causes that updates "
|
||||||
|
"of feeds will be probably much slower and may time-out often."));
|
||||||
|
m_ui.m_txtPassword->lineEdit()->setPlaceholderText(tr("Password for your Nextcloud account"));
|
||||||
|
m_ui.m_txtUsername->lineEdit()->setPlaceholderText(tr("Username for your Nextcloud account"));
|
||||||
|
m_ui.m_txtUrl->lineEdit()->setPlaceholderText(tr("URL of your Nextcloud server, without any API path"));
|
||||||
|
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Information,
|
||||||
|
tr("No test done yet."),
|
||||||
|
tr("Here, results of connection test are shown."));
|
||||||
|
m_ui.m_lblLimitMessages->setText(
|
||||||
|
tr("Limiting number of downloaded messages per feed makes updating of feeds faster but if your feed contains "
|
||||||
|
"bigger number of messages than specified limit, then some messages might not be downloaded during feed update."));
|
||||||
|
|
||||||
|
connect(m_ui.m_spinLimitMessages, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, [=](int value) {
|
||||||
|
if (value <= 0) {
|
||||||
|
m_ui.m_spinLimitMessages->setSuffix(QSL(" ") + tr("= unlimited"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui.m_spinLimitMessages->setSuffix(QSL(" ") + tr("messages"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
GuiUtilities::setLabelAsNotice(*m_ui.m_lblLimitMessages, false);
|
||||||
|
GuiUtilities::setLabelAsNotice(*m_ui.m_lblServerSideUpdateInformation, false);
|
||||||
|
|
||||||
|
connect(m_ui.m_checkShowPassword, &QCheckBox::toggled, this, &OwnCloudAccountDetails::displayPassword);
|
||||||
|
connect(m_ui.m_txtPassword->lineEdit(), &BaseLineEdit::textChanged, this, &OwnCloudAccountDetails::onPasswordChanged);
|
||||||
|
connect(m_ui.m_txtUsername->lineEdit(), &BaseLineEdit::textChanged, this, &OwnCloudAccountDetails::onUsernameChanged);
|
||||||
|
connect(m_ui.m_txtUrl->lineEdit(), &BaseLineEdit::textChanged, this, &OwnCloudAccountDetails::onUrlChanged);
|
||||||
|
connect(m_ui.m_btnTestSetup, &QPushButton::clicked, this, &OwnCloudAccountDetails::performTest);
|
||||||
|
|
||||||
|
setTabOrder(m_ui.m_txtUrl->lineEdit(), m_ui.m_checkDownloadOnlyUnreadMessages);
|
||||||
|
setTabOrder(m_ui.m_checkDownloadOnlyUnreadMessages, m_ui.m_checkServerSideUpdate);
|
||||||
|
setTabOrder(m_ui.m_checkServerSideUpdate, m_ui.m_spinLimitMessages);
|
||||||
|
setTabOrder(m_ui.m_spinLimitMessages, m_ui.m_txtUsername->lineEdit());
|
||||||
|
setTabOrder(m_ui.m_txtUsername->lineEdit(), m_ui.m_txtPassword->lineEdit());
|
||||||
|
setTabOrder(m_ui.m_txtPassword->lineEdit(), m_ui.m_checkShowPassword);
|
||||||
|
setTabOrder(m_ui.m_checkShowPassword, m_ui.m_btnTestSetup);
|
||||||
|
|
||||||
|
onPasswordChanged();
|
||||||
|
onUsernameChanged();
|
||||||
|
onUrlChanged();
|
||||||
|
displayPassword(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OwnCloudAccountDetails::displayPassword(bool display) {
|
||||||
|
m_ui.m_txtPassword->lineEdit()->setEchoMode(display ? QLineEdit::Normal : QLineEdit::Password);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OwnCloudAccountDetails::performTest() {
|
||||||
|
OwnCloudNetworkFactory factory;
|
||||||
|
|
||||||
|
factory.setAuthUsername(m_ui.m_txtUsername->lineEdit()->text());
|
||||||
|
factory.setAuthPassword(m_ui.m_txtPassword->lineEdit()->text());
|
||||||
|
factory.setUrl(m_ui.m_txtUrl->lineEdit()->text());
|
||||||
|
factory.setForceServerSideUpdate(m_ui.m_checkServerSideUpdate->isChecked());
|
||||||
|
|
||||||
|
OwnCloudStatusResponse result = factory.status();
|
||||||
|
|
||||||
|
if (result.networkError() != QNetworkReply::NetworkError::NoError) {
|
||||||
|
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
|
||||||
|
tr("Network error: '%1'.").arg(NetworkFactory::networkErrorText(result.networkError())),
|
||||||
|
tr("Network error, have you entered correct Nextcloud endpoint and password?"));
|
||||||
|
}
|
||||||
|
else if (result.isLoaded()) {
|
||||||
|
if (!SystemFactory::isVersionEqualOrNewer(result.version(), OWNCLOUD_MIN_VERSION)) {
|
||||||
|
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
|
||||||
|
tr("Installed version: %1, required at least: %2.").arg(result.version(), OWNCLOUD_MIN_VERSION),
|
||||||
|
tr("Selected Nextcloud News server is running unsupported version."));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Ok,
|
||||||
|
tr("Installed version: %1, required at least: %2.").arg(result.version(), OWNCLOUD_MIN_VERSION),
|
||||||
|
tr("Nextcloud News server is okay."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
|
||||||
|
tr("Unspecified error, did you enter correct URL?"),
|
||||||
|
tr("Unspecified error, did you enter correct URL?"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OwnCloudAccountDetails::onUsernameChanged() {
|
||||||
|
const QString username = m_ui.m_txtUsername->lineEdit()->text();
|
||||||
|
|
||||||
|
if (username.isEmpty()) {
|
||||||
|
m_ui.m_txtUsername->setStatus(WidgetWithStatus::StatusType::Error, tr("Username cannot be empty."));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui.m_txtUsername->setStatus(WidgetWithStatus::StatusType::Ok, tr("Username is okay."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OwnCloudAccountDetails::onPasswordChanged() {
|
||||||
|
const QString password = m_ui.m_txtPassword->lineEdit()->text();
|
||||||
|
|
||||||
|
if (password.isEmpty()) {
|
||||||
|
m_ui.m_txtPassword->setStatus(WidgetWithStatus::StatusType::Error, tr("Password cannot be empty."));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui.m_txtPassword->setStatus(WidgetWithStatus::StatusType::Ok, tr("Password is okay."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OwnCloudAccountDetails::onUrlChanged() {
|
||||||
|
const QString url = m_ui.m_txtUrl->lineEdit()->text();
|
||||||
|
|
||||||
|
if (url.isEmpty()) {
|
||||||
|
m_ui.m_txtUrl->setStatus(WidgetWithStatus::StatusType::Error, tr("URL cannot be empty."));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ui.m_txtUrl->setStatus(WidgetWithStatus::StatusType::Ok, tr("URL is okay."));
|
||||||
|
}
|
||||||
|
}
|
29
src/librssguard/services/owncloud/gui/owncloudaccountdetails.h
Executable file
29
src/librssguard/services/owncloud/gui/owncloudaccountdetails.h
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#ifndef OWNCLOUDACCOUNTDETAILS_H
|
||||||
|
#define OWNCLOUDACCOUNTDETAILS_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "ui_owncloudaccountdetails.h"
|
||||||
|
|
||||||
|
class OwnCloudAccountDetails : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
friend class FormEditOwnCloudAccount;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit OwnCloudAccountDetails(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void displayPassword(bool display);
|
||||||
|
void performTest();
|
||||||
|
void onUsernameChanged();
|
||||||
|
void onPasswordChanged();
|
||||||
|
void onUrlChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::OwnCloudAccountDetails m_ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OWNCLOUDACCOUNTDETAILS_H
|
213
src/librssguard/services/owncloud/gui/owncloudaccountdetails.ui
Executable file
213
src/librssguard/services/owncloud/gui/owncloudaccountdetails.ui
Executable file
|
@ -0,0 +1,213 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>OwnCloudAccountDetails</class>
|
||||||
|
<widget class="QWidget" name="OwnCloudAccountDetails">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>430</width>
|
||||||
|
<height>312</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QCheckBox" name="m_checkDownloadOnlyUnreadMessages">
|
||||||
|
<property name="text">
|
||||||
|
<string>Download only unread messages</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="m_checkServerSideUpdate">
|
||||||
|
<property name="text">
|
||||||
|
<string>Force execution of server-side update when updating feeds from RSS Guard</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Limit number of downloaded messages per feed</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>m_spinLimitMessages</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QSpinBox" name="m_spinLimitMessages">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>140</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string> = unlimited</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>-1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>1000</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>-1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="m_lblTitle">
|
||||||
|
<property name="text">
|
||||||
|
<string>URL</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>m_txtUrl</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="LineEditWithStatus" name="m_txtUrl" native="true"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="6" 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>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QCheckBox" name="m_checkShowPassword">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show password</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0" colspan="2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="m_btnTestSetup">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Test setup</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<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 row="8" column="0" colspan="2">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>409</width>
|
||||||
|
<height>35</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="m_lblLimitMessages">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="m_lblServerSideUpdateInformation">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</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_checkDownloadOnlyUnreadMessages</tabstop>
|
||||||
|
<tabstop>m_checkServerSideUpdate</tabstop>
|
||||||
|
<tabstop>m_spinLimitMessages</tabstop>
|
||||||
|
<tabstop>m_checkShowPassword</tabstop>
|
||||||
|
<tabstop>m_btnTestSetup</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Loading…
Add table
Reference in a new issue