File indexing completed on 2024-04-21 15:42:53

0001 /***************************************************************************
0002     The configuration dialog of Smb4K
0003                              -------------------
0004     begin                : Sa Apr 14 2007
0005     copyright            : (C) 2004-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 SMB4KCONFIGDIALOG_H
0027 #define SMB4KCONFIGDIALOG_H
0028 
0029 // Qt includes
0030 #include <QAbstractButton>
0031 
0032 // KDE includes
0033 #include <KConfigWidgets/KConfigDialog>
0034 
0035 // forward declarations
0036 class Smb4KSettings;
0037 
0038 /**
0039  * This is the (new) configuration dialog of Smb4K.
0040  *
0041  * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0042  */
0043 
0044 class Q_DECL_EXPORT Smb4KConfigDialog : public KConfigDialog
0045 {
0046   Q_OBJECT
0047 
0048   public:
0049     /**
0050      * The constructor
0051      * @param parent        The parent widget
0052      * @param args          The argument list
0053      */
0054     Smb4KConfigDialog(QWidget *parent, const QList<QVariant> &args);
0055     
0056     /**
0057      * The destructor
0058      */
0059     ~Smb4KConfigDialog();
0060 
0061   protected slots:
0062     /**
0063      * Reimplemented from KConfigDialog. Used to do things that 
0064      * KConfigDialog::updateSettings() does not do.
0065      */
0066     void updateSettings() override;
0067     
0068     /**
0069      * Reimplemented from KConfigDialog. Used to do things before
0070      * the dialog is shown.
0071      */
0072     void updateWidgets() override;
0073     
0074     /**
0075      * Reimplemented from QDialog. Used to reset things after the dialog was
0076      * closed via the 'Cancel' button.
0077      */
0078     void reject() override;
0079     
0080     /**
0081      * This slot is connected to the "Load" button of the "Wallet Entries" tab
0082      * of the "Authentication" configuration page. It loads the authentication
0083      * information and puts it into the list view.
0084      */
0085     void slotLoadAuthenticationInformation();
0086     
0087     /**
0088      * This slot is connected to the "Save" button of the "Wallet Entries" tab
0089      * of the "Authentication" configuration page. It saves the authentication
0090      * information.
0091      */
0092     void slotSaveAuthenticationInformation();
0093     
0094     /**
0095      * This slot is connected to the Smb4KAuthOptions::setDefaultLogin() signal.
0096      * It defines the default login.
0097      */
0098     void slotSetDefaultLogin();
0099     
0100     /**
0101      * Enable/disable the "Apply" button if settings that are not managed by
0102      * KConfig XT have changed.
0103      */
0104     void slotEnableApplyButton();
0105     
0106     /**
0107      * This slot is used to check the settings of the different pages.
0108      * 
0109      * @param current     the current dialog page
0110      * @param before      the previous dialog page
0111      */
0112     void slotCheckPage(KPageWidgetItem *current, KPageWidgetItem *before);
0113     
0114   private:
0115     /**
0116      * "User Interface" page
0117      */
0118     KPageWidgetItem *m_user_interface;
0119     
0120     /**
0121      * "Network" page
0122      */
0123     KPageWidgetItem *m_network;
0124     
0125     /**
0126      * "Authentication" page
0127      */
0128     KPageWidgetItem *m_authentication;
0129     
0130     /**
0131      * "Mounting" page
0132      */
0133     KPageWidgetItem *m_mounting;
0134     
0135     /**
0136      * "Synchronization" page
0137      */
0138     KPageWidgetItem *m_synchronization;
0139     
0140     /**
0141      * "Custom Options" page
0142      */
0143     KPageWidgetItem *m_custom_options;
0144     
0145     /**
0146      * "Profiles" page
0147      */
0148     KPageWidgetItem *m_profiles;
0149     
0150     /**
0151      * Set up the config dialog.
0152      */
0153     void setupDialog();
0154 
0155     /**
0156      * Load the custom Samba options
0157      */
0158     void loadCustomOptions();
0159 
0160     /**
0161      * Save the custom Samba options
0162      */
0163     void saveCustomOptions();
0164     
0165     /**
0166      * Takes care that the changes made to the profiles are propagated
0167      * to the core classes via the profiles manager.
0168      */
0169     void propagateProfilesChanges();
0170     
0171     /**
0172      * Checks the settings in the Network page.
0173      * 
0174      * @returns TRUE if everything is OK and FALSE otherwise.
0175      */
0176     bool checkNetworkPage();
0177     
0178     /**
0179      * Checks the settings in the Mounting page.
0180      * 
0181      * @returns TRUE if everything is OK and FALSE otherwise.
0182      */
0183     bool checkMountingPage();
0184     
0185     /**
0186      * Checks the settings in the Synchronization page.
0187      * 
0188      * @returns TRUE if everything is OK and FALSE otherwise.
0189      */
0190     bool checkSynchronizationPage();
0191 
0192     /**
0193      * Checks that mandatory needed input is provided for settings that
0194      * need it. This function will report all missing input to the user
0195      * via a message box.
0196      *
0197      * @returns TRUE if the check passed and FALSE if it failed.
0198      */
0199     bool checkSettings();
0200 };
0201 
0202 #endif