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

0001 /* ============================================================
0002 * Falkon - Qt web browser
0003 * Copyright (C) 2010-2018 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 SIDEBAR_H
0019 #define SIDEBAR_H
0020 
0021 #include <QWidget>
0022 #include <QHash>
0023 #include <QPointer>
0024 
0025 #include "qzcommon.h"
0026 
0027 class QVBoxLayout;
0028 class QMenu;
0029 
0030 class DockTitleBarWidget;
0031 class SideBarInterface;
0032 class SideBarManager;
0033 class BrowserWindow;
0034 
0035 class FALKON_EXPORT SideBar : public QWidget
0036 {
0037     Q_OBJECT
0038 public:
0039     explicit SideBar(SideBarManager* manager, BrowserWindow* window);
0040 
0041     void showBookmarks();
0042     void showHistory();
0043 
0044     void setTitle(const QString &title);
0045     void setWidget(QWidget* widget);
0046 
0047 public Q_SLOTS:
0048     void close();
0049 
0050 private:
0051     BrowserWindow* m_window;
0052     QVBoxLayout* m_layout;
0053     DockTitleBarWidget* m_titleBar;
0054     SideBarManager* m_manager;
0055 };
0056 
0057 class FALKON_EXPORT SideBarManager : public QObject
0058 {
0059     Q_OBJECT
0060 public:
0061     explicit SideBarManager(BrowserWindow* parent);
0062 
0063     QString activeSideBar() const;
0064 
0065     void createMenu(QMenu* menu);
0066 
0067     void showSideBar(const QString &id, bool toggle = true);
0068     void sideBarRemoved(const QString &id);
0069     void closeSideBar();
0070 
0071     static void addSidebar(const QString &id, SideBarInterface* interface);
0072     static void removeSidebar(SideBarInterface *interface);
0073 
0074 private Q_SLOTS:
0075     void slotShowSideBar();
0076 
0077 private:
0078     BrowserWindow* m_window;
0079     QPointer<SideBar> m_sideBar;
0080     QMenu* m_menu;
0081 
0082     QString m_activeBar;
0083 };
0084 
0085 #endif // SIDEBAR_H