1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Merge pull request #572 from ff2000/locatiobarpopup

Add new class "LocationBarPopup"
This commit is contained in:
David Rosca 2012-09-15 09:17:06 -07:00
commit c4eacede53
9 changed files with 65 additions and 74 deletions

View File

@ -29,7 +29,7 @@
#include <QTimer>
BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* parent)
: QMenu(parent)
: LocationBarPopup(parent)
, ui(new Ui::BookmarksWidget)
, p_QupZilla(mainClass)
, m_url(view->url())
@ -39,7 +39,6 @@ BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* pa
, m_edited(false)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
// The locationbar's direction is direction of its text,
// it dynamically changes and so, it's not good choice for this widget.
@ -53,14 +52,6 @@ BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* pa
tr("Remove from Speed Dial"));
loadBookmark();
if (mApp->currentStyle() == "gtk+" || mApp->currentStyle() == "bespin") {
// Use light color for QLabels with problematic styles
QPalette pal = palette();
pal.setColor(QPalette::WindowText, QToolTip::palette().color(QPalette::ToolTipText));
ui->label->setPalette(pal);
ui->label_2->setPalette(pal);
}
}
void BookmarksWidget::loadBookmark()
@ -140,17 +131,6 @@ void BookmarksWidget::on_saveRemove_clicked(bool)
QTimer::singleShot(hideDelay, this, SLOT(close()));
}
void BookmarksWidget::showAt(QWidget* _parent)
{
layout()->invalidate();
layout()->activate();
QPoint p = _parent->mapToGlobal(QPoint(0, 0));
move((p.x() + _parent->width()) - width(), p.y() + _parent->height());
show();
}
BookmarksWidget::~BookmarksWidget()
{
delete ui;

View File

@ -22,6 +22,7 @@
#include <QMenu>
#include "qz_namespace.h"
#include "locationbarpopup.h"
namespace Ui
{
@ -33,13 +34,12 @@ class SpeedDial;
class BookmarksModel;
class QupZilla;
class QT_QUPZILLA_EXPORT BookmarksWidget : public QMenu
class QT_QUPZILLA_EXPORT BookmarksWidget : public LocationBarPopup
{
Q_OBJECT
public:
explicit BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* parent = 0);
~BookmarksWidget();
void showAt(QWidget* _parent);
signals:
void bookmarkDeleted();

View File

@ -53,6 +53,7 @@ SOURCES += \
history/historymanager.cpp \
navigation/websearchbar.cpp \
navigation/locationbar.cpp \
navigation/locationbarpopup.cpp \
network/networkmanagerproxy.cpp \
network/networkmanager.cpp \
other/updater.cpp \

View File

@ -0,0 +1,29 @@
#include <QLayout>
#include "locationbarpopup.h"
LocationBarPopup::LocationBarPopup(QWidget* parent)
: QFrame(parent, Qt::Popup)
, m_alignment(Qt::AlignRight)
{
setAttribute(Qt::WA_DeleteOnClose);
setFrameStyle(QFrame::Panel | QFrame::Raised);
setLineWidth(1);
setMidLineWidth(2);
}
void LocationBarPopup::showAt(QWidget* parent)
{
layout()->invalidate();
layout()->activate();
QPoint p = parent->mapToGlobal(QPoint(0, 0));
if (m_alignment == Qt::AlignRight) {
p.setX(p.x() + parent->width() - width());
}
p.setY(p.y() + parent->height());
move(p);
show();
}

View File

@ -0,0 +1,24 @@
#ifndef QUPZILLA_LOCATION_BAR_POPUP
#define QUPZILLA_LOCATION_BAR_POPUP
#include <QFrame>
class LocationBarPopup : public QFrame
{
public:
LocationBarPopup(QWidget* parent);
void showAt(QWidget* parent);
void setPopupAlignment(Qt::Alignment alignment) {
m_alignment = alignment;
}
Qt::Alignment popupAlignment() const {
return m_alignment;
}
private:
Qt::Alignment m_alignment;
};
#endif

View File

@ -28,7 +28,7 @@
#include <QWebFrame>
RSSWidget::RSSWidget(WebView* view, QWidget* parent)
: QMenu(parent)
: LocationBarPopup(parent)
, ui(new Ui::RSSWidget)
, m_view(view)
{
@ -59,33 +59,9 @@ RSSWidget::RSSWidget(WebView* view, QWidget* parent)
ui->gridLayout->addWidget(label, i, 0);
ui->gridLayout->addWidget(button, i, 1);
connect(button, SIGNAL(clicked()), this, SLOT(addRss()));
if (mApp->currentStyle() == "gtk+" || mApp->currentStyle() == "bespin") {
// Use light color for QLabels with problematic styles
QPalette pal = palette();
pal.setColor(QPalette::WindowText, QToolTip::palette().color(QPalette::ToolTipText));
ui->label_2->setPalette(pal);
label->setPalette(pal);
}
}
}
void RSSWidget::showAt(QWidget* _parent)
{
layout()->invalidate();
layout()->activate();
const QPoint &widgetPos = _parent->mapToGlobal(QPoint(0, 0));
QPoint newPos;
newPos.setX(widgetPos.x() + _parent->width() - width());
newPos.setY(widgetPos.y() + _parent->height());
move(newPos);
show();
}
void RSSWidget::addRss()
{
if (!m_view) {

View File

@ -21,6 +21,7 @@
#include <QMenu>
#include "qz_namespace.h"
#include "locationbarpopup.h"
namespace Ui
{
@ -29,7 +30,7 @@ class RSSWidget;
class WebView;
class QT_QUPZILLA_EXPORT RSSWidget : public QMenu
class QT_QUPZILLA_EXPORT RSSWidget : public LocationBarPopup
{
Q_OBJECT
@ -37,8 +38,6 @@ public:
explicit RSSWidget(WebView* view, QWidget* parent = 0);
~RSSWidget();
void showAt(QWidget* _parent);
private slots:
void addRss();

View File

@ -26,13 +26,15 @@
#include <QSqlQuery>
SiteInfoWidget::SiteInfoWidget(QupZilla* mainClass, QWidget* parent)
: QMenu(parent)
: LocationBarPopup(parent)
, ui(new Ui::SiteInfoWidget)
, p_QupZilla(mainClass)
{
this->setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);
setPopupAlignment(Qt::AlignLeft);
WebView* view = p_QupZilla->weView();
WebPage* webPage = view->page();
QUrl url = view->url();
@ -80,25 +82,6 @@ SiteInfoWidget::SiteInfoWidget(QupZilla* mainClass, QWidget* parent)
}
}
connect(ui->pushButton, SIGNAL(clicked()), p_QupZilla, SLOT(showPageInfo()));
if (mApp->currentStyle() == "gtk+" || mApp->currentStyle() == "bespin") {
// Use light color for QLabels with problematic styles
QPalette pal = palette();
pal.setColor(QPalette::WindowText, QToolTip::palette().color(QPalette::Inactive, QPalette::ToolTipText));
ui->historyLabel->setPalette(pal);
ui->secureLabel->setPalette(pal);
}
}
void SiteInfoWidget::showAt(QWidget* _parent)
{
layout()->invalidate();
layout()->activate();
QPoint p = _parent->mapToGlobal(QPoint(0, 0));
move(p.x(), p.y() + _parent->height());
show();
}
SiteInfoWidget::~SiteInfoWidget()

View File

@ -21,6 +21,7 @@
#include <QMenu>
#include "qz_namespace.h"
#include <locationbarpopup.h>
namespace Ui
{
@ -29,15 +30,13 @@ class SiteInfoWidget;
class QupZilla;
class QT_QUPZILLA_EXPORT SiteInfoWidget : public QMenu
class QT_QUPZILLA_EXPORT SiteInfoWidget : public LocationBarPopup
{
Q_OBJECT
public:
explicit SiteInfoWidget(QupZilla* mainClass, QWidget* parent = 0);
~SiteInfoWidget();
void showAt(QWidget* _parent);
private:
Ui::SiteInfoWidget* ui;
QupZilla* p_QupZilla;