File indexing completed on 2024-04-28 15:26:50

0001 /*
0002     SPDX-FileCopyrightText: 2006 Aaron J. Seigo <aseigo@kde.org>
0003     SPDX-FileCopyrightText: 2009 Peter Penz <peter.penz@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef KURLNAVIGATORPROTOCOLCOMBO_P_H
0009 #define KURLNAVIGATORPROTOCOLCOMBO_P_H
0010 
0011 #include "kurlnavigatorbuttonbase_p.h"
0012 
0013 #include <QHash>
0014 
0015 class QMenu;
0016 
0017 namespace KDEPrivate
0018 {
0019 /**
0020  * @brief A combobox listing available protocols.
0021  *
0022  * The widget is used by the URL navigator for offering the available
0023  * protocols for non-local URLs.
0024  *
0025  * @see KUrlNavigator
0026  */
0027 class KUrlNavigatorProtocolCombo : public KUrlNavigatorButtonBase
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     explicit KUrlNavigatorProtocolCombo(const QString &protocol, KUrlNavigator *parent = nullptr);
0033 
0034     QString currentProtocol() const;
0035 
0036     void setCustomProtocols(const QStringList &protocols);
0037 
0038     QSize sizeHint() const override;
0039 
0040 public Q_SLOTS:
0041     void setProtocol(const QString &protocol);
0042 
0043 Q_SIGNALS:
0044     void activated(const QString &protocol);
0045 
0046 protected:
0047     void showEvent(QShowEvent *event) override;
0048     void paintEvent(QPaintEvent *event) override;
0049 
0050 private Q_SLOTS:
0051     void setProtocolFromMenu(QAction *action);
0052 
0053 private:
0054     void updateMenu();
0055     void initializeCategories();
0056 
0057     enum ProtocolCategory {
0058         CoreCategory,
0059         PlacesCategory,
0060         DevicesCategory,
0061         SubversionCategory,
0062         OtherCategory,
0063         CategoryCount, // mandatory last entry
0064     };
0065 
0066     QMenu *m_menu;
0067     QStringList m_protocols;
0068     QHash<QString, ProtocolCategory> m_categories;
0069 };
0070 
0071 } // namespace KDEPrivate
0072 
0073 #endif