Changeset View
Changeset View
Standalone View
Standalone View
applets/colorpicker/plugin/colorpickerplugin.cpp
Show All 16 Lines | |||||
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/> | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/> | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "colorpickerplugin.h" | 21 | #include "colorpickerplugin.h" | ||
22 | 22 | | |||
23 | #include <QtQml> | 23 | #include <QtQml> | ||
24 | 24 | | |||
25 | #include <QColor> | ||||
26 | | ||||
25 | #include "grabwidget.h" | 27 | #include "grabwidget.h" | ||
26 | 28 | | |||
29 | class Utils : public QObject | ||||
30 | { | ||||
31 | Q_OBJECT | ||||
32 | | ||||
33 | public: | ||||
34 | Q_INVOKABLE bool isValidColor(const QString &colorString) const | ||||
35 | { | ||||
36 | return QColor::isValidColor(colorString); | ||||
37 | } | ||||
38 | | ||||
39 | }; | ||||
40 | | ||||
41 | static QObject *utils_singletontype_provider(QQmlEngine *, QJSEngine *) | ||||
42 | { | ||||
43 | return new Utils(); | ||||
44 | } | ||||
45 | | ||||
27 | void ColorPickerPlugin::registerTypes(const char* uri) | 46 | void ColorPickerPlugin::registerTypes(const char* uri) | ||
28 | { | 47 | { | ||
29 | Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.colorpicker")); | 48 | Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.colorpicker")); | ||
30 | qmlRegisterType<GrabWidget>(uri, 2, 0, "GrabWidget"); | 49 | qmlRegisterType<GrabWidget>(uri, 2, 0, "GrabWidget"); | ||
50 | qmlRegisterSingletonType<Utils>(uri, 2, 0, "Utils", utils_singletontype_provider); | ||||
31 | } | 51 | } | ||
52 | | ||||
53 | #include "colorpickerplugin.moc" |