File indexing completed on 2024-02-25 16:46:45

0001 /***************************************************************************
0002     smb4kbookmarkmenu  -  Bookmark menu
0003                              -------------------
0004     begin                : Sat Apr 02 2011
0005     copyright            : (C) 2011-2019 by Alexander Reinholdt
0006     email                : alexander.reinholdt@kdemail.net
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *   This program is free software; you can redistribute it and/or modify  *
0011  *   it under the terms of the GNU General Public License as published by  *
0012  *   the Free Software Foundation; either version 2 of the License, or     *
0013  *   (at your option) any later version.                                   *
0014  *                                                                         *
0015  *   This program is distributed in the hope that it will be useful, but   *
0016  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
0017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
0018  *   General Public License for more details.                              *
0019  *                                                                         *
0020  *   You should have received a copy of the GNU General Public License     *
0021  *   along with this program; if not, write to the                         *
0022  *   Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,*
0023  *   MA 02110-1335, USA                                                    *
0024  ***************************************************************************/
0025 
0026 #ifndef SMB4KBOOKMARKMENU_H
0027 #define SMB4KBOOKMARKMENU_H
0028 
0029 // application specific includes
0030 #include "smb4kglobal.h"
0031 
0032 // Qt includes
0033 #include <QAction>
0034 #include <QActionGroup>
0035 #include <QPointer>
0036 
0037 // KDE includes
0038 #include <KWidgetsAddons/KActionMenu>
0039 #include <KXmlGui/KActionCollection>
0040 
0041 // forward declarations
0042 class Smb4KBookmark;
0043 
0044 
0045 class Smb4KBookmarkMenu : public KActionMenu
0046 {
0047   Q_OBJECT
0048 
0049   public:
0050     /**
0051      * Enumeration
0052      */
0053     enum Type { MainWindow,
0054                 SystemTray };
0055     
0056     /**
0057      * Constructor
0058      */
0059     explicit Smb4KBookmarkMenu(int type,
0060                                 QWidget *parentWidget = 0,
0061                                 QObject *parent = 0);
0062 
0063     /**
0064      * Destructor
0065      */
0066     ~Smb4KBookmarkMenu();
0067 
0068     /**
0069      * Force the menu to be set up again. This should be called if 
0070      * the settings changed and the handling of bookmarks might be
0071      * affected.
0072      */
0073     void refreshMenu();
0074     
0075     /**
0076      * Enable/disable the 'Add Bookmark' action
0077      */
0078     void setBookmarkActionEnabled(bool enable);
0079     
0080   Q_SIGNALS:
0081     /**
0082      * This signal is emitted when the 'Add Bookmark' is triggered.
0083      */
0084     void addBookmark();
0085 
0086   protected Q_SLOTS:
0087     /**
0088      * Called when the edit action is triggered
0089      */
0090     void slotEditActionTriggered(bool checked);
0091     
0092     /**
0093      * Called when the add action is triggered
0094      */
0095     void slotAddActionTriggered(bool checked);
0096     
0097     /**
0098      * Called when the toplevel mount action is triggered
0099      */
0100     void slotToplevelMountActionTriggered(bool checked);
0101     
0102     /**
0103      * Called when a group action is triggered
0104      */
0105     void slotGroupActionTriggered(QAction *action);
0106     
0107     /**
0108      * Called when a bookmark action is triggered
0109      */
0110     void slotBookmarkActionTriggered(QAction *action);
0111 
0112     /**
0113      * Called when the list bookmarks has been updated
0114      */
0115     void slotBookmarksUpdated();
0116     
0117     /**
0118      * Called when a bookmark was unmounted
0119      */
0120     void slotEnableBookmark(const SharePtr &share);
0121 
0122   private:
0123     /**
0124      * Set up the menu
0125      */
0126     void setupMenu();
0127     
0128     /**
0129      * Type
0130      */
0131     int m_type;
0132 
0133     /**
0134      * Widget that should be used as parent
0135      */
0136     QWidget *m_parent_widget;
0137     
0138     /**
0139      * The actions
0140      */
0141     QActionGroup *m_actions;
0142 
0143     /**
0144      * The bookmarks
0145      */
0146     QActionGroup *m_bookmarks;
0147 };
0148 
0149 #endif