Added desktop widget, and .desktop file to porperly install widget in hildon
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Tue, 31 Aug 2010 07:20:25 +0000 (09:20 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Tue, 31 Aug 2010 07:20:25 +0000 (09:20 +0200)
data/other/mdictionarywidget.desktop [new file with mode: 0644]
trunk/src/desktopWidget/MainWidget.cpp [new file with mode: 0644]
trunk/src/desktopWidget/MainWidget.h [new file with mode: 0644]
trunk/src/desktopWidget/desktopWidget.pro [new file with mode: 0644]
trunk/src/desktopWidget/main.cpp [new file with mode: 0644]
trunk/src/src.pro

diff --git a/data/other/mdictionarywidget.desktop b/data/other/mdictionarywidget.desktop
new file mode 100644 (file)
index 0000000..32eeeee
--- /dev/null
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name=mDictionary Widget
+Type=qt
+X-Path=/usr/lib/hildon-desktop/mdictionarywidget
+X-Multiple-Instances=false
+X-home-applet-minwidth=100
+X-home-applet-minheight=72
diff --git a/trunk/src/desktopWidget/MainWidget.cpp b/trunk/src/desktopWidget/MainWidget.cpp
new file mode 100644 (file)
index 0000000..42a5766
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary 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 General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#include "MainWidget.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <QtGui/QX11Info>
+
+MainWidget::MainWidget(QWidget *parent) :
+    QWidget(parent)
+{
+    QCoreApplication::instance()->setApplicationName(
+            "mDictionary desktop widget");
+
+    // Get required atoms
+    Atom winTypeAtom = XInternAtom(
+            QX11Info::display(), "_NET_WM_WINDOW_TYPE", false);
+
+    Atom homeAppletAto = XInternAtom(
+            QX11Info::display(), "_HILDON_WM_WINDOW_TYPE_HOME_APPLET", false);
+
+    Atom appletIDAtom = XInternAtom(
+            QX11Info::display(), "_HILDON_APPLET_ID", false);
+
+    Atom utf8Atom = XInternAtom(
+            QX11Info::display(), "UTF8_STRING", false);
+
+    Atom appletSettingAtom = XInternAtom(
+            QX11Info::display(), "_HILDON_APPLET_SETTINGS", false);
+
+
+    // Set correct window type
+    XChangeProperty(QX11Info::display(), winId(), winTypeAtom, XA_ATOM, 32,
+                    PropModeReplace, (unsigned char *) &homeAppletAto, 1);
+
+
+
+    // Use application name to fill AppletID
+    QByteArray id (QCoreApplication::instance()->applicationName().remove(' ').toUtf8());
+
+    XChangeProperty(QX11Info::display(), winId(), appletIDAtom, utf8Atom, 8,
+                    PropModeReplace, (unsigned char *)id.constData(),
+                    id.length());
+
+
+    layout = new QVBoxLayout;
+    setLayout(layout);
+
+    searchStringLineEdit = new QLineEdit;
+    searchButton = new QPushButton(tr("Search"));
+
+    layout->addWidget(searchStringLineEdit);
+    layout->addWidget(searchButton);
+}
diff --git a/trunk/src/desktopWidget/MainWidget.h b/trunk/src/desktopWidget/MainWidget.h
new file mode 100644 (file)
index 0000000..c6fa486
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary 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 General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#ifndef MAINWIDGET_H
+#define MAINWIDGET_H
+
+#include <QWidget>
+#include <QtGui>
+
+class MainWidget : public QWidget
+{
+    Q_OBJECT
+public:
+    explicit MainWidget(QWidget *parent = 0);
+
+private:
+    QLineEdit* searchStringLineEdit;
+    QPushButton* searchButton;
+    QVBoxLayout* layout;
+};
+
+#endif // MAINWIDGET_H
diff --git a/trunk/src/desktopWidget/desktopWidget.pro b/trunk/src/desktopWidget/desktopWidget.pro
new file mode 100644 (file)
index 0000000..c8fccfa
--- /dev/null
@@ -0,0 +1,41 @@
+# -------------------------------------------------
+# Project created by QtCreator 2010-08-03T08:54:27
+# -------------------------------------------------
+QT += core \
+      gui \
+
+TARGET = mdictionarywidget
+
+TEMPLATE = app
+
+MDICT_BINDIR = $$[MDICT_BINDIR]
+
+isEmpty(MDICT_BINDIR):MDICT_BINDIR = .
+
+DESTDIR = $${MDICT_BINDIR}
+
+
+unix {
+    # VARIABLES
+    isEmpty(PREFIX):PREFIX = /usr
+    BINDIR = $$PREFIX/bin
+    DATADIR = $$PREFIX/share
+    DEFINES += DATADIR=\\\"$$DATADIR\\\" \
+        PKGDATADIR=\\\"$$PKGDATADIR\\\"
+    
+    # MAKE INSTALL
+    INSTALLS += target \
+        desktop
+
+    target.path = /usr/lib/hildon-desktop
+
+    desktop.path = $$DATADIR/applications/hildon-home
+    desktop.files += ../../../data/other/$${TARGET}.desktop
+}
+
+SOURCES += \
+    main.cpp \
+    MainWidget.cpp
+
+HEADERS += \
+    MainWidget.h
diff --git a/trunk/src/desktopWidget/main.cpp b/trunk/src/desktopWidget/main.cpp
new file mode 100644 (file)
index 0000000..b6e1148
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary 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 General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#include <QtGui/QApplication>
+#include "MainWidget.h"
+#include <X11/extensions/Xrender.h>
+
+int main(int argc, char *argv[]) {
+
+    Display *dpy = XOpenDisplay(0); // open default display
+    if (!dpy) {
+        qWarning("Cannot connect to the X server");
+        exit(1);
+    }
+
+
+    QApplication a(dpy, argc, argv);
+    QApplication::setOrganizationName("Comarch S.A.");
+    QApplication::setOrganizationDomain("comarch.com");
+    QApplication::setApplicationName("mDictionaryWidget");
+
+    MainWidget w;
+
+    w.show();
+
+    return a.exec();
+}
index 25f3dfd..e2e1358 100644 (file)
@@ -1,5 +1,5 @@
 TEMPLATE=subdirs
-SUBDIRS = plugins base
+SUBDIRS = plugins base desktopWidget
 
 check.target = check
 check.CONFIG = recursive