Cherry-picking upstream version 0.9.0+20151028.

ubuntu/cosmic debian/0.9.0+20151028-1
Alf Gaida 9 years ago
parent f6ac7317b3
commit ecfd0a3c37

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>284</height>
<width>350</width>
<height>301</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
@ -70,6 +70,12 @@
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Some notifications set their own on-screen duration.</string>
</property>

6
debian/changelog vendored

@ -1,3 +1,9 @@
lxqt-notificationd (0.9.0+20151028-1) experimental; urgency=medium
* Cherry-picked upstream version 0.9.0+20151028.
-- Alf Gaida <agaida@siduction.org> Fri, 30 Oct 2015 01:42:07 +0100
lxqt-notificationd (0.9.0+20150903-1) experimental; urgency=medium
* Cherry-picked upstream version 0.9.0+20150903.

@ -33,12 +33,15 @@
#include <QDebug>
#include <XdgIcon>
#include <KWindowSystem/KWindowSystem>
#include <QMouseEvent>
#include <QPushButton>
#include "notification.h"
#include "notificationwidgets.h"
#define ICONSIZE QSize(32, 32)
Notification::Notification(const QString &application,
const QString &summary, const QString &body,
const QString &icon, int timeout,
@ -46,6 +49,7 @@ Notification::Notification(const QString &application,
QWidget *parent)
: QWidget(parent),
m_timer(0),
m_linkHovered(false),
m_actionWidget(0)
{
setupUi(this);
@ -57,7 +61,14 @@ Notification::Notification(const QString &application,
setValues(application, summary, body, icon, timeout, actions, hints);
connect(closeButton, SIGNAL(clicked()), this, SLOT(closeButton_clicked()));
connect(closeButton, &QPushButton::clicked, this, &Notification::closeButton_clicked);
for (QLabel *label : {bodyLabel, summaryLabel})
{
connect(label, &QLabel::linkHovered, this, &Notification::linkHovered);
label->installEventFilter(this);
}
}
void Notification::setValues(const QString &application,
@ -145,7 +156,7 @@ void Notification::setValues(const QString &application,
if (timeout > 0)
{
m_timer = new NotificationTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SIGNAL(timeout()));
connect(m_timer, &NotificationTimer::timeout, this, &Notification::timeout);
m_timer->start(timeout);
}
@ -174,8 +185,10 @@ void Notification::setValues(const QString &application,
m_actionWidget = new NotificationActionsButtonsWidget(actions, this);
else
m_actionWidget = new NotificationActionsComboWidget(actions, this);
connect(m_actionWidget, SIGNAL(actionTriggered(const QString &)),
this, SIGNAL(actionTriggered(const QString &)));
connect(m_actionWidget, &NotificationActionsWidget::actionTriggered,
this, &Notification::actionTriggered);
actionsLayout->addWidget(m_actionWidget);
m_actionWidget->show();
}
@ -272,6 +285,25 @@ void Notification::leaveEvent(QEvent * event)
m_timer->resume();
}
bool Notification::eventFilter(QObject *obj, QEvent *event)
{
// Catch mouseReleaseEvent on child labels if a link is not currently being hovered.
//
// This workarounds QTBUG-49025 where clicking on text does not propagate the mouseReleaseEvent
// to the parent even though the text is not selectable and no link is being clicked.
if (event->type() == QEvent::MouseButtonRelease && !m_linkHovered)
{
mouseReleaseEvent(static_cast<QMouseEvent*>(event));
return true;
}
return false;
}
void Notification::linkHovered(QString link)
{
m_linkHovered = !link.isEmpty();
}
void Notification::mouseReleaseEvent(QMouseEvent * event)
{
// qDebug() << "CLICKED" << event;

@ -99,6 +99,7 @@ private:
NotificationTimer *m_timer;
QPixmap m_pixmap;
bool m_linkHovered;
NotificationActionsWidget *m_actionWidget;
@ -106,9 +107,11 @@ private:
void paintEvent(QPaintEvent *);
QPixmap getPixmapFromHint(const QVariant &argument) const;
QPixmap getPixmapFromString(const QString &str) const;
bool eventFilter(QObject *obj, QEvent *event);
private slots:
void closeButton_clicked();
void linkHovered(QString);
};

@ -82,7 +82,7 @@
<string notr="true">TextLabel</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>false</bool>

@ -55,10 +55,10 @@ NotificationArea::NotificationArea(QWidget *parent)
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
connect(m_layout, SIGNAL(allNotificationsClosed()), this, SLOT(close()));
connect(m_layout, SIGNAL(notificationAvailable()), this, SLOT(show()));
connect(m_layout, SIGNAL(heightChanged(int)), this, SLOT(setHeight(int)));
connect(qApp->desktop(), SIGNAL(workAreaResized(int)), SLOT(setHeight()));
connect(m_layout, &NotificationLayout::allNotificationsClosed, this, &NotificationArea::close);
connect(m_layout, &NotificationLayout::notificationAvailable, this, &NotificationArea::show);
connect(m_layout, &NotificationLayout::heightChanged, this, &NotificationArea::setHeight);
connect(qApp->desktop(), &QDesktopWidget::workAreaResized, this, &NotificationArea::setHeight);
}
void NotificationArea::setHeight(int contentHeight)

@ -96,10 +96,10 @@ void NotificationLayout::addNotification(uint id, const QString &application,
}
}
connect(n, SIGNAL(timeout()), this, SLOT(removeNotificationTimeout()));
connect(n, SIGNAL(userCanceled()), this, SLOT(removeNotificationUser()));
connect(n, SIGNAL(actionTriggered(QString)),
this, SLOT(notificationActionCalled(QString)));
connect(n, &Notification::timeout, this, &NotificationLayout::removeNotificationTimeout);
connect(n, &Notification::userCanceled, this, &NotificationLayout::removeNotificationUser);
connect(n, &Notification::actionTriggered,
this, &NotificationLayout::notificationActionCalled);
m_notifications[id] = n;
m_layout->addWidget(n);
n->show();

@ -39,77 +39,77 @@
NotificationActionsWidget::NotificationActionsWidget(const QStringList& actions, QWidget *parent)
: QWidget(parent)
{
for (int i = 0; i < actions.count(); ++i)
for (int i = 0; i < actions.count(); i += 2)
{
if (i == actions.count()-1)
{
qDebug() << "NotificationActionsWidget actions has contains pairs (id, value, id, value...) got odd count:" << actions.count() << "Actions:" << actions;
m_actionMap[actions.at(i)] = actions.at(i);
}
else
QString key = actions[i];
QString value;
if (i == actions.count() - 1)
{
m_actionMap[actions.at(i)] = actions.at(i+1);
}
++i; // move to the next ID
value = key;
qWarning() << "Odd number of elements in action list. Last action will use key as text (" << key << ")";
} else {
value = actions[i + 1];
}
// if there is only one action let's take it as a default one
if (m_actionMap.count() == 1)
m_defaultAction = m_actionMap[m_actionMap.keys().at(0)];
if (key == "default")
m_defaultAction = key;
m_actions.append({key, value});
}
qDebug() << "NotificationActionsWidget processed actions:" << m_actionMap;
// if there is only one action let's use it as the default one
if (m_actions.count() == 1)
m_defaultAction = m_actions[0].first;
}
NotificationActionsButtonsWidget::NotificationActionsButtonsWidget(const QStringList& actions, QWidget *parent)
: NotificationActionsWidget(actions, parent)
{
QHashIterator<QString,QString> it(m_actionMap);
QHBoxLayout *l = new QHBoxLayout();
setLayout(l);
QButtonGroup *group = new QButtonGroup(this);
while (it.hasNext())
for (auto const & action : m_actions)
{
it.next();
QPushButton *b = new QPushButton(it.value(), this);
QPushButton *b = new QPushButton(action.second, this);
b->setObjectName(action.first);
l->addWidget(b);
group->addButton(b);
if (it.key() == "default")
{
if (action.first == m_defaultAction)
b->setFocus(Qt::OtherFocusReason);
m_defaultAction = it.key();
}
}
connect(group, SIGNAL(buttonClicked(QAbstractButton*)),
this, SLOT(actionButtonActivated(QAbstractButton*)));
connect(group, static_cast<void (QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
this, &NotificationActionsButtonsWidget::actionButtonActivated);
}
void NotificationActionsButtonsWidget::actionButtonActivated(QAbstractButton* button)
{
emit actionTriggered(m_actionMap.key(button->text()));
emit actionTriggered(button->objectName());
}
NotificationActionsComboWidget::NotificationActionsComboWidget(const QStringList& actions, QWidget *parent)
: NotificationActionsWidget(actions, parent)
{
QHashIterator<QString,QString> it(m_actionMap);
QHBoxLayout *l = new QHBoxLayout();
setLayout(l);
l->addWidget(new QLabel(tr("Actions:"), this));
m_comboBox = new QComboBox(this);
int currentIndex = -1;
while (it.hasNext())
for (int i = 0; i < m_actions.count(); ++i)
{
it.next();
m_comboBox->addItem(it.value(), it.key());
if (it.key() == "default")
auto const & action = m_actions[i];
m_comboBox->addItem(action.second, action.first);
if (action.first == m_defaultAction)
{
currentIndex = m_comboBox->count()-1;
m_defaultAction = it.key();
currentIndex = i;
}
}
l->addWidget(m_comboBox);
@ -119,8 +119,8 @@ NotificationActionsComboWidget::NotificationActionsComboWidget(const QStringList
QPushButton *b = new QPushButton(tr("OK"), this);
l->addWidget(b);
connect(b, SIGNAL(clicked()),
this, SLOT(actionComboBoxActivated()));
connect(b, &QPushButton::clicked,
this, &NotificationActionsComboWidget::actionComboBoxActivated);
}
void NotificationActionsComboWidget::actionComboBoxActivated()
@ -130,5 +130,5 @@ void NotificationActionsComboWidget::actionComboBoxActivated()
int ix = m_comboBox->currentIndex();
if (ix == -1)
return;
emit actionTriggered(m_actionMap.key(m_comboBox->itemText(ix)));
emit actionTriggered(m_actions[ix].first);
}

@ -65,7 +65,7 @@ signals:
protected:
QString m_defaultAction;
QHash<QString,QString> m_actionMap;
QList<QPair<QString/*action key*/, QString/*action value*/>> m_actions;
};
class NotificationActionsButtonsWidget : public NotificationActionsWidget

@ -43,18 +43,18 @@ Notifyd::Notifyd(QObject* parent)
m_settings = new LXQt::Settings("notifications");
reloadSettings();
connect(this, SIGNAL(notificationAdded(uint,QString,QString,QString,QString,int,QStringList,QVariantMap)),
m_area->layout(), SLOT(addNotification(uint,QString,QString,QString,QString,int,QStringList,QVariantMap)));
connect(this, SIGNAL(notificationClosed(uint, uint)),
m_area->layout(), SLOT(removeNotification(uint, uint)));
connect(this, &Notifyd::notificationAdded,
m_area->layout(), &NotificationLayout::addNotification);
connect(this, &Notifyd::notificationClosed,
m_area->layout(), &NotificationLayout::removeNotification);
// feedback for original caller
connect(m_area->layout(), SIGNAL(notificationClosed(uint,uint)),
this, SIGNAL(NotificationClosed(uint,uint)));
connect(m_area->layout(), SIGNAL(actionInvoked(uint, QString)),
this, SIGNAL(ActionInvoked(uint,QString)));
connect(m_area->layout(), &NotificationLayout::notificationClosed,
this, &Notifyd::NotificationClosed);
connect(m_area->layout(), &NotificationLayout::actionInvoked,
this, &Notifyd::ActionInvoked);
connect(m_settings, SIGNAL(settingsChanged()),
this, SLOT(reloadSettings()));
connect(m_settings, &LXQt::Settings::settingsChanged,
this, &Notifyd::reloadSettings);
}

Loading…
Cancel
Save