2012-03-04 14:25:52 +01:00
|
|
|
/* ============================================================
|
|
|
|
* QupZilla - WebKit based browser
|
2014-01-11 16:11:42 +01:00
|
|
|
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
2012-03-04 14:25:52 +01:00
|
|
|
*
|
|
|
|
* 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"
|
2012-04-03 19:28:12 +02:00
|
|
|
#include "webpage.h"
|
2012-03-04 14:25:52 +01:00
|
|
|
#include "statusbarmessage.h"
|
|
|
|
#include "mainapplication.h"
|
|
|
|
|
|
|
|
#include <QStatusBar>
|
|
|
|
#include <QStyle>
|
|
|
|
|
2014-02-19 22:07:21 +01:00
|
|
|
PopupStatusBarMessage::PopupStatusBarMessage(PopupWindow* window)
|
|
|
|
: m_popupWindow(window)
|
|
|
|
, m_statusBarText(new TipLabel(window))
|
2012-03-04 14:25:52 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void PopupStatusBarMessage::showMessage(const QString &message)
|
|
|
|
{
|
|
|
|
if (m_popupWindow->statusBar()->isVisible()) {
|
|
|
|
m_popupWindow->statusBar()->showMessage(message);
|
|
|
|
}
|
2012-09-03 22:48:52 +02:00
|
|
|
#ifdef Q_OS_WIN
|
2012-03-04 14:25:52 +01:00
|
|
|
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());
|
2012-03-04 14:25:52 +01:00
|
|
|
m_statusBarText->resize(m_statusBarText->sizeHint());
|
|
|
|
|
|
|
|
QPoint position;
|
2015-08-30 17:42:58 +02:00
|
|
|
position.setY(view->height() - m_statusBarText->height());
|
2012-03-04 14:25:52 +01:00
|
|
|
|
|
|
|
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));
|
2012-03-26 17:47:05 +02:00
|
|
|
m_statusBarText->show(view);
|
2012-03-04 14:25:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PopupStatusBarMessage::clearMessage()
|
|
|
|
{
|
|
|
|
if (m_popupWindow->statusBar()->isVisible()) {
|
2012-09-02 11:42:41 +02:00
|
|
|
m_popupWindow->statusBar()->showMessage(QString());
|
2012-03-04 14:25:52 +01:00
|
|
|
}
|
|
|
|
else {
|
2012-03-21 13:00:30 +01:00
|
|
|
m_statusBarText->hideDelayed();
|
2012-03-04 14:25:52 +01:00
|
|
|
}
|
|
|
|
}
|