Commit 8704e084 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Move in korganizer directory

parent 2c1f717a
......@@ -4,6 +4,7 @@ add_definitions( -DQT_NO_CAST_FROM_ASCII )
add_definitions( -DQT_NO_CAST_TO_ASCII )
add_subdirectory(src)
add_subdirectory(korgac)
if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
......
project(korgac)
add_definitions(-DTRANSLATION_DOMAIN=\"korgac\")
add_definitions( -DQT_NO_CAST_FROM_ASCII )
add_definitions( -DQT_NO_CAST_TO_ASCII )
add_subdirectory(pixmaps)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
########### next target ###############
set(korgac_SRCS
koalarmclient.cpp
)
ecm_qt_declare_logging_category(korgac_SRCS HEADER koalarmclient_debug.h IDENTIFIER KOALARMCLIENT_LOG CATEGORY_NAME log_koalarmclient)
set(korgac_SRCS ${korgac_SRCS} korgacmain.cpp)
set(korgac_SRCS
${korgac_SRCS}
alarmdialog.cpp
alarmdockwindow.cpp
mailclient.cpp
)
set(korganizer_xml ../src/data/org.kde.korganizer.Korganizer.xml)
qt5_add_dbus_interface(korgac_SRCS ${korganizer_xml}
korganizer_interface
)
qt5_add_dbus_adaptor(korgac_SRCS org.kde.korganizer.KOrgac.xml koalarmclient.h
KOAlarmClient
)
file(GLOB ICONS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/pixmaps/*-apps-korgac.png")
ecm_add_app_icon(korgac_SRCS ICONS ${ICONS_SRCS})
add_executable(korgac ${korgac_SRCS})
if( APPLE )
set_target_properties(korgac PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/Info.plist.template
)
set_target_properties(korgac PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER "org.kde.pim.korgac"
)
set_target_properties(korgac PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "KOrganizer Reminder Client"
)
endif()
target_link_libraries(korgac
KF5::AkonadiCalendar
KF5::AkonadiMime
KF5::CalendarSupport
KF5::IncidenceEditor
KF5::AkonadiCore
KF5::CalendarCore
KF5::CalendarUtils
KF5::IdentityManagement
KF5::MailTransport
KF5::Codecs
KF5::DBusAddons
Phonon::phonon4qt5
)
install(TARGETS
korgac ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}
)
install(PROGRAMS
org.kde.korgac.desktop
DESTINATION ${KDE_INSTALL_AUTOSTARTDIR}
)
install(FILES
org.kde.korganizer.KOrgac.xml
DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR}
)
if ("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
endif()
// DOXYGEN_REFERENCES = kdecore kdeui
#! /bin/sh
$XGETTEXT `find . -name "*.cpp" -o -name "*.h" | grep -v '/tests/'` -o $podir/korgac.pot
This diff is collapsed.
/*
This file is part of the KDE reminder agent.
Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef KORGAC_ALARMDIALOG_H
#define KORGAC_ALARMDIALOG_H
#include <Akonadi/Calendar/ETMCalendar>
#include <Item>
#include <QDialog>
#include <KCalCore/Incidence>
#include <KDateTime>
#include <QPoint>
#include <QTimer>
namespace Akonadi
{
class Item;
}
namespace KIdentityManagement
{
class IdentityManager;
}
namespace CalendarSupport
{
class IncidenceViewer;
}
class ReminderTreeItem;
class KComboBox;
class QDateTime;
class QTreeWidget;
class QTreeWidgetItem;
class QSpinBox;
class AlarmDialog : public QDialog
{
Q_OBJECT
public:
explicit AlarmDialog(const Akonadi::ETMCalendar::Ptr &calendar, QWidget *parent = Q_NULLPTR);
~AlarmDialog();
void addIncidence(const Akonadi::Item &incidence, const QDateTime &reminderAt,
const QString &displayText);
void setRemindAt(const QDateTime &dt);
void eventNotification();
public Q_SLOTS:
void slotOk(); // suspend
void slotUser1(); // edit
void slotUser2(); // dismiss all
void slotUser3(); // dismiss selected
void slotSave();
void wakeUp();
void show();
void edit();
void suspend();
void suspendAll();
void dismissAll();
void dismissCurrent();
/*reimp*/
void accept() Q_DECL_OVERRIDE;
/**
If an incidence changed, for example in korg, we must update
the date and summary shown in the list view.
*/
void slotCalendarChanged();
Q_SIGNALS:
void reminderCount(int count);
private Q_SLOTS:
void update();
void updateButtons();
protected:
void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
void closeEvent(QCloseEvent *) Q_DECL_OVERRIDE;
private:
typedef QList<ReminderTreeItem *> ReminderList;
static KDateTime triggerDateForIncidence(const KCalCore::Incidence::Ptr &inc,
const QDateTime &reminderAt,
QString &displayStr);
// Removes each Incidence-X group that has one of the specified uids
void removeFromConfig(const QList<Akonadi::Item::Id> &);
// Opens through dbus, @deprecated
bool openIncidenceEditorThroughKOrganizer(const KCalCore::Incidence::Ptr &incidence);
// opens directly
bool openIncidenceEditorNG(const Akonadi::Item &incidence);
bool startKOrganizer();
ReminderTreeItem *searchByItem(const Akonadi::Item &incidence);
void setTimer();
void dismiss(ReminderList selections);
int activeCount();
ReminderList selectedItems() const;
void toggleDetails(QTreeWidgetItem *item);
void showDetails(QTreeWidgetItem *item);
Akonadi::ETMCalendar::Ptr mCalendar;
QTreeWidget *mIncidenceTree;
CalendarSupport::IncidenceViewer *mDetailView;
KIdentityManagement::IdentityManager *mIdentityManager;
QPoint mPos;
QSpinBox *mSuspendSpin;
KComboBox *mSuspendUnit;
QTimer mSuspendTimer;
QTreeWidgetItem *mLastItem;
QPushButton *mUser1Button;
QPushButton *mUser2Button;
QPushButton *mUser3Button;
QPushButton *mOkButton;
};
#endif
/*
This file is part of KOrganizer.
This file is part of the KDE reminder agent.
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
Copyright (c) 2008-2009 Allen Winter <winter@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include "alarmdockwindow.h"
#include <QAction>
#include <KActionCollection>
#include <KConfigGroup>
#include <KIconEffect>
#include <KIconLoader>
#include <KLocalizedString>
#include <KMessageBox>
#include <KStandardAction>
#include <KToolInvocation>
#include <KSharedConfig>
#include <QMenu>
#include "koalarmclient_debug.h"
AlarmDockWindow::AlarmDockWindow()
: KStatusNotifierItem(0)
{
// Read the autostart status from the config file
KConfigGroup config(KSharedConfig::openConfig(), "General");
const bool autostartSet = config.hasKey("Autostart");
const bool autostart = config.readEntry("Autostart", true);
const bool alarmsEnabled = config.readEntry("Enabled", true);
mName = i18nc("@title:window", "KOrganizer Reminder Daemon");
setToolTipTitle(mName);
setToolTipIconByName(QStringLiteral("korgac"));
// Set up icons
KIconLoader::global()->addAppDir(QStringLiteral("korgac"));
QString iconPath = KIconLoader::global()->iconPath(QStringLiteral("korgac"), KIconLoader::Panel);
QIcon iconEnabled = QIcon(iconPath);
if (iconEnabled.isNull()) {
KMessageBox::sorry(associatedWidget(),
i18nc("@info", "Cannot load system tray icon."));
} else {
KIconLoader loader;
QImage iconDisabled =
iconEnabled.pixmap(loader.currentSize(KIconLoader::Panel)).toImage();
KIconEffect::toGray(iconDisabled, 1.0);
mIconDisabled = QIcon(QPixmap::fromImage(iconDisabled));
}
changeSystrayIcon(alarmsEnabled);
// Set up the context menu
mSuspendAll =
contextMenu()->addAction(i18nc("@action:inmenu", "Suspend All Reminders"), this,
SLOT(slotSuspendAll()));
mDismissAll =
contextMenu()->addAction(i18nc("@action:inmenu", "Dismiss All Reminders"), this,
SLOT(slotDismissAll()));
mSuspendAll->setEnabled(false);
mDismissAll->setEnabled(false);
contextMenu()->addSeparator();
mAlarmsEnabled =
contextMenu()->addAction(i18nc("@action:inmenu", "Enable Reminders"));
connect(mAlarmsEnabled, &QAction::toggled, this, &AlarmDockWindow::toggleAlarmsEnabled);
mAlarmsEnabled->setCheckable(true);
mAutostart =
contextMenu()->addAction(i18nc("@action:inmenu", "Start Reminder Daemon at Login"));
connect(mAutostart, &QAction::toggled, this, &AlarmDockWindow::toggleAutostart);
mAutostart->setCheckable(true);
mAlarmsEnabled->setChecked(alarmsEnabled);
mAutostart->setChecked(autostart);
// Disable standard quit behaviour. We have to intercept the quit even,
// if the main window is hidden.
QAction *act = action(QStringLiteral("quit"));
if (act) {
act->disconnect(SIGNAL(triggered(bool)), this, SLOT(maybeQuit()));
connect(act, &QAction::triggered, this, &AlarmDockWindow::slotQuit);
} else {
qCDebug(KOALARMCLIENT_LOG) << "No Quit standard action.";
}
mAutostartSet = autostartSet;
}
AlarmDockWindow::~AlarmDockWindow()
{
}
void AlarmDockWindow::slotUpdate(int reminders)
{
const bool actif = (reminders > 0);
mSuspendAll->setEnabled(actif);
mDismissAll->setEnabled(actif);
if (actif) {
setToolTip(QStringLiteral("korgac"), mName, i18ncp("@info:status",
"There is 1 active reminder.",
"There are %1 active reminders.", reminders));
} else {
setToolTip(QStringLiteral("korgac"), mName, i18nc("@info:status", "No active reminders."));
}
}
void AlarmDockWindow::toggleAlarmsEnabled(bool checked)
{
changeSystrayIcon(checked);
KConfigGroup config(KSharedConfig::openConfig(), "General");
config.writeEntry("Enabled", checked);
config.sync();
}
void AlarmDockWindow::toggleAutostart(bool checked)
{
qCDebug(KOALARMCLIENT_LOG);
mAutostartSet = true;
enableAutostart(checked);
}
void AlarmDockWindow::slotSuspendAll()
{
Q_EMIT suspendAllSignal();
}
void AlarmDockWindow::slotDismissAll()
{
Q_EMIT dismissAllSignal();
}
void AlarmDockWindow::enableAutostart(bool enable)
{
KConfigGroup config(KSharedConfig::openConfig(), "General");
config.writeEntry("Autostart", enable);
config.sync();
}
void AlarmDockWindow::activate(const QPoint &pos)
{
Q_UNUSED(pos);
KToolInvocation::startServiceByDesktopName(QStringLiteral("korganizer"), QString());
}
void AlarmDockWindow::slotQuit()
{
if (mAutostartSet == true) {
int result = KMessageBox::warningContinueCancel(
associatedWidget(),
xi18nc("@info",
"Do you want to quit the KOrganizer reminder daemon?<nl/>"
"<note> you will not get calendar reminders unless the daemon is running.</note>"),
i18nc("@title:window", "Close KOrganizer Reminder Daemon"),
KStandardGuiItem::quit());
if (result == KMessageBox::Continue) {
Q_EMIT quitSignal();
}
} else {
int result = KMessageBox::questionYesNoCancel(
associatedWidget(),
xi18nc("@info",
"Do you want to start the KOrganizer reminder daemon at login?<nl/>"
"<note> you will not get calendar reminders unless the daemon is running.</note>"),
i18nc("@title:window", "Close KOrganizer Reminder Daemon"),
KGuiItem(i18nc("@action:button start the reminder daemon", "Start")),
KGuiItem(i18nc("@action:button do not start the reminder daemon", "Do Not Start")),
KStandardGuiItem::cancel(),
QStringLiteral("AskForStartAtLogin"));
bool autostart = true;
if (result == KMessageBox::No) {
autostart = false;
}
enableAutostart(autostart);
if (result != KMessageBox::Cancel) {
Q_EMIT quitSignal();
}
}
}
void AlarmDockWindow::changeSystrayIcon(bool alarmsEnabled)
{
if (alarmsEnabled) {
setIconByName(QStringLiteral("korgac"));
} else {
setIconByPixmap(mIconDisabled.pixmap(22, 22));
}
}
/*
This file is part of the KDE reminder agent.
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
Copyright (c) 2008-2009 Allen Winter <winter@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef KORGAC_ALARMDOCKWINDOW_H
#define KORGAC_ALARMDOCKWINDOW_H
#include <KStatusNotifierItem>
#include <QAction>
#include <QIcon>
class AlarmDockWindow : public KStatusNotifierItem
{
Q_OBJECT
public:
AlarmDockWindow();
virtual ~AlarmDockWindow();
void enableAutostart(bool enabled);
public Q_SLOTS:
void toggleAlarmsEnabled(bool checked);
void toggleAutostart(bool checked);
void slotUpdate(int reminders);
Q_SIGNALS:
void quitSignal();
void suspendAllSignal();
void dismissAllSignal();
protected Q_SLOTS:
void activate(const QPoint &pos) Q_DECL_OVERRIDE;
void slotQuit();
void slotSuspendAll();
void slotDismissAll();
private:
void changeSystrayIcon(bool alarmsEnabled);
QIcon mIconDisabled;
QString mName;
QAction *mAlarmsEnabled;
QAction *mAutostart;
QAction *mSuspendAll;
QAction *mDismissAll;
bool mAutostartSet;
};
#endif
/*
This file is part of the KDE reminder agent.
Copyright (c) 2002,2003 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include "koalarmclient.h"
#include "alarmdialog.h"
#include "alarmdockwindow.h"
#include "korgacadaptor.h"
#include <CalendarSupport/Utils>
#include <AkonadiCore/ChangeRecorder>
#include <AkonadiCore/Collection>
#include <kdbusconnectionpool.h>
#include <AkonadiCore/EntityTreeModel>
#include <AkonadiCore/Item>
#include <AkonadiCore/ItemFetchScope>
#include <AkonadiCore/Session>
#include <KCalCore/Calendar>
#include <KCheckableProxyModel>
#include <KConfig>
#include <KConfigGroup>
#include <QApplication>
#include "koalarmclient_debug.h"
using namespace KCalCore;
KOAlarmClient::KOAlarmClient(QObject *parent)
: QObject(parent), mDocker(0), mDialog(0)
{
new KOrgacAdaptor(this);
KDBusConnectionPool::threadConnection().registerObject(QStringLiteral("/ac"), this);
qCDebug(KOALARMCLIENT_LOG);
if (dockerEnabled()) {
mDocker = new AlarmDockWindow;
connect(this, &KOAlarmClient::reminderCount, mDocker, &AlarmDockWindow::slotUpdate);
connect(mDocker, &AlarmDockWindow::quitSignal, this, &KOAlarmClient::slotQuit);
}
QStringList mimeTypes;
mimeTypes << Event::eventMimeType() << Todo::todoMimeType();
mCalendar = Akonadi::ETMCalendar::Ptr(new Akonadi::ETMCalendar(mimeTypes));
mCalendar->setObjectName(QStringLiteral("KOrgac's calendar"));
mETM = mCalendar->entityTreeModel();
connect(&mCheckTimer, &QTimer::timeout, this, &KOAlarmClient::checkAlarms);
connect(mETM, &Akonadi::EntityTreeModel::collectionPopulated, this, &KOAlarmClient::deferredInit);
connect(mETM, &Akonadi::EntityTreeModel::collectionTreeFetched, this, &KOAlarmClient::deferredInit);
KConfigGroup alarmGroup(KSharedConfig::openConfig(), "Alarms");
const int interval = alarmGroup.readEntry("Interval", 60);
qCDebug(KOALARMCLIENT_LOG) << "KOAlarmClient check interval:" << interval << "seconds.";
mLastChecked = alarmGroup.readEntry("CalendarsLastChecked", QDateTime());
checkAlarms();
mCheckTimer.start(1000 * interval); // interval in seconds
connect(qApp, &QApplication::commitDataRequest, this, &KOAlarmClient::slotCommitData);
}