KisNewsWidget.h 2.15 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * Copyright (c) 2018 boud <boud@valdyas.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
#ifndef KISNEWSWIDGET_H
#define KISNEWSWIDGET_H

#include <QWidget>
#include <QListView>
23
#include <QStyledItemDelegate>
24 25 26 27 28

#include <ui_KisNewsPage.h>

class MultiFeedRssModel;

29 30 31 32 33 34 35 36 37
class KisNewsDelegate : public QStyledItemDelegate
{
    Q_OBJECT
public:
    KisNewsDelegate(QObject *parent = 0);
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
    QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
};

38 39 40 41 42 43 44 45
/**
 * @brief The KisNewsWidget class shows the latest news from Krita.org
 */
class KisNewsWidget : public QWidget, public Ui::KisNewsPage
{
    Q_OBJECT
public:
    explicit KisNewsWidget(QWidget *parent = nullptr);
46

47
    void setAnalyticsTracking(QString text);
48

49
    bool hasUpdateAvailable();
50 51
    QString versionNumber();
    QString versionLink();
52 53 54 55

Q_SIGNALS:
    void newsDataChanged();

56 57 58
private Q_SLOTS:
    void toggleNews(bool toggle);
    void itemSelected(const QModelIndex &idx);
59
    void rssDataChanged();
60 61 62
private:
    bool m_getNews {false};
    MultiFeedRssModel *m_rssModel {0};
63
    QString analyticsTrackingParameters;
64 65 66 67 68 69 70 71 72

    /// for new Krita version notification
    QString newVersionNumber;
    QString newVersionLink;

    // version checking logic tells us we need to update our Krita
    void calculateVersionUpdateStatus();
    bool needsVersionUpdate = false;

73 74 75
};

#endif // KISNEWSWIDGET_H