mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Merge pull request #572 from ff2000/locatiobarpopup
Add new class "LocationBarPopup"
This commit is contained in:
commit
c4eacede53
@ -29,7 +29,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* parent)
|
BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* parent)
|
||||||
: QMenu(parent)
|
: LocationBarPopup(parent)
|
||||||
, ui(new Ui::BookmarksWidget)
|
, ui(new Ui::BookmarksWidget)
|
||||||
, p_QupZilla(mainClass)
|
, p_QupZilla(mainClass)
|
||||||
, m_url(view->url())
|
, m_url(view->url())
|
||||||
@ -39,7 +39,6 @@ BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* pa
|
|||||||
, m_edited(false)
|
, m_edited(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
|
|
||||||
// The locationbar's direction is direction of its text,
|
// The locationbar's direction is direction of its text,
|
||||||
// it dynamically changes and so, it's not good choice for this widget.
|
// 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"));
|
tr("Remove from Speed Dial"));
|
||||||
|
|
||||||
loadBookmark();
|
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()
|
void BookmarksWidget::loadBookmark()
|
||||||
@ -140,17 +131,6 @@ void BookmarksWidget::on_saveRemove_clicked(bool)
|
|||||||
QTimer::singleShot(hideDelay, this, SLOT(close()));
|
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()
|
BookmarksWidget::~BookmarksWidget()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
#include "qz_namespace.h"
|
#include "qz_namespace.h"
|
||||||
|
#include "locationbarpopup.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@ -33,13 +34,12 @@ class SpeedDial;
|
|||||||
class BookmarksModel;
|
class BookmarksModel;
|
||||||
class QupZilla;
|
class QupZilla;
|
||||||
|
|
||||||
class QT_QUPZILLA_EXPORT BookmarksWidget : public QMenu
|
class QT_QUPZILLA_EXPORT BookmarksWidget : public LocationBarPopup
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* parent = 0);
|
explicit BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* parent = 0);
|
||||||
~BookmarksWidget();
|
~BookmarksWidget();
|
||||||
void showAt(QWidget* _parent);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void bookmarkDeleted();
|
void bookmarkDeleted();
|
||||||
|
@ -53,6 +53,7 @@ SOURCES += \
|
|||||||
history/historymanager.cpp \
|
history/historymanager.cpp \
|
||||||
navigation/websearchbar.cpp \
|
navigation/websearchbar.cpp \
|
||||||
navigation/locationbar.cpp \
|
navigation/locationbar.cpp \
|
||||||
|
navigation/locationbarpopup.cpp \
|
||||||
network/networkmanagerproxy.cpp \
|
network/networkmanagerproxy.cpp \
|
||||||
network/networkmanager.cpp \
|
network/networkmanager.cpp \
|
||||||
other/updater.cpp \
|
other/updater.cpp \
|
||||||
|
29
src/lib/navigation/locationbarpopup.cpp
Normal file
29
src/lib/navigation/locationbarpopup.cpp
Normal 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();
|
||||||
|
}
|
24
src/lib/navigation/locationbarpopup.h
Normal file
24
src/lib/navigation/locationbarpopup.h
Normal 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
|
@ -28,7 +28,7 @@
|
|||||||
#include <QWebFrame>
|
#include <QWebFrame>
|
||||||
|
|
||||||
RSSWidget::RSSWidget(WebView* view, QWidget* parent)
|
RSSWidget::RSSWidget(WebView* view, QWidget* parent)
|
||||||
: QMenu(parent)
|
: LocationBarPopup(parent)
|
||||||
, ui(new Ui::RSSWidget)
|
, ui(new Ui::RSSWidget)
|
||||||
, m_view(view)
|
, m_view(view)
|
||||||
{
|
{
|
||||||
@ -59,33 +59,9 @@ RSSWidget::RSSWidget(WebView* view, QWidget* parent)
|
|||||||
ui->gridLayout->addWidget(label, i, 0);
|
ui->gridLayout->addWidget(label, i, 0);
|
||||||
ui->gridLayout->addWidget(button, i, 1);
|
ui->gridLayout->addWidget(button, i, 1);
|
||||||
connect(button, SIGNAL(clicked()), this, SLOT(addRss()));
|
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()
|
void RSSWidget::addRss()
|
||||||
{
|
{
|
||||||
if (!m_view) {
|
if (!m_view) {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
#include "qz_namespace.h"
|
#include "qz_namespace.h"
|
||||||
|
#include "locationbarpopup.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@ -29,7 +30,7 @@ class RSSWidget;
|
|||||||
|
|
||||||
class WebView;
|
class WebView;
|
||||||
|
|
||||||
class QT_QUPZILLA_EXPORT RSSWidget : public QMenu
|
class QT_QUPZILLA_EXPORT RSSWidget : public LocationBarPopup
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -37,8 +38,6 @@ public:
|
|||||||
explicit RSSWidget(WebView* view, QWidget* parent = 0);
|
explicit RSSWidget(WebView* view, QWidget* parent = 0);
|
||||||
~RSSWidget();
|
~RSSWidget();
|
||||||
|
|
||||||
void showAt(QWidget* _parent);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addRss();
|
void addRss();
|
||||||
|
|
||||||
|
@ -26,13 +26,15 @@
|
|||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
|
|
||||||
SiteInfoWidget::SiteInfoWidget(QupZilla* mainClass, QWidget* parent)
|
SiteInfoWidget::SiteInfoWidget(QupZilla* mainClass, QWidget* parent)
|
||||||
: QMenu(parent)
|
: LocationBarPopup(parent)
|
||||||
, ui(new Ui::SiteInfoWidget)
|
, ui(new Ui::SiteInfoWidget)
|
||||||
, p_QupZilla(mainClass)
|
, p_QupZilla(mainClass)
|
||||||
{
|
{
|
||||||
this->setAttribute(Qt::WA_DeleteOnClose);
|
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
setPopupAlignment(Qt::AlignLeft);
|
||||||
|
|
||||||
WebView* view = p_QupZilla->weView();
|
WebView* view = p_QupZilla->weView();
|
||||||
WebPage* webPage = view->page();
|
WebPage* webPage = view->page();
|
||||||
QUrl url = view->url();
|
QUrl url = view->url();
|
||||||
@ -80,25 +82,6 @@ SiteInfoWidget::SiteInfoWidget(QupZilla* mainClass, QWidget* parent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
connect(ui->pushButton, SIGNAL(clicked()), p_QupZilla, SLOT(showPageInfo()));
|
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()
|
SiteInfoWidget::~SiteInfoWidget()
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
#include "qz_namespace.h"
|
#include "qz_namespace.h"
|
||||||
|
#include <locationbarpopup.h>
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@ -29,15 +30,13 @@ class SiteInfoWidget;
|
|||||||
|
|
||||||
class QupZilla;
|
class QupZilla;
|
||||||
|
|
||||||
class QT_QUPZILLA_EXPORT SiteInfoWidget : public QMenu
|
class QT_QUPZILLA_EXPORT SiteInfoWidget : public LocationBarPopup
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SiteInfoWidget(QupZilla* mainClass, QWidget* parent = 0);
|
explicit SiteInfoWidget(QupZilla* mainClass, QWidget* parent = 0);
|
||||||
~SiteInfoWidget();
|
~SiteInfoWidget();
|
||||||
|
|
||||||
void showAt(QWidget* _parent);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SiteInfoWidget* ui;
|
Ui::SiteInfoWidget* ui;
|
||||||
QupZilla* p_QupZilla;
|
QupZilla* p_QupZilla;
|
||||||
|
Loading…
Reference in New Issue
Block a user