File indexing completed on 2024-05-12 16:39:34
0001 /* This file is part of the KDE project 0002 Copyright (C) 2016 Jarosław Staniek <staniek@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #define QT_ONLY 0021 #ifdef QT_GUI_LIB 0022 # include <QGuiApplication> 0023 # include <QIcon> 0024 #else 0025 # include <QCoreApplication> 0026 #endif 0027 #include <QResource> 0028 #include <QDomDocument> 0029 0030 #include <iostream> 0031 #include "../../src/main/KexiRegisterResource_p.h" 0032 0033 //! @internal runtime check for existence of breeze icons 0034 int main(int argc, char *argv[]) 0035 { 0036 #ifdef QT_GUI_LIB 0037 QGuiApplication app(argc, argv); 0038 #else 0039 QCoreApplication app(argc, argv); 0040 #endif 0041 QString errorMessage; 0042 QString detailsErrorMessage; 0043 const char *file 0044 = "The icon resource is invalid, please build repository " 0045 "from https://invent.kde.org/frameworks/breeze-icons (with -DBINARY_ICONS_RESOURCE=ON) " 0046 "or install the \"breeze-icon-theme\" and \"breeze-icon-theme-rcc\" packages.\nIssue: "; 0047 if (!registerGlobalBreezeIconsResource(&errorMessage, &detailsErrorMessage)) { 0048 std::cerr << file << " " << errorMessage.toStdString() 0049 << detailsErrorMessage.toStdString() << std::endl; 0050 return 1; 0051 } 0052 setupBreezeIconTheme(); 0053 const char *iconName = "document-save-as"; 0054 const QString iconPath(":/actions/%1/%2.svg"); 0055 const QList<int> expectedSizes({16, 22, 32}); 0056 for(int size : expectedSizes) { 0057 QFile file(iconPath.arg(size).arg(iconName)); 0058 if (!file.open(QIODevice::ReadOnly)) { 0059 return 1; 0060 } 0061 if (file.size() < 100 || file.size() > 50000) { 0062 return 1; 0063 } 0064 QDomDocument doc; 0065 if (!doc.setContent(&file)) { 0066 return 1; 0067 } 0068 file.seek(0); 0069 qDebug() << file.readAll(); 0070 file.close(); 0071 } 0072 #ifdef QT_GUI_LIB 0073 // try to load the icons 0074 const QIcon icon(QIcon::fromTheme(iconName)); 0075 if (icon.themeName() != "breeze") { 0076 std::cerr << file << "resource's theme is \"" << icon.themeName().toStdString() 0077 << "\", expected: \"breeze\"" << std::endl; 0078 return 1; 0079 } 0080 QSet<int> foundSizes; 0081 foreach(const QSize &size, icon.availableSizes()) { 0082 foundSizes += size.width(); 0083 } 0084 for(int size : expectedSizes) { 0085 if (!foundSizes.contains(size)) { 0086 std::cerr << file << "\"" << iconName << "\" icon not found for size " << size << std::endl; 0087 return 1; 0088 } 0089 } 0090 #endif 0091 return 0; 0092 }