File indexing completed on 2024-12-01 04:37:15

0001 /*
0002     Configuration page for the custom settings
0003 
0004     SPDX-FileCopyrightText: 2013-2023 Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef SMB4KCONFIGPAGECUSTOMSETTINGS_H
0009 #define SMB4KCONFIGPAGECUSTOMSETTINGS_H
0010 
0011 // application specific includes
0012 #include "core/smb4kglobal.h"
0013 #include "smb4kcustomsettingseditorwidget.h"
0014 
0015 // Qt includes
0016 #include <QListWidget>
0017 #include <QPushButton>
0018 #include <QWidget>
0019 
0020 // KDE includes
0021 #include <KMessageWidget>
0022 
0023 /**
0024  * This configuration page takes care of the custom settings
0025  *
0026  * @author Alexander Reinholdt <alexander.reinholdt@kdemail.net>
0027  * @since 1.1.0
0028  */
0029 
0030 class Smb4KConfigPageCustomSettings : public QWidget
0031 {
0032     Q_OBJECT
0033 
0034 public:
0035     /**
0036      * Constructor
0037      */
0038     explicit Smb4KConfigPageCustomSettings(QWidget *parent = nullptr);
0039 
0040     /**
0041      * Destructor
0042      */
0043     virtual ~Smb4KConfigPageCustomSettings();
0044 
0045     /**
0046      * Returns TRUE if there may be changed custom settings. You must check if
0047      * this is indeed the case in you code.
0048      *
0049      * @returns TRUE if custom settings may have changed.
0050      */
0051     bool customSettingsChanged();
0052 
0053 public Q_SLOTS:
0054     /**
0055      * This function loads the list of custom settings.
0056      */
0057     void loadCustomSettings();
0058 
0059     /**
0060      * This function saves the list of custom settings.
0061      */
0062     void saveCustomSettings();
0063 
0064 protected:
0065     /**
0066      * Reimplemented from QObject
0067      */
0068     bool eventFilter(QObject *obj, QEvent *e) override;
0069 
0070 Q_SIGNALS:
0071     /**
0072      * This signal is emitted every time the custom settings potentially were
0073      * modified by the user. When this signal is emitted, it does not necessarily
0074      * mean that any custom setting changed. It only means that the user edited
0075      * one option.
0076      */
0077     void customSettingsModified();
0078 
0079 protected Q_SLOTS:
0080     /**
0081      * This slot is called when the item selection changed.
0082      */
0083     void slotItemSelectionChanged();
0084 
0085     /**
0086      * This slot is invoked when an item is double clicked. It is used
0087      * to edit the item the user double clicked.
0088      *
0089      * @param item            The item that was double clicked.
0090      */
0091     void slotEditCustomItem(QListWidgetItem *item);
0092 
0093     /**
0094      * This slot is called when custom settings are to be edited.
0095      *
0096      * @param checked         TRUE if the button is checked and FALSE otherwise.
0097      */
0098     void slotEditButtonClicked(bool checked);
0099 
0100     /**
0101      * This slot is called when a custom option is to be removed.
0102      *
0103      * @param checked         TRUE if the button is checked and FALSE otherwise.
0104      */
0105     void slotRemoveButtonClicked(bool checked);
0106 
0107     /**
0108      * This slot is called when the list of custom settings is to be cleared.
0109      *
0110      * @param checked         TRUE if the button is checked and FALSE otherwise.
0111      */
0112     void slotClearButtonClicked(bool checked);
0113 
0114     /**
0115      * This slot is called when the actions performed on the custom settings
0116      * are to be reset.
0117      *
0118      * @param checked         TRUE if the button is checked and FALSE otherwise.
0119      */
0120     void slotResetButtonClicked(bool checked);
0121 
0122     /**
0123      * Enable/disable the buttons
0124      */
0125     void slotEnableButtons();
0126 
0127     /**
0128      * Called when the selected custom setting is edited
0129      *
0130      * @param changed           TRUE if the settings are changed and FALSE if not
0131      */
0132     void slotCustomSettingsEdited(bool changed);
0133 
0134 private:
0135     void setRemovalMessage(const Smb4KCustomSettings &settings);
0136     QListWidget *m_listWidget;
0137     QListWidgetItem *m_itemToEdit;
0138     Smb4KCustomSettingsEditorWidget *m_editorWidget;
0139     KMessageWidget *m_messageWidget;
0140     bool m_customSettingsChanged;
0141     bool m_savingCustomSettings;
0142     QPushButton *m_resetButton;
0143     QPushButton *m_editButton;
0144     QPushButton *m_removeButton;
0145     QPushButton *m_clearButton;
0146 };
0147 
0148 #endif