linux fixes

This commit is contained in:
Patrick von Reth 2014-02-21 01:12:14 +01:00
parent 4d92fb8afc
commit fd37a449b0
3 changed files with 26 additions and 16 deletions

View File

@ -27,8 +27,9 @@
using namespace Snore;
NotifyWidget::NotifyWidget(int pos,QWidget *parent) :
QWidget(parent, Qt::SplashScreen | Qt::WindowStaysOnTopHint),
QWidget(parent, Qt::Popup | Qt::WindowStaysOnTopHint),
ui(new Ui::NotifyWidget),
m_moveTimer(new QTimer(this)),
m_desktop(QDesktopWidget().availableGeometry()),
m_id(pos),
m_mem(QString("SnoreNotifyWidget%1").arg(QString::number(m_id))),
@ -62,6 +63,11 @@ NotifyWidget::NotifyWidget(int pos,QWidget *parent) :
m_dest = QPoint(m_desktop.topRight().x() - width(), m_desktop.topRight().y() + m_scaler->scaledY(10) + (m_scaler->scaledY(10) + height()) * pos);
m_start = QPoint(m_desktop.topRight().x(), m_dest.y());
snoreDebug( SNORE_DEBUG ) << m_dest << m_start << size();
m_moveTimer->setInterval(2);
connect( m_moveTimer, SIGNAL(timeout()), this, SLOT(slotMove()));
}
NotifyWidget::~NotifyWidget()
@ -73,19 +79,18 @@ NotifyWidget::~NotifyWidget()
void NotifyWidget::display(const Notification &notification)
{
update(notification);
m_dist = 0;
m_moveTimer->start();
snoreDebug( SNORE_DEBUG ) << notification.id();
move(m_start);
show();
m_moveTimer = new QTimer(this);
m_moveTimer->setInterval(2);
connect( m_moveTimer, SIGNAL(timeout()), this, SLOT(slotMove()));
m_moveTimer->start();
snoreDebug( SNORE_DEBUG ) << notification;
}
void NotifyWidget::update(const Notification &notification)
{
m_notification = notification;
snoreDebug( SNORE_DEBUG ) << notification.id();
ui->titel->setText(notification.title());
ui->body->setText(notification.text());
@ -132,6 +137,7 @@ bool NotifyWidget::release()
out = true;
}
m_mem.unlock();
hide();
}
return out;
}
@ -148,23 +154,22 @@ int NotifyWidget::id()
void NotifyWidget::slotMove()
{
move(pos().x()-1, pos().y());
if(m_dest == pos())
QPoint dest(m_start.x() - m_dist++, m_start.y());
move(dest);
if(m_dist >= width())
{
m_moveTimer->deleteLater();
m_moveTimer->stop();
}
}
void NotifyWidget::on_closeButton_clicked()
{
emit dismissed();
hide();
}
void NotifyWidget::mousePressEvent(QMouseEvent *)
{
emit invoked();
hide();
}
void NotifyWidget::setPalette(const QImage &img)
@ -198,3 +203,8 @@ void NotifyWidget::setPalette(const QImage &img)
ui->body->setPalette(p);
ui->titel->setPalette(p);
}
void NotifyWidget::on_body_linkActivated(const QString &link)
{
snoreDebug( SNORE_DEBUG ) << link;
}

View File

@ -60,6 +60,8 @@ private slots:
void on_closeButton_clicked();
void on_body_linkActivated(const QString &link);
protected:
void mousePressEvent(QMouseEvent *e);
@ -72,6 +74,7 @@ private:
QTimer *m_moveTimer;
QPoint m_dest;
QPoint m_start;
int m_dist;
QRect m_desktop;
TomahawkUtils::DpiScaler *m_scaler;
Snore::Notification m_notification;

View File

@ -177,7 +177,7 @@
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="margin">
<number>0</number>
@ -185,9 +185,6 @@
<property name="indent">
<number>0</number>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>