summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bookmarks/CMakeLists.txt3
-rw-r--r--src/bookmarks/bookmarksmenu.cpp2
-rw-r--r--src/bookmarks/bookmarksmenu.hpp2
-rw-r--r--src/bookmarks/bookmarkstoolbar.cpp93
-rw-r--r--src/bookmarks/bookmarkstoolbar.h67
-rw-r--r--src/bookmarks/bookmarkstoolbar.hpp58
-rw-r--r--src/rekonqwindow.ui16
-rw-r--r--src/rekonqwindow_class.cpp3
8 files changed, 118 insertions, 126 deletions
diff --git a/src/bookmarks/CMakeLists.txt b/src/bookmarks/CMakeLists.txt
index 1d0f846f..d2651ce9 100644
--- a/src/bookmarks/CMakeLists.txt
+++ b/src/bookmarks/CMakeLists.txt
@@ -1,6 +1,4 @@
add_library(bookmarks STATIC
-# bookmarkowner.cpp bookmarkowner.h
-# bookmarkstoolbar.cpp bookmarkstoolbar.h
# Bookmarks Model
bookmark.cpp bookmark.hpp
bookmarkstreeitem.cpp bookmarkstreeitem.hpp
@@ -9,6 +7,7 @@ add_library(bookmarks STATIC
bookmarkstreeformat_xbel_read.cpp bookmarkstreeformat_xbel_write.cpp
# UI
bookmarksmenu.cpp bookmarksmenu.hpp
+ bookmarkstoolbar.cpp bookmarkstoolbar.hpp
)
target_include_directories(bookmarks PUBLIC ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(bookmarks PUBLIC Qt6::Core Qt6::Widgets)
diff --git a/src/bookmarks/bookmarksmenu.cpp b/src/bookmarks/bookmarksmenu.cpp
index 761a0026..aad7289e 100644
--- a/src/bookmarks/bookmarksmenu.cpp
+++ b/src/bookmarks/bookmarksmenu.cpp
@@ -6,8 +6,6 @@
* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
* SPDX-License-Identifier: GPL-3.0-only
* Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
- * ============================================================
- * Description: rekonq bookmarks menu
* ============================================================ */
#include "bookmarksmenu.hpp"
diff --git a/src/bookmarks/bookmarksmenu.hpp b/src/bookmarks/bookmarksmenu.hpp
index ad175991..f162244e 100644
--- a/src/bookmarks/bookmarksmenu.hpp
+++ b/src/bookmarks/bookmarksmenu.hpp
@@ -6,8 +6,6 @@
* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
* SPDX-License-Identifier: GPL-3.0-only
* Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
- * ============================================================
- * Description: rekonq bookmarks menu
* ============================================================ */
#pragma once
diff --git a/src/bookmarks/bookmarkstoolbar.cpp b/src/bookmarks/bookmarkstoolbar.cpp
index 658aa0c0..353e61b9 100644
--- a/src/bookmarks/bookmarkstoolbar.cpp
+++ b/src/bookmarks/bookmarkstoolbar.cpp
@@ -1,70 +1,56 @@
/* ============================================================
- *
- * This file is a part of the rekonq project
- *
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-2.0-or-later
* Copyright (C) 2008-2013 by Andrea Diamantini <adjam7 at gmail dot com>
* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License or (at your option) version 3 or any later version
- * accepted by the membership of KDE e.V. (or its successor approved
- * by the membership of KDE e.V.), which shall act as a proxy
- * defined in Section 14 of version 3 of the license.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
* ============================================================ */
-// Self Includes
-#include "bookmarkstoolbar.h"
-#include "bookmarkstoolbar.moc"
+#include "bookmarkstoolbar.hpp"
+#include "bookmarkstreemodel.hpp"
+#include <QShowEvent>
-// Local Includes
-#include "bookmarkmanager.h"
-#include "bookmarkowner.h"
-#include "bookmarkscontextmenu.h"
+BookmarkToolBar::BookmarkToolBar(QWidget *parent) : QToolBar(parent)
+{
+ /*
+setContextMenuPolicy(Qt::CustomContextMenu);
-#include "iconmanager.h"
-#include "webwindow.h"
+connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
+connect(BookmarkManager::self()->manager(), SIGNAL(changed(QString, QString)), this, SLOT(hideMenu()));
-// KDE Includes
-#include <KMenu>
+setAcceptDrops(true);
+installEventFilter(this);
+setShortcutEnabled(false);
-// Qt Includes
-#include <QActionEvent>
-#include <QApplication>
-#include <QFrame>
+if (isVisible()) {
+ BookmarkManager::self()->fillBookmarkBar(this);
+ m_filled = true;
+}
+*/
+}
-BookmarkToolBar::BookmarkToolBar(QWidget *parent)
- : KToolBar(parent, false, false), m_currentMenu(0), m_dragAction(0), m_dropAction(0), m_checkedAction(0),
- m_filled(false)
+void BookmarkToolBar::showEvent(QShowEvent *event)
{
- setContextMenuPolicy(Qt::CustomContextMenu);
-
- connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
- connect(BookmarkManager::self()->manager(), SIGNAL(changed(QString, QString)), this, SLOT(hideMenu()));
-
- setAcceptDrops(true);
- installEventFilter(this);
- setShortcutEnabled(false);
-
- if (isVisible()) {
- BookmarkManager::self()->fillBookmarkBar(this);
- m_filled = true;
+ Q_CHECK_PTR(model);
+
+ clear();
+
+ const auto *root = model->item();
+ Q_CHECK_PTR(root);
+ for (int i = 0; i < root->childCount(); ++i) {
+ const auto *child = root->child(i);
+ if (child->type() != BookmarksTreeItem::Bookmark) continue;
+ auto *action = addAction(child->data(BookmarksTreeItem::Title).toString(), this, [this, child]() {
+ emit loadUrl(child->data(BookmarksTreeItem::Href).toUrl(), rekonq::CurrentTab);
+ });
}
-}
-BookmarkToolBar::~BookmarkToolBar() { clear(); }
+ event->accept();
+}
+/*
void BookmarkToolBar::contextMenu(const QPoint &point)
{
KBookmarkActionInterface *action = dynamic_cast<KBookmarkActionInterface *>(actionAt(point));
@@ -402,3 +388,4 @@ void BookmarkToolBar::dragDestroyed()
delete m_dropAction;
m_dropAction = 0;
}
+*/
diff --git a/src/bookmarks/bookmarkstoolbar.h b/src/bookmarks/bookmarkstoolbar.h
deleted file mode 100644
index d325def4..00000000
--- a/src/bookmarks/bookmarkstoolbar.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2008-2013 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef BOOKMARKSTOOLBAR_H
-#define BOOKMARKSTOOLBAR_H
-
-#include "rekonq.hpp"
-#include <QToolBar>
-
-/**
- * This class manage the bookmark toolbar.
- * Some events from the toolbar are handled to allow the drag and drop
- */
-
-class BookmarkToolBar : public QToolBar {
- Q_OBJECT
-
-public:
- explicit BookmarkToolBar(QWidget *parent);
- ~BookmarkToolBar();
-
-protected:
- bool eventFilter(QObject *watched, QEvent *event);
-
-private Q_SLOTS:
- void contextMenu(const QPoint &);
- void menuDisplayed();
- void menuHidden();
- void hideMenu();
- void dragDestroyed();
-
-private:
- void startDrag();
-
- KMenu *m_currentMenu;
- QPoint m_startDragPos;
- QAction *m_dragAction;
- QAction *m_dropAction;
- QAction *m_checkedAction;
- bool m_filled;
-};
-
-#endif // BOOKMARKSTOOLBAR_H
diff --git a/src/bookmarks/bookmarkstoolbar.hpp b/src/bookmarks/bookmarkstoolbar.hpp
new file mode 100644
index 00000000..6aaa750a
--- /dev/null
+++ b/src/bookmarks/bookmarkstoolbar.hpp
@@ -0,0 +1,58 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright (C) 2008-2013 by Andrea Diamantini <adjam7 at gmail dot com>
+ * Copyright (C) 2010 by Yoann Laissus <yoann dot laissus at gmail dot com>
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
+#pragma once
+
+#include "rekonq.hpp"
+#include <QToolBar>
+
+class BookmarksTreeModel;
+
+/**
+ * This class manage the bookmark toolbar.
+ * Some events from the toolbar are handled to allow the drag and drop
+ */
+class BookmarkToolBar : public QToolBar {
+ Q_OBJECT
+
+public:
+ explicit BookmarkToolBar(QWidget *parent = nullptr);
+ ~BookmarkToolBar() override = default;
+
+ void setModel(BookmarksTreeModel *ptr)
+ {
+ Q_CHECK_PTR(ptr);
+ model = ptr;
+ }
+
+signals:
+ void loadUrl(const QUrl &url, rekonq::OpenType type);
+
+protected:
+ void showEvent(QShowEvent *event) override;
+ // bool eventFilter(QObject *watched, QEvent *event);
+
+private slots:
+ // void contextMenu(const QPoint &);
+ // void menuDisplayed();
+ // void menuHidden();
+ // void hideMenu();
+ // void dragDestroyed();
+
+private:
+ BookmarksTreeModel *model = nullptr;
+ void startDrag();
+
+ QPoint m_startDragPos;
+ QAction *m_dragAction = nullptr;
+ QAction *m_dropAction = nullptr;
+ QAction *m_checkedAction = nullptr;
+ bool m_filled = false;
+};
diff --git a/src/rekonqwindow.ui b/src/rekonqwindow.ui
index e12fc519..7879f848 100644
--- a/src/rekonqwindow.ui
+++ b/src/rekonqwindow.ui
@@ -209,6 +209,17 @@
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
+ <widget class="BookmarkToolBar" name="bookmarksToolBar">
+ <property name="windowTitle">
+ <string>toolBar</string>
+ </property>
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
<action name="actionTaskManager">
<property name="text">
<string>Task Manager</string>
@@ -278,6 +289,11 @@
<extends>QMenu</extends>
<header>bookmarks/bookmarksmenu.hpp</header>
</customwidget>
+ <customwidget>
+ <class>BookmarkToolBar</class>
+ <extends>QToolBar</extends>
+ <header>bookmarks/bookmarkstoolbar.hpp</header>
+ </customwidget>
</customwidgets>
<resources/>
<connections>
diff --git a/src/rekonqwindow_class.cpp b/src/rekonqwindow_class.cpp
index 517742f4..cf721448 100644
--- a/src/rekonqwindow_class.cpp
+++ b/src/rekonqwindow_class.cpp
@@ -31,10 +31,13 @@ RekonqWindow::RekonqWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::Re
#ifndef REKONQ_TEST
ui->bookmarksPanel->setModel(Application::instance()->bookmarks());
+ ui->bookmarksToolBar->setModel(Application::instance()->bookmarks());
ui->menuBookmarks->setModel(Application::instance()->bookmarks());
#endif
connect(ui->bookmarksPanel, &BookmarksPanel::loadUrl, this,
qOverload<const QUrl &, rekonq::OpenType>(&RekonqWindow::loadUrl));
+ connect(ui->bookmarksToolBar, &BookmarkToolBar::loadUrl, this,
+ qOverload<const QUrl &, rekonq::OpenType>(&RekonqWindow::loadUrl));
connect(ui->menuBookmarks, &BookmarksMenu::loadUrl, this,
qOverload<const QUrl &, rekonq::OpenType>(&RekonqWindow::loadUrl));