File indexing completed on 2024-06-16 10:53:59

0001 /*
0002     The configuration page for the authentication settings of Smb4K
0003 
0004     SPDX-FileCopyrightText: 2003-2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef SMB4KCONFIGPAGEAUTHENTICATION_H
0009 #define SMB4KCONFIGPAGEAUTHENTICATION_H
0010 
0011 // Application specific includes
0012 #include "core/smb4kauthinfo.h"
0013 
0014 // Qt includes
0015 #include <QCheckBox>
0016 #include <QList>
0017 #include <QListWidget>
0018 #include <QPushButton>
0019 #include <QWidget>
0020 
0021 // Forward declarations
0022 class QListWidgetItem;
0023 
0024 /**
0025  * This is the configuration tab for the authentication settings
0026  * of Smb4K.
0027  *
0028  * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0029  */
0030 
0031 class Smb4KConfigPageAuthentication : public QWidget
0032 {
0033     Q_OBJECT
0034 
0035 public:
0036     /**
0037      * The constructor.
0038      *
0039      * @param parent          The parent widget
0040      */
0041     explicit Smb4KConfigPageAuthentication(QWidget *parent = nullptr);
0042 
0043     /**
0044      * The destructor.
0045      */
0046     virtual ~Smb4KConfigPageAuthentication();
0047 
0048     /**
0049      * Load the login credentials.
0050      */
0051     void loadLoginCredentials();
0052 
0053     /**
0054      * Save the login credentials.
0055      */
0056     void saveLoginCredentials();
0057 
0058     /**
0059      * Returns TRUE if the wallet entries are loaded and FALSE otherwise.
0060      *
0061      * @returns TRUE if the wallet entries are loaded
0062      */
0063     bool loginCredentialsLoaded();
0064 
0065     /**
0066      * This functions checks the entries in this widget against the ones in
0067      * the wallet and returns the result. If the login credentials were not
0068      * loaded, this function will always return FALSE.
0069      *
0070      * @returns TRUE if the wallet entries have changed and FALSE otherwise.
0071      */
0072     bool loginCredentialsChanged();
0073 
0074 Q_SIGNALS:
0075     /**
0076      * This signal is emitted every time the wallet entries potentially were
0077      * modified by the user. When this signal is emitted, it does not necessarily
0078      * mean that any wallet entry indeed changed. It only means that the user
0079      * edited one.
0080      */
0081     void walletEntriesModified();
0082 
0083 protected:
0084     /**
0085      * Reimplemented.
0086      */
0087     bool eventFilter(QObject *object, QEvent *event) override;
0088 
0089 protected Q_SLOTS:
0090     /**
0091      * This slot is called when the "Use wallet" check box is toggled.
0092      *
0093      * @param checked       TRUE if the check box is checked and otherwise
0094      *                      FALSE.
0095      */
0096     void slotKWalletButtonToggled(bool checked);
0097 
0098     /**
0099      * This slot is invoked when the "Default login" check box is toggled.
0100      *
0101      * @param checked       TRUE if the check box is checked and otherwise
0102      *                      FALSE.
0103      */
0104     void slotDefaultLoginToggled(bool checked);
0105 
0106     /**
0107      * This slot is called when the wallet entries are to be loaded.
0108      *
0109      * @param checked         TRUE if the button is checked and FALSE otherwise.
0110      */
0111     void slotLoadButtonClicked(bool checked);
0112 
0113     /**
0114      * This slot is called when the list of all wallet entries is to be saved.
0115      *
0116      * @param checked         TRUE if the button is checked and FALSE otherwise.
0117      */
0118     void slotSaveButtonClicked(bool checked);
0119 
0120     /**
0121      * This slot is called when a wallet entry is to be edited.
0122      *
0123      * @param checked         TRUE if the button is checked and FALSE otherwise.
0124      */
0125     void slotEditButtonClicked(bool checked);
0126 
0127     /**
0128      * This slot is called when a wallet entry is to be removed.
0129      *
0130      * @param checked         TRUE if the button is checked and FALSE otherwise.
0131      */
0132     void slotRemoveButtonClicked(bool checked);
0133 
0134     /**
0135      * This slot is called when the list of all wallet entries is to be cleared.
0136      *
0137      * @param checked         TRUE if the button is checked and FALSE otherwise.
0138      */
0139     void slotClearButtonClicked(bool checked);
0140 
0141     /**
0142      * This slot is called when the actions performed on the custom options
0143      * are to be reset.
0144      *
0145      * @param checked         TRUE if the button is checked and FALSE otherwise.
0146      */
0147     void slotResetButtonClicked(bool checked);
0148 
0149     /**
0150      * This slot is called when the reset button is to be enabled/disabled.
0151      */
0152     void slotEnableResetButton();
0153 
0154     /**
0155      * This slot is called when an wallet item in the list view is double clicked.
0156      *
0157      * @param item          The item that was double clicked.
0158      */
0159     void slotWalletItemDoubleClicked(QListWidgetItem *item);
0160 
0161 private:
0162     QWidget *m_walletEntriesEditor;
0163     QListWidget *m_walletEntriesWidget;
0164     QPushButton *m_loadButton;
0165     QPushButton *m_saveButton;
0166     QPushButton *m_editButton;
0167     QPushButton *m_removeButton;
0168     QPushButton *m_clearButton;
0169     QPushButton *m_resetButton;
0170     QCheckBox *m_useDefaultLogin;
0171     QList<Smb4KAuthInfo *> m_entriesList;
0172     // FIXME: Do we need this at all?
0173     bool m_entriesLoaded;
0174 };
0175 
0176 #endif