File indexing completed on 2024-04-28 04:21:22
0001 // SPDX-FileCopyrightText: 2012 Jesper K. Pedersen <jesper.pedersen@kdab.com> 0002 // SPDX-FileCopyrightText: 2013-2023 Johannes Zarl-Zierl <johannes@zarl-zierl.at> 0003 // SPDX-FileCopyrightText: 2018-2022 Tobias Leupold <tl@stonemx.de> 0004 // 0005 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 0007 #ifndef FILTERWIDGET_H 0008 #define FILTERWIDGET_H 0009 0010 #include <DB/search/ImageSearchInfo.h> 0011 0012 #include <KToolBar> 0013 0014 class KActionCollection; 0015 class KRatingWidget; 0016 class QAction; 0017 class QLabel; 0018 class QWidget; 0019 0020 namespace ThumbnailView 0021 { 0022 /** 0023 * @brief The FilterWidget class provides a KToolBar widget to interact with the thumbnail filter. 0024 * You can use it to set the rating filter, and it gives some visual feedback when the filter changes. 0025 * 0026 * \image html FilterWidget.png "FilterWidget when no filter is set" 0027 */ 0028 class FilterWidget : public KToolBar 0029 { 0030 Q_OBJECT 0031 public: 0032 explicit FilterWidget(QWidget *parent = nullptr); 0033 0034 /** 0035 * @brief actions contains shortcut actions for setting the rating filter. 0036 * @see ThumbnailFacade::actions() 0037 * @return the QActions for this widget. 0038 */ 0039 KActionCollection *actions() const; 0040 0041 Q_SIGNALS: 0042 void filterToggled(bool enabled); 0043 void ratingChanged(short rating); 0044 0045 public Q_SLOTS: 0046 void setFilter(const DB::ImageSearchInfo &filter); 0047 /** 0048 * @brief setEnabled enables or disables the filter controls. 0049 * If the ThumbnailView is not active, setEnable should be set to \c false. 0050 * @param enabled 0051 */ 0052 void setEnabled(bool enabled); 0053 0054 protected Q_SLOTS: 0055 void slotRatingChanged(int rating); 0056 void resetLabelText(); 0057 0058 private: 0059 KActionCollection *m_actions; 0060 QAction *m_toggleFilter; 0061 KRatingWidget *m_rating; 0062 QLabel *m_label; 0063 }; 0064 } 0065 0066 #endif // FILTERWIDGET_H