Messagelib

quicksearchwarning.cpp
1/*
2 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "quicksearchwarning.h"
8#include "messagelistsettings.h"
9#include <KLocalizedString>
10#include <QAction>
11using namespace MessageList::Core;
12
13QuickSearchWarning::QuickSearchWarning(QWidget *parent)
14 : KMessageWidget(parent)
15{
16 setVisible(false);
17 setCloseButtonVisible(true);
18 setMessageType(Warning);
19 setWordWrap(true);
20 setPosition(KMessageWidget::Header);
21 setText(i18n("The words less than 3 letters are ignored."));
22 auto action = new QAction(i18nc("@action", "Do not show again"), this);
23 action->setObjectName(QLatin1StringView("donotshowagain"));
24 connect(action, &QAction::triggered, this, &QuickSearchWarning::slotDoNotRememberIt);
25 addAction(action);
26}
27
28QuickSearchWarning::~QuickSearchWarning() = default;
29
30void QuickSearchWarning::setSearchText(const QString &text)
31{
32 if (!MessageList::MessageListSettings::quickSearchWarningDoNotShowAgain()) {
34 bool foundLessThanThreeCharacters = false;
35 for (const QStringView splitText : lstText) {
36 if (splitText.trimmed().size() < 3) {
37 foundLessThanThreeCharacters = true;
38 break;
39 }
40 }
41 if (foundLessThanThreeCharacters) {
43 } else {
45 }
46 }
47}
48
49void QuickSearchWarning::slotDoNotRememberIt()
50{
51 MessageList::MessageListSettings::setQuickSearchWarningDoNotShowAgain(true);
53}
54
55#include "moc_quicksearchwarning.cpp"
void animatedHide()
QString text() const
void animatedShow()
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
The implementation independent part of the MessageList library.
Definition aggregation.h:22
void triggered(bool checked)
QList< QStringView > split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
SkipEmptyParts
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.