From f3221c70d6a9d77b9cbfb2da93fd3aa5e40d374f Mon Sep 17 00:00:00 2001 From: Franz Fellner Date: Sat, 15 Sep 2012 17:39:54 +0200 Subject: [PATCH] Introduce LocationBarPopup as base for - popups in the location bar. The switch is needed due to palette problems on some color schemes (e.g. inverted look for popupmenus or tooltips), which could lead to unreadable text. --- src/lib/bookmarks/bookmarkswidget.cpp | 22 +--------------------- src/lib/bookmarks/bookmarkswidget.h | 4 ++-- src/lib/lib.pro | 1 + src/lib/rss/rsswidget.cpp | 26 +------------------------- src/lib/rss/rsswidget.h | 5 ++--- src/lib/webview/siteinfowidget.cpp | 23 +++-------------------- src/lib/webview/siteinfowidget.h | 5 ++--- 7 files changed, 12 insertions(+), 74 deletions(-) diff --git a/src/lib/bookmarks/bookmarkswidget.cpp b/src/lib/bookmarks/bookmarkswidget.cpp index 4e6d01267..e2b585084 100644 --- a/src/lib/bookmarks/bookmarkswidget.cpp +++ b/src/lib/bookmarks/bookmarkswidget.cpp @@ -29,7 +29,7 @@ #include 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; diff --git a/src/lib/bookmarks/bookmarkswidget.h b/src/lib/bookmarks/bookmarkswidget.h index 8475639b9..721fcc102 100644 --- a/src/lib/bookmarks/bookmarkswidget.h +++ b/src/lib/bookmarks/bookmarkswidget.h @@ -22,6 +22,7 @@ #include #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(); diff --git a/src/lib/lib.pro b/src/lib/lib.pro index 676709933..2470b59aa 100644 --- a/src/lib/lib.pro +++ b/src/lib/lib.pro @@ -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 \ diff --git a/src/lib/rss/rsswidget.cpp b/src/lib/rss/rsswidget.cpp index 2defdd7d2..064cf03df 100644 --- a/src/lib/rss/rsswidget.cpp +++ b/src/lib/rss/rsswidget.cpp @@ -28,7 +28,7 @@ #include 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) { diff --git a/src/lib/rss/rsswidget.h b/src/lib/rss/rsswidget.h index b6975aa09..d62a8119e 100644 --- a/src/lib/rss/rsswidget.h +++ b/src/lib/rss/rsswidget.h @@ -21,6 +21,7 @@ #include #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(); diff --git a/src/lib/webview/siteinfowidget.cpp b/src/lib/webview/siteinfowidget.cpp index f0d5eb0eb..ab6dfe5f0 100644 --- a/src/lib/webview/siteinfowidget.cpp +++ b/src/lib/webview/siteinfowidget.cpp @@ -26,13 +26,15 @@ #include 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() diff --git a/src/lib/webview/siteinfowidget.h b/src/lib/webview/siteinfowidget.h index 557a9091d..e82938f16 100644 --- a/src/lib/webview/siteinfowidget.h +++ b/src/lib/webview/siteinfowidget.h @@ -21,6 +21,7 @@ #include #include "qz_namespace.h" +#include 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;