mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Improved opening bookmarks inside subfolders. Closes #54
This commit is contained in:
parent
7d3fa5d4c4
commit
6378c4d3fe
@ -22,6 +22,7 @@
|
||||
#include "historymodel.h"
|
||||
#include "toolbutton.h"
|
||||
#include "databasewriter.h"
|
||||
#include "menu.h"
|
||||
|
||||
BookmarksToolbar::BookmarksToolbar(QupZilla* mainClass, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
@ -239,7 +240,7 @@ void BookmarksToolbar::subfolderAdded(const QString &name)
|
||||
b->setIcon(style()->standardIcon(QStyle::SP_DirIcon));
|
||||
b->setText(name);
|
||||
|
||||
QMenu* menu = new QMenu(name);
|
||||
Menu* menu = new Menu(name);
|
||||
b->setMenu(menu);
|
||||
connect(menu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowFolderMenu()));
|
||||
|
||||
@ -420,7 +421,7 @@ void BookmarksToolbar::refreshBookmarks()
|
||||
b->setIcon(style()->standardIcon(QStyle::SP_DirIcon));
|
||||
b->setText(query.value(0).toString());
|
||||
|
||||
QMenu* menu = new QMenu(query.value(0).toString());
|
||||
Menu* menu = new Menu(query.value(0).toString());
|
||||
b->setMenu(menu);
|
||||
connect(menu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowFolderMenu()));
|
||||
|
||||
@ -434,7 +435,7 @@ void BookmarksToolbar::refreshBookmarks()
|
||||
m_mostVis->setText(tr("Most visited"));
|
||||
m_mostVis->setToolTip(tr("Sites you visited the most"));
|
||||
|
||||
m_menuMostVisited = new QMenu();
|
||||
m_menuMostVisited = new Menu();
|
||||
m_mostVis->setMenu(m_menuMostVisited);
|
||||
connect(m_menuMostVisited, SIGNAL(aboutToShow()), this, SLOT(refreshMostVisited()));
|
||||
|
||||
@ -466,7 +467,12 @@ void BookmarksToolbar::aboutToShowFolderMenu()
|
||||
title.truncate(40);
|
||||
title += "..";
|
||||
}
|
||||
menu->addAction(icon, title, p_QupZilla, SLOT(loadActionUrl()))->setData(url);
|
||||
|
||||
Action* act = new Action(icon, title);
|
||||
act->setData(url);
|
||||
connect (act, SIGNAL(triggered()), p_QupZilla, SLOT(loadActionUrl()));
|
||||
connect (act, SIGNAL(middleClicked()), p_QupZilla, SLOT(loadActionUrlInNewTab()));
|
||||
menu->addAction(act);
|
||||
}
|
||||
|
||||
if (menu->isEmpty()) {
|
||||
@ -484,7 +490,12 @@ void BookmarksToolbar::refreshMostVisited()
|
||||
entry.title.truncate(40);
|
||||
entry.title += "..";
|
||||
}
|
||||
m_menuMostVisited->addAction(_iconForUrl(entry.url), entry.title, p_QupZilla, SLOT(loadActionUrl()))->setData(entry.url);
|
||||
|
||||
Action* act = new Action(_iconForUrl(entry.url), entry.title);
|
||||
act->setData(entry.url);
|
||||
connect (act, SIGNAL(triggered()), p_QupZilla, SLOT(loadActionUrl()));
|
||||
connect (act, SIGNAL(middleClicked()), p_QupZilla, SLOT(loadActionUrlInNewTab()));
|
||||
m_menuMostVisited->addAction(act);
|
||||
}
|
||||
|
||||
if (m_menuMostVisited->isEmpty()) {
|
||||
|
@ -28,6 +28,7 @@ class QupZilla;
|
||||
class BookmarksModel;
|
||||
class HistoryModel;
|
||||
class ToolButton;
|
||||
class Menu;
|
||||
class BookmarksToolbar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -68,7 +69,7 @@ private:
|
||||
QupZilla* p_QupZilla;
|
||||
BookmarksModel* m_bookmarksModel;
|
||||
HistoryModel* m_historyModel;
|
||||
QMenu* m_menuMostVisited;
|
||||
Menu* m_menuMostVisited;
|
||||
ToolButton* m_mostVis;
|
||||
QHBoxLayout* m_layout;
|
||||
};
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "sourceviewersearch.h"
|
||||
#include "globalfunctions.h"
|
||||
#include "iconprovider.h"
|
||||
#include "menu.h"
|
||||
|
||||
SourceViewer::SourceViewer(QWebPage* page, const QString &selectedHtml) :
|
||||
QWidget(0)
|
||||
|
@ -175,7 +175,8 @@ SOURCES += main.cpp\
|
||||
tools/pagethumbnailer.cpp \
|
||||
plugins/speeddial.cpp \
|
||||
other/databasewriter.cpp \
|
||||
bookmarksimport/htmlimporter.cpp
|
||||
bookmarksimport/htmlimporter.cpp \
|
||||
tools/menu.cpp
|
||||
|
||||
HEADERS += \
|
||||
3rdparty/qtwin.h \
|
||||
@ -293,7 +294,8 @@ HEADERS += \
|
||||
tools/pagethumbnailer.h \
|
||||
plugins/speeddial.h \
|
||||
other/databasewriter.h \
|
||||
bookmarksimport/htmlimporter.h
|
||||
bookmarksimport/htmlimporter.h \
|
||||
tools/menu.h
|
||||
|
||||
FORMS += \
|
||||
preferences/autofillmanager.ui \
|
||||
@ -390,3 +392,5 @@ equals(d_w7api, "true") { DEFINES += W7API }
|
||||
|
||||
message(Using following defines)
|
||||
message($$DEFINES)
|
||||
|
||||
|
||||
|
53
src/tools/menu.cpp
Normal file
53
src/tools/menu.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "menu.h"
|
||||
|
||||
Menu::Menu(QWidget *parent)
|
||||
: QMenu(parent)
|
||||
{
|
||||
}
|
||||
|
||||
Menu::Menu(const QString &title, QWidget* parent)
|
||||
: QMenu(title, parent)
|
||||
{
|
||||
}
|
||||
|
||||
void Menu::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
Action* act = qobject_cast<Action*> (actionAt(e->pos()));
|
||||
|
||||
if (!act) {
|
||||
QMenu::mouseReleaseEvent(e);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e->button() == Qt::LeftButton && e->modifiers() == Qt::NoModifier) {
|
||||
act->trigger();
|
||||
close();
|
||||
e->accept();
|
||||
}
|
||||
else if (e->button() == Qt::MiddleButton || (e->button() == Qt::LeftButton && e->modifiers() == Qt::ControlModifier)) {
|
||||
act->triggerMiddleClick();
|
||||
close();
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Action::Action(QObject* parent)
|
||||
: QAction(parent)
|
||||
{
|
||||
}
|
||||
|
||||
Action::Action(const QString &text, QObject *parent)
|
||||
: QAction(text, parent)
|
||||
{
|
||||
}
|
||||
|
||||
Action::Action(const QIcon &icon, const QString &text, QObject *parent)
|
||||
: QAction(icon, text, parent)
|
||||
{
|
||||
}
|
||||
|
||||
void Action::triggerMiddleClick()
|
||||
{
|
||||
emit middleClicked();
|
||||
}
|
39
src/tools/menu.h
Normal file
39
src/tools/menu.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef MENU_H
|
||||
#define MENU_H
|
||||
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
|
||||
class Menu : public QMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Menu(QWidget *parent = 0);
|
||||
explicit Menu(const QString &title, QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
|
||||
};
|
||||
|
||||
class Action : public QAction
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Action(QObject *parent = 0);
|
||||
explicit Action(const QString &text, QObject *parent = 0);
|
||||
explicit Action(const QIcon &icon, const QString &text, QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
void middleClicked();
|
||||
|
||||
public slots:
|
||||
void triggerMiddleClick();
|
||||
|
||||
};
|
||||
|
||||
#endif // MENU_H
|
Loading…
Reference in New Issue
Block a user