1 /* ============================================================
2 * Falkon - Qt web browser
3 * Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 * ============================================================ */
18 #ifndef SIDEBAR_H
19 #define SIDEBAR_H
20 
21 #include <QWidget>
22 #include <QHash>
23 #include <QPointer>
24 
25 #include "qzcommon.h"
26 
27 class QVBoxLayout;
28 class QMenu;
29 
30 class DockTitleBarWidget;
31 class SideBarInterface;
32 class SideBarManager;
33 class BrowserWindow;
34 
35 class FALKON_EXPORT SideBar : public QWidget
36 {
37     Q_OBJECT
38 public:
39     explicit SideBar(SideBarManager* manager, BrowserWindow* window);
40 
41     void showBookmarks();
42     void showHistory();
43 
44     void setTitle(const QString &title);
45     void setWidget(QWidget* widget);
46 
47 public Q_SLOTS:
48     void close();
49 
50 private:
51     BrowserWindow* m_window;
52     QVBoxLayout* m_layout;
53     DockTitleBarWidget* m_titleBar;
54     SideBarManager* m_manager;
55 };
56 
57 class FALKON_EXPORT SideBarManager : public QObject
58 {
59     Q_OBJECT
60 public:
61     explicit SideBarManager(BrowserWindow* parent);
62 
63     QString activeSideBar() const;
64 
65     void createMenu(QMenu* menu);
66 
67     void showSideBar(const QString &id, bool toggle = true);
68     void sideBarRemoved(const QString &id);
69     void closeSideBar();
70 
71     static void addSidebar(const QString &id, SideBarInterface* interface);
72     static void removeSidebar(SideBarInterface *interface);
73 
74 private Q_SLOTS:
75     void slotShowSideBar();
76 
77 private:
78     BrowserWindow* m_window;
79     QPointer<SideBar> m_sideBar;
80     QMenu* m_menu;
81 
82     QString m_activeBar;
83 };
84 
85 #endif // SIDEBAR_H
86