Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportUtils_p.cpp
- This file was copied from src/common/KReportUtils_p.h.
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project | ||
---|---|---|---|---|---|
2 | Copyright (C) 2015-2016 Jarosław Staniek <staniek@kde.org> | 2 | Copyright (C) 2016 Adam Pigg <sadam@piggz.co.uk> | ||
staniek: undo:
- copyright removal :)
- typo in email | |||||
3 | 3 | | |||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public | ||
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either | ||
7 | version 2.1 of the License, or (at your option) any later version. | 7 | version 2.1 of the License, or (at your option) any later version. | ||
8 | 8 | | |||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Library General Public License for more details. | 12 | Library General Public License for more details. | ||
13 | 13 | | |||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301, USA. | 17 | Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #ifndef KREPORTUTILS_P_H | 20 | #include "KReportUtils_p.h" | ||
21 | #define KREPORTUTILS_P_H | 21 | #include "config-kreport.h" | ||
22 | 22 | | |||
23 | #include <QApplication> | 23 | #ifdef Q_OS_WIN | ||
24 | #define KPATH_SEPARATOR ';' | ||||
25 | #else | ||||
26 | #define KPATH_SEPARATOR ':' | ||||
27 | #endif | ||||
24 | 28 | | |||
25 | #include <KConfigGroup> | 29 | class KReportDpiSingleton | ||
26 | #include <KSharedConfig> | 30 | { | ||
27 | #include <KMessageBox> | 31 | public: | ||
32 | KReportDpiSingleton(); | ||||
28 | 33 | | |||
29 | #include <QCoreApplication> | 34 | int m_dpiX; | ||
30 | #include <QDir> | 35 | int m_dpiY; | ||
31 | #include <QFileInfo> | 36 | }; | ||
32 | #include <QRegularExpression> | 37 | | ||
33 | #include <QResource> | 38 | KReportDpiSingleton::KReportDpiSingleton() | ||
34 | #include <QStandardPaths> | 39 | { | ||
35 | #include <QDebug> | 40 | // Another way to get the DPI of the display would be QPaintDeviceMetrics, | ||
41 | // but we have no widget here (and moving this to KoView wouldn't allow | ||||
42 | // using this from the document easily). | ||||
43 | #ifdef Q_WS_X11 | ||||
44 | m_dpiX = QX11Info::appDpiX(); | ||||
45 | m_dpiY = QX11Info::appDpiY(); | ||||
46 | #else | ||||
47 | QDesktopWidget *w = QApplication::desktop(); | ||||
48 | if (w) { | ||||
49 | m_dpiX = w->logicalDpiX(); | ||||
50 | m_dpiY = w->logicalDpiY(); | ||||
51 | } else { | ||||
52 | m_dpiX = 75; | ||||
53 | m_dpiY = 75; | ||||
54 | } | ||||
55 | #endif | ||||
56 | } | ||||
57 | | ||||
58 | Q_GLOBAL_STATIC(KReportDpiSingleton, s_instance) | ||||
36 | 59 | | |||
37 | // This is a private code made inline for use in the lib and examples. | | |||
38 | //! @todo Move to a shared lib to use in other Kexi libraries as well. | | |||
39 | 60 | | |||
40 | namespace KReportPrivate { | | |||
41 | 61 | | |||
42 | //! @todo Support other themes | 62 | namespace KReportPrivate | ||
43 | const QString supportedIconTheme = QLatin1String("breeze"); | 63 | { | ||
44 | 64 | | |||
45 | //! @brief @return true if @a path is readable | | |||
46 | bool fileReadable(const QString &path) | 65 | bool fileReadable(const QString &path) | ||
47 | { | 66 | { | ||
48 | return !path.isEmpty() && QFileInfo(path).isReadable(); | 67 | return !path.isEmpty() && QFileInfo(path).isReadable(); | ||
49 | } | 68 | } | ||
50 | 69 | | |||
51 | //! @brief Used for a workaround: locations for QStandardPaths::AppDataLocation end with app name. | | |||
52 | //! If this is not an expected app but for example a test app, replace | | |||
53 | //! the subdir name with app name so we can find resource file(s). | | |||
54 | QStringList correctStandardLocations(const QString &privateName, | 70 | QStringList correctStandardLocations(const QString &privateName, | ||
55 | QStandardPaths::StandardLocation location, | 71 | QStandardPaths::StandardLocation location, | ||
56 | const QString &extraLocation) | 72 | const QString &extraLocation) | ||
57 | { | 73 | { | ||
58 | QStringList result; | 74 | QStringList result; | ||
59 | if (!privateName.isEmpty()) { | 75 | if (!privateName.isEmpty()) { | ||
60 | QRegularExpression re(QLatin1Char('/') + QCoreApplication::applicationName() + QLatin1Char('$')); | 76 | QRegularExpression re(QLatin1Char('/') + QCoreApplication::applicationName() + QLatin1Char('$')); | ||
61 | QStringList standardLocations(QStandardPaths::standardLocations(location)); | 77 | QStringList standardLocations(QStandardPaths::standardLocations(location)); | ||
62 | if (!extraLocation.isEmpty()) { | 78 | if (!extraLocation.isEmpty()) { | ||
63 | standardLocations.append(extraLocation); | 79 | standardLocations.append(extraLocation); | ||
64 | } | 80 | } | ||
65 | for(const QString &dir : standardLocations) { | 81 | for(const QString &dir : standardLocations) { | ||
66 | if (dir.indexOf(re) != -1) { | 82 | if (dir.indexOf(re) != -1) { | ||
67 | QString realDir(dir); | 83 | QString realDir(dir); | ||
68 | realDir.replace(re, QLatin1Char('/') + privateName); | 84 | realDir.replace(re, QLatin1Char('/') + privateName); | ||
69 | result.append(realDir); | 85 | result.append(realDir); | ||
70 | } | 86 | } | ||
71 | } | 87 | } | ||
72 | } | 88 | } | ||
73 | return result; | 89 | return result; | ||
74 | } | 90 | } | ||
75 | 91 | | |||
76 | #ifdef Q_OS_WIN | | |||
77 | #define KPATH_SEPARATOR ';' | | |||
78 | #else | | |||
79 | #define KPATH_SEPARATOR ':' | | |||
80 | #endif | | |||
81 | | ||||
82 | /*! @brief Locates a file path for specified parameters | | |||
83 | * @param privateName Name to be used instead of application name for resource lookup | | |||
84 | * @param path Relative path to the resource file | | |||
85 | * @param location Standard file location to use for file lookup | | |||
86 | * @param extraLocation Extra directory path for file lookup | | |||
87 | * @return Empty string on failure | | |||
88 | */ | | |||
89 | QString locateFile(const QString &privateName, | 92 | QString locateFile(const QString &privateName, | ||
90 | const QString& path, QStandardPaths::StandardLocation location, | 93 | const QString& path, QStandardPaths::StandardLocation location, | ||
91 | const QString &extraLocation) | 94 | const QString &extraLocation) | ||
92 | { | 95 | { | ||
93 | // let QStandardPaths handle this, it will look for app local stuff | 96 | // let QStandardPaths handle this, it will look for app local stuff | ||
94 | QString fullPath = QFileInfo( | 97 | QString fullPath = QFileInfo( | ||
95 | QStandardPaths::locate(location, path)).canonicalFilePath(); | 98 | QStandardPaths::locate(location, path)).canonicalFilePath(); | ||
96 | if (fileReadable(fullPath)) { | 99 | if (fileReadable(fullPath)) { | ||
Show All 19 Lines | 118 | for(const QString &dir : correctedStandardLocations) { | |||
116 | fullPath = QFileInfo(dir + QLatin1Char('/') + path).canonicalFilePath(); | 119 | fullPath = QFileInfo(dir + QLatin1Char('/') + path).canonicalFilePath(); | ||
117 | if (fileReadable(fullPath)) { | 120 | if (fileReadable(fullPath)) { | ||
118 | return fullPath; | 121 | return fullPath; | ||
119 | } | 122 | } | ||
120 | } | 123 | } | ||
121 | return QString(); | 124 | return QString(); | ||
122 | } | 125 | } | ||
123 | 126 | | |||
124 | /*! @brief Registers icons resource file | | |||
125 | * @param privateName Name to be used instead of application name for resource lookup | | |||
126 | * @param path Relative path to the resource file | | |||
127 | * @param location Standard file location to use for file lookup | | |||
128 | * @param resourceRoot A resource root for QResource::registerResource() | | |||
129 | * @param errorMessage On failure it is set to a brief error message. | | |||
130 | * @param errorDescription On failure it is set to a detailed error message. | | |||
131 | * other for warning | | |||
132 | */ | | |||
133 | bool registerIconsResource(const QString &privateName, const QString& path, | 127 | bool registerIconsResource(const QString &privateName, const QString& path, | ||
134 | QStandardPaths::StandardLocation location, | 128 | QStandardPaths::StandardLocation location, | ||
135 | const QString &resourceRoot, const QString &extraLocation, | 129 | const QString &resourceRoot, const QString &extraLocation, | ||
136 | QString *errorMessage, QString *detailedErrorMessage) | 130 | QString *errorMessage, QString *detailedErrorMessage) | ||
137 | { | 131 | { | ||
138 | const QString fullPath = locateFile(privateName, path, location, extraLocation); | 132 | const QString fullPath = locateFile(privateName, path, location, extraLocation); | ||
139 | if (fullPath.isEmpty() || !QFileInfo(fullPath).isReadable() | 133 | if (fullPath.isEmpty() || !QFileInfo(fullPath).isReadable() | ||
140 | || !QResource::registerResource(fullPath, resourceRoot)) | 134 | || !QResource::registerResource(fullPath, resourceRoot)) | ||
Show All 19 Lines | |||||
160 | #endif | 154 | #endif | ||
161 | return false; | 155 | return false; | ||
162 | } | 156 | } | ||
163 | *errorMessage = QString(); | 157 | *errorMessage = QString(); | ||
164 | *detailedErrorMessage = QString(); | 158 | *detailedErrorMessage = QString(); | ||
165 | return true; | 159 | return true; | ||
166 | } | 160 | } | ||
167 | 161 | | |||
168 | /*! @brief Registers a global icon resource file | | |||
169 | * @param themeName A name of icon theme to use. | | |||
170 | * @param errorMessage On failure it is set to a brief error message. | | |||
171 | * @param errorDescription On failure it is set to a detailed error message. | | |||
172 | * other for warning | | |||
173 | */ | | |||
174 | bool registerGlobalIconsResource(const QString &themeName, | 162 | bool registerGlobalIconsResource(const QString &themeName, | ||
175 | QString *errorMessage, | 163 | QString *errorMessage, | ||
176 | QString *detailedErrorMessage) | 164 | QString *detailedErrorMessage) | ||
177 | { | 165 | { | ||
178 | QString extraLocation; | 166 | QString extraLocation; | ||
179 | #ifdef CMAKE_INSTALL_FULL_ICONDIR | 167 | #ifdef CMAKE_INSTALL_FULL_ICONDIR | ||
180 | extraLocation = QDir::fromNativeSeparators(QFile::decodeName(CMAKE_INSTALL_FULL_ICONDIR)); | 168 | extraLocation = QDir::fromNativeSeparators(QFile::decodeName(CMAKE_INSTALL_FULL_ICONDIR)); | ||
181 | if (extraLocation.endsWith("/icons")) { | 169 | if (extraLocation.endsWith("/icons")) { | ||
182 | extraLocation.chop(QLatin1String("/icons").size()); | 170 | extraLocation.chop(QLatin1String("/icons").size()); | ||
183 | } | 171 | } | ||
184 | #elif defined(Q_OS_WIN) | 172 | #elif defined(Q_OS_WIN) | ||
185 | extraLocation = QCoreApplication::applicationDirPath() + QStringLiteral("/data"); | 173 | extraLocation = QCoreApplication::applicationDirPath() + QStringLiteral("/data"); | ||
186 | #endif | 174 | #endif | ||
187 | return registerIconsResource(QString(), QString::fromLatin1("icons/%1/%1-icons.rcc").arg(themeName), | 175 | return registerIconsResource(QString(), QString::fromLatin1("icons/%1/%1-icons.rcc").arg(themeName), | ||
188 | QStandardPaths::GenericDataLocation, | 176 | QStandardPaths::GenericDataLocation, | ||
189 | QStringLiteral("/icons/") + themeName, | 177 | QStringLiteral("/icons/") + themeName, | ||
190 | extraLocation, errorMessage, | 178 | extraLocation, errorMessage, | ||
191 | detailedErrorMessage); | 179 | detailedErrorMessage); | ||
192 | } | 180 | } | ||
193 | 181 | | |||
194 | /*! @brief Registers a global icon resource file | | |||
195 | * @param themeName A name of icon theme to use. | | |||
196 | */ | | |||
197 | bool registerGlobalIconsResource(const QString &themeName) | 182 | bool registerGlobalIconsResource(const QString &themeName) | ||
198 | { | 183 | { | ||
199 | QString errorMessage; | 184 | QString errorMessage; | ||
200 | QString detailedErrorMessage; | 185 | QString detailedErrorMessage; | ||
201 | if (!registerGlobalIconsResource(themeName, &errorMessage, &detailedErrorMessage)) { | 186 | if (!registerGlobalIconsResource(themeName, &errorMessage, &detailedErrorMessage)) { | ||
202 | if (detailedErrorMessage.isEmpty()) { | 187 | if (detailedErrorMessage.isEmpty()) { | ||
203 | KMessageBox::error(nullptr, errorMessage); | 188 | KMessageBox::error(nullptr, errorMessage); | ||
204 | } else { | 189 | } else { | ||
205 | KMessageBox::detailedError(nullptr, errorMessage, detailedErrorMessage); | 190 | KMessageBox::detailedError(nullptr, errorMessage, detailedErrorMessage); | ||
206 | } | 191 | } | ||
207 | qWarning() << qPrintable(errorMessage); | 192 | qWarning() << qPrintable(errorMessage); | ||
208 | return false; | 193 | return false; | ||
209 | } | 194 | } | ||
210 | return true; | 195 | return true; | ||
211 | } | 196 | } | ||
212 | 197 | | |||
213 | /*! @brief Registers a global icon resource file for default theme name. | | |||
214 | */ | | |||
215 | bool registerGlobalIconsResource() | 198 | bool registerGlobalIconsResource() | ||
216 | { | 199 | { | ||
217 | return registerGlobalIconsResource(supportedIconTheme); | 200 | return registerGlobalIconsResource(supportedIconTheme); | ||
218 | } | 201 | } | ||
219 | 202 | | |||
220 | /*! @brief Sets up a private icon resource file | | |||
221 | * @return @c false on failure and sets error message. Does not warn or exit on failure. | | |||
222 | * @param privateName Name to be used instead of application name for resource lookup | | |||
223 | * @param path Relative path to the resource file | | |||
224 | * @param themeName Icon theme to use. It affects filename. | | |||
225 | * @param errorMessage On failure it is set to a brief error message | | |||
226 | * @param errorDescription On failure it is set to a detailed error message | | |||
227 | * other for warning | | |||
228 | * @param prefix Resource path prefix. The default is useful for library-global resource, | | |||
229 | * other values is useful for plugins. | | |||
230 | */ | | |||
231 | bool setupPrivateIconsResource(const QString &privateName, const QString& path, | 203 | bool setupPrivateIconsResource(const QString &privateName, const QString& path, | ||
232 | const QString &themeName, | 204 | const QString &themeName, | ||
233 | QString *errorMessage, QString *detailedErrorMessage, | 205 | QString *errorMessage, QString *detailedErrorMessage, | ||
234 | const QString &prefix = QLatin1String(":/icons")) | 206 | const QString &prefix) | ||
235 | { | 207 | { | ||
236 | // Register application's resource first to have priority over the theme. | 208 | // Register application's resource first to have priority over the theme. | ||
237 | // Some icons may exists in both resources. | 209 | // Some icons may exists in both resources. | ||
238 | if (!registerIconsResource(privateName, path, | 210 | if (!registerIconsResource(privateName, path, | ||
239 | QStandardPaths::AppDataLocation, | 211 | QStandardPaths::AppDataLocation, | ||
240 | QString(), QString(), errorMessage, detailedErrorMessage)) | 212 | QString(), QString(), errorMessage, detailedErrorMessage)) | ||
241 | { | 213 | { | ||
242 | return false; | 214 | return false; | ||
Show All 12 Lines | 223 | #endif | |||
255 | // tell KIconLoader an co. about the theme | 227 | // tell KIconLoader an co. about the theme | ||
256 | if (changeTheme) { | 228 | if (changeTheme) { | ||
257 | cg.writeEntry("Theme", themeName); | 229 | cg.writeEntry("Theme", themeName); | ||
258 | cg.sync(); | 230 | cg.sync(); | ||
259 | } | 231 | } | ||
260 | return true; | 232 | return true; | ||
261 | } | 233 | } | ||
262 | 234 | | |||
263 | /*! @brief Sets up a private icon resource file | | |||
264 | * @return @c false on failure and sets error message. | | |||
265 | * @param privateName Name to be used instead of application name for resource lookup | | |||
266 | * @param path Relative path to the resource file | | |||
267 | * @param themeName Icon theme to use. It affects filename. | | |||
268 | * @param errorMessage On failure it is set to a brief error message. | | |||
269 | * @param errorDescription On failure it is set to a detailed error message. | | |||
270 | * other for warning | | |||
271 | * @param prefix Resource path prefix. The default is useful for library-global resource, | | |||
272 | * other values is useful for plugins. | | |||
273 | */ | | |||
274 | bool setupPrivateIconsResourceWithMessage(const QString &privateName, const QString& path, | 235 | bool setupPrivateIconsResourceWithMessage(const QString &privateName, const QString& path, | ||
275 | const QString &themeName, | 236 | const QString &themeName, | ||
276 | QString *errorMessage, QString *detailedErrorMessage, | 237 | QString *errorMessage, QString *detailedErrorMessage, | ||
277 | const QString &prefix = QLatin1String(":/icons")) | 238 | const QString &prefix) | ||
278 | { | 239 | { | ||
279 | if (!setupPrivateIconsResource(privateName, path, themeName, | 240 | if (!setupPrivateIconsResource(privateName, path, themeName, | ||
280 | errorMessage, detailedErrorMessage, prefix)) | 241 | errorMessage, detailedErrorMessage, prefix)) | ||
281 | { | 242 | { | ||
282 | if (detailedErrorMessage->isEmpty()) { | 243 | if (detailedErrorMessage->isEmpty()) { | ||
283 | KMessageBox::error(nullptr, *errorMessage); | 244 | KMessageBox::error(nullptr, *errorMessage); | ||
284 | } else { | 245 | } else { | ||
285 | KMessageBox::detailedError(nullptr, *errorMessage, *detailedErrorMessage); | 246 | KMessageBox::detailedError(nullptr, *errorMessage, *detailedErrorMessage); | ||
286 | } | 247 | } | ||
287 | return false; | 248 | return false; | ||
288 | } | 249 | } | ||
289 | return true; | 250 | return true; | ||
290 | } | 251 | } | ||
291 | 252 | | |||
292 | /*! @overload setupPrivateIconsResourceWithMessage(QString &privateName, const QString& path, | | |||
293 | const QString &themeName, | | |||
294 | QString *errorMessage, QString *detailedErrorMessage, | | |||
295 | const QString &prefix = QLatin1String(":/icons")) | | |||
296 | Uses default theme name. | | |||
297 | */ | | |||
298 | bool setupPrivateIconsResourceWithMessage(const QString &privateName, const QString& path, | 253 | bool setupPrivateIconsResourceWithMessage(const QString &privateName, const QString& path, | ||
299 | QString *errorMessage, QString *detailedErrorMessage, | 254 | QString *errorMessage, QString *detailedErrorMessage, | ||
300 | const QString &prefix = QLatin1String(":/icons")) | 255 | const QString &prefix) | ||
301 | { | 256 | { | ||
302 | return setupPrivateIconsResourceWithMessage(privateName, path, supportedIconTheme, | 257 | return setupPrivateIconsResourceWithMessage(privateName, path, supportedIconTheme, | ||
303 | errorMessage, detailedErrorMessage, prefix); | 258 | errorMessage, detailedErrorMessage, prefix); | ||
304 | } | 259 | } | ||
305 | 260 | | |||
306 | /*! @brief Sets up a private icon resource file | | |||
307 | * Warns on failure and returns @c false. | | |||
308 | * @param privateName Name to be used instead of application name for resource lookup | | |||
309 | * @param path Relative path to the resource file | | |||
310 | * @param messageType Type of message to use on error, QtFatalMsg for fatal exit and any | | |||
311 | * other for warning | | |||
312 | * @param prefix Resource path prefix. The default is useful for library-global resource, | | |||
313 | * other values is useful for plugins. | | |||
314 | */ | | |||
315 | bool setupPrivateIconsResourceWithMessage(const QString &privateName, const QString& path, | 261 | bool setupPrivateIconsResourceWithMessage(const QString &privateName, const QString& path, | ||
316 | QtMsgType messageType, | 262 | QtMsgType messageType, | ||
317 | const QString &prefix = QLatin1String(":/icons")) | 263 | const QString &prefix) | ||
318 | { | 264 | { | ||
319 | QString errorMessage; | 265 | QString errorMessage; | ||
320 | QString detailedErrorMessage; | 266 | QString detailedErrorMessage; | ||
321 | if (!setupPrivateIconsResourceWithMessage(privateName, path, | 267 | if (!setupPrivateIconsResourceWithMessage(privateName, path, | ||
322 | &errorMessage, &detailedErrorMessage, prefix)) { | 268 | &errorMessage, &detailedErrorMessage, prefix)) { | ||
323 | if (messageType == QtFatalMsg) { | 269 | if (messageType == QtFatalMsg) { | ||
324 | qFatal("%s %s", qPrintable(errorMessage), qPrintable(detailedErrorMessage)); | 270 | qFatal("%s %s", qPrintable(errorMessage), qPrintable(detailedErrorMessage)); | ||
325 | } else { | 271 | } else { | ||
326 | qWarning() << qPrintable(errorMessage) << qPrintable(detailedErrorMessage); | 272 | qWarning() << qPrintable(errorMessage) << qPrintable(detailedErrorMessage); | ||
327 | } | 273 | } | ||
328 | return false; | 274 | return false; | ||
329 | } | 275 | } | ||
330 | return true; | 276 | return true; | ||
331 | } | 277 | } | ||
332 | 278 | | |||
333 | //! Sets up a global icon theme if it is different from supported. | | |||
334 | //! Warns on failure and returns @c false. | | |||
335 | bool setupGlobalIconTheme() | 279 | bool setupGlobalIconTheme() | ||
336 | { | 280 | { | ||
337 | if (0 != QIcon::themeName().compare(supportedIconTheme, Qt::CaseInsensitive)) { | 281 | if (0 != QIcon::themeName().compare(supportedIconTheme, Qt::CaseInsensitive)) { | ||
338 | const QString message = QString::fromLatin1( | 282 | const QString message = QString::fromLatin1( | ||
339 | "\"%1\" supports only \"%2\" icon theme but current system theme is \"%3\". " | 283 | "\"%1\" supports only \"%2\" icon theme but current system theme is \"%3\". " | ||
340 | "Application's icon theme will be changed to \"%2\". " | 284 | "Application's icon theme will be changed to \"%2\". " | ||
341 | "Please consider adding support for other themes to %4.") | 285 | "Please consider adding support for other themes to %4.") | ||
342 | .arg(QLatin1String(KREPORT_BASE_NAME)).arg(supportedIconTheme).arg(QIcon::themeName()) | 286 | .arg(QLatin1String(KREPORT_BASE_NAME)).arg(supportedIconTheme).arg(QIcon::themeName()) | ||
343 | .arg(QCoreApplication::applicationName()); | 287 | .arg(QCoreApplication::applicationName()); | ||
344 | qDebug() << qPrintable(message); | 288 | qDebug() << qPrintable(message); | ||
345 | if (!registerGlobalIconsResource()) { | 289 | if (!registerGlobalIconsResource()) { | ||
346 | // don't fail, just warn | 290 | // don't fail, just warn | ||
347 | const QString message = QString::fromLatin1( | 291 | const QString message = QString::fromLatin1( | ||
348 | "Failed to set icon theme to \"%1\". Icons in the application will be inconsistent. " | 292 | "Failed to set icon theme to \"%1\". Icons in the application will be inconsistent. " | ||
349 | "Please install .rcc file(s) for the system theme.") | 293 | "Please install .rcc file(s) for the system theme.") | ||
350 | .arg(supportedIconTheme); | 294 | .arg(supportedIconTheme); | ||
351 | qDebug() << qPrintable(message); | 295 | qDebug() << qPrintable(message); | ||
352 | return false; | 296 | return false; | ||
353 | } | 297 | } | ||
354 | } | 298 | } | ||
355 | return true; | 299 | return true; | ||
356 | } | 300 | } | ||
357 | 301 | | |||
358 | } // KReportPrivate | 302 | int dpiX() | ||
303 | { | ||||
304 | return s_instance->m_dpiX; | ||||
305 | } | ||||
359 | 306 | | |||
360 | #endif | 307 | int dpiY() | ||
308 | { | ||||
309 | return s_instance->m_dpiY; | ||||
310 | } | ||||
311 | | ||||
312 | } |
undo: