File indexing completed on 2024-04-28 04:58:30

0001 /* This file is part of the KDE project
0002     SPDX-FileCopyrightText: 2023 Stefano Crocco <stefano.crocco@alice.it>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef KONQ_CONFIGDIALOG_H
0008 #define KONQ_CONFIGDIALOG_H
0009 
0010 #include <KCMultiDialog>
0011 
0012 #include <QPointer>
0013 
0014 namespace Konq {
0015 
0016 /**
0017 * @brief Konqueror configuration dialog
0018 */
0019 class ConfigDialog : public KCMultiDialog
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     /**
0025      * @brief Constructor
0026      * @param parent the parent widget
0027      */
0028     ConfigDialog(QWidget *parent = nullptr);
0029 
0030     /**
0031      * @brief destructor
0032      */
0033     ~ConfigDialog();
0034 
0035     /**
0036      * @brief Overrides `KCMultiDialog::sizeHint()` to take into account the size of all pages
0037      *
0038      * This is needed because `KCMultiDialog::sizeHint()` only takes into account the size hint of the current page
0039      *
0040      * @return a `QSize` whose width and height are the maximum between the width and height of `KCMultiDialog::sizeHint()`
0041      * and of the size hints of each page
0042      * @note Once this method is called, this value will cached and won't be updated anymore
0043      */
0044     QSize sizeHint() const override;
0045 
0046     /**
0047      * @brief Enum describing the different pages
0048      */
0049     enum Module {
0050         GeneralModule, //!< The general module
0051         PerformanceModule, //!< The performance module
0052         TabsModule, //!< The tab options module
0053         BookmarksModule, //!< The bookmarks module
0054         KonqModule, //!< The Konqueror behavior module
0055         DolphinGeneralModule, //!< The Dolphin general module
0056 #if QT_VERSION_MAJOR < 6
0057         DolphinNavigationModule, //!< The Dolphin navigation module
0058 #endif
0059         DolphinViewModesModule, //!< The Dolphin views module
0060         TrashModule, //!< The trash module
0061         FileTypesModule, //!< The file types module
0062         HtmlBehaviorModule, //!< The HTML behavior module
0063         HtmlAppearanceModule, //!< The HTML HTML appearance module
0064         AdBlockModule, //!< The AdBlock module
0065         HtmlCacheModule, //!< The HTML cache module
0066         WebShortcutsModule, //!< The web shortcuts module
0067         ProxyModule, //!< The proxy module
0068         HistoryModule, //!< The history module
0069         CookiesModule, //!< The cookies module
0070         JavaModule, //!< The java/javascript module
0071         UserAgentModule //!< The user agent module
0072     };
0073 
0074     /**
0075      * @brief Overload of `KCMultiDialog::setCurrentPage()` taking a Module
0076      * @param module the module to display
0077      */
0078     void setCurrentPage(Module module);
0079 
0080 private:
0081 
0082     /**
0083      * @brief Computes the size hint from the size hints of each module and from `KCMultiDialog::sizeHint()`
0084      */
0085     QSize computeSizeHint() const;
0086 
0087     /**
0088      * @brief Removes a tab with settings which don't apply to Konqueror from the General Dolphin KCM
0089      *
0090      * The General Dolphin KCM contains a tab which entries which only applies to Dolphin itself, so
0091      * we remove that tab to avoid confusing the user.
0092      */
0093     void fixDolphinGeneralPage(KPageWidgetItem *it);
0094 
0095     mutable QSize m_sizeHint; //!< The cached value of the size hint
0096     QHash<Module, QPointer<KPageWidgetItem>> m_pages; //!< A hash mapping module types to pages
0097 };
0098 }
0099 #endif //KONQ_CONFIGDIALOG_H