1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-14 11:02:19 +01:00
falkonOfficial/src/lib/popupwindow/popupstatusbarmessage.cpp

73 lines
2.3 KiB
C++
Raw Normal View History

/* ============================================================
2017-08-25 17:11:29 +02:00
* Falkon - Qt web browser
2014-01-11 16:11:42 +01:00
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "popupstatusbarmessage.h"
#include "popupwindow.h"
#include "popupwebview.h"
#include "webpage.h"
#include "statusbarmessage.h"
#include "mainapplication.h"
#include <QStatusBar>
#include <QStyle>
PopupStatusBarMessage::PopupStatusBarMessage(PopupWindow* window)
: m_popupWindow(window)
, m_statusBarText(new TipLabel(window))
{
}
void PopupStatusBarMessage::showMessage(const QString &message)
{
if (m_popupWindow->statusBar()->isVisible()) {
m_popupWindow->statusBar()->showMessage(message);
}
#ifdef Q_OS_WIN
else if (mApp->activeWindow() == m_popupWindow) {
#else
else {
#endif
PopupWebView* view = m_popupWindow->webView();
m_statusBarText->setText(message);
2015-08-30 17:42:58 +02:00
m_statusBarText->setMaximumWidth(view->width());
m_statusBarText->resize(m_statusBarText->sizeHint());
QPoint position;
2015-08-30 17:42:58 +02:00
position.setY(view->height() - m_statusBarText->height());
QRect statusRect = QRect(view->mapToGlobal(QPoint(0, position.y())), m_statusBarText->size());
if (statusRect.contains(QCursor::pos())) {
position.setY(position.y() - m_statusBarText->height());
}
m_statusBarText->move(view->mapToGlobal(position));
m_statusBarText->show(view);
}
}
void PopupStatusBarMessage::clearMessage()
{
if (m_popupWindow->statusBar()->isVisible()) {
m_popupWindow->statusBar()->showMessage(QString());
}
else {
m_statusBarText->hideDelayed();
}
}