File indexing completed on 2024-04-21 04:58:15

0001 /* This file is part of the KDE project
0002     SPDX-FileCopyrightText: 1998, 1999 Simon Hausmann <hausmann@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef __konq_guiclients_h__
0008 #define __konq_guiclients_h__
0009 
0010 #include "pluginmetadatautils.h"
0011 #include "konq_popupmenu.h"
0012 
0013 #include <KActionCollection>
0014 #include <KXMLGUIClient>
0015 #include <KPluginMetaData>
0016 
0017 #include <QObject>
0018 #include <QHash>
0019 
0020 class QAction;
0021 class KonqMainWindow;
0022 class KonqView;
0023 
0024 /**
0025  * PopupMenuGUIClient has most of the konqueror logic for KonqPopupMenu.
0026  * It holds an actionCollection and takes care of the preview and tabhandling groups for KonqPopupMenu.
0027  */
0028 class PopupMenuGUIClient : public QObject
0029 {
0030     Q_OBJECT
0031 public:
0032     // The action groups are inserted into @p actionGroups
0033     PopupMenuGUIClient(const QVector<KPluginMetaData> &embeddingServices,
0034                        KonqPopupMenu::ActionGroupMap &actionGroups,
0035                        QAction *showMenuBar, QAction *stopFullScreen);
0036     ~PopupMenuGUIClient() override;
0037 
0038     KActionCollection *actionCollection()
0039     {
0040         return &m_actionCollection;
0041     }
0042 
0043 signals:
0044     void openEmbedded(const KPluginMetaData &part);
0045 
0046 private slots:
0047     void slotOpenEmbedded();
0048 
0049 private:
0050     QAction *addEmbeddingPlugin(int idx, const QString &name, const KPluginMetaData &plugin);
0051 
0052     KActionCollection m_actionCollection;
0053     QVector<KPluginMetaData>  m_embeddingServices;
0054 };
0055 
0056 class ToggleViewGUIClient : public QObject
0057 {
0058     Q_OBJECT
0059 public:
0060     explicit ToggleViewGUIClient(KonqMainWindow *mainWindow);
0061     ~ToggleViewGUIClient() override;
0062 
0063     bool empty() const
0064     {
0065         return m_empty;
0066     }
0067 
0068     QList<QAction *> actions() const;
0069     QAction *action(const QString &name)
0070     {
0071         return m_actions[ name ];
0072     }
0073 
0074     void saveConfig(bool add, const QString &serviceName);
0075 
0076 private Q_SLOTS:
0077     void slotToggleView(bool toggle);
0078     void slotViewAdded(KonqView *view);
0079     void slotViewRemoved(KonqView *view);
0080 private:
0081     KonqMainWindow *m_mainWindow;
0082     QHash<QString, QAction *> m_actions;
0083 
0084     //TODO: is this really needed? Wouldn't it be enough to use m_actions.isEmpty()?
0085     bool m_empty;
0086     QMap<QString, bool> m_mapOrientation;
0087 };
0088 
0089 #endif