mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Written new class notification which all notifications will subclass.
Notification class implements show/hide animation
This commit is contained in:
parent
cb80d133b3
commit
538522a4a2
@ -86,7 +86,9 @@ SOURCES += main.cpp\
|
||||
autofill/autofillnotification.cpp \
|
||||
rss/rssnotification.cpp \
|
||||
navigation/locationpopup.cpp \
|
||||
preferences/sslmanager.cpp
|
||||
preferences/sslmanager.cpp \
|
||||
tools/notification.cpp \
|
||||
tools/htmlhighlighter.cpp
|
||||
|
||||
HEADERS += 3rdparty/squeezelabel.h \
|
||||
3rdparty/qtwin.h \
|
||||
@ -142,7 +144,9 @@ HEADERS += 3rdparty/squeezelabel.h \
|
||||
autofill/autofillnotification.h \
|
||||
rss/rssnotification.h \
|
||||
navigation/locationpopup.h \
|
||||
preferences/sslmanager.h
|
||||
preferences/sslmanager.h \
|
||||
tools/notification.h \
|
||||
tools/htmlhighlighter.h
|
||||
|
||||
FORMS += \
|
||||
preferences/autofillmanager.ui \
|
||||
|
@ -19,9 +19,10 @@
|
||||
#include "ui_autofillnotification.h"
|
||||
#include "autofillmodel.h"
|
||||
#include "mainapplication.h"
|
||||
#include "notification.h"
|
||||
|
||||
AutoFillNotification::AutoFillNotification(QUrl url, QByteArray data, QString pass, QWidget *parent)
|
||||
:QWidget(parent)
|
||||
:Notification(parent)
|
||||
,ui(new Ui::AutoFillWidget)
|
||||
,m_url(url)
|
||||
,m_data(data)
|
||||
@ -42,29 +43,7 @@ AutoFillNotification::AutoFillNotification(QUrl url, QByteArray data, QString pa
|
||||
connect(ui->never, SIGNAL(clicked()), this, SLOT(never()));
|
||||
connect(ui->notnow, SIGNAL(clicked()), this, SLOT(hide()));
|
||||
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
|
||||
|
||||
m_animation = new QTimeLine(300, this);
|
||||
m_animation->setFrameRange(0, sizeHint().height());
|
||||
|
||||
setMinimumHeight(1);
|
||||
setMaximumHeight(1);
|
||||
connect(m_animation, SIGNAL(frameChanged(int)),this, SLOT(frameChanged(int)));
|
||||
QTimer::singleShot(1, m_animation, SLOT(start()));
|
||||
}
|
||||
|
||||
void AutoFillNotification::hide()
|
||||
{
|
||||
m_animation->setDirection(QTimeLine::Backward);
|
||||
|
||||
m_animation->stop();
|
||||
m_animation->start();
|
||||
connect(m_animation, SIGNAL(finished()), this, SLOT(close()));
|
||||
}
|
||||
|
||||
void AutoFillNotification::frameChanged(int frame)
|
||||
{
|
||||
setMinimumHeight(frame);
|
||||
setMaximumHeight(frame);
|
||||
QTimer::singleShot(1, this, SLOT(startAnimation()));
|
||||
}
|
||||
|
||||
void AutoFillNotification::never()
|
||||
|
@ -20,15 +20,16 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QUrl>
|
||||
#include <QTimeLine>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
|
||||
#include "notification.h"
|
||||
|
||||
namespace Ui {
|
||||
class AutoFillWidget;
|
||||
}
|
||||
|
||||
class AutoFillNotification : public QWidget
|
||||
class Notification;
|
||||
class AutoFillNotification : public Notification
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -37,12 +38,9 @@ public:
|
||||
~AutoFillNotification();
|
||||
|
||||
private slots:
|
||||
void frameChanged(int frame);
|
||||
void remember();
|
||||
void never();
|
||||
|
||||
void hide();
|
||||
|
||||
private:
|
||||
Ui::AutoFillWidget *ui;
|
||||
QUrl m_url;
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "qupzilla.h"
|
||||
|
||||
RSSNotification::RSSNotification(QString host, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
Notification(parent),
|
||||
ui(new Ui::RSSNotification)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
@ -38,29 +38,7 @@ RSSNotification::RSSNotification(QString host, QWidget *parent) :
|
||||
connect(ui->pushButton, SIGNAL(clicked()), mApp->getWindow(), SLOT(showRSSManager()));
|
||||
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(hide()));
|
||||
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
|
||||
|
||||
m_animation = new QTimeLine(300, this);
|
||||
m_animation->setFrameRange(0, sizeHint().height());
|
||||
|
||||
setMinimumHeight(1);
|
||||
setMaximumHeight(1);
|
||||
connect(m_animation, SIGNAL(frameChanged(int)),this, SLOT(frameChanged(int)));
|
||||
QTimer::singleShot(1, m_animation, SLOT(start()));
|
||||
}
|
||||
|
||||
void RSSNotification::hide()
|
||||
{
|
||||
m_animation->setDirection(QTimeLine::Backward);
|
||||
|
||||
m_animation->stop();
|
||||
m_animation->start();
|
||||
connect(m_animation, SIGNAL(finished()), this, SLOT(close()));
|
||||
}
|
||||
|
||||
void RSSNotification::frameChanged(int frame)
|
||||
{
|
||||
setMinimumHeight(frame);
|
||||
setMaximumHeight(frame);
|
||||
QTimer::singleShot(1, this, SLOT(startAnimation()));
|
||||
}
|
||||
|
||||
RSSNotification::~RSSNotification()
|
||||
|
@ -19,13 +19,15 @@
|
||||
#define RSSNOTIFICATION_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimeLine>
|
||||
|
||||
#include "notification.h"
|
||||
|
||||
namespace Ui {
|
||||
class RSSNotification;
|
||||
}
|
||||
|
||||
class RSSNotification : public QWidget
|
||||
class Notification;
|
||||
class RSSNotification : public Notification
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -33,10 +35,6 @@ public:
|
||||
explicit RSSNotification(QString host, QWidget *parent = 0);
|
||||
~RSSNotification();
|
||||
|
||||
private slots:
|
||||
void hide();
|
||||
void frameChanged(int frame);
|
||||
|
||||
private:
|
||||
Ui::RSSNotification *ui;
|
||||
QTimeLine* m_animation;
|
||||
|
39
src/tools/notification.cpp
Normal file
39
src/tools/notification.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include "notification.h"
|
||||
|
||||
Notification::Notification(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
,m_animation(0)
|
||||
{
|
||||
setMinimumHeight(1);
|
||||
setMaximumHeight(1);
|
||||
setUpdatesEnabled(false);
|
||||
}
|
||||
void Notification::startAnimation()
|
||||
{
|
||||
m_animation = new QTimeLine(300, this);
|
||||
m_animation->setFrameRange(0, sizeHint().height());
|
||||
setMinimumHeight(1);
|
||||
setMaximumHeight(1);
|
||||
setUpdatesEnabled(true);
|
||||
connect(m_animation, SIGNAL(frameChanged(int)),this, SLOT(frameChanged(int)));
|
||||
QTimer::singleShot(1, m_animation, SLOT(start()));
|
||||
}
|
||||
|
||||
void Notification::hide()
|
||||
{
|
||||
if (!m_animation) {
|
||||
close();
|
||||
return;
|
||||
}
|
||||
m_animation->setDirection(QTimeLine::Backward);
|
||||
|
||||
m_animation->stop();
|
||||
m_animation->start();
|
||||
connect(m_animation, SIGNAL(finished()), this, SLOT(close()));
|
||||
}
|
||||
|
||||
void Notification::frameChanged(int frame)
|
||||
{
|
||||
setMinimumHeight(frame);
|
||||
setMaximumHeight(frame);
|
||||
}
|
25
src/tools/notification.h
Normal file
25
src/tools/notification.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef NOTIFICATION_H
|
||||
#define NOTIFICATION_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimeLine>
|
||||
#include <QTimer>
|
||||
|
||||
class Notification : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Notification(QWidget *parent = 0);
|
||||
|
||||
public slots:
|
||||
void hide();
|
||||
void startAnimation();
|
||||
|
||||
private slots:
|
||||
void frameChanged(int frame);
|
||||
|
||||
private:
|
||||
QTimeLine* m_animation;
|
||||
};
|
||||
|
||||
#endif // NOTIFICATION_H
|
Loading…
Reference in New Issue
Block a user