File indexing completed on 2024-05-19 04:59:19

0001 /* ============================================================
0002 * TabManager plugin for Falkon
0003 * Copyright (C) 2013-2017  S. Razi Alavizadeh <s.r.alavizadeh@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 TABMANAGERPLUGIN_H
0019 #define TABMANAGERPLUGIN_H
0020 
0021 
0022 #include "plugininterface.h"
0023 #include "tabmanagerwidgetcontroller.h"
0024 
0025 #include <QDebug>
0026 #include <QLabel>
0027 #include <QMessageBox>
0028 #include <QVBoxLayout>
0029 #include <QPointer>
0030 
0031 class TabManagerWidget;
0032 
0033 class TabManagerPlugin : public QObject, public PluginInterface
0034 {
0035     Q_OBJECT
0036     Q_INTERFACES(PluginInterface)
0037     Q_PLUGIN_METADATA(IID "Falkon.Browser.plugin.TabManagerPlugin" FILE "tabmanager.json")
0038 
0039 public:
0040     explicit TabManagerPlugin();
0041 
0042     void init(InitState state, const QString &settingsPath) override;
0043     void unload() override;
0044     bool testPlugin() override;
0045     void showSettings(QWidget *parent) override;
0046 
0047     void populateExtensionsMenu(QMenu *menu) override;
0048 
0049     enum ViewType {
0050         ShowAsSideBar = 0,
0051         ShowAsWindow = 1,
0052         Undefined = -1
0053     };
0054 
0055     void removeManagerWidget();
0056 
0057     ViewType viewType();
0058     void setViewType(ViewType type);
0059 
0060     static QString settingsPath();
0061     void saveSettings();
0062 
0063     bool asTabBarReplacement() const;
0064     void setAsTabBarReplacement(bool yes);
0065 
0066 public Q_SLOTS:
0067     void insertManagerWidget();
0068 
0069 private Q_SLOTS:
0070     void mainWindowCreated(BrowserWindow* window, bool refresh = true);
0071 
0072 private:
0073     void setTabBarVisible(bool visible);
0074 
0075     TabManagerWidgetController* m_controller;
0076     TabManagerWidget* m_tabManagerWidget;
0077     static QString s_settingsPath;
0078     ViewType m_viewType;
0079     bool m_initState;
0080     bool m_asTabBarReplacement;
0081 };
0082 
0083 #endif // TABMANAGERPLUGIN_H