diff --git a/plasmoid/plugin/xtouchscreen.cpp b/plasmoid/plugin/xtouchscreen.cpp new file mode 100644 index 0000000..1226535 --- /dev/null +++ b/plasmoid/plugin/xtouchscreen.cpp @@ -0,0 +1,144 @@ +/************************************************************************************* + * Copyright 2017 by Sebastian Kügler * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * + *************************************************************************************/ + +#include "xtouchscreen.h" +// #include "../../src/debug_p.h" + +#include + +using namespace KScreen; + +class XTouchscreen::Private +{ + public: + Private(): + id(0), + rotation(Output::None) + {} + + Private(const Private &other): + id(other.id), + name(other.name), + transformationMatrix(other.transformationMatrix), + rotation(other.rotation) + {} + + + int id; + QString name; + QString transformationMatrix; + Output::Rotation rotation; +}; + +XTouchscreen::XTouchscreen(QObject* parent) + : QObject(parent) + , d(new Private()) +{ + +} + +XTouchscreen::XTouchscreen(XTouchscreen::Private *dd) + : QObject() + , d(dd) +{ +} + +XTouchscreen::~XTouchscreen() +{ + delete d; +} + +// XTouchscreenPtr XTouchscreen::clone() const +// { +// return XTouchscreenPtr(new XTouchscreen(new Private(*d))); +// } + +int XTouchscreen::id() const +{ + return d->id; +} + +void XTouchscreen::setId(int id) +{ + if (d->id == id) { + return; + } + + d->id = id; +} + +QString XTouchscreen::name() const +{ + return d->name; +} + +void XTouchscreen::setName(const QString& name) +{ + if (d->name == name) { + return; + } + + d->name = name; + + Q_EMIT nameChanged(); +} + +QString XTouchscreen::transformationMatrix() const +{ + return d->transformationMatrix; +} + +void XTouchscreen::setTransformationMatrix(const QString& matrix) +{ + if (d->transformationMatrix == matrix) { + return; + } + + d->transformationMatrix = matrix; + + Q_EMIT transformationMatrixChanged(); +} + +Output::Rotation XTouchscreen::rotation() const +{ + return d->rotation; +} + +void XTouchscreen::setRotation(Output::Rotation rotation) +{ + if (d->rotation == rotation) { + return; + } + + d->rotation = rotation; + + Q_EMIT rotationChanged(); +} +/* +QDebug operator<<(QDebug dbg, const KScreen::XTouchscreenPtr &touchscreen) +{ + if(touchscreen) { + dbg << "KScreen::XTouchscreen(" << touchscreen->id() << " " + << touchscreen->name() + << touchscreen->transformationMatrix() + << ")"; + } else { + dbg << "KScreen::XTouchscreen(NULL)"; + } + return dbg; +}*/ diff --git a/plasmoid/plugin/xtouchscreen.h b/plasmoid/plugin/xtouchscreen.h new file mode 100644 index 0000000..fd76d91 --- /dev/null +++ b/plasmoid/plugin/xtouchscreen.h @@ -0,0 +1,83 @@ +/************************************************************************************* + * Copyright 2017 by Sebastian Kügler * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * + *************************************************************************************/ + +#ifndef XTOUCHSCREEN_H +#define XTOUCHSCREEN_H + +// #include "../../src/kscreen_export.h" +// #include "../../src/types.h" + +#include + +#include +#include + +namespace KScreen { + +class XTouchscreen : public QObject +{ + Q_OBJECT + + public: + Q_ENUMS(Rotation) + Q_PROPERTY(int id READ id CONSTANT) + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(Output::Rotation rotation READ rotation WRITE setRotation NOTIFY rotationChanged) + //Q_PROPERTY(QString transformationMatrix READ transformationMatrix WRITE setTransformationMatrix NOTIFY transformationMatrixChanged) + + explicit XTouchscreen(QObject* parent = nullptr); + virtual ~XTouchscreen(); + + //XTouchscreenPtr clone() const; + + int id() const; + void setId(int id); + + QString name() const; + void setName(const QString& name); + + Output::Rotation rotation() const; + void setRotation(Output::Rotation rotation); + + QString transformationMatrix() const; + void setTransformationMatrix(const QString& matrix); + + +Q_SIGNALS: + void nameChanged() const; + void rotationChanged() const; + void transformationMatrixChanged() const; + + private: + + Q_DISABLE_COPY(XTouchscreen) + + class Private; + Private * const d = nullptr; + + XTouchscreen(Private *dd); +}; + +} //KScreen namespace + +//KSCREEN_EXPORT QDebug operator<<(QDebug dbg, const KScreen::XTouchscreenPtr &output); + +//Q_DECLARE_METATYPE(KScreen::XTouchscreenList) +// Q_DECLARE_METATYPE(KScreen::XTouchscreen::Rotation) + +#endif // XTOUCHSCREEN_H