1 /***************************************************************************
2     The configuration page for the authentication settings of Smb4K
3                              -------------------
4     begin                : Sa Nov 15 2003
5     copyright            : (C) 2003-2019 by Alexander Reinholdt
6     email                : alexander.reinholdt@kdemail.net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  *   This program is free software; you can redistribute it and/or modify  *
11  *   it under the terms of the GNU General Public License as published by  *
12  *   the Free Software Foundation; either version 2 of the License, or     *
13  *   (at your option) any later version.                                   *
14  *                                                                         *
15  *   This program is distributed in the hope that it will be useful, but   *
16  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
18  *   General Public License for more details.                              *
19  *                                                                         *
20  *   You should have received a copy of the GNU General Public License     *
21  *   along with this program; if not, write to the                         *
22  *   Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,*
23  *   MA 02110-1335, USA                                                    *
24  ***************************************************************************/
25 
26 #ifndef SMB4KCONFIGPAGEAUTHENTICATION_H
27 #define SMB4KCONFIGPAGEAUTHENTICATION_H
28 
29 // Application specific includes
30 #include "core/smb4kauthinfo.h"
31 
32 // Qt includes
33 #include <QList>
34 #include <QListWidget>
35 
36 /**
37  * This is the configuration tab for the authentication settings
38  * of Smb4K.
39  *
40  * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net>
41  */
42 
43 
44 class Smb4KConfigPageAuthentication : public QWidget
45 {
46   Q_OBJECT
47 
48   public:
49     /**
50      * The constructor.
51      *
52      * @param parent          The parent widget
53      */
54     explicit Smb4KConfigPageAuthentication(QWidget *parent = 0);
55 
56     /**
57      * The destructor.
58      */
59     virtual ~Smb4KConfigPageAuthentication();
60 
61     /**
62      * Insert the list of authentication information entries into the internal
63      * list of wallet entries. This function will not display the entries. You
64      * need to call displayWalletEntries() for this.
65      *
66      * @param entries       The list of entries
67      */
68     void insertWalletEntries(const QList<Smb4KAuthInfo *> &entries);
69 
70     /**
71      * Get the - maybe modified - entries.
72      *
73      * @returns the list of entries.
74      */
getWalletEntries()75     const QList<Smb4KAuthInfo *> &getWalletEntries() { return m_entriesList; }
76 
77     /**
78      * Returns TRUE if the wallet entries are displayed and FALSE otherwise.
79      *
80      * @returns TRUE if the wallet entries are displayed
81      */
walletEntriesDisplayed()82     bool walletEntriesDisplayed() { return m_entries_displayed; }
83 
84     /**
85      * Returns TRUE in the case the wallet entries might have changed. You need
86      * to check this outside this widget, whether a change indeed occurred.
87      *
88      * @returns TRUE if the wallet entries might have changed.
89      */
walletEntriesMaybeChanged()90     bool walletEntriesMaybeChanged() { return m_maybe_changed; }
91 
92   signals:
93     /**
94      * Emitted when the "Load" button is clicked.
95      */
96     void loadWalletEntries();
97 
98     /**
99      * Emitted when the "Save" button is clicked.
100      */
101     void saveWalletEntries();
102 
103     /**
104      * Emitted when the default login should be (re-)defined.
105      */
106     void setDefaultLogin();
107 
108     /**
109      * This signal is emitted every time the wallet entries potentially were
110      * modified by the user. When this signal is emitted, it does not necessarily
111      * mean that any wallet entry indeed changed. It only means that the user
112      * edited one.
113      */
114     void walletEntriesModified();
115 
116   protected:
117     /**
118      * Reimplemented.
119      */
120     bool eventFilter(QObject *object, QEvent *event) override;
121 
122   protected slots:
123     /**
124      * This slot is called when the "Use wallet" check box is toggled.
125      *
126      * @param checked       TRUE if the check box is checked and otherwise
127      *                      FALSE.
128      */
129     void slotKWalletButtonToggled(bool checked);
130 
131     /**
132      * This slot is invoked when the "Default login" check box is toggled.
133      *
134      * @param checked       TRUE if the check box is checked and otherwise
135      *                      FALSE.
136      */
137     void slotDefaultLoginToggled(bool checked);
138 
139     /**
140      * This slot is connected to the KListWidget::itemSelectionChanged() signal.
141      * It unmarks and enables/disables the "Show details" checkbox and clears the
142      * the details widget.
143      */
144     void slotItemSelectionChanged();
145 
146     /**
147      * This slot is connected to the QTableWidget::cellChanged() signal and commits
148      * changes the user applied to the entries to the internal list and enables the
149      * "Undo" action.
150      *
151      * @param row             The row of the cell that was changed
152      *
153      * @param column          The column of the cell that was changed
154      */
155     void slotDetailsChanged(int row, int column);
156 
157     /**
158      * This slot is called when the edit action is clicked.
159      */
160     void slotEditClicked();
161 
162     /**
163      * This slot is connected to the "Remove" button
164      */
165     void slotRemoveClicked();
166 
167     /**
168      * This slot is connected to the "Clear" button
169      */
170     void slotClearClicked();
171 
172     /**
173      * This slot is connected to the "Save" button and resets all actions.
174      *
175      * @param checked         TRUE if the action is checked
176      */
177     void slotSaveClicked(bool checked);
178 
179   private:
180     void loadDetails(Smb4KAuthInfo *authInfo);
181     void clearDetails();
182     QList<Smb4KAuthInfo *> m_entriesList;
183     bool m_entries_displayed;
184     bool m_maybe_changed;
185 };
186 
187 #endif
188