File indexing completed on 2024-03-24 16:27:30

0001 /***************************************************************************
0002     The main window of Smb4K
0003                              -------------------
0004     begin                : Di Jan 1 2008
0005     copyright            : (C) 2008-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 SMB4KMAINWINDOW_H
0027 #define SMB4KMAINWINDOW_H
0028 
0029 // application specific includes
0030 #include "core/smb4kglobal.h"
0031 
0032 // Qt includes
0033 #include <QUrl>
0034 #include <QActionGroup>
0035 #include <QLabel>
0036 #include <QProgressBar>
0037 #include <QDockWidget>
0038 
0039 // KDE includes
0040 #include <KXmlGui/KXmlGuiWindow>
0041 
0042 // forward declarations
0043 class Smb4KSystemTray;
0044 class Smb4KPrintInfo;
0045 class Smb4KSynchronizationInfo;
0046 
0047 /**
0048  * This is the main window of Smb4K. It provides the network browser, the
0049  * shares view and all other dialogs as well as a menu, status and tool bar.
0050  *
0051  * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0052  */
0053 
0054 class Smb4KMainWindow : public KXmlGuiWindow
0055 {
0056   Q_OBJECT
0057 
0058   public:
0059     /**
0060      * The constructor
0061      */
0062     Smb4KMainWindow();
0063 
0064     /**
0065      * The destructor
0066      */
0067     ~Smb4KMainWindow();
0068 
0069   protected:
0070     /**
0071      * Reimplemented from KMainWindow.
0072      */
0073     bool queryClose() override;
0074     
0075     /**
0076      * Reimplemented from KMainWindow
0077      */
0078     bool eventFilter(QObject *obj, QEvent *e) override;
0079 
0080   protected slots:
0081     /**
0082      * Quits the application.
0083      */
0084     void slotQuit();
0085 
0086     /**
0087      * Opens the configuration dialog.
0088      */
0089     void slotConfigDialog();
0090 
0091     /**
0092      * Reloads settings, if necessary. This slot is connected to
0093      * the KConfigDialog::settingsChanged() signal.
0094      *
0095      * @param dialogName      The name of the configuration dialog
0096      */
0097     void slotSettingsChanged(const QString &dialogName);
0098 
0099     /**
0100      * This slot is called when a bookmark should be added.
0101      *
0102      * @param checked       TRUE if the action is checked
0103      */
0104     void slotAddBookmarks();
0105 
0106     /**
0107      * This slot is connected to the Smb4KWalletManager::initialized() signal.
0108      * It checks the state of the wallet manager and sets the icon in the status
0109      * bar accordingly.
0110      */
0111     void slotWalletManagerInitialized();
0112     
0113     /**
0114      * This slot shows a busy bar and a status message according to the action performed by 
0115      * the client. It is connected to the Smb4KClient::aboutToStart() signal.
0116      *
0117      * @param item          The network item
0118      *
0119      * @param process       The process
0120      */
0121     void slotClientAboutToStart(const NetworkItemPtr &item, int process);
0122     
0123     /**
0124      * this slot shows a status message according to the action that was just finished by the 
0125      * client and hides the status bar if appropriate. It is connected to the Smb4KClient::finished()
0126      * signal.
0127      * 
0128      * @param item          The network item
0129      * 
0130      * @param process       The process
0131      */
0132     void slotClientFinished(const NetworkItemPtr &item, int process);
0133 
0134     /**
0135      * This slot shows a status message according to the action performed by the 
0136      * mounter as well as a busy bar. It is connected to the Smb4KMounter::aboutToStart() 
0137      * signal.
0138      * @param process       The process
0139      */
0140     void slotMounterAboutToStart(int process);
0141     
0142     /**
0143      * This shows a status message according to the action that was just finished by
0144      * the mounter and hides the busy bar if appropriate. It is connected to the 
0145      * Smb4KMounter::finished() signal.
0146      * @param process       The process
0147      */
0148     void slotMounterFinished(int process);
0149                                                                 
0150     /**
0151      * This slot gives the visual mount feedback in the status bar. It is 
0152      * connected to the Smb4KMounter::mounted() signal.
0153      * 
0154      * @param share         The share object
0155      */
0156     void slotVisualMountFeedback(const SharePtr &share);
0157     
0158     /**
0159      * This slot gives the visual unmount feedback in the status bar. It is 
0160      * connected to the Smb4KMounter::unmounted() signal.
0161      * 
0162      * @param share         The share object
0163      */
0164     void slotVisualUnmountFeedback(const SharePtr &share);
0165                                   
0166     /**
0167      * This slot shows a message according to the action performed by the synchronizer.
0168      * It is connected to the Smb4KSynchronizer::aboutToStart() signal.
0169      *
0170      * @param dest          The path of the destination
0171      */
0172     void slotSynchronizerAboutToStart(const QString &dest);
0173 
0174     /**
0175      * This slot shows a message according to the finished action that were reported
0176      * by the synchronizer. It is connected to the Smb4KSynchronizer::finished() signal.
0177      *
0178      * @param dest          The path of the destination
0179      */
0180     void slotSynchronizerFinished(const QString &dest);
0181 
0182     /**
0183      * This slot hides the feedback icon in the status bar. It is connected to
0184      * a QTimer::singleShot() signal.
0185      */
0186     void slotEndVisualFeedback();
0187 
0188     /**
0189      * Enable/disable the "Add Bookmark" action
0190      */
0191     void slotEnableBookmarkAction();
0192     
0193     /**
0194      * This slot is connected to the visibilityChanged() signals of the network browser
0195      * dock widget. It is used to get the tool bars right.
0196      *
0197      * @param visible         If the dock widget is visible.
0198      */
0199     void slotNetworkBrowserVisibilityChanged(bool visible);
0200     
0201     /**
0202      * This slot is connected to the visibilityChanged() signals of the shares view
0203      * dock widget. It is used to get the tool bars right.
0204      *
0205      * @param visible         If the dock widget is visible.
0206      */
0207     void slotSharesViewVisibilityChanged(bool visible);
0208 
0209   private:
0210     /**
0211      * Set up the main window actions
0212      */
0213     void setupActions();
0214 
0215     /**
0216      * Set up the status bar
0217      */
0218     void setupStatusBar();
0219 
0220     /**
0221      * Set up the main window's view
0222      */
0223     void setupView();
0224     
0225     /**
0226      * Set up menu bar
0227      */
0228     void setupMenuBar();
0229 
0230     /**
0231      * Set up the system tray widget
0232      */
0233     void setupSystemTrayWidget();
0234 
0235     /**
0236      * Loads the settings
0237      */
0238     void loadSettings();
0239 
0240     /**
0241      * Saves the settings
0242      */
0243     void saveSettings();
0244     
0245     /**
0246      * Set up the mount indicator
0247      */
0248     void setupMountIndicator();
0249     
0250     /**
0251      * Setup the dynamic action list
0252      */
0253     void setupDynamicActionList(QDockWidget *dock);
0254     
0255     /**
0256      * This is the progress bar in the status bar.
0257      */
0258     QProgressBar *m_progress_bar;
0259 
0260     /**
0261      * This is the pixmap label that represents the state of
0262      * the password handler in the status bar.
0263      */
0264     QLabel *m_pass_icon;
0265 
0266     /**
0267      * This icon gives feedback on actions that took place like
0268      * mounting a share, etc.
0269      */
0270     QLabel *m_feedback_icon;
0271 
0272     /**
0273      * The system tray widget
0274      */
0275     Smb4KSystemTray *m_system_tray_widget;
0276     
0277     /**
0278      * This is the widget (embedded into a dock widget) that has 
0279      * the focus. 
0280      */
0281     QWidget *m_focusWidget;
0282 
0283     /**
0284      * Dock widgets action group;
0285      */
0286     QActionGroup *m_dockWidgets;
0287 };
0288 
0289 #endif