File indexing completed on 2024-12-22 04:13:16

0001 /*
0002  * SPDX-FileCopyrightText: 2018 boud <boud@valdyas.org>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 #ifndef KISNEWSWIDGET_H
0007 #define KISNEWSWIDGET_H
0008 
0009 #include <QWidget>
0010 #include <QListView>
0011 #include <QSet>
0012 #include <QStyledItemDelegate>
0013 #include <KisKineticScroller.h>
0014 
0015 #include <ui_KisNewsPage.h>
0016 
0017 class MultiFeedRssModel;
0018 
0019 class KisNewsDelegate : public QStyledItemDelegate
0020 {
0021     Q_OBJECT
0022 public:
0023     KisNewsDelegate(QObject *parent = 0);
0024     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0025     QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0026 };
0027 
0028 /**
0029  * @brief The KisNewsWidget class shows the latest news from Krita.org
0030  */
0031 class KisNewsWidget : public QWidget, public Ui::KisNewsPage
0032 {
0033     Q_OBJECT
0034 public:
0035     explicit KisNewsWidget(QWidget *parent = nullptr);
0036 
0037     void setAnalyticsTracking(QString text);
0038     void toggleNewsLanguage(QString langCode, bool enabled);
0039 
0040 Q_SIGNALS:
0041     void newsDataChanged();
0042 
0043 protected:
0044     bool eventFilter(QObject *watched, QEvent *event) override;
0045 
0046 private Q_SLOTS:
0047     void toggleNews(bool toggle);
0048     void itemSelected(const QModelIndex &idx);
0049     void rssDataChanged();
0050     void slotScrollerStateChanged(QScroller::State state){ KisKineticScroller::updateCursor(this, state); }
0051 
0052 private:
0053     bool m_getNews {false};
0054     MultiFeedRssModel *m_rssModel {0};
0055     QString m_analyticsTrackingParameters;
0056     QSet<QString> m_enabledFeeds;
0057 };
0058 
0059 #endif // KISNEWSWIDGET_H