Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: http://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtFeedback module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at http://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or later as published by the Free |
28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
29 | ** the packaging of this file. Please review the following information to |
30 | ** ensure the GNU General Public License version 2.0 requirements will be |
31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
32 | ** |
33 | ** $QT_END_LICENSE$ |
34 | ** |
35 | ****************************************************************************/ |
36 | #ifndef QFEEDBACKPLUGINSEARCH_H |
37 | #define QFEEDBACKPLUGINSEARCH_H |
38 | |
39 | #include <QCoreApplication> |
40 | #include <QStringList> |
41 | #include <QDir> |
42 | #include <QDebug> |
43 | |
44 | QT_BEGIN_NAMESPACE |
45 | |
46 | #define CHECKDIR(dir) (dir).exists() |
47 | |
48 | inline QStringList getPluginPaths(const QString& plugintype) |
49 | { |
50 | #if !defined QT_NO_DEBUG |
51 | const bool showDebug = qgetenv(varName: "QT_DEBUG_PLUGINS").toInt() > 0; |
52 | #endif |
53 | |
54 | QStringList paths = QCoreApplication::libraryPaths(); |
55 | #if !defined QT_NO_DEBUG |
56 | if (showDebug) |
57 | qDebug() << "Plugin paths:"<< paths; |
58 | #endif |
59 | |
60 | // Temp variable to avoid multiple identical paths |
61 | // (we don't convert the list to set first, because that loses the order) |
62 | QSet<QString> processed; |
63 | |
64 | /* The list of discovered plugins */ |
65 | QStringList plugins; |
66 | |
67 | /* Enumerate our plugin paths */ |
68 | for (int i=0; i < paths.count(); i++) { |
69 | if (processed.contains(value: paths.at(i))) |
70 | continue; |
71 | processed.insert(value: paths.at(i)); |
72 | QDir pluginsDir(paths.at(i)); |
73 | if (!CHECKDIR(pluginsDir)) |
74 | continue; |
75 | |
76 | #if defined(Q_OS_WIN) |
77 | if (pluginsDir.dirName().toLower() == QLatin1String("debug") || pluginsDir.dirName().toLower() == QLatin1String( "release")) |
78 | pluginsDir.cdUp(); |
79 | #elif defined(Q_OS_MAC) |
80 | if (pluginsDir.dirName() == QLatin1String("MacOS")) { |
81 | pluginsDir.cdUp(); |
82 | pluginsDir.cdUp(); |
83 | pluginsDir.cdUp(); |
84 | } |
85 | #endif |
86 | |
87 | QString subdir(QLatin1String("plugins/")); |
88 | subdir += plugintype; |
89 | if (pluginsDir.path().endsWith(s: QLatin1String("/plugins")) |
90 | || pluginsDir.path().endsWith(s: QLatin1String("/plugins/"))) |
91 | subdir = plugintype; |
92 | |
93 | if (CHECKDIR(QDir(pluginsDir.filePath(subdir)))) { |
94 | pluginsDir.cd(dirName: subdir); |
95 | QStringList files = pluginsDir.entryList(filters: QDir::Files); |
96 | |
97 | #if !defined QT_NO_DEBUG |
98 | if (showDebug) |
99 | qDebug() << "Looking for "<< plugintype << " plugins in"<< pluginsDir.path() << files; |
100 | #endif |
101 | |
102 | for (int j=0; j < files.count(); j++) { |
103 | plugins << pluginsDir.absoluteFilePath(fileName: files.at(i: j)); |
104 | } |
105 | } |
106 | } |
107 | |
108 | return plugins; |
109 | } |
110 | |
111 | QT_END_NAMESPACE |
112 | |
113 | #endif |
114 |
Warning: That file was not part of the compilation database. It may have many parsing errors.