Messagelib

filtersavedmenu.cpp
1/*
2 SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "filtersavedmenu.h"
8#include "core/filtersavedmanager.h"
9#include <KLocalizedString>
10#include <QAction>
11#include <QIcon>
12using namespace MessageList::Core;
13
14FilterSavedMenu::FilterSavedMenu(QWidget *parent)
15 : QMenu(parent)
16 , mSaveAction(new QAction(QIcon::fromTheme(QStringLiteral("document-save-as")), i18nc("@action", "Save Filter..."), this))
17 , mConfigureAction(new QAction(QIcon::fromTheme(QStringLiteral("settings-configure")), i18nc("@action", "Configure..."), this))
18{
19 connect(this, &FilterSavedMenu::aboutToShow, this, &FilterSavedMenu::slotShowMenu);
20}
21
22FilterSavedMenu::~FilterSavedMenu() = default;
23
24void FilterSavedMenu::slotShowMenu()
25{
26 for (auto act : std::as_const(mListAction)) {
27 removeAction(act);
28 }
29 qDeleteAll(mListAction);
30 mListAction.clear();
31 removeAction(mSaveAction);
32 removeAction(mConfigureAction);
33 clear();
34 FilterSavedManager::self()->loadMenu(this);
35 if (!isEmpty()) {
37 }
38 addAction(mSaveAction);
40 addAction(mConfigureAction);
41 connect(mSaveAction, &QAction::triggered, this, &FilterSavedMenu::saveFilter);
42 connect(mConfigureAction, &QAction::triggered, this, &FilterSavedMenu::configureFilters);
43}
44
45#include "moc_filtersavedmenu.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
The implementation independent part of the MessageList library.
Definition aggregation.h:22
void triggered(bool checked)
void clear()
QAction * addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut)
QAction * addSeparator()
void clear()
bool isEmpty() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void removeAction(QAction *action)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:08:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.