11#include "editor/widgets/preferredlineeditwidget.h"
12#include "webselecttypecombobox.h"
13#include <KLocalizedString>
19WebWidget::WebWidget(
QWidget *parent)
21 , mWebSiteEdit(new PreferredLineEditWidget(this))
24 , mWebType(new
Akonadi::WebSelectTypeCombobox(this))
27 layout->setSpacing(0);
28 layout->setContentsMargins({});
30 mWebSiteEdit->setTrapReturnKey(
true);
31 mWebSiteEdit->setPlaceholderText(
i18nc(
"@info:placeholder",
"Add a Web Site"));
33 layout->addWidget(mWebSiteEdit);
34 connect(mWebSiteEdit, &PreferredLineEditWidget::preferredChanged,
this, &WebWidget::slotPreferredChanged);
37 layout->addWidget(mWebType);
41 mAddButton->setToolTip(
i18nc(
"@info:tooltip",
"Add a Web Site"));
43 layout->addWidget(mAddButton);
47 mRemoveButton->setToolTip(
i18nc(
"@info:tooltip",
"Remove Web Site"));
49 layout->addWidget(mRemoveButton);
52WebWidget::~WebWidget() =
default;
54void WebWidget::clearWidget()
56 mWebSiteEdit->clear();
57 mWebType->setCurrentIndex(0);
60void WebWidget::updateAddRemoveButton(
bool addButtonEnabled)
62 mAddButton->setEnabled(addButtonEnabled);
65void WebWidget::slotAddWeb()
70void WebWidget::slotRemoveWeb()
75void WebWidget::setPreferred(
bool b)
77 mWebSiteEdit->setPreferred(b);
80KContacts::ResourceLocatorUrl WebWidget::url()
82 mUrl.setUrl(QUrl(mWebSiteEdit->text().trimmed()));
83 mUrl.setPreferred(mWebSiteEdit->preferred());
88void WebWidget::loadWebSite(
const KContacts::ResourceLocatorUrl &url)
91 setPreferred(url.isPreferred());
92 mWebType->setCurrentIndex(mWebType->findData((
int)url.type()));
93 mWebSiteEdit->setText(mUrl.url().toDisplayString());
96void WebWidget::setReadOnly(
bool readOnly)
98 mWebSiteEdit->setReadOnly(readOnly);
99 mAddButton->setEnabled(!readOnly);
100 mRemoveButton->setEnabled(!readOnly);
101 mWebType->setEnabled(!readOnly);
104void WebWidget::slotPreferredChanged()
106 Q_EMIT preferredChanged(
this);
109#include "moc_webwidget.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
A widget for editing the display name of a contact.
QIcon fromTheme(const QString &name)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)