Commit 20b0a45c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Transform as singleton

parent c13f5caa
......@@ -19,6 +19,12 @@ FilterSavedManager::~FilterSavedManager()
{
}
FilterSavedManager *FilterSavedManager::self()
{
static FilterSavedManager s_self;
return &s_self;
}
void FilterSavedManager::saveFilter(MessageList::Core::Filter *filter, const QString &filtername)
{
filter->save(KSharedConfig::openConfig(), filtername);
......
......@@ -21,6 +21,9 @@ public:
void saveFilter(MessageList::Core::Filter *filter, const QString &filtername);
void loadMenu(QMenu *menu);
static FilterSavedManager *self();
Q_SIGNALS:
void activateFilter(const QString &identifier);
};
......
......@@ -15,7 +15,6 @@ FilterSavedMenu::FilterSavedMenu(QWidget *parent)
: QMenu(parent)
, mSaveAction(new QAction(QIcon::fromTheme(QStringLiteral("document-save-as")), i18n("Save Filter..."), this))
, mConfigureAction(new QAction(i18n("Configure..."), this))
, mFilterSaveManager(new FilterSavedManager(this))
{
connect(this, &FilterSavedMenu::aboutToShow, this, &FilterSavedMenu::slotShowMenu);
connect(mSaveAction, &QAction::triggered, this, &FilterSavedMenu::saveFilter);
......@@ -30,6 +29,7 @@ void FilterSavedMenu::slotShowMenu()
{
// TODO load current Filter saved action
mListAction.clear();
FilterSavedManager::self()->loadMenu(this);
if (isEmpty()) {
addSeparator();
addAction(mSaveAction);
......
......@@ -14,7 +14,6 @@ namespace MessageList
{
namespace Core
{
class FilterSavedManager;
class MESSAGELIST_TESTS_EXPORT FilterSavedMenu : public QMenu
{
Q_OBJECT
......@@ -32,7 +31,6 @@ private:
QAction *const mSaveAction;
QAction *const mConfigureAction;
QList<QAction *> mListAction;
FilterSavedManager *const mFilterSaveManager;
};
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment