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

Cleanup in NavigationBar and WebSearchBar:

* move helper-functions in navigationbar.cpp into NavigationBar [private]
* remove (unused) 2nd arg in WebSearchBar/NavigationBar and use mainClass as parent.
* remove NavigationBar-destructor (not needed)
* remove WebSearchBar::m_menu and create a QMenu-instance directly in WebSearchBar::contextMenuEvent()
This commit is contained in:
Franz Fellner 2012-10-01 11:26:07 +02:00
parent bf3b05d501
commit 204e942f87
4 changed files with 24 additions and 27 deletions

View File

@ -34,7 +34,7 @@
#include <QStackedWidget>
#include <QWebHistory>
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;
}

View File

@ -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;

View File

@ -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)

View File

@ -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<SearchEnginesDialog> m_searchDialog;
QMenu* m_menu;
QAction* m_pasteAndGoAction;
QAction* m_clearAction;