This commit is contained in:
Martin Rotter 2020-11-30 12:51:31 +01:00
parent 74c583413e
commit db92b9d27b
7 changed files with 42 additions and 56 deletions

View File

@ -53,13 +53,6 @@ void DynamicShortcutsWidget::populate(QList<QAction*> actions) {
});
int row_id = 0;
// FIXME: Maybe separate actions into "categories". Each category will start with label.
// I will assign each QAaction a property called "category" with some enum value.
// Like:
// File, FeedsCategories, Messages, Tools, WebBrowser, Help
// This will be setup in FormMain::allActions().
// Then here I will process actions into categories.
for (QAction* action : actions) {
// Create shortcut catcher for this action and set default shortcut.
auto* catcher = new ShortcutCatcher(this);

View File

@ -49,7 +49,6 @@ bool FormAddEditLabel::execForEdit(Label* lbl) {
auto exit_code = exec();
if (exit_code == QDialog::DialogCode::Accepted) {
// TODO: Place server-side changes perhaps to here?
m_editableLabel->setColor(m_ui.m_btnColor->color());
m_editableLabel->setTitle(m_ui.m_txtName->lineEdit()->text());
return true;

View File

@ -5,6 +5,7 @@
#include "core/feedsmodel.h"
#include "definitions/definitions.h"
#include "gui/baselineedit.h"
#include "gui/guiutilities.h"
#include "gui/messagebox.h"
#include "gui/systemtrayicon.h"
#include "miscellaneous/iconfactory.h"
@ -22,17 +23,13 @@
#include <QTextCodec>
FormFeedDetails::FormFeedDetails(ServiceRoot* service_root, QWidget* parent)
: QDialog(parent),
m_editableFeed(nullptr),
m_serviceRoot(service_root) {
: QDialog(parent), m_editableFeed(nullptr), m_serviceRoot(service_root) {
initialize();
createConnections();
}
int FormFeedDetails::editBaseFeed(Feed* input_feed) {
setEditableFeed(input_feed);
// Run the dialog.
return QDialog::exec();
}
@ -53,9 +50,6 @@ void FormFeedDetails::apply() {
new_feed.setAutoUpdateInitialInterval(int(m_ui->m_spinAutoUpdateInterval->value()));
if (m_editableFeed != nullptr) {
// NOTE: Co s tim?
//new_feed->setParent(m_editableFeed->parent());
// Edit the feed.
bool edited = m_editableFeed->editItself(&new_feed);
@ -92,7 +86,7 @@ void FormFeedDetails::createConnections() {
}
void FormFeedDetails::setEditableFeed(Feed* editable_feed) {
setWindowTitle(tr("Edit feed '%1'").arg(editable_feed->title()));
setWindowTitle(tr("Edit '%1'").arg(editable_feed->title()));
m_editableFeed = editable_feed;
@ -105,8 +99,7 @@ void FormFeedDetails::initialize() {
m_ui->setupUi(this);
// Set flags and attributes.
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint);
setWindowIcon(qApp->icons()->fromTheme(QSL("application-rss+xml")));
GuiUtilities::applyDialogProperties(*this, qApp->icons()->fromTheme(QSL("application-rss+xml")));
// Setup auto-update options.
m_ui->m_spinAutoUpdateInterval->setValue(DEFAULT_AUTO_UPDATE_INTERVAL);

View File

@ -3,45 +3,45 @@
#include "services/standard/gui/authenticationdetails.h"
AuthenticationDetails::AuthenticationDetails(QWidget* parent) : QWidget(parent) {
ui.setupUi(this);
m_ui.setupUi(this);
// Set text boxes.
ui.m_txtUsername->lineEdit()->setPlaceholderText(tr("Username"));
ui.m_txtUsername->lineEdit()->setToolTip(tr("Set username to access the feed."));
ui.m_txtPassword->lineEdit()->setPlaceholderText(tr("Password"));
ui.m_txtPassword->lineEdit()->setToolTip(tr("Set password to access the feed."));
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(ui.m_txtUsername->lineEdit(), &BaseLineEdit::textChanged, this, &AuthenticationDetails::onUsernameChanged);
connect(ui.m_txtPassword->lineEdit(), &BaseLineEdit::textChanged, this, &AuthenticationDetails::onPasswordChanged);
connect(ui.m_gbAuthentication, &QGroupBox::toggled, this, &AuthenticationDetails::onAuthenticationSwitched);
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 = !ui.m_gbAuthentication->isChecked() || !new_username.simplified().isEmpty();
bool is_username_ok = !m_ui.m_gbAuthentication->isChecked() || !new_username.simplified().isEmpty();
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."));
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 = !ui.m_gbAuthentication->isChecked() || !new_password.simplified().isEmpty();
bool is_password_ok = !m_ui.m_gbAuthentication->isChecked() || !new_password.simplified().isEmpty();
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."));
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(ui.m_txtUsername->lineEdit()->text());
onPasswordChanged(ui.m_txtPassword->lineEdit()->text());
onUsernameChanged(m_ui.m_txtUsername->lineEdit()->text());
onPasswordChanged(m_ui.m_txtPassword->lineEdit()->text());
}

View File

@ -21,7 +21,7 @@ class AuthenticationDetails : public QWidget {
void onAuthenticationSwitched();
private:
Ui::AuthenticationDetails ui;
Ui::AuthenticationDetails m_ui;
};
#endif // AUTHENTICATIONDETAILS_H

View File

@ -25,7 +25,7 @@ FormStandardFeedDetails::FormStandardFeedDetails(ServiceRoot* service_root, QWid
connect(m_standardFeedDetails->m_actionFetchIcon, &QAction::triggered, this, &FormStandardFeedDetails::guessIconOnly);
}
int FormStandardFeedDetails::addEditFeed(Feed* input_feed, RootItem* parent_to_select, const QString& url) {
int FormStandardFeedDetails::addEditFeed(StandardFeed* input_feed, RootItem* parent_to_select, const QString& url) {
// Load categories.
m_standardFeedDetails->loadCategories(m_serviceRoot->getSubTreeCategories(), m_serviceRoot);
@ -44,14 +44,14 @@ int FormStandardFeedDetails::addEditFeed(Feed* input_feed, RootItem* parent_to_s
void FormStandardFeedDetails::guessFeed() {
m_standardFeedDetails->guessFeed(m_standardFeedDetails->ui.m_txtUrl->lineEdit()->text(),
m_authDetails->ui.m_txtUsername->lineEdit()->text(),
m_authDetails->ui.m_txtPassword->lineEdit()->text());
m_authDetails->m_ui.m_txtUsername->lineEdit()->text(),
m_authDetails->m_ui.m_txtPassword->lineEdit()->text());
}
void FormStandardFeedDetails::guessIconOnly() {
m_standardFeedDetails->guessIconOnly(m_standardFeedDetails->ui.m_txtUrl->lineEdit()->text(),
m_authDetails->ui.m_txtUsername->lineEdit()->text(),
m_authDetails->ui.m_txtPassword->lineEdit()->text());
m_authDetails->m_ui.m_txtUsername->lineEdit()->text(),
m_authDetails->m_ui.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->ui.m_gbAuthentication->isChecked());
new_feed->setUsername(m_authDetails->ui.m_txtUsername->lineEdit()->text());
new_feed->setPassword(m_authDetails->ui.m_txtPassword->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->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->ui.m_gbAuthentication->setChecked(editable_feed->passwordProtected());
m_authDetails->ui.m_txtUsername->lineEdit()->setText(editable_feed->username());
m_authDetails->ui.m_txtPassword->lineEdit()->setText(editable_feed->password());
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());
}

View File

@ -7,6 +7,7 @@
class StandardFeedDetails;
class AuthenticationDetails;
class StandardFeed;
class FormStandardFeedDetails : public FormFeedDetails {
Q_OBJECT
@ -15,7 +16,7 @@ class FormStandardFeedDetails : public FormFeedDetails {
explicit FormStandardFeedDetails(ServiceRoot* service_root, QWidget* parent = nullptr);
public slots:
int addEditFeed(Feed* input_feed, RootItem* parent_to_select, const QString& url = QString());
int addEditFeed(StandardFeed* input_feed, RootItem* parent_to_select, const QString& url = QString());
private slots:
void guessFeed();