1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Opens all bookmarks in folder after middle click in menu. Closes #68

- also setting title of new tab when loading bookmarks/history when
   possible (when we know title of history entry / bookmark, let
   show on tab its title, rather than showing just "New page")
This commit is contained in:
nowrep 2011-12-20 18:58:42 +01:00
parent 8bb47a0a5f
commit 1898643224
13 changed files with 45 additions and 14 deletions

View File

@ -271,6 +271,7 @@ void QupZilla::setupMenu()
connect(m_menuHistory, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHistoryMenu()));
connect(m_menuHistory, SIGNAL(aboutToHide()), this, SLOT(aboutToHideHistoryMenu()));
connect(m_menuBookmarks, SIGNAL(aboutToShow()), this, SLOT(aboutToShowBookmarksMenu()));
connect(m_menuBookmarks, SIGNAL(menuMiddleClicked(Menu*)), this, SLOT(loadFolderBookmarks(Menu*)));
connect(m_menuHelp, SIGNAL(aboutToShow()), this, SLOT(aboutToShowHelpMenu()));
connect(m_menuTools, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolsMenu()));
@ -963,6 +964,18 @@ void QupZilla::loadActionUrlInNewNotSelectedTab()
}
}
void QupZilla::loadFolderBookmarks(Menu *menu)
{
QString folder = BookmarksModel::fromTranslatedFolder(menu->title());
if (folder.isEmpty()) {
return;
}
foreach(Bookmark b, mApp->bookmarksModel()->folderBookmarks(folder)) {
tabWidget()->addView(b.url, b.title, TabWidget::NewNotSelectedTab);
}
}
void QupZilla::loadAddress(const QUrl &url)
{
weView()->load(url);

View File

@ -126,6 +126,7 @@ public slots:
void loadActionUrl();
void loadActionUrlInNewTab();
void loadActionUrlInNewNotSelectedTab();
void loadFolderBookmarks(Menu* menu);
void bookmarkPage();
void loadAddress(const QUrl &url);

View File

@ -162,7 +162,7 @@ void BookmarksManager::itemControlClicked(QTreeWidgetItem* item)
if (!item || item->text(1).isEmpty()) {
return;
}
getQupZilla()->tabWidget()->addView(QUrl(item->text(1)));
getQupZilla()->tabWidget()->addView(QUrl(item->text(1)), item->text(0));
}
void BookmarksManager::loadInNewTab()

View File

@ -209,7 +209,7 @@ void BookmarksToolbar::loadClickedBookmarkInNewTab()
Bookmark bookmark = button->data().value<Bookmark>();
p_QupZilla->tabWidget()->addView(bookmark.url);
p_QupZilla->tabWidget()->addView(bookmark.url, bookmark.title);
}
void BookmarksToolbar::loadFolderBookmarksInTabs()
@ -225,7 +225,7 @@ void BookmarksToolbar::loadFolderBookmarksInTabs()
}
foreach (Bookmark b, m_bookmarksModel->folderBookmarks(folder)) {
p_QupZilla->tabWidget()->addView(b.url, b.title);
p_QupZilla->tabWidget()->addView(b.url, b.title, TabWidget::NewNotSelectedTab);
}
}

View File

@ -75,7 +75,7 @@ void HistoryManager::itemDoubleClicked(QTreeWidgetItem* item)
}
QUrl url = QUrl::fromEncoded(item->text(1).toUtf8());
getQupZilla()->tabWidget()->addView(url);
getQupZilla()->tabWidget()->addView(url, item->text(0));
}
void HistoryManager::loadInNewTab()

View File

@ -58,7 +58,7 @@ void BookmarksSideBar::itemControlClicked(QTreeWidgetItem* item)
}
QUrl url = QUrl::fromEncoded(item->text(1).toUtf8());
p_QupZilla->tabWidget()->addView(url);
p_QupZilla->tabWidget()->addView(url, item->text(0));
}
void BookmarksSideBar::itemDoubleClicked(QTreeWidgetItem* item)

View File

@ -61,7 +61,7 @@ void HistorySideBar::itemControlClicked(QTreeWidgetItem* item)
}
QUrl url = QUrl::fromEncoded(item->text(1).toUtf8());
p_QupZilla->tabWidget()->addView(url);
p_QupZilla->tabWidget()->addView(url, item->text(0));
}
void HistorySideBar::loadInNewTab()

View File

@ -17,6 +17,8 @@
* ============================================================ */
#include "enhancedmenu.h"
#include <QDebug>
Menu::Menu(QWidget* parent)
: QMenu(parent)
{
@ -29,7 +31,21 @@ Menu::Menu(const QString &title, QWidget* parent)
void Menu::mouseReleaseEvent(QMouseEvent* e)
{
Action* act = qobject_cast<Action*> (actionAt(e->pos()));
QAction* qact = actionAt(e->pos());
Action* act = qobject_cast<Action*> (qact);
if (qact && qact->menu()) {
Menu* m = qobject_cast<Menu*> (qact->menu());
if (!m) {
QMenu::mouseReleaseEvent(e);
return;
}
if (e->button() == Qt::MiddleButton || (e->button() == Qt::LeftButton && e->modifiers() == Qt::ControlModifier)) {
closeAllMenus();
emit menuMiddleClicked(m);
}
}
if (!act) {
QMenu::mouseReleaseEvent(e);

View File

@ -21,6 +21,7 @@
#include <QMenu>
#include <QMouseEvent>
class Action;
class Menu : public QMenu
{
Q_OBJECT
@ -29,14 +30,13 @@ public:
explicit Menu(const QString &title, QWidget* parent = 0);
signals:
void menuMiddleClicked(Menu*);
public slots:
private:
void mouseReleaseEvent(QMouseEvent* e);
void closeAllMenus();
};
class Action : public QAction

View File

@ -313,7 +313,7 @@ int TabBar::normalTabsCount()
void TabBar::mouseDoubleClickEvent(QMouseEvent* event)
{
if (event->button() == Qt::LeftButton && tabAt(event->pos()) == -1) {
m_tabWidget->addView(QUrl(), tr("New tab"), TabWidget::NewTab, true);
m_tabWidget->addView(QUrl(), tr("New tab"), TabWidget::NewSelectedTab, true);
return;
}

View File

@ -422,7 +422,7 @@ void TabWidget::duplicateTab(int index)
QDataStream tabHistoryStream(&history, QIODevice::WriteOnly);
tabHistoryStream << *weView(index)->history();
int id = addView(url, tr("New tab"), TabWidget::NewNotSelectedTab);
int id = addView(url, tabText(index), TabWidget::NewNotSelectedTab);
QDataStream historyStream(history);
historyStream >> *weView(id)->history();
}

View File

@ -290,8 +290,9 @@ void WebView::stopAnimation()
QMovie* mov = animationLoading(tabIndex(), false)->movie();
if (mov) {
mov->stop();
iconChanged();
}
iconChanged();
}
void WebView::setIp(const QHostInfo &info)
@ -726,7 +727,7 @@ void WebView::showSource()
p_QupZilla->showSource();
}
#if QT_VERSION == 0x040800
#if QT_VERSION >= 0x040800
void WebView::showSourceOfSelection()
{
p_QupZilla->showSource(selectedHtml());

View File

@ -115,7 +115,7 @@ private slots:
void sendLinkByMail();
void bookmarkLink();
void showSource();
#if QT_VERSION == 0x040800
#if QT_VERSION >= 0x040800
void showSourceOfSelection();
#endif
void showSiteInfo();