File indexing completed on 2024-05-12 04:57:58

0001 /* ============================================================
0002 * Falkon - Qt web browser
0003 * Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
0004 *
0005 * This program is free software: you can redistribute it and/or modify
0006 * it under the terms of the GNU General Public License as published by
0007 * the Free Software Foundation, either version 3 of the License, or
0008 * (at your option) any later version.
0009 *
0010 * This program is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 * GNU General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU General Public License
0016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017 * ============================================================ */
0018 #ifndef BOOKMARKSTOOLBAR_H
0019 #define BOOKMARKSTOOLBAR_H
0020 
0021 #include <QWidget>
0022 
0023 #include "qzcommon.h"
0024 
0025 class QHBoxLayout;
0026 class QTimer;
0027 
0028 class BrowserWindow;
0029 class Bookmarks;
0030 class BookmarkItem;
0031 class BookmarksToolbarButton;
0032 
0033 class FALKON_EXPORT BookmarksToolbar : public QWidget
0034 {
0035     Q_OBJECT
0036 public:
0037     explicit BookmarksToolbar(BrowserWindow* window, QWidget* parent = nullptr);
0038 
0039 private Q_SLOTS:
0040     void contextMenuRequested(const QPoint &pos);
0041 
0042     void refresh();
0043     void bookmarksChanged();
0044     void showOnlyIconsChanged(bool state);
0045     void showOnlyTextChanged(bool state);
0046 
0047     void openBookmarkInNewTab();
0048     void openBookmarkInNewWindow();
0049     void openBookmarkInNewPrivateWindow();
0050     void createNewFolder();
0051     void editBookmark();
0052     void deleteBookmark();
0053 
0054 private:
0055     void clear();
0056     void addItem(BookmarkItem* item);
0057     BookmarksToolbarButton* buttonAt(const QPoint &pos);
0058 
0059     QSize minimumSizeHint() const override;
0060 
0061     void dropEvent(QDropEvent* e) override;
0062     void dragEnterEvent(QDragEnterEvent* e) override;
0063     void dragMoveEvent(QDragMoveEvent* e) override;
0064     void dragLeaveEvent(QDragLeaveEvent* e) override;
0065     void paintEvent(QPaintEvent* p) override;
0066 
0067     BrowserWindow* m_window;
0068     Bookmarks* m_bookmarks;
0069     BookmarkItem* m_clickedBookmark;
0070     QHBoxLayout* m_layout;
0071     QTimer* m_updateTimer;
0072     QAction* m_actShowOnlyIcons = nullptr;
0073     QAction* m_actShowOnlyText = nullptr;
0074 
0075     int m_dropRow;
0076     QPoint m_dropPos;
0077     void clearDropIndicator();
0078 };
0079 
0080 #endif // BOOKMARKSTOOLBAR_H