File indexing completed on 2024-04-21 12:30:49

0001 /*
0002     smb4ksharesmenu  -  Shares menu
0003 
0004     SPDX-FileCopyrightText: 2011-2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef SMB4KSHARESMENU_H
0009 #define SMB4KSHARESMENU_H
0010 
0011 // application specific includes
0012 #include "core/smb4kglobal.h"
0013 
0014 // Qt includes
0015 #include <QAction>
0016 #include <QActionGroup>
0017 
0018 // KDE includes
0019 #include <KActionMenu>
0020 
0021 // forward declarations
0022 class Smb4KShare;
0023 
0024 class Smb4KSharesMenu : public KActionMenu
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     /**
0030      * Constructor
0031      */
0032     explicit Smb4KSharesMenu(QObject *parent = nullptr);
0033 
0034     /**
0035      * Destructor
0036      */
0037     ~Smb4KSharesMenu();
0038 
0039     /**
0040      * Refresh the shares menu
0041      */
0042     void refreshMenu();
0043 
0044 protected Q_SLOTS:
0045     /**
0046      * This slot is invokes when a share was mounted
0047      */
0048     void slotShareMounted(const SharePtr &share);
0049 
0050     /**
0051      * This slot is invoked when a share was unmounted
0052      */
0053     void slotShareUnmounted(const SharePtr &share);
0054 
0055     /**
0056      * This slot is invoked when the modifictions of the
0057      * mounted shares list are finished.
0058      */
0059     void slotMountedSharesListChanged();
0060 
0061     /**
0062      * This slot unmounts all shares at once.
0063      */
0064     void slotUnmountAllShares();
0065 
0066     /**
0067      * This slot is called when an action is triggered.
0068      *
0069      * @param action        The action that was triggered
0070      */
0071     void slotShareAction(QAction *action);
0072 
0073 private:
0074     /**
0075      * Add a share to the menu
0076      */
0077     void addShareToMenu(const SharePtr &share);
0078 
0079     /**
0080      * Remove a share from the menu
0081      */
0082     void removeShareFromMenu(const SharePtr &share);
0083 
0084     /**
0085      * Share menus
0086      */
0087     QActionGroup *m_menus;
0088 
0089     /**
0090      * Share actions
0091      */
0092     QActionGroup *m_actions;
0093 
0094     /**
0095      * The Unmount All action
0096      */
0097     QAction *m_unmountAll;
0098 
0099     /**
0100      * The separator action
0101      */
0102     QAction *m_separator;
0103 };
0104 
0105 #endif