29#include <QStyleOptionFrame>
31#include <QStylePainter>
53 setCursor(Qt::PointingHandCursor);
67void StatusBarButton::clicked()
71 c->popupPosition = [=](
const QSize &size) {
72 QPoint pos = mapToGlobal(rect().topRight());
73 if (QApplication::isRightToLeft()) {
74 pos.setX(pos.x() - rect().width());
76 pos.setX(pos.x() - size.width());
78 pos.setY(pos.y() - size.height());
79 c->popupOpened =
true;
82 c->popupClosed = [=]() {
86 if (!c->popupOpened) {
91void StatusBarButton::updateIcon()
93 const QIcon::Mode mode = m_button->
isActive() ? QIcon::Normal : QIcon::Disabled;
94 const QImage img = m_button->
icon().pixmap(size(), mode).toImage();
95 setPixmap(QPixmap::fromImage(img, Qt::MonoOnly));
98void StatusBarButton::updateToolTip()
100 QString text = m_button->
toolTip();
110 setWindowFlags(Qt::ToolTip);
111 setForegroundRole(QPalette::ToolTipText);
112 setBackgroundRole(QPalette::ToolTipBase);
113 setPalette(QToolTip::palette());
115 setFrameStyle(QFrame::NoFrame);
116 setContentsMargins(3, 3, 3, 3);
118 m_timer =
new QTimer(
this);
119 m_timer->setSingleShot(
true);
120 m_timer->setInterval(500);
121 connect(m_timer, &QTimer::timeout,
this, &QWidget::hide);
128 widget->installEventFilter(
this);
129 SqueezeLabelV1::show();
137void TipLabel::paintEvent(QPaintEvent* ev)
139 QStylePainter p(
this);
140 QStyleOptionFrame opt;
142 p.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
154 case QEvent::WindowDeactivate:
159 case QEvent::MouseMove:
160 case QEvent::MouseButtonPress:
161 case QEvent::MouseButtonRelease:
175 , m_statusBarText(new
TipLabel(window))
182 const static QChar LRE(0x202a);
183 QStatusBar::showMessage(message.isRightToLeft() ? message : (LRE + message), timeout);
187 if (
mApp->activeWindow() != m_window) {
194 const int horizontalScrollSize = view->
scrollBarGeometry(Qt::Horizontal).height();
196 m_statusBarText->setText(message);
197 m_statusBarText->setMaximumWidth(view->width() - verticalScrollSize);
198 m_statusBarText->resize(m_statusBarText->sizeHint());
200 QPoint position(0, view->height() - horizontalScrollSize - m_statusBarText->height());
201 const QRect statusRect = QRect(view->mapToGlobal(QPoint(0, position.y())), m_statusBarText->size());
203 if (statusRect.contains(QCursor::pos())) {
204 position.setY(position.y() - m_statusBarText->height());
207 m_statusBarText->move(view->mapToGlobal(position));
208 m_statusBarText->
show(view);
213 QStatusBar::clearMessage();
219 if (!button || !button->
isValid()) {
224 widget->setProperty(
"button-id", button->
id());
227 data.id = button->
id();
228 data.widget = widget;
229 data.button = button;
230 m_widgets[data.id] = data;
232 addPermanentWidget(widget);
237 if (!button || !m_widgets.contains(button->
id())) {
241 delete m_widgets.take(button->
id()).widget;
246 if (event->button() == Qt::RightButton) {
249 context.exec(QCursor::pos());
252 QStatusBar::mousePressEvent(event);
void toggleShowStatusBar()
TabbedWebView * weView() const
void paintEvent(QPaintEvent *event) override
void mousePressEvent(QMouseEvent *event) override
StatusBar(BrowserWindow *window)
void addButton(AbstractButtonInterface *button)
void removeButton(AbstractButtonInterface *button)
void showMessage(const QString &message, int timeout=0)
bool eventFilter(QObject *o, QEvent *e) override
TipLabel(QWidget *parent)
void show(QWidget *widget)
QRect scrollBarGeometry(Qt::Orientation orientation) const