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

WebTab: Show notifications over webview

Mouse grab permission workaround now can be removed as the notification
(and mouse cursor) is inside webview
This commit is contained in:
David Rosca 2017-01-21 16:33:32 +01:00
parent 5cc7dd080e
commit eeef5da06c
3 changed files with 25 additions and 21 deletions

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2013-2015 David Rosca <nowrep@gmail.com>
* QupZilla - Qt web browser
* Copyright (C) 2013-2017 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
@ -87,15 +87,7 @@ void HTML5PermissionsNotification::grantPermissions()
return;
}
QTimer::singleShot(0, this, [this]() {
// We need to have cursor inside view to correctly grab mouse
if (m_feature == QWebEnginePage::MouseLock) {
QWidget *view = m_page->view();
QCursor::setPos(view->mapToGlobal(view->rect().center()));
}
m_page->setFeaturePermission(m_origin, m_feature, QWebEnginePage::PermissionGrantedByUser);
});
if (ui->remember->isChecked()) {
mApp->html5PermissionsManager()->rememberPermissions(m_origin, m_feature, QWebEnginePage::PermissionGrantedByUser);

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
* QupZilla - Qt web browser
* Copyright (C) 2010-2017 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
@ -385,14 +385,14 @@ void WebTab::p_restoreTab(const WebTab::SavedTab &tab)
void WebTab::showNotification(QWidget* notif)
{
const int notifPos = 0;
if (m_layout->count() > notifPos + 1) {
delete m_layout->itemAt(notifPos)->widget();
if (m_notification) {
delete m_notification;
}
m_layout->insertWidget(notifPos, notif);
notif->show();
m_notification = notif;
m_notification->setParent(this);
m_notification->setFixedWidth(width());;
m_notification->show();
}
void WebTab::loadStarted()
@ -445,6 +445,15 @@ void WebTab::showEvent(QShowEvent* event)
}
}
void WebTab::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
if (m_notification) {
m_notification->setFixedWidth(width());
}
}
bool WebTab::isCurrentTab() const
{
return m_tabBar && tabIndex() == m_tabBar->currentIndex();

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
* QupZilla - Qt web browser
* Copyright (C) 2010-2017 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
@ -21,6 +21,7 @@
#include <QWidget>
#include <QIcon>
#include <QUrl>
#include <QPointer>
#include "qzcommon.h"
@ -111,6 +112,7 @@ private slots:
private:
void showEvent(QShowEvent* event);
void resizeEvent(QResizeEvent *event) override;
BrowserWindow* m_window;
QVBoxLayout* m_layout;
@ -121,6 +123,7 @@ private:
LocationBar* m_locationBar;
TabIcon* m_tabIcon;
TabBar* m_tabBar;
QPointer<QWidget> m_notification;
SavedTab m_savedTab;
bool m_isPinned;