mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-14 11:02:19 +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:
parent
bf3b05d501
commit
204e942f87
|
@ -34,7 +34,7 @@
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QWebHistory>
|
#include <QWebHistory>
|
||||||
|
|
||||||
QString titleForUrl(QString title, const QUrl &url)
|
QString NavigationBar::titleForUrl(QString title, const QUrl &url)
|
||||||
{
|
{
|
||||||
if (title.isEmpty()) {
|
if (title.isEmpty()) {
|
||||||
title = url.toString(QUrl::RemoveFragment);
|
title = url.toString(QUrl::RemoveFragment);
|
||||||
|
@ -50,7 +50,7 @@ QString titleForUrl(QString title, const QUrl &url)
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon iconForPage(const QUrl &url, const QIcon &sIcon)
|
QIcon NavigationBar::iconForPage(const QUrl &url, const QIcon &sIcon)
|
||||||
{
|
{
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
icon.addPixmap(url.scheme() == QLatin1String("qupzilla") ? QIcon(":icons/qupzilla.png").pixmap(16, 16) : _iconForUrl(url).pixmap(16, 16));
|
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;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationBar::NavigationBar(QupZilla* mainClass, QWidget* parent)
|
NavigationBar::NavigationBar(QupZilla* mainClass)
|
||||||
: QWidget(parent)
|
: QWidget(mainClass)
|
||||||
, p_QupZilla(mainClass)
|
, p_QupZilla(mainClass)
|
||||||
{
|
{
|
||||||
setObjectName("navigationbar");
|
setObjectName("navigationbar");
|
||||||
|
@ -356,8 +356,3 @@ void NavigationBar::goForwardInNewTab()
|
||||||
|
|
||||||
goAtHistoryIndexInNewTab(itemIndex);
|
goAtHistoryIndexInNewTab(itemIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationBar::~NavigationBar()
|
|
||||||
{
|
|
||||||
delete m_searchLine;
|
|
||||||
}
|
|
||||||
|
|
|
@ -30,12 +30,13 @@ class WebSearchBar;
|
||||||
class QupZilla;
|
class QupZilla;
|
||||||
class ReloadStopButton;
|
class ReloadStopButton;
|
||||||
class Menu;
|
class Menu;
|
||||||
|
class QUrl;
|
||||||
|
|
||||||
class QT_QUPZILLA_EXPORT NavigationBar : public QWidget
|
class QT_QUPZILLA_EXPORT NavigationBar : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit NavigationBar(QupZilla* mainClass, QWidget* parent = 0);
|
explicit NavigationBar(QupZilla* mainClass);
|
||||||
~NavigationBar();
|
|
||||||
|
|
||||||
void setSplitterSizes(int locationBar, int websearchBar);
|
void setSplitterSizes(int locationBar, int websearchBar);
|
||||||
|
|
||||||
|
@ -71,6 +72,9 @@ private slots:
|
||||||
void clearHistory();
|
void clearHistory();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString titleForUrl(QString title, const QUrl &url);
|
||||||
|
QIcon iconForPage(const QUrl &url, const QIcon &sIcon);
|
||||||
|
|
||||||
QupZilla* p_QupZilla;
|
QupZilla* p_QupZilla;
|
||||||
|
|
||||||
QHBoxLayout* m_layout;
|
QHBoxLayout* m_layout;
|
||||||
|
|
|
@ -50,10 +50,9 @@ void WebSearchBar_Button::contextMenuEvent(QContextMenuEvent* event)
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebSearchBar::WebSearchBar(QupZilla* mainClass, QWidget* parent)
|
WebSearchBar::WebSearchBar(QupZilla* mainClass)
|
||||||
: LineEdit(parent)
|
: LineEdit(mainClass)
|
||||||
, p_QupZilla(mainClass)
|
, p_QupZilla(mainClass)
|
||||||
, m_menu(new QMenu(this))
|
|
||||||
, m_pasteAndGoAction(0)
|
, m_pasteAndGoAction(0)
|
||||||
, m_clearAction(0)
|
, m_clearAction(0)
|
||||||
, m_reloadingEngines(false)
|
, m_reloadingEngines(false)
|
||||||
|
@ -266,13 +265,13 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event)
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu* tempMenu = createStandardContextMenu();
|
QMenu* tempMenu = createStandardContextMenu();
|
||||||
m_menu->clear();
|
QMenu menu(this);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach(QAction * act, tempMenu->actions()) {
|
foreach(QAction * act, tempMenu->actions()) {
|
||||||
act->setParent(m_menu);
|
act->setParent(&menu);
|
||||||
tempMenu->removeAction(act);
|
tempMenu->removeAction(act);
|
||||||
m_menu->addAction(act);
|
menu.addAction(act);
|
||||||
|
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -289,13 +288,13 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event)
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
act->setIcon(QIcon::fromTheme("edit-paste"));
|
act->setIcon(QIcon::fromTheme("edit-paste"));
|
||||||
m_menu->addAction(act);
|
menu.addAction(act);
|
||||||
m_menu->addAction(m_pasteAndGoAction);
|
menu.addAction(m_pasteAndGoAction);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
act->setIcon(QIcon::fromTheme("edit-delete"));
|
act->setIcon(QIcon::fromTheme("edit-delete"));
|
||||||
m_menu->addAction(act);
|
menu.addAction(act);
|
||||||
m_menu->addAction(m_clearAction);
|
menu.addAction(m_clearAction);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
act->setIcon(QIcon::fromTheme("edit-select-all"));
|
act->setIcon(QIcon::fromTheme("edit-select-all"));
|
||||||
|
@ -306,13 +305,13 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event)
|
||||||
|
|
||||||
tempMenu->deleteLater();
|
tempMenu->deleteLater();
|
||||||
|
|
||||||
m_menu->addSeparator();
|
menu.addSeparator();
|
||||||
QAction* act = m_menu->addAction(tr("Show suggestions"));
|
QAction* act = menu.addAction(tr("Show suggestions"));
|
||||||
act->setCheckable(true);
|
act->setCheckable(true);
|
||||||
act->setChecked(qzSettings->showSearchSuggestions);
|
act->setChecked(qzSettings->showSearchSuggestions);
|
||||||
connect(act, SIGNAL(triggered(bool)), this, SLOT(enableSearchSuggestions(bool)));
|
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->setCheckable(true);
|
||||||
instantSearch->setChecked(qzSettings->searchOnEngineChange);
|
instantSearch->setChecked(qzSettings->searchOnEngineChange);
|
||||||
connect(instantSearch, SIGNAL(triggered(bool)), this, SLOT(instantSearchChanged(bool)));
|
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
|
//Prevent choosing first option with double rightclick
|
||||||
QPoint pos = event->globalPos();
|
QPoint pos = event->globalPos();
|
||||||
QPoint p(pos.x(), pos.y() + 1);
|
QPoint p(pos.x(), pos.y() + 1);
|
||||||
m_menu->popup(p);
|
menu.exec(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSearchBar::focusOutEvent(QFocusEvent* e)
|
void WebSearchBar::focusOutEvent(QFocusEvent* e)
|
||||||
|
|
|
@ -52,7 +52,7 @@ class QT_QUPZILLA_EXPORT WebSearchBar : public LineEdit
|
||||||
Q_PROPERTY(int fixedheight READ height WRITE setFixedHeight)
|
Q_PROPERTY(int fixedheight READ height WRITE setFixedHeight)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WebSearchBar(QupZilla* mainClass, QWidget* parent = 0);
|
explicit WebSearchBar(QupZilla* mainClass);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void searchChanged(const ButtonWithMenu::Item &item);
|
void searchChanged(const ButtonWithMenu::Item &item);
|
||||||
|
@ -93,7 +93,6 @@ private:
|
||||||
SearchEnginesManager* m_searchManager;
|
SearchEnginesManager* m_searchManager;
|
||||||
QWeakPointer<SearchEnginesDialog> m_searchDialog;
|
QWeakPointer<SearchEnginesDialog> m_searchDialog;
|
||||||
|
|
||||||
QMenu* m_menu;
|
|
||||||
QAction* m_pasteAndGoAction;
|
QAction* m_pasteAndGoAction;
|
||||||
QAction* m_clearAction;
|
QAction* m_clearAction;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user