Falkon Develop
Cross-platform Qt-based web browser
popupstatusbarmessage.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
19#include "popupwindow.h"
20#include "popupwebview.h"
21#include "webpage.h"
22#include "mainapplication.h"
23
24#include <QStatusBar>
25#include <QStyle>
26
28 : m_popupWindow(window)
29 , m_statusBarText(new TipLabel(window))
30{
31}
32
33void PopupStatusBarMessage::showMessage(const QString &message)
34{
35 if (m_popupWindow->statusBar()->isVisible()) {
36 m_popupWindow->statusBar()->showMessage(message);
37 }
38#ifdef Q_OS_WIN
39 else if (mApp->activeWindow() == m_popupWindow) {
40#else
41 else {
42#endif
43 PopupWebView* view = m_popupWindow->webView();
44
45 m_statusBarText->setText(message);
46 m_statusBarText->setMaximumWidth(view->width());
47 m_statusBarText->resize(m_statusBarText->sizeHint());
48
49 QPoint position;
50 position.setY(view->height() - m_statusBarText->height());
51
52 QRect statusRect = QRect(view->mapToGlobal(QPoint(0, position.y())), m_statusBarText->size());
53
54 if (statusRect.contains(QCursor::pos())) {
55 position.setY(position.y() - m_statusBarText->height());
56 }
57
58 m_statusBarText->move(view->mapToGlobal(position));
59 m_statusBarText->show(view);
60 }
61}
62
64{
65 if (m_popupWindow->statusBar()->isVisible()) {
66 m_popupWindow->statusBar()->showMessage(QString());
67 }
68 else {
69 m_statusBarText->hideDelayed();
70 }
71}
PopupStatusBarMessage(PopupWindow *window)
void showMessage(const QString &message)
QStatusBar * statusBar()
PopupWebView * webView()
void show(QWidget *widget)
Definition: statusbar.cpp:124
void hideDelayed()
Definition: statusbar.cpp:132
#define mApp