Libksieve

sievehelpbutton.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 #include "sievehelpbutton.h"
7 
8 #include <KIO/JobUiDelegate>
9 #include <KIO/OpenUrlJob>
10 #include <KLocalizedString>
11 #include <QIcon>
12 #include <QWhatsThis>
13 #include <QWhatsThisClickedEvent>
14 
15 using namespace KSieveUi;
16 SieveHelpButton::SieveHelpButton(QWidget *parent)
17  : QToolButton(parent)
18 {
19  setToolTip(i18n("Help"));
20  setIcon(QIcon::fromTheme(QStringLiteral("help-hint")));
21 }
22 
23 SieveHelpButton::~SieveHelpButton()
24 {
25 }
26 
27 bool SieveHelpButton::event(QEvent *event)
28 {
29  if (event->type() == QEvent::WhatsThisClicked) {
30  auto clicked = static_cast<QWhatsThisClickedEvent *>(event);
31  auto job = new KIO::OpenUrlJob(QUrl(clicked->href()));
32  job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
33  job->start();
34  return true;
35  }
36  return QToolButton::event(event);
37 }
WhatsThisClicked
QEvent::Type type() const const
virtual bool event(QEvent *event) override
QString i18n(const char *text, const TYPE &arg...)
QIcon fromTheme(const QString &name)
void setToolTip(const QString &)
virtual bool event(QEvent *event) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Apr 16 2021 23:09:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.