mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
Fixed occasional random crashes + middle mouse click improvements
Using now qobject_cast everywhere possible instead of c++ type cast Middle mouse click in bookmarks manager (library + sidebar + toolbar) and history manager (library + sidebar) now opens a new tab
This commit is contained in:
parent
e243b1baf4
commit
dca3d3a31a
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
inline WebView* weView() const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_tabWidget->currentIndex())); if (!webTab) return 0; return webTab->view(); }
|
||||
inline WebView* weView(int index) const { WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index)); if (!webTab) return 0; return webTab->view(); }
|
||||
inline LocationBar* locationBar() { return (LocationBar*) m_tabWidget->locationBars()->currentWidget(); }
|
||||
inline LocationBar* locationBar() { return qobject_cast<LocationBar*>(m_tabWidget->locationBars()->currentWidget()); }
|
||||
inline TabWidget* tabWidget() { return m_tabWidget; }
|
||||
inline BookmarksToolbar* bookmarksToolbar() { return m_bookmarksToolbar; }
|
||||
inline StatusBarMessage* statusBarMessage() { return m_statusBarMessage; }
|
||||
|
|
|
@ -42,6 +42,7 @@ BookmarksManager::BookmarksManager(QupZilla* mainClass, QWidget* parent) :
|
|||
connect(ui->addFolder, SIGNAL(clicked()), this, SLOT(addFolder()));
|
||||
connect(ui->bookmarksTree, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &)));
|
||||
connect(ui->bookmarksTree, SIGNAL(itemControlClicked(QTreeWidgetItem*)), this, SLOT(itemControlClicked(QTreeWidgetItem*)));
|
||||
connect(ui->bookmarksTree, SIGNAL(itemMiddleButtonClicked(QTreeWidgetItem*)), this, SLOT(itemControlClicked(QTreeWidgetItem*)));
|
||||
|
||||
connect(m_bookmarksModel, SIGNAL(bookmarkAdded(BookmarksModel::Bookmark)), this, SLOT(addBookmark(BookmarksModel::Bookmark)));
|
||||
connect(m_bookmarksModel, SIGNAL(bookmarkDeleted(BookmarksModel::Bookmark)), this, SLOT(removeBookmark(BookmarksModel::Bookmark)));
|
||||
|
@ -404,7 +405,7 @@ void BookmarksManager::insertAllTabs()
|
|||
|
||||
void BookmarksManager::optimizeDb()
|
||||
{
|
||||
BrowsingLibrary* b = (BrowsingLibrary*) parentWidget();
|
||||
BrowsingLibrary* b = qobject_cast<BrowsingLibrary*>(parentWidget());
|
||||
if (!b)
|
||||
return;
|
||||
b->optimizeDatabase();
|
||||
|
|
|
@ -77,6 +77,15 @@ void BookmarksToolbar::loadClickedBookmark()
|
|||
p_QupZilla->loadAddress(button->data().toUrl());
|
||||
}
|
||||
|
||||
void BookmarksToolbar::loadClickedBookmarkInNewTab()
|
||||
{
|
||||
ToolButton* button = qobject_cast<ToolButton*>(sender());
|
||||
if (!button)
|
||||
return;
|
||||
|
||||
p_QupZilla->tabWidget()->addView(button->data().toUrl());
|
||||
}
|
||||
|
||||
void BookmarksToolbar::showMostVisited()
|
||||
{
|
||||
m_bookmarksModel->setShowingMostVisited(!m_bookmarksModel->isShowingMostVisited());
|
||||
|
@ -103,6 +112,7 @@ void BookmarksToolbar::addBookmark(const BookmarksModel::Bookmark &bookmark)
|
|||
button->setWhatsThis(bookmark.title);
|
||||
|
||||
connect(button, SIGNAL(clicked()), this, SLOT(loadClickedBookmark()));
|
||||
connect(button, SIGNAL(middleMouseClicked()), this, SLOT(loadClickedBookmarkInNewTab()));
|
||||
m_layout->insertWidget(m_layout->count() - 2, button);
|
||||
}
|
||||
|
||||
|
@ -173,6 +183,7 @@ void BookmarksToolbar::refreshBookmarks()
|
|||
button->setAutoRaise(true);
|
||||
|
||||
connect(button, SIGNAL(clicked()), this, SLOT(loadClickedBookmark()));
|
||||
connect(button, SIGNAL(middleMouseClicked()), this, SLOT(loadClickedBookmarkInNewTab()));
|
||||
m_layout->addWidget(button);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ public slots:
|
|||
|
||||
private slots:
|
||||
void loadClickedBookmark();
|
||||
void loadClickedBookmarkInNewTab();
|
||||
|
||||
void hidePanel();
|
||||
void addBookmark(const BookmarksModel::Bookmark &bookmark);
|
||||
void removeBookmark(const BookmarksModel::Bookmark &bookmark);
|
||||
|
|
|
@ -35,6 +35,8 @@ HistoryManager::HistoryManager(QupZilla* mainClass, QWidget* parent) :
|
|||
qz_centerWidgetOnScreen(this);
|
||||
|
||||
connect(ui->historyTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this, SLOT(itemDoubleClicked(QTreeWidgetItem*)));
|
||||
connect(ui->historyTree, SIGNAL(itemMiddleButtonClicked(QTreeWidgetItem*)),this, SLOT(itemDoubleClicked(QTreeWidgetItem*)));
|
||||
|
||||
connect(ui->deleteB, SIGNAL(clicked()), this, SLOT(deleteItem()));
|
||||
connect(ui->clearAll, SIGNAL(clicked()), this, SLOT(clearHistory()));
|
||||
connect(ui->historyTree, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &)));
|
||||
|
@ -270,7 +272,7 @@ void HistoryManager::search(const QString &searchText)
|
|||
|
||||
void HistoryManager::optimizeDb()
|
||||
{
|
||||
BrowsingLibrary* b = (BrowsingLibrary*) parentWidget();
|
||||
BrowsingLibrary* b = qobject_cast<BrowsingLibrary*>(parentWidget());
|
||||
if (!b)
|
||||
return;
|
||||
b->optimizeDatabase();
|
||||
|
|
|
@ -46,6 +46,7 @@ public slots:
|
|||
private slots:
|
||||
void optimizeDb();
|
||||
void itemDoubleClicked(QTreeWidgetItem* item);
|
||||
|
||||
void deleteItem();
|
||||
void clearHistory();
|
||||
void contextMenuRequested(const QPoint &position);
|
||||
|
|
|
@ -89,8 +89,8 @@ void LocationCompleter::refreshCompleter(QString string)
|
|||
QSqlQuery query;
|
||||
query.exec("SELECT title, url FROM history WHERE title LIKE '%"+string+"%' OR url LIKE '%"+string+"%' ORDER BY count DESC LIMIT "+QString::number(limit));
|
||||
int i = 0;
|
||||
QStandardItemModel* cModel = (QStandardItemModel*)model();
|
||||
QTreeView* treeView = (QTreeView*)popup();
|
||||
QStandardItemModel* cModel = qobject_cast<QStandardItemModel*>(model());
|
||||
QTreeView* treeView = qobject_cast<QTreeView*>(popup());
|
||||
|
||||
cModel->clear();
|
||||
while(query.next()) {
|
||||
|
|
|
@ -325,7 +325,7 @@ bool RSSManager::addRssFeed(const QString &address, const QString &title, const
|
|||
|
||||
void RSSManager::optimizeDb()
|
||||
{
|
||||
BrowsingLibrary* b = (BrowsingLibrary*) parentWidget();
|
||||
BrowsingLibrary* b = qobject_cast<BrowsingLibrary*>(parentWidget());
|
||||
if (!b)
|
||||
return;
|
||||
b->optimizeDatabase();
|
||||
|
|
|
@ -25,18 +25,19 @@
|
|||
#include "tabwidget.h"
|
||||
#include "bookmarksmodel.h"
|
||||
|
||||
BookmarksSideBar::BookmarksSideBar(QupZilla* mainClass, QWidget* parent) :
|
||||
QWidget(parent)
|
||||
,m_isRefreshing(false)
|
||||
,ui(new Ui::BookmarksSideBar)
|
||||
,p_QupZilla(mainClass)
|
||||
,m_bookmarksModel(mApp->bookmarksModel())
|
||||
BookmarksSideBar::BookmarksSideBar(QupZilla* mainClass, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_isRefreshing(false)
|
||||
, ui(new Ui::BookmarksSideBar)
|
||||
, p_QupZilla(mainClass)
|
||||
, m_bookmarksModel(mApp->bookmarksModel())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->bookmarksTree->setDefaultItemShowMode(TreeWidget::ItemsExpanded);
|
||||
connect(ui->bookmarksTree, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &)));
|
||||
connect(ui->bookmarksTree, SIGNAL(itemControlClicked(QTreeWidgetItem*)), this, SLOT(itemControlClicked(QTreeWidgetItem*)));
|
||||
connect(ui->bookmarksTree, SIGNAL(itemMiddleButtonClicked(QTreeWidgetItem*)), this, SLOT(itemControlClicked(QTreeWidgetItem*)));
|
||||
connect(ui->bookmarksTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*)));
|
||||
connect(ui->search, SIGNAL(textChanged(QString)), ui->bookmarksTree, SLOT(filterString(QString)));
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <QWidget>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QInputDialog>
|
||||
#include <QPointer>
|
||||
|
||||
#include "bookmarksmodel.h"
|
||||
|
||||
|
@ -63,7 +62,7 @@ private:
|
|||
|
||||
bool m_isRefreshing;
|
||||
Ui::BookmarksSideBar* ui;
|
||||
QPointer<QupZilla> p_QupZilla;
|
||||
QupZilla* p_QupZilla;
|
||||
BookmarksModel* m_bookmarksModel;
|
||||
};
|
||||
|
||||
|
|
|
@ -29,8 +29,10 @@ HistorySideBar::HistorySideBar(QupZilla* mainClass, QWidget* parent) :
|
|||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->historyTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),this, SLOT(itemDoubleClicked(QTreeWidgetItem*)));
|
||||
connect(ui->historyTree, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &)));
|
||||
connect(ui->historyTree, SIGNAL(itemControlClicked(QTreeWidgetItem*)), this, SLOT(itemControlClicked(QTreeWidgetItem*)));
|
||||
connect(ui->historyTree, SIGNAL(itemMiddleButtonClicked(QTreeWidgetItem*)), this, SLOT(itemControlClicked(QTreeWidgetItem*)));
|
||||
|
||||
connect(ui->historyTree, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &)));
|
||||
connect(ui->search, SIGNAL(textEdited(QString)), ui->historyTree, SLOT(filterString(QString)));
|
||||
// connect(ui->search, SIGNAL(textEdited(QString)), this, SLOT(search()));
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
#include "historysidebar.h"
|
||||
#include "qupzilla.h"
|
||||
|
||||
SideBar::SideBar(QWidget* parent)
|
||||
SideBar::SideBar(QupZilla* mainClass, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, p_QupZilla((QupZilla*)parentWidget())
|
||||
, p_QupZilla(mainClass)
|
||||
, m_activeWidget(None)
|
||||
{
|
||||
setObjectName("sidebar");
|
||||
|
@ -41,7 +41,7 @@ SideBar::SideBar(QWidget* parent)
|
|||
void SideBar::showBookmarks()
|
||||
{
|
||||
m_titleBar->setTitle(tr("Bookmarks"));
|
||||
BookmarksSideBar* bar = new BookmarksSideBar((QupZilla*)parentWidget());
|
||||
BookmarksSideBar* bar = new BookmarksSideBar(p_QupZilla);
|
||||
setWidget(bar);
|
||||
m_activeWidget = Bookmarks;
|
||||
|
||||
|
@ -52,7 +52,7 @@ void SideBar::showBookmarks()
|
|||
void SideBar::showHistory()
|
||||
{
|
||||
m_titleBar->setTitle(tr("History"));
|
||||
HistorySideBar* bar = new HistorySideBar((QupZilla*)parentWidget());
|
||||
HistorySideBar* bar = new HistorySideBar(p_QupZilla);
|
||||
setWidget(bar);
|
||||
m_activeWidget = History;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class SideBar : public QWidget
|
|||
public:
|
||||
enum SideWidget { None = 0, Bookmarks, History, RSS };
|
||||
|
||||
explicit SideBar(QWidget* parent = 0);
|
||||
explicit SideBar(QupZilla* mainClass, QWidget* parent = 0);
|
||||
~SideBar();
|
||||
|
||||
void showBookmarks();
|
||||
|
|
|
@ -64,6 +64,15 @@ void ToolButton::setMultiIcon(const QPixmap &icon)
|
|||
setFixedSize(m_normalIcon.size());
|
||||
}
|
||||
|
||||
void ToolButton::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->buttons() == Qt::MiddleButton) {
|
||||
emit middleMouseClicked();
|
||||
}
|
||||
|
||||
QToolButton::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void ToolButton::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
if (!m_usingMultiIcon) {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionToolButton>
|
||||
#include <QMouseEvent>
|
||||
|
||||
class ToolButton : public QToolButton
|
||||
{
|
||||
|
@ -48,10 +49,12 @@ public:
|
|||
void setIcon(const QIcon &icon);
|
||||
|
||||
signals:
|
||||
void middleMouseClicked();
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
bool m_usingMultiIcon;
|
||||
|
|
|
@ -65,6 +65,9 @@ void TreeWidget::mousePressEvent(QMouseEvent* event)
|
|||
if (event->modifiers() == Qt::ControlModifier)
|
||||
emit itemControlClicked(itemAt(event->pos()));
|
||||
|
||||
if (event->buttons() == Qt::MiddleButton)
|
||||
emit itemMiddleButtonClicked(itemAt(event->pos()));
|
||||
|
||||
QTreeWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
|
||||
signals:
|
||||
void itemControlClicked(QTreeWidgetItem* item);
|
||||
void itemMiddleButtonClicked(QTreeWidgetItem* item);
|
||||
|
||||
public slots:
|
||||
void filterString(QString string);
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
#define PINNED_TAB_WIDTH 31
|
||||
#endif
|
||||
|
||||
TabBar::TabBar(QupZilla* mainClass, QWidget* parent)
|
||||
: QTabBar(parent)
|
||||
TabBar::TabBar(QupZilla* mainClass, TabWidget* tabWidget)
|
||||
: QTabBar()
|
||||
, p_QupZilla(mainClass)
|
||||
, m_tabWidget((TabWidget*)parentWidget())
|
||||
, m_tabWidget(tabWidget)
|
||||
, m_clickedTab(0)
|
||||
, m_pinnedTabsCount(0)
|
||||
{
|
||||
|
@ -173,7 +173,7 @@ void TabBar::hideCloseButton(int index)
|
|||
|
||||
void TabBar::updateCloseButton(int index)
|
||||
{
|
||||
QAbstractButton* button = (QAbstractButton*)tabButton(index, QTabBar::RightSide);
|
||||
QAbstractButton* button = qobject_cast<QAbstractButton*>(tabButton(index, QTabBar::RightSide));
|
||||
if (!button)
|
||||
return;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class TabBar : public QTabBar
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TabBar(QupZilla* mainClass, QWidget* parent = 0);
|
||||
explicit TabBar(QupZilla* mainClass, TabWidget* tabWidget);
|
||||
// void hideCloseButton(int index);
|
||||
// void showCloseButton(int index);
|
||||
void updateCloseButton(int index);
|
||||
|
|
|
@ -216,7 +216,7 @@ int TabWidget::addView(QUrl url, const QString &title, OpenUrlIn openIn, bool se
|
|||
|
||||
LocationBar* locBar = new LocationBar(p_QupZilla);
|
||||
m_locationBars->addWidget(locBar);
|
||||
int index = addTab(new WebTab(p_QupZilla, locBar),"");
|
||||
int index = addTab(new WebTab(p_QupZilla, locBar), "");
|
||||
WebView* webView = weView(index);
|
||||
locBar->setWebView(webView);
|
||||
|
||||
|
@ -495,7 +495,7 @@ void TabWidget::restorePinnedTabs()
|
|||
} else {
|
||||
addedIndex = addView(url);
|
||||
}
|
||||
WebTab* webTab = (WebTab*)widget(addedIndex);
|
||||
WebTab* webTab = qobject_cast<WebTab*>(widget(addedIndex));
|
||||
if (webTab) {
|
||||
webTab->setPinned(true);
|
||||
emit pinnedTabAdded();
|
||||
|
|
|
@ -313,7 +313,7 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte
|
|||
|
||||
bool WebPage::javaScriptPrompt(QWebFrame* originatingFrame, const QString &msg, const QString &defaultValue, QString* result)
|
||||
{
|
||||
WebView* _view = (WebView*)originatingFrame->page()->view();
|
||||
WebView* _view = qobject_cast<WebView*>(originatingFrame->page()->view());
|
||||
|
||||
Widget* widget = new Widget(_view->webTab());
|
||||
Ui_jsPrompt* ui = new Ui_jsPrompt();
|
||||
|
@ -355,7 +355,7 @@ bool WebPage::javaScriptPrompt(QWebFrame* originatingFrame, const QString &msg,
|
|||
|
||||
bool WebPage::javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg)
|
||||
{
|
||||
WebView* _view = (WebView*)originatingFrame->page()->view();
|
||||
WebView* _view = qobject_cast<WebView*>(originatingFrame->page()->view());
|
||||
|
||||
Widget* widget = new Widget(_view->webTab());
|
||||
Ui_jsConfirm* ui = new Ui_jsConfirm();
|
||||
|
@ -396,7 +396,7 @@ void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
|
|||
if (m_blockAlerts)
|
||||
return;
|
||||
|
||||
WebView* _view = (WebView*)originatingFrame->page()->view();
|
||||
WebView* _view = qobject_cast<WebView*>(originatingFrame->page()->view());
|
||||
|
||||
Widget* widget = new Widget(_view->webTab());
|
||||
Ui_jsAlert* ui = new Ui_jsAlert();
|
||||
|
|
Loading…
Reference in New Issue
Block a user