Created
August 15, 2015 23:32
-
-
Save cestrand/5d1c4ee6486e176bed5d to your computer and use it in GitHub Desktop.
KDE Plasma 4 applet template for Qt Creator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "main.h" | |
#include <QPainter> | |
#include <plasma/theme.h> | |
MyPlasmaApplet::MyPlasmaApplet(QObject *parent, const QVariantList &args) : Plasma::Applet(parent, args) | |
{ // rather don't add other stuff here. Use init() instead | |
setBackgroundHints(DefaultBackground); | |
resize(200, 200); | |
} | |
MyPlasmaApplet::~MyPlasmaApplet() | |
{ | |
} | |
void MyPlasmaApplet::init() | |
{ | |
} | |
void MyPlasmaApplet::paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect) | |
{ | |
p->drawText(contentsRect, Qt::AlignTop|Qt::AlignHCenter, "Hello World!"); | |
} | |
K_EXPORT_PLASMA_APPLET(myplasmaapplet, MyPlasmaApplet) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MYPLASMAAPPLET_HEADER | |
#define MYPLASMAAPPLET_HEADER | |
#include <Plasma/Applet> | |
class MyPlasmaApplet : public Plasma::Applet { | |
Q_OBJECT | |
public: | |
MyPlasmaApplet(QObject* parent, const QVariantList &args); | |
~MyPlasmaApplet(); | |
void init(); | |
void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect &contentsRect); | |
}; | |
#endif // MYPLASMAAPPLET_HEADER |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QT += core gui | |
CONFIG += plugin no_plugin_name_prefix release | |
TARGET = plasma_applet_myplasmaapplet | |
TEMPLATE = lib | |
HEADERS += main.h | |
SOURCES += main.cpp | |
INCLUDEPATH +="/usr/include/KDE/" | |
LIBS +=-lkdecore -lkdeui -lkutils -lkio | |
unix { | |
INSTALLS += target \ | |
desktop | |
desktop.path = /usr/share/kde4/services/ | |
desktop.files += plasma-applet-myplasmaapplet.desktop | |
target.path = /usr/lib/kde4/ | |
target.files += plasma_applet_myplasmaapplet.so | |
} | |
DISTFILES += plasma-applet-myplasmaapplet.desktop | |
QMAKE_DISTCLEAN += *.so* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Desktop Entry] | |
Name=My plasma applet | |
Comment= | |
Type=Service | |
ServiceTypes=Plasma/Applet | |
X-KDE-Library=plasma_applet_myplasmaapplet | |
X-KDE-PluginInfo-Name=myplasmaapplet | |
X-KDE-PluginInfo-Category= | |
X-KDE-PluginInfo-Author= | |
X-KDE-PluginInfo-Email= | |
X-KDE-PluginInfo-Version=0.1 | |
X-KDE-PluginInfo-Website= | |
X-KDE-PluginInfo-Depends= | |
X-KDE-PluginInfo-License=GPL | |
X-KDE-PluginInfo-EnabledByDefault=true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment