File indexing completed on 2024-05-19 05:05:44
0001 /*************************************************************************** 0002 * SPDX-License-Identifier: GPL-2.0-or-later 0003 * * 0004 * SPDX-FileCopyrightText: 2004-2019 Thomas Fischer <fischer@unix-ag.uni-kl.de> 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, * 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0014 * GNU General Public License for more details. * 0015 * * 0016 * You should have received a copy of the GNU General Public License * 0017 * along with this program; if not, see <https://www.gnu.org/licenses/>. * 0018 ***************************************************************************/ 0019 0020 #ifndef KBIBTEX_NETWORKING_FAVICONLOCATOR_H 0021 #define KBIBTEX_NETWORKING_FAVICONLOCATOR_H 0022 0023 #include <QObject> 0024 #include <QIcon> 0025 #include <QUrl> 0026 0027 /** 0028 * This class tries to locate and download the favicon for a given 0029 * webpage. Upon success, a signal will be triggered. 0030 * At any point in time, the icon can be queried using a function, 0031 * but as long as no specific favicon got retrieved, this function 0032 * will return a generic icon only. 0033 * Favicons located once will be cached on a per-application base. 0034 * 0035 * @author Thomas Fischer <fischer@unix-ag.uni-kl.de> 0036 */ 0037 class FavIconLocator : public QObject 0038 { 0039 Q_OBJECT 0040 public: 0041 /** 0042 * Start searching for a favicon belonging to a given webpage. 0043 * Search will run asynchronous, its end is signalled with 0044 * @see gotIcon(). 0045 * @param webpageUrl Webpage where to search for a favicon 0046 * @param parent QObject-based parent of this object 0047 */ 0048 explicit FavIconLocator(const QUrl &webpageUrl, QObject *parent); 0049 0050 /** 0051 * Icon know for the webpage this specific object was created 0052 * for. In case no favicon has been downloaded yet (still in 0053 * progress or download failed), then a generic icon will be 0054 * returned. 0055 * 0056 * @return Either the webpage's favicon or a generic icon 0057 */ 0058 QIcon icon() const; 0059 0060 Q_SIGNALS: 0061 /** 0062 * Asynchronous search for a favicon concluded either with the 0063 * retrieved favicon or, in case of any failure, a generic icon. 0064 */ 0065 void gotIcon(QIcon); 0066 0067 private: 0068 QIcon favIcon; 0069 }; 0070 0071 #endif // KBIBTEX_NETWORKING_FAVICONLOCATOR_H