1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-14 02:52:12 +01:00

Address of hovered link won't stuck at screen when changing to other

window anymore.
This commit is contained in:
nowrep 2011-07-19 23:26:34 +02:00
parent 9801c59535
commit a8881c1d73
2 changed files with 64 additions and 23 deletions

View File

@ -2,38 +2,60 @@
#include "qupzilla.h" #include "qupzilla.h"
#include "squeezelabelv1.h" #include "squeezelabelv1.h"
TipLabel::TipLabel(QupZilla* parent) : SqueezeLabelV1(parent) , p_QupZilla(parent)
{
m_timer = new QTimer();
m_timer->setInterval(300);
connect(m_timer, SIGNAL(timeout()), this, SLOT(checkMainWindowFocus()));
class TipLabel : public SqueezeLabelV1 { setWindowFlags(Qt::ToolTip);
public: setForegroundRole(QPalette::ToolTipText);
TipLabel() setBackgroundRole(QPalette::ToolTipBase);
{ setPalette(QToolTip::palette());
setWindowFlags(Qt::ToolTip); ensurePolished();
setForegroundRole(QPalette::ToolTipText); setFrameStyle(QFrame::NoFrame);
setBackgroundRole(QPalette::ToolTipBase); setMargin(2);
setPalette(QToolTip::palette()); }
ensurePolished();
setFrameStyle(QFrame::NoFrame);
setMargin(2);
}
void paintEvent(QPaintEvent *ev) void TipLabel::paintEvent(QPaintEvent *ev)
{ {
QStylePainter p(this); QStylePainter p(this);
QStyleOptionFrame opt; QStyleOptionFrame opt;
opt.init(this); opt.init(this);
p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); p.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
p.end(); p.end();
SqueezeLabelV1::paintEvent(ev);
}
void TipLabel::show()
{
if (!p_QupZilla->weView()->hasFocus())
return;
m_timer->start();
SqueezeLabelV1::show();
}
void TipLabel::hide()
{
m_timer->stop();
SqueezeLabelV1::hide();
}
void TipLabel::checkMainWindowFocus()
{
if (!p_QupZilla->weView()->hasFocus())
hide();
}
SqueezeLabelV1::paintEvent(ev);
}
};
StatusBarMessage::StatusBarMessage(QupZilla* mainClass) StatusBarMessage::StatusBarMessage(QupZilla* mainClass)
: QObject() : QObject()
, p_QupZilla(mainClass) , p_QupZilla(mainClass)
{ {
m_statusBarText = new TipLabel(); m_statusBarText = new TipLabel(mainClass);
} }
#define STATUS_Y_OFFSET -35 #define STATUS_Y_OFFSET -35

View File

@ -3,9 +3,28 @@
#include <QObject> #include <QObject>
#include <QToolTip> #include <QToolTip>
#include "squeezelabelv1.h"
class QupZilla; class QupZilla;
class TipLabel; class TipLabel;
class TipLabel : public SqueezeLabelV1 {
Q_OBJECT
public:
TipLabel(QupZilla* parent);
void paintEvent(QPaintEvent *ev);
void show();
void hide();
private slots:
void checkMainWindowFocus();
private:
QTimer* m_timer;
QupZilla* p_QupZilla;
};
class StatusBarMessage : public QObject class StatusBarMessage : public QObject
{ {
Q_OBJECT Q_OBJECT