1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

PopupWindow: Use same notifications as WebTab

This commit is contained in:
David Rosca 2017-01-22 14:58:45 +01:00
parent 635cc8e5eb
commit abc7a2528b
3 changed files with 28 additions and 7 deletions

View File

@ -54,6 +54,17 @@ PopupWindow::PopupWindow(PopupWebView* view)
m_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_statusBarMessage = new PopupStatusBarMessage(this);
m_notificationWidget = new QWidget(this);
m_notificationWidget->setAutoFillBackground(true);
QPalette pal = m_notificationWidget->palette();
pal.setColor(QPalette::Background, pal.window().color().darker(110));
m_notificationWidget->setPalette(pal);
QVBoxLayout *nlayout = new QVBoxLayout(m_notificationWidget);
nlayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
nlayout->setContentsMargins(0, 0, 0, 0);
nlayout->setSpacing(1);
m_menuBar = new QMenuBar(this);
QMenu* menuFile = new QMenu(tr("File"));
@ -158,11 +169,11 @@ PopupWebView* PopupWindow::webView()
void PopupWindow::showNotification(QWidget* notif)
{
if (m_layout->count() > 4) {
delete m_layout->itemAt(2)->widget();
}
m_layout->insertWidget(2, notif);
m_notificationWidget->setParent(nullptr);
m_notificationWidget->setParent(m_view->overlayWidget());
m_notificationWidget->setFixedWidth(m_view->width());
m_notificationWidget->layout()->addWidget(notif);
m_notificationWidget->show();
notif->show();
}
@ -218,6 +229,13 @@ void PopupWindow::closeEvent(QCloseEvent* event)
event->accept();
}
void PopupWindow::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
m_notificationWidget->setFixedWidth(m_view->width());
}
void PopupWindow::searchOnPage()
{
if (!m_search) {

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2015 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
@ -60,6 +60,7 @@ private slots:
private:
void closeEvent(QCloseEvent* event);
void resizeEvent(QResizeEvent *event) override;
PopupWebView* m_view;
PopupLocationBar* m_locationBar;
@ -74,6 +75,7 @@ private:
QAction* m_actionReload;
QAction* m_actionStop;
QPointer<SearchToolBar> m_search;
QWidget *m_notificationWidget;
};
#endif // POPUPWINDOW_H

View File

@ -425,6 +425,7 @@ void WebTab::showNotification(QWidget* notif)
{
m_notificationWidget->setParent(nullptr);
m_notificationWidget->setParent(this);
m_notificationWidget->setFixedWidth(width());
m_notificationWidget->layout()->addWidget(notif);
m_notificationWidget->show();
notif->show();