1 /* ============================================================ 2 * QuiteRSS is a open-source cross-platform RSS/Atom news feeds reader 3 * Copyright (C) 2011-2020 QuiteRSS Team <quiterssteam@gmail.com> 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <https://www.gnu.org/licenses/>. 17 * ============================================================ */ 18 #ifndef NEWSTABWIDGET_H 19 #define NEWSTABWIDGET_H 20 21 #ifdef HAVE_QT5 22 #include <QtWidgets> 23 #else 24 #include <QtGui> 25 #endif 26 #include <QtSql> 27 #include <QtWebKit> 28 29 #include "feedsproxymodel.h" 30 #include "feedsmodel.h" 31 #include "feedsview.h" 32 #include "findtext.h" 33 #include "lineedit.h" 34 #include "locationbar.h" 35 #include "newsheader.h" 36 #include "newsmodel.h" 37 #include "newsview.h" 38 #include "webview.h" 39 40 class MainWindow; 41 42 #define TOP_POSITION 0 43 #define BOTTOM_POSITION 1 44 #define RIGHT_POSITION 2 45 #define LEFT_POSITION 3 46 47 #define RESIZESTEP 25 // News list/browser size step 48 49 class NewsTabWidget : public QWidget 50 { 51 Q_OBJECT 52 public: 53 enum TabType { 54 TabTypeFeed, 55 TabTypeUnread, 56 TabTypeStar, 57 TabTypeDel, 58 TabTypeLabel, 59 TabTypeWeb, 60 TabTypeDownloads 61 }; 62 63 enum RefreshNewspaper { 64 RefreshAll, 65 RefreshInsert, 66 RefreshWithPos 67 }; 68 69 explicit NewsTabWidget(QWidget *parent, TabType type, int feedId = -1, int feedParId = -1); 70 ~NewsTabWidget(); 71 72 void disconnectObjects(); 73 74 void retranslateStrings(); 75 void setSettings(bool init = true, bool newTab = true); 76 void setNewsLayout(); 77 void setBrowserPosition(); 78 void markNewsRead(); 79 void markAllNewsRead(); 80 void markNewsStar(); 81 void setLabelNews(int labelId); 82 void deleteNews(); 83 void deleteAllNewsList(); 84 void restoreNews(); 85 void slotCopyLinkNews(); 86 void showLabelsMenu(); 87 void savePageAsDescript(); 88 89 bool openUrl(const QUrl &url); 90 void openInBrowserNews(); 91 void openInExternalBrowserNews(); 92 void openNewsNewTab(); 93 94 void updateWebView(QModelIndex index); 95 void loadNewspaper(int refresh = RefreshAll); 96 void hideWebContent(); 97 QString getLinkNews(int row); 98 99 void reduceNewsList(); 100 void increaseNewsList(); 101 102 int findUnreadNews(bool next); 103 104 void setTextTab(const QString &text); 105 106 void slotShareNews(QAction *action); 107 108 /*! \brief Convert \a countString to unreadCount depending on \a type_ 109 * \param countString from categories tree 110 * \return unreadCount for displaying in status 111 */ 112 int getUnreadCount(QString countString); 113 114 TabType type_; 115 int feedId_; 116 int feedParId_; 117 int currentNewsIdOld; 118 bool autoLoadImages_; 119 int labelId_; 120 QString categoryFilterStr_; 121 122 FindTextContent *findText_; 123 124 NewsModel *newsModel_; 125 NewsView *newsView_; 126 NewsHeader *newsHeader_; 127 QToolBar *newsToolBar_; 128 QSplitter *newsTabWidgetSplitter_; 129 130 QWidget *newsWidget_; 131 WebView *webView_; 132 QToolBar *webToolBar_; 133 LocationBar *locationBar_; 134 QWidget *webControlPanel_; 135 136 QLabel *newsIconTitle_; 137 QMovie *newsIconMovie_; 138 QLabel *newsTextTitle_; 139 QWidget *newsTitleLabel_; 140 QToolButton *closeButton_; 141 142 QAction *separatorRAct_; 143 144 public slots: 145 void setAutoLoadImages(bool apply = true); 146 void slotNewsViewClicked(QModelIndex index); 147 void slotNewsViewSelected(QModelIndex index, bool clicked=false); 148 void slotNewsViewDoubleClicked(QModelIndex index); 149 void slotNewsMiddleClicked(QModelIndex index); 150 void slotNewsUpPressed(QModelIndex index=QModelIndex()); 151 void slotNewsDownPressed(QModelIndex index=QModelIndex()); 152 void slotNewsHomePressed(QModelIndex index=QModelIndex()); 153 void slotNewsEndPressed(QModelIndex index=QModelIndex()); 154 void slotNewsPageUpPressed(QModelIndex index=QModelIndex()); 155 void slotNewsPageDownPressed(QModelIndex index=QModelIndex()); 156 void slotSort(int column, int order); 157 158 signals: 159 void signalSetHtmlWebView(const QString &html = "", const QUrl &baseUrl = QUrl()); 160 void signalSetTextTab(const QString &text, NewsTabWidget *widget); 161 void loadProgress(int); 162 163 private slots: 164 void showContextMenuNews(const QPoint &pos); 165 void slotSetItemRead(QModelIndex index, int read); 166 void slotSetItemStar(QModelIndex index, int starred); 167 void slotMarkReadTimeout(); 168 169 void slotSetHtmlWebView(const QString &html); 170 void webHomePage(); 171 void openPageInExternalBrowser(); 172 void slotLinkClicked(QUrl url); 173 void slotLinkHovered(const QString &link, const QString &str1="", const QString &str2=""); 174 void slotSetValue(int value); 175 void slotLoadStarted(); 176 void slotLoadFinished(bool); 177 void slotUrlEnter(); 178 void slotUrlChanged(const QUrl &url); 179 void showContextWebPage(const QPoint &p); 180 void openUrlInExternalBrowser(); 181 182 void slotTabClose(); 183 void webTitleChanged(QString title); 184 void openLink(); 185 void openLinkInNewTab(); 186 187 void slotFindText(const QString& text); 188 void slotSelectFind(); 189 190 void setWebToolbarVisible(bool show = true, bool checked = true); 191 192 void slotNewslLabelClicked(QModelIndex index); 193 194 private: 195 void createNewsList(); 196 void createWebWidget(); 197 QString getHtmlLabels(int row); 198 void actionNewspaper(QUrl url); 199 200 MainWindow *mainWindow_; 201 QSqlDatabase db_; 202 203 FeedsModel *feedsModel_; 204 FeedsProxyModel *feedsProxyModel_; 205 FeedsView *feedsView_; 206 207 QFrame *lineWebWidget; 208 QWidget *webWidget_; 209 QProgressBar *webViewProgress_; 210 QLabel *webViewProgressLabel_; 211 212 QAction *webHomePageAct_; 213 QAction *webExternalBrowserAct_; 214 QAction *urlExternalBrowserAct_; 215 216 QTimer *markNewsReadTimer_; 217 218 int webDefaultFontSize_; 219 int webDefaultFixedFontSize_; 220 221 QUrl linkUrl_; 222 QString linkNewsString_; 223 224 QWidget *newsPanelWidget_; 225 bool webToolbarShow_; 226 227 QString newspaperHeadHtml_; 228 QString newspaperHtml_; 229 QString newspaperHtmlRtl_; 230 QString htmlString_; 231 QString htmlRtlString_; 232 QString cssString_; 233 QString audioPlayerHtml_; 234 QString videoPlayerHtml_; 235 236 }; 237 238 #endif // NEWSTABWIDGET_H 239