Messagelib

filtersavedmenu.cpp
1 /*
2  SPDX-FileCopyrightText: 2021-2022 Laurent Montel <[email protected]>
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>
12 using namespace MessageList::Core;
13 
14 FilterSavedMenu::FilterSavedMenu(QWidget *parent)
15  : QMenu(parent)
16  , mSaveAction(new QAction(QIcon::fromTheme(QStringLiteral("document-save-as")), i18n("Save Filter..."), this))
17  , mConfigureAction(new QAction(QIcon::fromTheme(QStringLiteral("settings-configure")), i18n("Configure..."), this))
18 {
19  connect(this, &FilterSavedMenu::aboutToShow, this, &FilterSavedMenu::slotShowMenu);
20 }
21 
22 FilterSavedMenu::~FilterSavedMenu() = default;
23 
24 void 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()) {
36  addSeparator();
37  }
38  addAction(mSaveAction);
39  addSeparator();
40  addAction(mConfigureAction);
41  connect(mSaveAction, &QAction::triggered, this, &FilterSavedMenu::saveFilter);
42  connect(mConfigureAction, &QAction::triggered, this, &FilterSavedMenu::configureFilters);
43 }
KGuiItem clear()
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString i18n(const char *text, const TYPE &arg...)
void triggered(bool checked)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue May 17 2022 04:00:04 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.