diff --git a/src/lib/navigation/navigationbar.cpp b/src/lib/navigation/navigationbar.cpp index 7f37272bc..d468beca1 100644 --- a/src/lib/navigation/navigationbar.cpp +++ b/src/lib/navigation/navigationbar.cpp @@ -34,7 +34,7 @@ #include #include -QString titleForUrl(QString title, const QUrl &url) +QString NavigationBar::titleForUrl(QString title, const QUrl &url) { if (title.isEmpty()) { title = url.toString(QUrl::RemoveFragment); @@ -50,7 +50,7 @@ QString titleForUrl(QString title, const QUrl &url) return title; } -QIcon iconForPage(const QUrl &url, const QIcon &sIcon) +QIcon NavigationBar::iconForPage(const QUrl &url, const QIcon &sIcon) { QIcon icon; icon.addPixmap(url.scheme() == QLatin1String("qupzilla") ? QIcon(":icons/qupzilla.png").pixmap(16, 16) : _iconForUrl(url).pixmap(16, 16)); @@ -58,8 +58,8 @@ QIcon iconForPage(const QUrl &url, const QIcon &sIcon) return icon; } -NavigationBar::NavigationBar(QupZilla* mainClass, QWidget* parent) - : QWidget(parent) +NavigationBar::NavigationBar(QupZilla* mainClass) + : QWidget(mainClass) , p_QupZilla(mainClass) { setObjectName("navigationbar"); @@ -356,8 +356,3 @@ void NavigationBar::goForwardInNewTab() goAtHistoryIndexInNewTab(itemIndex); } - -NavigationBar::~NavigationBar() -{ - delete m_searchLine; -} diff --git a/src/lib/navigation/navigationbar.h b/src/lib/navigation/navigationbar.h index 8a1a88b53..0c5ef7a57 100644 --- a/src/lib/navigation/navigationbar.h +++ b/src/lib/navigation/navigationbar.h @@ -30,12 +30,13 @@ class WebSearchBar; class QupZilla; class ReloadStopButton; class Menu; +class QUrl; + class QT_QUPZILLA_EXPORT NavigationBar : public QWidget { Q_OBJECT public: - explicit NavigationBar(QupZilla* mainClass, QWidget* parent = 0); - ~NavigationBar(); + explicit NavigationBar(QupZilla* mainClass); void setSplitterSizes(int locationBar, int websearchBar); @@ -71,6 +72,9 @@ private slots: void clearHistory(); private: + QString titleForUrl(QString title, const QUrl &url); + QIcon iconForPage(const QUrl &url, const QIcon &sIcon); + QupZilla* p_QupZilla; QHBoxLayout* m_layout; diff --git a/src/lib/navigation/websearchbar.cpp b/src/lib/navigation/websearchbar.cpp index ebc36a425..b2868ea8b 100644 --- a/src/lib/navigation/websearchbar.cpp +++ b/src/lib/navigation/websearchbar.cpp @@ -50,10 +50,9 @@ void WebSearchBar_Button::contextMenuEvent(QContextMenuEvent* event) event->accept(); } -WebSearchBar::WebSearchBar(QupZilla* mainClass, QWidget* parent) - : LineEdit(parent) +WebSearchBar::WebSearchBar(QupZilla* mainClass) + : LineEdit(mainClass) , p_QupZilla(mainClass) - , m_menu(new QMenu(this)) , m_pasteAndGoAction(0) , m_clearAction(0) , m_reloadingEngines(false) @@ -266,13 +265,13 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event) } QMenu* tempMenu = createStandardContextMenu(); - m_menu->clear(); + QMenu menu(this); int i = 0; foreach(QAction * act, tempMenu->actions()) { - act->setParent(m_menu); + act->setParent(&menu); tempMenu->removeAction(act); - m_menu->addAction(act); + menu.addAction(act); switch (i) { case 0: @@ -289,13 +288,13 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event) break; case 5: act->setIcon(QIcon::fromTheme("edit-paste")); - m_menu->addAction(act); - m_menu->addAction(m_pasteAndGoAction); + menu.addAction(act); + menu.addAction(m_pasteAndGoAction); break; case 6: act->setIcon(QIcon::fromTheme("edit-delete")); - m_menu->addAction(act); - m_menu->addAction(m_clearAction); + menu.addAction(act); + menu.addAction(m_clearAction); break; case 8: act->setIcon(QIcon::fromTheme("edit-select-all")); @@ -306,13 +305,13 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event) tempMenu->deleteLater(); - m_menu->addSeparator(); - QAction* act = m_menu->addAction(tr("Show suggestions")); + menu.addSeparator(); + QAction* act = menu.addAction(tr("Show suggestions")); act->setCheckable(true); act->setChecked(qzSettings->showSearchSuggestions); connect(act, SIGNAL(triggered(bool)), this, SLOT(enableSearchSuggestions(bool))); - QAction* instantSearch = m_menu->addAction(tr("Search when engine changed")); + QAction* instantSearch = menu.addAction(tr("Search when engine changed")); instantSearch->setCheckable(true); instantSearch->setChecked(qzSettings->searchOnEngineChange); connect(instantSearch, SIGNAL(triggered(bool)), this, SLOT(instantSearchChanged(bool))); @@ -322,7 +321,7 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event) //Prevent choosing first option with double rightclick QPoint pos = event->globalPos(); QPoint p(pos.x(), pos.y() + 1); - m_menu->popup(p); + menu.exec(p); } void WebSearchBar::focusOutEvent(QFocusEvent* e) diff --git a/src/lib/navigation/websearchbar.h b/src/lib/navigation/websearchbar.h index baff041c6..4f7891562 100644 --- a/src/lib/navigation/websearchbar.h +++ b/src/lib/navigation/websearchbar.h @@ -52,7 +52,7 @@ class QT_QUPZILLA_EXPORT WebSearchBar : public LineEdit Q_PROPERTY(int fixedheight READ height WRITE setFixedHeight) public: - explicit WebSearchBar(QupZilla* mainClass, QWidget* parent = 0); + explicit WebSearchBar(QupZilla* mainClass); private slots: void searchChanged(const ButtonWithMenu::Item &item); @@ -93,7 +93,6 @@ private: SearchEnginesManager* m_searchManager; QWeakPointer m_searchDialog; - QMenu* m_menu; QAction* m_pasteAndGoAction; QAction* m_clearAction;