Commit b255eea7 authored by Laurent Montel's avatar Laurent Montel 😁

Add abstractselectemail class

parent 4a82b38b
......@@ -202,6 +202,7 @@ set(ksieveui_widgets_SRCS
widgets/managesievewidget.cpp
widgets/abstractmoveimapfolderwidget.cpp
widgets/abstractregexpeditorlineedit.cpp
widgets/abstractselectemaillineedit.cpp
widgets/lineeditvalidator.cpp
widgets/includefilelineedit.cpp
widgets/moveimapfolderwidget.cpp
......@@ -334,6 +335,7 @@ ecm_generate_headers(ksieveui_Camelcasewidgets_HEADERS
ManageSieveTreeView
AbstractMoveImapFolderWidget
AbstractRegexpEditorLineEdit
AbstractSelectEmailLineEdit
REQUIRED_HEADERS ksieveui_widgets_HEADERS
PREFIX KSieveUi
RELATIVE widgets
......
......@@ -69,7 +69,7 @@ bool SieveActionRedirect::setParamWidgetValue(QXmlStreamReader &element, QWidget
while (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("str")) {
QLineEdit *edit = w->findChild<AddressLineEdit *>(QStringLiteral("RedirectEdit"));
AddressLineEdit *edit = w->findChild<AddressLineEdit *>(QStringLiteral("RedirectEdit"));
const QString tagValue = element.readElementText();
edit->setText(AutoCreateScriptUtil::quoteStr(tagValue));
} else if (tagName == QLatin1String("tag")) {
......@@ -110,7 +110,7 @@ bool SieveActionRedirect::setParamWidgetValue(QXmlStreamReader &element, QWidget
QString SieveActionRedirect::code(QWidget *w) const
{
QString result = QStringLiteral("redirect ");
const QLineEdit *edit = w->findChild<AddressLineEdit *>(QStringLiteral("RedirectEdit"));
const AddressLineEdit *edit = w->findChild<AddressLineEdit *>(QStringLiteral("RedirectEdit"));
const QString text = edit->text();
if (mHasCopySupport) {
......
......@@ -19,15 +19,20 @@
#include "addresslineedit.h"
#include <KLocalizedString>
#include <KColorScheme>
#include <QHBoxLayout>
using namespace KSieveUi;
AddressLineEdit::AddressLineEdit(QWidget *parent)
: QLineEdit(parent)
: AbstractSelectEmailLineEdit(parent)
{
setClearButtonEnabled(true);
setPlaceholderText(i18n("Define Email Address..."));
connect(this, &AddressLineEdit::textChanged, this, &AddressLineEdit::slotTextChanged);
QHBoxLayout *mainLayout = new QHBoxLayout(this);
mainLayout->setMargin(0);
mLineEdit = new QLineEdit(this);
mainLayout->addWidget(mLineEdit);
mLineEdit->setClearButtonEnabled(true);
mLineEdit->setPlaceholderText(i18n("Define Email Address..."));
connect(mLineEdit, &QLineEdit::textChanged, this, &AddressLineEdit::slotTextChanged);
}
AddressLineEdit::~AddressLineEdit()
......@@ -57,12 +62,23 @@ void AddressLineEdit::verifyAddress()
styleSheet = mNegativeBackground;
}
}
setStyleSheet(styleSheet);
mLineEdit->setStyleSheet(styleSheet);
#endif
}
void AddressLineEdit::focusOutEvent(QFocusEvent *ev)
{
verifyAddress();
QLineEdit::focusOutEvent(ev);
AbstractSelectEmailLineEdit::focusOutEvent(ev);
}
void KSieveUi::AddressLineEdit::setText(const QString &str)
{
mLineEdit->setText(str);
}
QString KSieveUi::AddressLineEdit::text() const
{
return mLineEdit->text();
}
......@@ -20,15 +20,18 @@
#define ADDRESSLINEEDIT_H
#include <QLineEdit>
#include <KSieveUi/AbstractSelectEmailLineEdit>
namespace KSieveUi {
class AddressLineEdit : public QLineEdit
class AddressLineEdit : public AbstractSelectEmailLineEdit
{
Q_OBJECT
public:
explicit AddressLineEdit(QWidget *parent = nullptr);
~AddressLineEdit() override;
void setText(const QString &str) override;
QString text() const override;
Q_SIGNALS:
void valueChanged();
......@@ -38,6 +41,7 @@ protected:
private:
void slotTextChanged();
void verifyAddress();
QLineEdit *mLineEdit = nullptr;
QString mNegativeBackground;
bool mIncorrectEmail = false;
};
......
/*
Copyright (C) 2018 Laurent Montel <montel@kde.org>
This program 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 2 of the License, or (at your option) any later version.
This program 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 this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "abstractselectemaillineedit.h"
using namespace KSieveUi;
AbstractSelectEmailLineEdit::AbstractSelectEmailLineEdit(QWidget *parent)
: QWidget(parent)
{
}
AbstractSelectEmailLineEdit::~AbstractSelectEmailLineEdit()
{
}
/*
Copyright (C) 2018 Laurent Montel <montel@kde.org>
This program 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 2 of the License, or (at your option) any later version.
This program 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 this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef ABSTRACTSELECTEMAILLINEEDIT_H
#define ABSTRACTSELECTEMAILLINEEDIT_H
#include <QWidget>
#include "ksieveui_export.h"
namespace KSieveUi
{
class KSIEVEUI_EXPORT AbstractSelectEmailLineEdit : public QWidget
{
Q_OBJECT
public:
explicit AbstractSelectEmailLineEdit(QWidget *parent = nullptr);
~AbstractSelectEmailLineEdit();
virtual void setText(const QString &str) = 0;
virtual QString text() const = 0;
};
}
#endif // ABSTRACTSELECTEMAILLINEEDIT_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment