mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-10 07:26:22 +00:00
make everything unix eol
This commit is contained in:
parent
bcbfb7ee98
commit
8720c0c6d7
@ -1,88 +1,88 @@
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "alert.h"
|
||||
#include "alert_p.h"
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
Alert::Alert() :
|
||||
d(NULL)
|
||||
{}
|
||||
|
||||
Alert::Alert (const QString &name, const QString &title, const Icon &icon, bool active):
|
||||
d(new AlertData(name, title, icon, active))
|
||||
{}
|
||||
|
||||
Alert::Alert(const Alert &other):
|
||||
d(other.d)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Alert &Alert::operator=(const Alert &other)
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Alert::~Alert()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
QString Alert::name() const
|
||||
{
|
||||
return d->m_name;
|
||||
}
|
||||
|
||||
QString Alert::title() const
|
||||
{
|
||||
return d->m_title;
|
||||
}
|
||||
|
||||
const Icon &Alert::icon() const
|
||||
{
|
||||
return d->m_icon;
|
||||
}
|
||||
|
||||
bool Alert::isActive() const
|
||||
{
|
||||
return d->m_active;
|
||||
}
|
||||
|
||||
bool Alert::isValid() const
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
QDebug operator<<(QDebug debug, const Alert &alert)
|
||||
{
|
||||
if(alert.isValid())
|
||||
{
|
||||
debug << "Snore::Alert(" << alert.name() << ", " << alert.title() << ")" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
debug << "Snore::Alert(0x00)" ;
|
||||
}
|
||||
return debug.maybeSpace();
|
||||
}
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "alert.h"
|
||||
#include "alert_p.h"
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
Alert::Alert() :
|
||||
d(NULL)
|
||||
{}
|
||||
|
||||
Alert::Alert (const QString &name, const QString &title, const Icon &icon, bool active):
|
||||
d(new AlertData(name, title, icon, active))
|
||||
{}
|
||||
|
||||
Alert::Alert(const Alert &other):
|
||||
d(other.d)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Alert &Alert::operator=(const Alert &other)
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Alert::~Alert()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
QString Alert::name() const
|
||||
{
|
||||
return d->m_name;
|
||||
}
|
||||
|
||||
QString Alert::title() const
|
||||
{
|
||||
return d->m_title;
|
||||
}
|
||||
|
||||
const Icon &Alert::icon() const
|
||||
{
|
||||
return d->m_icon;
|
||||
}
|
||||
|
||||
bool Alert::isActive() const
|
||||
{
|
||||
return d->m_active;
|
||||
}
|
||||
|
||||
bool Alert::isValid() const
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
QDebug operator<<(QDebug debug, const Alert &alert)
|
||||
{
|
||||
if(alert.isValid())
|
||||
{
|
||||
debug << "Snore::Alert(" << alert.name() << ", " << alert.title() << ")" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
debug << "Snore::Alert(0x00)" ;
|
||||
}
|
||||
return debug.maybeSpace();
|
||||
}
|
||||
|
112
src/core/alert.h
112
src/core/alert.h
@ -1,56 +1,56 @@
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ALERT_H
|
||||
#define ALERT_H
|
||||
|
||||
#include "snore_exports.h"
|
||||
#include "notification/icon.h"
|
||||
|
||||
#include <QSharedData>
|
||||
|
||||
namespace Snore{
|
||||
|
||||
class AlertData;
|
||||
|
||||
class SNORE_EXPORT Alert
|
||||
{
|
||||
friend class AlertData;
|
||||
public:
|
||||
Alert();
|
||||
explicit Alert(const QString &name, const QString &title="", const Icon &icon = Icon(":/root/snore.png"), bool active=true );
|
||||
Alert(const Alert &other);
|
||||
Alert &operator=(const Alert &other);
|
||||
~Alert();
|
||||
|
||||
QString name() const;
|
||||
QString title() const;
|
||||
const Icon &icon() const;
|
||||
bool isActive() const;
|
||||
bool isValid() const;
|
||||
private:
|
||||
QExplicitlySharedDataPointer<AlertData> d;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
QDebug SNORE_EXPORT operator<< ( QDebug debug, const Snore::Alert &alert );
|
||||
|
||||
|
||||
#endif // ALERT_H
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ALERT_H
|
||||
#define ALERT_H
|
||||
|
||||
#include "snore_exports.h"
|
||||
#include "notification/icon.h"
|
||||
|
||||
#include <QSharedData>
|
||||
|
||||
namespace Snore{
|
||||
|
||||
class AlertData;
|
||||
|
||||
class SNORE_EXPORT Alert
|
||||
{
|
||||
friend class AlertData;
|
||||
public:
|
||||
Alert();
|
||||
explicit Alert(const QString &name, const QString &title="", const Icon &icon = Icon(":/root/snore.png"), bool active=true );
|
||||
Alert(const Alert &other);
|
||||
Alert &operator=(const Alert &other);
|
||||
~Alert();
|
||||
|
||||
QString name() const;
|
||||
QString title() const;
|
||||
const Icon &icon() const;
|
||||
bool isActive() const;
|
||||
bool isValid() const;
|
||||
private:
|
||||
QExplicitlySharedDataPointer<AlertData> d;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
QDebug SNORE_EXPORT operator<< ( QDebug debug, const Snore::Alert &alert );
|
||||
|
||||
|
||||
#endif // ALERT_H
|
||||
|
@ -1,35 +1,35 @@
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "alert_p.h"
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
AlertData::AlertData(const QString &name, const QString &title, const Icon &icon, bool active):
|
||||
m_name(name),
|
||||
m_title(title),
|
||||
m_icon(icon),
|
||||
m_active(active)
|
||||
{
|
||||
}
|
||||
|
||||
AlertData::~AlertData()
|
||||
{
|
||||
|
||||
}
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "alert_p.h"
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
AlertData::AlertData(const QString &name, const QString &title, const Icon &icon, bool active):
|
||||
m_name(name),
|
||||
m_title(title),
|
||||
m_icon(icon),
|
||||
m_active(active)
|
||||
{
|
||||
}
|
||||
|
||||
AlertData::~AlertData()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1,48 +1,48 @@
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ALERT_P_H
|
||||
#define ALERT_P_H
|
||||
|
||||
#include <QString>
|
||||
#include <QSharedData>
|
||||
|
||||
#include "alert.h"
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
class AlertData : public QSharedData
|
||||
{
|
||||
friend class Alert;
|
||||
public:
|
||||
AlertData(const QString &name, const QString &title, const Icon &icon, bool active);
|
||||
~AlertData();
|
||||
|
||||
QString m_name;
|
||||
QString m_title;
|
||||
Icon m_icon;
|
||||
bool m_active;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(AlertData)
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ALERT_P_H
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ALERT_P_H
|
||||
#define ALERT_P_H
|
||||
|
||||
#include <QString>
|
||||
#include <QSharedData>
|
||||
|
||||
#include "alert.h"
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
class AlertData : public QSharedData
|
||||
{
|
||||
friend class Alert;
|
||||
public:
|
||||
AlertData(const QString &name, const QString &title, const Icon &icon, bool active);
|
||||
~AlertData();
|
||||
|
||||
QString m_name;
|
||||
QString m_title;
|
||||
Icon m_icon;
|
||||
bool m_active;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(AlertData)
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // ALERT_P_H
|
||||
|
@ -1,34 +1,34 @@
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "application_p.h"
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
ApplicationData::ApplicationData(const QString &name, const Icon &icon):
|
||||
m_name(name),
|
||||
m_icon(icon)
|
||||
{
|
||||
Q_ASSERT_X(!name.isEmpty(),Q_FUNC_INFO, "invalid name detected");
|
||||
}
|
||||
|
||||
ApplicationData::~ApplicationData()
|
||||
{
|
||||
|
||||
}
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "application_p.h"
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
ApplicationData::ApplicationData(const QString &name, const Icon &icon):
|
||||
m_name(name),
|
||||
m_icon(icon)
|
||||
{
|
||||
Q_ASSERT_X(!name.isEmpty(),Q_FUNC_INFO, "invalid name detected");
|
||||
}
|
||||
|
||||
ApplicationData::~ApplicationData()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1,43 +1,43 @@
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef APPLICATION_P_H
|
||||
#define APPLICATION_P_H
|
||||
|
||||
#include <QString>
|
||||
#include <QSharedData>
|
||||
|
||||
#include "application.h"
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
class ApplicationData : public QSharedData
|
||||
{
|
||||
public:
|
||||
ApplicationData(const QString &name, const Icon &icon);
|
||||
~ApplicationData();
|
||||
|
||||
QString m_name;
|
||||
Icon m_icon;
|
||||
QHash<QString,Alert> m_alerts;
|
||||
Hint m_hint;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // APPLICATION_P_H
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef APPLICATION_P_H
|
||||
#define APPLICATION_P_H
|
||||
|
||||
#include <QString>
|
||||
#include <QSharedData>
|
||||
|
||||
#include "application.h"
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
class ApplicationData : public QSharedData
|
||||
{
|
||||
public:
|
||||
ApplicationData(const QString &name, const Icon &icon);
|
||||
~ApplicationData();
|
||||
|
||||
QString m_name;
|
||||
Icon m_icon;
|
||||
QHash<QString,Alert> m_alerts;
|
||||
Hint m_hint;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // APPLICATION_P_H
|
||||
|
104
src/core/log.h
104
src/core/log.h
@ -1,52 +1,52 @@
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
|
||||
#include <QDebug>
|
||||
#include "snore_exports.h"
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
class SNORE_EXPORT Log : public QDebug
|
||||
{
|
||||
public:
|
||||
Log(int lvl);
|
||||
~Log();
|
||||
|
||||
static inline int debugLvl()
|
||||
{
|
||||
static int lvl = qgetenv("SNORE_DEBUG_LVL").toInt();
|
||||
return lvl;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_lvl;
|
||||
QString m_msg;
|
||||
|
||||
void log();
|
||||
};
|
||||
}
|
||||
|
||||
#define snoreDebug(x) Snore::Log( x ) << Q_FUNC_INFO
|
||||
#define SNORE_DEBUG 3
|
||||
#define SNORE_INFO 2
|
||||
#define SNORE_WARNING 1
|
||||
#endif // LOG_H
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
|
||||
#include <QDebug>
|
||||
#include "snore_exports.h"
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
class SNORE_EXPORT Log : public QDebug
|
||||
{
|
||||
public:
|
||||
Log(int lvl);
|
||||
~Log();
|
||||
|
||||
static inline int debugLvl()
|
||||
{
|
||||
static int lvl = qgetenv("SNORE_DEBUG_LVL").toInt();
|
||||
return lvl;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_lvl;
|
||||
QString m_msg;
|
||||
|
||||
void log();
|
||||
};
|
||||
}
|
||||
|
||||
#define snoreDebug(x) Snore::Log( x ) << Q_FUNC_INFO
|
||||
#define SNORE_DEBUG 3
|
||||
#define SNORE_INFO 2
|
||||
#define SNORE_WARNING 1
|
||||
#endif // LOG_H
|
||||
|
@ -1,134 +1,134 @@
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2013-2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "icon_p.h"
|
||||
#include "../snore_p.h"
|
||||
|
||||
#include <QEventLoop>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QHash>
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
IconData::IconData(const QString &url):
|
||||
m_url(url),
|
||||
m_hash(SnoreCorePrivate::computeHash(m_url.toLatin1())),
|
||||
m_localUrl(QString("%1%2.png").arg(SnoreCorePrivate::snoreTMP(), m_hash)),
|
||||
m_isLocalFile(false),
|
||||
m_isResource(m_url.startsWith(":/"))
|
||||
{
|
||||
if(!m_isResource && QFile(url).exists())
|
||||
{
|
||||
m_isLocalFile = true;
|
||||
m_localUrl = url;
|
||||
}
|
||||
m_isRemoteFile = !m_isLocalFile && ! m_isResource;
|
||||
}
|
||||
|
||||
IconData::IconData(const QImage &img):
|
||||
m_img(img),
|
||||
m_data(dataFromImage(img)),
|
||||
m_hash(SnoreCorePrivate::computeHash(m_data)),
|
||||
m_localUrl(QString("%1%2.png").arg(SnoreCorePrivate::snoreTMP(), m_hash)),
|
||||
m_isLocalFile(false),
|
||||
m_isResource(false),
|
||||
m_isRemoteFile(false)
|
||||
{
|
||||
}
|
||||
|
||||
IconData::~IconData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
const QByteArray &Snore::IconData::imageData()
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
if(m_data.isEmpty())
|
||||
{
|
||||
if(m_isRemoteFile)
|
||||
{
|
||||
download();
|
||||
}
|
||||
}
|
||||
return m_data;
|
||||
}
|
||||
|
||||
const QImage &IconData::image()
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
if(m_img.isNull())
|
||||
{
|
||||
if(!m_isRemoteFile )
|
||||
{
|
||||
m_img = QImage(m_url);
|
||||
}
|
||||
else
|
||||
{
|
||||
download();
|
||||
}
|
||||
}
|
||||
return m_img;
|
||||
}
|
||||
|
||||
QString IconData::localUrl()
|
||||
{
|
||||
if(!m_isLocalFile && !QFile(m_localUrl).exists())
|
||||
{
|
||||
QImage img = image();
|
||||
if(!QFile(m_localUrl).exists())
|
||||
{
|
||||
img.save(m_localUrl ,"PNG");
|
||||
}
|
||||
}
|
||||
return m_localUrl;
|
||||
}
|
||||
|
||||
|
||||
void IconData::download()
|
||||
{
|
||||
if(m_isRemoteFile && m_data.isEmpty())
|
||||
{
|
||||
if(!QFile(m_localUrl).exists())
|
||||
{
|
||||
qDebug() << "Downloading:" << m_url;
|
||||
QNetworkAccessManager manager;
|
||||
QEventLoop loop;
|
||||
QNetworkRequest request(m_url);
|
||||
request.setRawHeader("User-Agent", "SnoreNotify");
|
||||
QNetworkReply *reply = manager.get(request);
|
||||
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||
QTimer::singleShot(1000,&loop, SLOT(quit()));//timeout
|
||||
loop.exec();
|
||||
if(reply->isFinished())
|
||||
{
|
||||
m_data = reply->readAll();
|
||||
m_img = QImage::fromData(m_data, "PNG");
|
||||
m_img.save(m_localUrl,"PNG");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_img = QImage(m_localUrl);
|
||||
m_data = dataFromImage(m_img);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2013-2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "icon_p.h"
|
||||
#include "../snore_p.h"
|
||||
|
||||
#include <QEventLoop>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QHash>
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
IconData::IconData(const QString &url):
|
||||
m_url(url),
|
||||
m_hash(SnoreCorePrivate::computeHash(m_url.toLatin1())),
|
||||
m_localUrl(QString("%1%2.png").arg(SnoreCorePrivate::snoreTMP(), m_hash)),
|
||||
m_isLocalFile(false),
|
||||
m_isResource(m_url.startsWith(":/"))
|
||||
{
|
||||
if(!m_isResource && QFile(url).exists())
|
||||
{
|
||||
m_isLocalFile = true;
|
||||
m_localUrl = url;
|
||||
}
|
||||
m_isRemoteFile = !m_isLocalFile && ! m_isResource;
|
||||
}
|
||||
|
||||
IconData::IconData(const QImage &img):
|
||||
m_img(img),
|
||||
m_data(dataFromImage(img)),
|
||||
m_hash(SnoreCorePrivate::computeHash(m_data)),
|
||||
m_localUrl(QString("%1%2.png").arg(SnoreCorePrivate::snoreTMP(), m_hash)),
|
||||
m_isLocalFile(false),
|
||||
m_isResource(false),
|
||||
m_isRemoteFile(false)
|
||||
{
|
||||
}
|
||||
|
||||
IconData::~IconData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
const QByteArray &Snore::IconData::imageData()
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
if(m_data.isEmpty())
|
||||
{
|
||||
if(m_isRemoteFile)
|
||||
{
|
||||
download();
|
||||
}
|
||||
}
|
||||
return m_data;
|
||||
}
|
||||
|
||||
const QImage &IconData::image()
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
if(m_img.isNull())
|
||||
{
|
||||
if(!m_isRemoteFile )
|
||||
{
|
||||
m_img = QImage(m_url);
|
||||
}
|
||||
else
|
||||
{
|
||||
download();
|
||||
}
|
||||
}
|
||||
return m_img;
|
||||
}
|
||||
|
||||
QString IconData::localUrl()
|
||||
{
|
||||
if(!m_isLocalFile && !QFile(m_localUrl).exists())
|
||||
{
|
||||
QImage img = image();
|
||||
if(!QFile(m_localUrl).exists())
|
||||
{
|
||||
img.save(m_localUrl ,"PNG");
|
||||
}
|
||||
}
|
||||
return m_localUrl;
|
||||
}
|
||||
|
||||
|
||||
void IconData::download()
|
||||
{
|
||||
if(m_isRemoteFile && m_data.isEmpty())
|
||||
{
|
||||
if(!QFile(m_localUrl).exists())
|
||||
{
|
||||
qDebug() << "Downloading:" << m_url;
|
||||
QNetworkAccessManager manager;
|
||||
QEventLoop loop;
|
||||
QNetworkRequest request(m_url);
|
||||
request.setRawHeader("User-Agent", "SnoreNotify");
|
||||
QNetworkReply *reply = manager.get(request);
|
||||
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||
QTimer::singleShot(1000,&loop, SLOT(quit()));//timeout
|
||||
loop.exec();
|
||||
if(reply->isFinished())
|
||||
{
|
||||
m_data = reply->readAll();
|
||||
m_img = QImage::fromData(m_data, "PNG");
|
||||
m_img.save(m_localUrl,"PNG");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_img = QImage(m_localUrl);
|
||||
m_data = dataFromImage(m_img);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,56 +1,56 @@
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "notificationaction.h"
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
Action::Action():
|
||||
m_id(-1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Action::Action(int id, QString name):
|
||||
m_id(id),
|
||||
m_name(name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString Action::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
bool Action::isValid() const
|
||||
{
|
||||
return !m_name.isNull();
|
||||
}
|
||||
|
||||
int Action::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QDataStream &operator<< ( QDataStream &stream, const Action &a)
|
||||
{
|
||||
stream << a.id() << a.name();
|
||||
return stream;
|
||||
}
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "notificationaction.h"
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
Action::Action():
|
||||
m_id(-1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Action::Action(int id, QString name):
|
||||
m_id(id),
|
||||
m_name(name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString Action::name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
bool Action::isValid() const
|
||||
{
|
||||
return !m_name.isNull();
|
||||
}
|
||||
|
||||
int Action::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
QDataStream &operator<< ( QDataStream &stream, const Action &a)
|
||||
{
|
||||
stream << a.id() << a.name();
|
||||
return stream;
|
||||
}
|
||||
|
@ -1,48 +1,48 @@
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NOTIFICATIONACTION_H
|
||||
#define NOTIFICATIONACTION_H
|
||||
|
||||
#include "../snore_exports.h"
|
||||
|
||||
#include <QDataStream>
|
||||
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
|
||||
class SNORE_EXPORT Action
|
||||
{
|
||||
public:
|
||||
Action();
|
||||
Action(int id,QString name);
|
||||
|
||||
int id() const;
|
||||
QString name() const;
|
||||
bool isValid() const;
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
QString m_name;
|
||||
};
|
||||
}
|
||||
|
||||
QDataStream &operator<< ( QDataStream & stream, const Snore::Action &action);
|
||||
#endif // NOTIFICATIONACTION_H
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NOTIFICATIONACTION_H
|
||||
#define NOTIFICATIONACTION_H
|
||||
|
||||
#include "../snore_exports.h"
|
||||
|
||||
#include <QDataStream>
|
||||
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
|
||||
class SNORE_EXPORT Action
|
||||
{
|
||||
public:
|
||||
Action();
|
||||
Action(int id,QString name);
|
||||
|
||||
int id() const;
|
||||
QString name() const;
|
||||
bool isValid() const;
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
QString m_name;
|
||||
};
|
||||
}
|
||||
|
||||
QDataStream &operator<< ( QDataStream & stream, const Snore::Action &action);
|
||||
#endif // NOTIFICATIONACTION_H
|
||||
|
@ -1,89 +1,89 @@
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "snore_p.h"
|
||||
#include "snore.h"
|
||||
#include "plugins/plugins.h"
|
||||
#include "plugins/snorebackend.h"
|
||||
#include "plugins/snorefrontend.h"
|
||||
#include "notification/notification_p.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
|
||||
QString const SnoreCorePrivate::snoreTMP(){
|
||||
static QString tmp;
|
||||
if(tmp.isNull())
|
||||
{
|
||||
tmp = QString("%1/libsnore/").arg(QDir::tempPath());
|
||||
QDir(tmp).mkpath(".");
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
const QDir &SnoreCorePrivate::pluginDir(){
|
||||
static QDir path(QString("%1/../%2/libsnore").arg(qApp->applicationDirPath(), CMAKE_INSTALL_LIBDIR));
|
||||
if(!path.exists())
|
||||
{
|
||||
path = QDir(LIBSNORE_PLUGIN_PATH);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
SnoreCorePrivate::SnoreCorePrivate(QSystemTrayIcon *trayIcon):
|
||||
m_trayIcon(trayIcon),
|
||||
m_defaultApp("SnoreNotify",Icon(":/root/snore.png"))
|
||||
{
|
||||
m_defaultApp.addAlert(Alert("Default"));
|
||||
}
|
||||
|
||||
SnoreCorePrivate::~SnoreCorePrivate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const Application SnoreCorePrivate::defaultApplication() const
|
||||
{
|
||||
return m_defaultApp;
|
||||
}
|
||||
|
||||
void SnoreCorePrivate::notificationActionInvoked(Notification notification) const
|
||||
{
|
||||
Q_Q(const SnoreCore);
|
||||
emit const_cast<SnoreCore*>(q)->actionInvoked(notification);
|
||||
if ( notification.data()->source() )
|
||||
{
|
||||
notification.data()->source()->actionInvoked ( notification );
|
||||
}
|
||||
}
|
||||
|
||||
void SnoreCorePrivate::slotNotificationClosed(Notification n)
|
||||
{
|
||||
Q_Q(SnoreCore);
|
||||
emit q->notificationClosed(n);
|
||||
if(n.data()->source())
|
||||
{
|
||||
n.data()->source()->notificationClosed(n);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "snore_p.h"
|
||||
#include "snore.h"
|
||||
#include "plugins/plugins.h"
|
||||
#include "plugins/snorebackend.h"
|
||||
#include "plugins/snorefrontend.h"
|
||||
#include "notification/notification_p.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
using namespace Snore;
|
||||
|
||||
|
||||
QString const SnoreCorePrivate::snoreTMP(){
|
||||
static QString tmp;
|
||||
if(tmp.isNull())
|
||||
{
|
||||
tmp = QString("%1/libsnore/").arg(QDir::tempPath());
|
||||
QDir(tmp).mkpath(".");
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
const QDir &SnoreCorePrivate::pluginDir(){
|
||||
static QDir path(QString("%1/../%2/libsnore").arg(qApp->applicationDirPath(), CMAKE_INSTALL_LIBDIR));
|
||||
if(!path.exists())
|
||||
{
|
||||
path = QDir(LIBSNORE_PLUGIN_PATH);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
SnoreCorePrivate::SnoreCorePrivate(QSystemTrayIcon *trayIcon):
|
||||
m_trayIcon(trayIcon),
|
||||
m_defaultApp("SnoreNotify",Icon(":/root/snore.png"))
|
||||
{
|
||||
m_defaultApp.addAlert(Alert("Default"));
|
||||
}
|
||||
|
||||
SnoreCorePrivate::~SnoreCorePrivate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const Application SnoreCorePrivate::defaultApplication() const
|
||||
{
|
||||
return m_defaultApp;
|
||||
}
|
||||
|
||||
void SnoreCorePrivate::notificationActionInvoked(Notification notification) const
|
||||
{
|
||||
Q_Q(const SnoreCore);
|
||||
emit const_cast<SnoreCore*>(q)->actionInvoked(notification);
|
||||
if ( notification.data()->source() )
|
||||
{
|
||||
notification.data()->source()->actionInvoked ( notification );
|
||||
}
|
||||
}
|
||||
|
||||
void SnoreCorePrivate::slotNotificationClosed(Notification n)
|
||||
{
|
||||
Q_Q(SnoreCore);
|
||||
emit q->notificationClosed(n);
|
||||
if(n.data()->source())
|
||||
{
|
||||
n.data()->source()->notificationClosed(n);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,81 +1,81 @@
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SNORECOREPRIVATE_H
|
||||
#define SNORECOREPRIVATE_H
|
||||
|
||||
#include "snore.h"
|
||||
#include "plugins/snorebackend.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QPointer>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
class SNORE_EXPORT SnoreCorePrivate : public QObject
|
||||
{
|
||||
Q_DECLARE_PUBLIC(SnoreCore)
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static const QString snoreTMP();
|
||||
static const QDir &pluginDir();
|
||||
static inline QString computeHash(const QByteArray &data)
|
||||
{
|
||||
return QCryptographicHash::hash(data,QCryptographicHash::Md5).toHex();
|
||||
}
|
||||
public:
|
||||
SnoreCorePrivate(QSystemTrayIcon *trayIcon);
|
||||
~SnoreCorePrivate();
|
||||
const Application defaultApplication() const;
|
||||
|
||||
|
||||
void notificationActionInvoked(Notification notification) const;
|
||||
|
||||
signals:
|
||||
void applicationRegistered(const Snore::Application&);
|
||||
void applicationDeregistered(const Snore::Application&);
|
||||
void notify(Snore::Notification noti);
|
||||
|
||||
private slots:
|
||||
void slotNotificationClosed(Snore::Notification);
|
||||
|
||||
private:
|
||||
SnoreCore *q_ptr;
|
||||
Hint m_hints;
|
||||
|
||||
QHash<QString,Application> m_applications;
|
||||
|
||||
|
||||
QStringList m_notificationBackends;
|
||||
QStringList m_Frontends;
|
||||
QStringList m_secondaryNotificationBackends;
|
||||
QStringList m_plugins;
|
||||
|
||||
QPointer<SnoreBackend> m_notificationBackend;
|
||||
|
||||
QSystemTrayIcon *m_trayIcon;
|
||||
|
||||
Application m_defaultApp;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SNORECOREPRIVATE_H
|
||||
/*
|
||||
SnoreNotify is a Notification Framework based on Qt
|
||||
Copyright (C) 2014 Patrick von Reth <vonreth@kde.org>
|
||||
|
||||
|
||||
SnoreNotify is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
SnoreNotify 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SNORECOREPRIVATE_H
|
||||
#define SNORECOREPRIVATE_H
|
||||
|
||||
#include "snore.h"
|
||||
#include "plugins/snorebackend.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QPointer>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
namespace Snore
|
||||
{
|
||||
class SNORE_EXPORT SnoreCorePrivate : public QObject
|
||||
{
|
||||
Q_DECLARE_PUBLIC(SnoreCore)
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static const QString snoreTMP();
|
||||
static const QDir &pluginDir();
|
||||
static inline QString computeHash(const QByteArray &data)
|
||||
{
|
||||
return QCryptographicHash::hash(data,QCryptographicHash::Md5).toHex();
|
||||
}
|
||||
public:
|
||||
SnoreCorePrivate(QSystemTrayIcon *trayIcon);
|
||||
~SnoreCorePrivate();
|
||||
const Application defaultApplication() const;
|
||||
|
||||
|
||||
void notificationActionInvoked(Notification notification) const;
|
||||
|
||||
signals:
|
||||
void applicationRegistered(const Snore::Application&);
|
||||
void applicationDeregistered(const Snore::Application&);
|
||||
void notify(Snore::Notification noti);
|
||||
|
||||
private slots:
|
||||
void slotNotificationClosed(Snore::Notification);
|
||||
|
||||
private:
|
||||
SnoreCore *q_ptr;
|
||||
Hint m_hints;
|
||||
|
||||
QHash<QString,Application> m_applications;
|
||||
|
||||
|
||||
QStringList m_notificationBackends;
|
||||
QStringList m_Frontends;
|
||||
QStringList m_secondaryNotificationBackends;
|
||||
QStringList m_plugins;
|
||||
|
||||
QPointer<SnoreBackend> m_notificationBackend;
|
||||
|
||||
QSystemTrayIcon *m_trayIcon;
|
||||
|
||||
Application m_defaultApp;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SNORECOREPRIVATE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user