mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
TabBar now accepts drops so you can drop url on it and open new tab.
- small modifications in locationbar regarding focus handling
This commit is contained in:
parent
f92df65819
commit
7dff6ad103
@ -1548,6 +1548,7 @@ void QupZilla::startPrivate(bool state)
|
||||
QMessageBox::StandardButton button = QMessageBox::question(this, tr("Start Private Browsing"),
|
||||
message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
if (button != QMessageBox::Yes) {
|
||||
m_actionPrivateBrowsing->setChecked(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,12 @@ void BookmarkIcon::setBookmarkDisabled()
|
||||
setToolTip(tr("Bookmark this Page"));
|
||||
}
|
||||
|
||||
void BookmarkIcon::contextMenuEvent(QContextMenuEvent* ev)
|
||||
{
|
||||
// Prevent propagating to LocationBar
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
void BookmarkIcon::mousePressEvent(QMouseEvent* ev)
|
||||
{
|
||||
ClickableLabel::mousePressEvent(ev);
|
||||
|
@ -41,6 +41,7 @@ private slots:
|
||||
void speedDialChanged();
|
||||
|
||||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* ev);
|
||||
void mousePressEvent(QMouseEvent* ev);
|
||||
|
||||
void setBookmarkSaved();
|
||||
|
@ -579,16 +579,32 @@ void BookmarksToolbar::aboutToShowFolderMenu()
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksToolbar::dropEvent(QDropEvent* e)
|
||||
{
|
||||
const QMimeData* mime = e->mimeData();
|
||||
|
||||
if (!mime->hasUrls() || !mime->hasText()) {
|
||||
QWidget::dropEvent(e);
|
||||
return;
|
||||
}
|
||||
|
||||
QString title = mime->text();
|
||||
QUrl url = mime->urls().at(0);
|
||||
QIcon icon = IconProvider::iconFromImage(qvariant_cast<QImage>(mime->imageData()));
|
||||
|
||||
m_bookmarksModel->saveBookmark(url, title, icon, "bookmarksToolbar");
|
||||
}
|
||||
|
||||
void BookmarksToolbar::dragEnterEvent(QDragEnterEvent* e)
|
||||
{
|
||||
const QMimeData* mime = e->mimeData();
|
||||
|
||||
if (mime->hasUrls() || mime->hasText()) {
|
||||
if (mime->hasUrls() && mime->hasText()) {
|
||||
e->acceptProposedAction();
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget::dropEvent(e);
|
||||
QWidget::dragEnterEvent(e);
|
||||
}
|
||||
|
||||
void BookmarksToolbar::showOnlyIconsChanged()
|
||||
@ -608,22 +624,6 @@ void BookmarksToolbar::showOnlyIconsChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksToolbar::dropEvent(QDropEvent* e)
|
||||
{
|
||||
const QMimeData* mime = e->mimeData();
|
||||
|
||||
if (!mime->hasUrls() || !mime->hasText()) {
|
||||
QWidget::dropEvent(e);
|
||||
return;
|
||||
}
|
||||
|
||||
QString title = mime->text();
|
||||
QUrl url = mime->urls().at(0);
|
||||
QIcon icon = IconProvider::iconFromImage(qvariant_cast<QImage>(mime->imageData()));
|
||||
|
||||
m_bookmarksModel->saveBookmark(url, title, icon, "bookmarksToolbar");
|
||||
}
|
||||
|
||||
void BookmarksToolbar::refreshMostVisited()
|
||||
{
|
||||
m_menuMostVisited->clear();
|
||||
|
@ -26,6 +26,12 @@ DownIcon::DownIcon(QWidget* parent)
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void DownIcon::contextMenuEvent(QContextMenuEvent* ev)
|
||||
{
|
||||
// Prevent propagating to LocationBar
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
void DownIcon::mousePressEvent(QMouseEvent* ev)
|
||||
{
|
||||
ClickableLabel::mousePressEvent(ev);
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
explicit DownIcon(QWidget* parent = 0);
|
||||
|
||||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* ev);
|
||||
void mousePressEvent(QMouseEvent* ev);
|
||||
|
||||
};
|
||||
|
@ -27,6 +27,13 @@ GoIcon::GoIcon(QWidget* parent)
|
||||
setHidden(true);
|
||||
}
|
||||
|
||||
void GoIcon::contextMenuEvent(QContextMenuEvent* ev)
|
||||
{
|
||||
// Prevent propagating to LocationBar
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
|
||||
void GoIcon::mousePressEvent(QMouseEvent* ev)
|
||||
{
|
||||
ClickableLabel::mousePressEvent(ev);
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
explicit GoIcon(QWidget* parent = 0);
|
||||
|
||||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* ev);
|
||||
void mousePressEvent(QMouseEvent* ev);
|
||||
|
||||
};
|
||||
|
@ -32,21 +32,27 @@ SiteIcon::SiteIcon(LocationBar* parent)
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
}
|
||||
|
||||
void SiteIcon::contextMenuEvent(QContextMenuEvent* e)
|
||||
{
|
||||
// Prevent propagating to LocationBar
|
||||
e->accept();
|
||||
}
|
||||
|
||||
void SiteIcon::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
if (e->buttons() & Qt::LeftButton) {
|
||||
m_dragStartPosition = mapFromGlobal(e->globalPos());
|
||||
}
|
||||
|
||||
ToolButton::mousePressEvent(e);
|
||||
|
||||
// Prevent propagating to LocationBar
|
||||
e->accept();
|
||||
|
||||
ToolButton::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void SiteIcon::mouseMoveEvent(QMouseEvent* e)
|
||||
{
|
||||
if (!m_locationBar) {
|
||||
if (!m_locationBar || !(e->buttons() & Qt::LeftButton)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
explicit SiteIcon(LocationBar* parent);
|
||||
|
||||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* e);
|
||||
void mousePressEvent(QMouseEvent* e);
|
||||
void mouseMoveEvent(QMouseEvent* e);
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "licenseviewer.h"
|
||||
#include "globalfunctions.h"
|
||||
|
||||
LicenseViewer::LicenseViewer(QWidget *parent)
|
||||
LicenseViewer::LicenseViewer(QWidget* parent)
|
||||
: QTextBrowser()
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
@ -27,7 +27,7 @@ class QT_QUPZILLA_EXPORT LicenseViewer : public QTextBrowser
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LicenseViewer(QWidget *parent = 0);
|
||||
explicit LicenseViewer(QWidget* parent = 0);
|
||||
|
||||
void setLicenseFile(const QString &fileName);
|
||||
};
|
||||
|
@ -56,7 +56,7 @@ void SpeedDial::loadSettings()
|
||||
"url:\"http://www.qupzilla.com\"|title:\"QupZilla\";"
|
||||
"url:\"http://blog.qupzilla.com\"|title:\"QupZilla Blog\";"
|
||||
"url:\"https://github.com/nowrep/QupZilla\"|title:\"QupZilla GitHub\";"
|
||||
"url:\"http://facebook.com\"|title:\"Facebook\";";
|
||||
"url:\"https://facebook.com\"|title:\"Facebook\";";
|
||||
}
|
||||
changed(allPages);
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
#define DEFAULT_THEME_NAME "linux"
|
||||
#endif
|
||||
|
||||
ThemeManager::ThemeManager(QWidget* parent, Preferences *preferences)
|
||||
ThemeManager::ThemeManager(QWidget* parent, Preferences* preferences)
|
||||
: QWidget()
|
||||
, ui(new Ui::ThemeManager)
|
||||
, m_preferences(preferences)
|
||||
|
@ -37,7 +37,7 @@ class QT_QUPZILLA_EXPORT ThemeManager : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ThemeManager(QWidget *parent, Preferences *preferences);
|
||||
explicit ThemeManager(QWidget* parent, Preferences* preferences);
|
||||
~ThemeManager();
|
||||
|
||||
void save();
|
||||
|
@ -28,6 +28,12 @@ RssIcon::RssIcon(QWidget* parent)
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
void RssIcon::contextMenuEvent(QContextMenuEvent* ev)
|
||||
{
|
||||
// Prevent propagating to LocationBar
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
void RssIcon::mousePressEvent(QMouseEvent* ev)
|
||||
{
|
||||
ClickableLabel::mousePressEvent(ev);
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
explicit RssIcon(QWidget* parent = 0);
|
||||
|
||||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* ev);
|
||||
void mousePressEvent(QMouseEvent* ev);
|
||||
};
|
||||
|
||||
|
@ -57,6 +57,8 @@ TabBar::TabBar(QupZilla* mainClass, TabWidget* tabWidget)
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
loadSettings();
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &)));
|
||||
connect(m_tabWidget, SIGNAL(pinnedTabClosed()), this, SLOT(pinnedTabClosed()));
|
||||
connect(m_tabWidget, SIGNAL(pinnedTabAdded()), this, SLOT(pinnedTabAdded()));
|
||||
@ -386,6 +388,38 @@ void TabBar::mouseReleaseEvent(QMouseEvent* event)
|
||||
QTabBar::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void TabBar::dragEnterEvent(QDragEnterEvent* event)
|
||||
{
|
||||
const QMimeData* mime = event->mimeData();
|
||||
|
||||
if (mime->hasUrls()) {
|
||||
event->acceptProposedAction();
|
||||
return;
|
||||
}
|
||||
|
||||
QTabBar::dragEnterEvent(event);
|
||||
}
|
||||
|
||||
void TabBar::dropEvent(QDropEvent* event)
|
||||
{
|
||||
const QMimeData* mime = event->mimeData();
|
||||
|
||||
if (!mime->hasUrls()) {
|
||||
QTabBar::dropEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
int index = tabAt(event->pos());
|
||||
if (index == -1) {
|
||||
foreach(const QUrl & url, mime->urls()) {
|
||||
m_tabWidget->addView(url, Qz::NT_SelectedTabAtTheEnd);
|
||||
}
|
||||
}
|
||||
else {
|
||||
p_QupZilla->weView(index)->load(mime->urls().first());
|
||||
}
|
||||
}
|
||||
|
||||
void TabBar::disconnectObjects()
|
||||
{
|
||||
disconnect(this);
|
||||
|
@ -83,6 +83,9 @@ private:
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
void mouseDoubleClickEvent(QMouseEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dropEvent(QDropEvent* event);
|
||||
|
||||
QSize tabSizeHint(int index) const;
|
||||
// void tabInserted(int index);
|
||||
|
||||
|
@ -15,11 +15,11 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#include "tabwidget.h"
|
||||
#include "tabbar.h"
|
||||
#include "tabbedwebview.h"
|
||||
#include "webpage.h"
|
||||
#include "qupzilla.h"
|
||||
#include "tabwidget.h"
|
||||
#include "tabbar.h"
|
||||
#include "iconprovider.h"
|
||||
#include "mainapplication.h"
|
||||
#include "webtab.h"
|
||||
@ -27,7 +27,6 @@
|
||||
#include "closedtabsmanager.h"
|
||||
#include "progressbar.h"
|
||||
#include "navigationbar.h"
|
||||
#include "toolbutton.h"
|
||||
#include "locationbar.h"
|
||||
#include "websearchbar.h"
|
||||
#include "settings.h"
|
||||
@ -38,70 +37,43 @@
|
||||
#include <QStackedWidget>
|
||||
#include <QWebHistory>
|
||||
|
||||
class QT_QUPZILLA_EXPORT NewTabButton : public QToolButton
|
||||
AddTabButton::AddTabButton(TabWidget* tabWidget, TabBar* tabBar)
|
||||
: ToolButton(tabWidget)
|
||||
, m_tabBar(tabBar)
|
||||
, m_tabWidget(tabWidget)
|
||||
{
|
||||
public:
|
||||
explicit NewTabButton(QWidget* parent) : QToolButton(parent) {
|
||||
#ifndef Q_WS_WIN
|
||||
setIcon(QIcon::fromTheme("list-add"));
|
||||
setIconSize(QSize(16, 16));
|
||||
setObjectName("tabwidget-button-addtab");
|
||||
setAutoRaise(true);
|
||||
#endif
|
||||
}
|
||||
QSize sizeHint() const {
|
||||
QSize siz = QToolButton::sizeHint();
|
||||
siz.setWidth(26);
|
||||
return siz;
|
||||
}
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
setAcceptDrops(true);
|
||||
setToolTip(TabWidget::tr("New Tab"));
|
||||
}
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
private:
|
||||
void paintEvent(QPaintEvent*) {
|
||||
QPainter p(this);
|
||||
QStyleOptionTabV3 opt;
|
||||
opt.init(this);
|
||||
style()->drawControl(QStyle::CE_TabBarTab, &opt, &p, this);
|
||||
|
||||
QPixmap pix(":/icons/other/list-add.png");
|
||||
QRect r = this->rect();
|
||||
r.setHeight(r.height() + 3);
|
||||
r.setWidth(r.width() + 3);
|
||||
style()->drawItemPixmap(&p, r, Qt::AlignCenter, pix);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
class QT_QUPZILLA_EXPORT TabListButton : public QToolButton
|
||||
void AddTabButton::dragEnterEvent(QDragEnterEvent* event)
|
||||
{
|
||||
public:
|
||||
explicit TabListButton(QWidget* parent) : QToolButton(parent) {
|
||||
const QMimeData* mime = event->mimeData();
|
||||
|
||||
if (mime->hasUrls()) {
|
||||
event->acceptProposedAction();
|
||||
return;
|
||||
}
|
||||
|
||||
QSize sizeHint() const {
|
||||
QSize siz = QToolButton::sizeHint();
|
||||
siz.setWidth(20);
|
||||
return siz;
|
||||
ToolButton::dragEnterEvent(event);
|
||||
}
|
||||
|
||||
void AddTabButton::dropEvent(QDropEvent* event)
|
||||
{
|
||||
const QMimeData* mime = event->mimeData();
|
||||
|
||||
if (!mime->hasUrls()) {
|
||||
ToolButton::dropEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent*) {
|
||||
QPainter p(this);
|
||||
QStyleOptionToolButton opt;
|
||||
opt.init(this);
|
||||
if (isDown()) {
|
||||
opt.state |= QStyle::State_On;
|
||||
foreach(const QUrl & url, mime->urls()) {
|
||||
m_tabWidget->addView(url, Qz::NT_SelectedTabAtTheEnd);
|
||||
}
|
||||
if (opt.state & QStyle::State_MouseOver) {
|
||||
opt.activeSubControls = QStyle::SC_ToolButton;
|
||||
}
|
||||
if (!isChecked() && !isDown()) {
|
||||
opt.state |= QStyle::State_Raised;
|
||||
}
|
||||
opt.state |= QStyle::State_AutoRaise;
|
||||
|
||||
style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &p, this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent)
|
||||
: QTabWidget(parent)
|
||||
@ -142,11 +114,7 @@ TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent)
|
||||
m_buttonListTabs->setAutoRaise(true);
|
||||
m_buttonListTabs->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
m_buttonAddTab = new ToolButton(this);
|
||||
m_buttonAddTab->setObjectName("tabwidget-button-addtab");
|
||||
m_buttonAddTab->setAutoRaise(true);
|
||||
m_buttonAddTab->setToolTip(tr("New Tab"));
|
||||
m_buttonAddTab->setFocusPolicy(Qt::NoFocus);
|
||||
m_buttonAddTab = new AddTabButton(this, m_tabBar);
|
||||
|
||||
connect(m_buttonAddTab, SIGNAL(clicked()), p_QupZilla, SLOT(addTab()));
|
||||
connect(m_menuTabs, SIGNAL(aboutToShow()), this, SLOT(aboutToShowClosedTabsMenu()));
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <QTabWidget>
|
||||
#include <QUrl>
|
||||
|
||||
#include "toolbutton.h"
|
||||
#include "qz_namespace.h"
|
||||
|
||||
class QStackedWidget;
|
||||
@ -29,11 +30,22 @@ class QMenu;
|
||||
class QupZilla;
|
||||
class TabbedWebView;
|
||||
class TabBar;
|
||||
class TabWidget;
|
||||
class WebTab;
|
||||
class TabListButton;
|
||||
class NewTabButton;
|
||||
class ClosedTabsManager;
|
||||
class ToolButton;
|
||||
|
||||
class QT_QUPZILLA_EXPORT AddTabButton : public ToolButton
|
||||
{
|
||||
public:
|
||||
explicit AddTabButton(TabWidget* tabWidget, TabBar* tabBar);
|
||||
|
||||
private:
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dropEvent(QDropEvent* event);
|
||||
|
||||
TabBar* m_tabBar;
|
||||
TabWidget* m_tabWidget;
|
||||
};
|
||||
|
||||
class QT_QUPZILLA_EXPORT TabWidget : public QTabWidget
|
||||
{
|
||||
@ -56,7 +68,7 @@ public:
|
||||
QList<WebTab*> allTabs(bool withPinned = true);
|
||||
QStackedWidget* locationBars() { return m_locationBars; }
|
||||
ToolButton* buttonListTabs() { return m_buttonListTabs; }
|
||||
ToolButton* buttonAddTab() { return m_buttonAddTab; }
|
||||
AddTabButton* buttonAddTab() { return m_buttonAddTab; }
|
||||
|
||||
void createKeyPressEvent(QKeyEvent* event);
|
||||
void showTabBar();
|
||||
@ -114,7 +126,7 @@ private:
|
||||
|
||||
QMenu* m_menuTabs;
|
||||
ToolButton* m_buttonListTabs;
|
||||
ToolButton* m_buttonAddTab;
|
||||
AddTabButton* m_buttonAddTab;
|
||||
ClosedTabsManager* m_closedTabsManager;
|
||||
|
||||
QStackedWidget* m_locationBars;
|
||||
|
@ -167,6 +167,10 @@ void AKN_Handler::handleAccessKey(QKeyEvent* event)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
QChar key = text.at(0).toUpper();
|
||||
|
||||
if (m_accessKeyNodes.contains(key)) {
|
||||
@ -196,6 +200,10 @@ void AKN_Handler::handleAccessKey(QKeyEvent* event)
|
||||
|
||||
void AKN_Handler::showAccessKeys()
|
||||
{
|
||||
if (!m_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
QWebPage* page = m_view->page();
|
||||
|
||||
// Install event filter and connect loadStarted
|
||||
@ -284,7 +292,7 @@ void AKN_Handler::showAccessKeys()
|
||||
|
||||
void AKN_Handler::hideAccessKeys()
|
||||
{
|
||||
if (!m_accessKeyLabels.isEmpty()) {
|
||||
if (!m_accessKeyLabels.isEmpty() && m_view) {
|
||||
for (int i = 0; i < m_accessKeyLabels.count(); ++i) {
|
||||
QLabel* label = m_accessKeyLabels[i];
|
||||
label->hide();
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
AKN_Plugin::AKN_Plugin()
|
||||
: QObject()
|
||||
, m_handler(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <QSettings>
|
||||
#include <QTextBrowser>
|
||||
|
||||
AKN_Settings::AKN_Settings(AKN_Handler *handler, QWidget *parent)
|
||||
AKN_Settings::AKN_Settings(AKN_Handler* handler, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::AKN_Settings)
|
||||
, m_handler(handler)
|
||||
|
@ -20,7 +20,8 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class AKN_Settings;
|
||||
}
|
||||
|
||||
@ -31,7 +32,7 @@ class AKN_Settings : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AKN_Settings(AKN_Handler* handler, QWidget *parent = 0);
|
||||
explicit AKN_Settings(AKN_Handler* handler, QWidget* parent = 0);
|
||||
~AKN_Settings();
|
||||
|
||||
private slots:
|
||||
@ -39,7 +40,7 @@ private slots:
|
||||
void showLicence();
|
||||
|
||||
private:
|
||||
Ui::AKN_Settings *ui;
|
||||
Ui::AKN_Settings* ui;
|
||||
|
||||
AKN_Handler* m_handler;
|
||||
QString m_settingsPath;
|
||||
|
Loading…
Reference in New Issue
Block a user