Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit f4134855 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Port the NewMailNotifier agent to new configuration API

parent 612b4135
......@@ -5,27 +5,25 @@ add_definitions(-DTRANSLATION_DOMAIN=\"akonadi_newmailnotifier_agent\")
add_definitions( -DQT_NO_CAST_FROM_ASCII )
add_definitions( -DQT_NO_CAST_TO_ASCII )
set(newmailnotifier_common_SRCS)
kconfig_add_kcfg_files(newmailnotifier_common_SRCS
newmailnotifieragentsettings.kcfgc
)
ecm_qt_declare_logging_category(newmailnotifier_common_SRCS HEADER newmailnotifier_debug.h IDENTIFIER NEWMAILNOTIFIER_LOG CATEGORY_NAME org.kde.pim.newmailnotifier)
set(newmailnotifieragent_SRCS
newmailnotifiersettingsdialog.cpp
newmailnotifieragent.cpp
specialnotifierjob.cpp
newmailnotifierselectcollectionwidget.cpp
newmailnotifiershowmessagejob.cpp
${newmailnotifier_common_SRCS}
)
ecm_qt_declare_logging_category(newmailnotifieragent_SRCS HEADER newmailnotifier_debug.h IDENTIFIER NEWMAILNOTIFIER_LOG CATEGORY_NAME org.kde.pim.newmailnotifier)
kconfig_add_kcfg_files(newmailnotifieragent_SRCS
newmailnotifieragentsettings.kcfgc
)
qt5_add_dbus_adaptor(newmailnotifieragent_SRCS org.freedesktop.Akonadi.NewMailNotifier.xml newmailnotifieragent.h NewMailNotifierAgent)
add_executable( akonadi_newmailnotifier_agent ${newmailnotifieragent_SRCS})
target_link_libraries( akonadi_newmailnotifier_agent
KF5::AkonadiCore
KF5::Mime
......@@ -33,13 +31,9 @@ target_link_libraries( akonadi_newmailnotifier_agent
KF5::AkonadiContact
KF5::Codecs
KF5::IdentityManagement
KF5::NotifyConfig
KF5::AkonadiAgentBase
KF5::DBusAddons
KF5::XmlGui
KF5::Notifications
KF5::WindowSystem
KF5::Completion
KF5::Service
KF5::IconThemes
KF5::I18n
......@@ -65,3 +59,21 @@ install(TARGETS akonadi_newmailnotifier_agent ${KDE_INSTALL_TARGETS_DEFAULT_ARGS
install(FILES newmailnotifieragent.desktop DESTINATION "${KDE_INSTALL_DATAROOTDIR}/akonadi/agents")
install(FILES akonadi_newmailnotifier_agent.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFY5RCDIR} )
########################## Config plugin #################################
kcoreaddons_add_plugin(newmailnotifierconfig
SOURCES newmailnotifiersettingswidget.cpp
newmailnotifierselectcollectionwidget.cpp
${newmailnotifier_common_SRCS}
JSON "newmailnotifierconfig.json"
INSTALL_NAMESPACE "akonadi/config")
target_link_libraries(newmailnotifierconfig
KF5::AkonadiCore
Qt5::Widgets
KF5::NotifyConfig
KF5::ConfigGui
KF5::I18n
KF5::XmlGui
KF5::Mime
KF5::Completion
)
......@@ -45,7 +45,6 @@
#include <KLocalizedString>
#include <KMime/Message>
#include <KNotification>
#include <KWindowSystem>
#include <Kdelibs4ConfigMigrator>
#include "newmailnotifier_debug.h"
#include <KToolInvocation>
......@@ -237,21 +236,6 @@ void NewMailNotifierAgent::setShowButtonToDisplayMail(bool b)
NewMailNotifierAgentSettings::self()->save();
}
void NewMailNotifierAgent::showConfigureDialog(qlonglong windowId)
{
configure(windowId);
}
void NewMailNotifierAgent::configure(WId windowId)
{
QPointer<NewMailNotifierSettingsDialog> dialog = new NewMailNotifierSettingsDialog;
if (windowId) {
KWindowSystem::setMainWindow(dialog, windowId);
}
dialog->exec();
delete dialog;
}
bool NewMailNotifierAgent::excludeSpecialCollection(const Akonadi::Collection &collection) const
{
if (collection.hasAttribute<Akonadi::EntityHiddenAttribute>()) {
......
......@@ -47,8 +47,6 @@ class NewMailNotifierAgent : public Akonadi::AgentBase, public Akonadi::AgentBas
public:
explicit NewMailNotifierAgent(const QString &id);
void showConfigureDialog(qlonglong windowId = 0);
void setEnableAgent(bool b);
bool enabledAgent() const;
......@@ -91,9 +89,6 @@ protected:
void itemsFlagsChanged(const Akonadi::Item::List &items, const QSet<QByteArray> &addedFlags, const QSet<QByteArray> &removedFlags) override;
void doSetOnline(bool online) override;
private Q_SLOTS:
void configure(WId windowId) override;
private:
void slotShowNotifications();
void slotInstanceStatusChanged(const Akonadi::AgentInstance &instance);
......
......@@ -4,6 +4,7 @@
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<include>KLocalizedString</include>
<kcfgfile arg="true" />
<group name="General">
<entry name="verboseNotification" key="verboseNotification" type="Bool">
<default>true</default>
......
# Code generation options for kconfig_compiler
File=newmailnotifieragentsettings.kcfg
ClassName=NewMailNotifierAgentSettings
Singleton=true
Mutators=true
Singleton=true
{
"X-Akonadi-PluginType": "AgentConfig",
"X-Akonadi-Library": "newmailnotifierconfig",
"X-Akonadi-AgentConfig-Type": "akonadi_newmailnotifier_agent"
}
/*
Copyright (c) 2013-2018 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef NEWMAILNOTIFIERSETTINGSDIALOG_H
#define NEWMAILNOTIFIERSETTINGSDIALOG_H
#include <QDialog>
#include <Collection>
class KNotifyConfigWidget;
class QCheckBox;
class QLineEdit;
class NewMailNotifierSelectCollectionWidget;
class NewMailNotifierSettingsDialog : public QDialog
{
Q_OBJECT
public:
explicit NewMailNotifierSettingsDialog(QWidget *parent = nullptr);
~NewMailNotifierSettingsDialog();
private:
void slotOkClicked();
void slotHelpLinkClicked(const QString &);
void writeConfig();
void readConfig();
QCheckBox *mShowPhoto = nullptr;
QCheckBox *mShowFrom = nullptr;
QCheckBox *mShowSubject = nullptr;
QCheckBox *mShowFolders = nullptr;
QCheckBox *mExcludeMySelf = nullptr;
QCheckBox *mAllowToShowMail = nullptr;
QCheckBox *mKeepPersistentNotification = nullptr;
KNotifyConfigWidget *mNotify = nullptr;
QCheckBox *mTextToSpeak = nullptr;
QLineEdit *mTextToSpeakSetting = nullptr;
NewMailNotifierSelectCollectionWidget *mSelectCollection = nullptr;
};
#endif // NEWMAILNOTIFIERSETTINGSDIALOG_H
/*
Copyright (c) 2013-2018 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef NEWMAILNOTIFIERSETTINGSWIDGET_H
#define NEWMAILNOTIFIERSETTINGSWIDGET_H
#include <QDialog>
#include <AkonadiCore/Collection>
#include <AkonadiCore/AgentConfigurationBase>
class KNotifyConfigWidget;
class QCheckBox;
class QLineEdit;
class NewMailNotifierSelectCollectionWidget;
class NewMailNotifierSettingsWidget : public Akonadi::AgentConfigurationBase
{
Q_OBJECT
public:
explicit NewMailNotifierSettingsWidget(KSharedConfigPtr config, QWidget *parent, const QVariantList &args);
~NewMailNotifierSettingsWidget() override;
void load() override;
bool save() const override;
private Q_SLOTS:
void slotHelpLinkClicked(const QString &);
private:
QCheckBox *mShowPhoto = nullptr;
QCheckBox *mShowFrom = nullptr;
QCheckBox *mShowSubject = nullptr;
QCheckBox *mShowFolders = nullptr;
QCheckBox *mExcludeMySelf = nullptr;
QCheckBox *mAllowToShowMail = nullptr;
QCheckBox *mKeepPersistentNotification = nullptr;
KNotifyConfigWidget *mNotify = nullptr;
QCheckBox *mTextToSpeak = nullptr;
QLineEdit *mTextToSpeakSetting = nullptr;
NewMailNotifierSelectCollectionWidget *mSelectCollection = nullptr;
};
AKONADI_AGENTCONFIG_FACTORY(NewMailNotifierSettingsFactory, "newmailnotifierconfig.json", NewMailNotifierSettingsWidget)
#endif // NEWMAILNOTIFIERSETTINGSWIDGET_H
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.Akonadi.NewMailNotifier">
<method name="showConfigureDialog" >
<arg direction="in" type="x" name="windowId" />
</method>
<method name="setEnableAgent" >
<arg type="b" direction="in"/>
</method>
......
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