--- /dev/null
+[D-BUS Service]
+Name=com.comarch.mdictionary
+Exec=/usr/bin/mdictionary
Icon=mdictionary
Exec=/usr/bin/mdictionary
X-Maemo-Category=Main
+X-Osso-Service=com.comarch.mdictionary
gui \
sql \
xml \
- xmlpatterns
+ xmlpatterns \
+ dbus
maemo5:QT += maemo5
TARGET = mdictionary
gui/BookmarksWidget.cpp \
gui/WelcomeScreenWidget.cpp \
gui/AboutWidget.cpp \
- gui/TranslationTextEdit.cpp
+ gui/TranslationTextEdit.cpp \
+ gui/DBusAdapter.cpp
HEADERS += gui/MainWindow.h \
backbone/ConfigGenerator.h \
gui/AboutWidget.h \
../includes/Notify.h \
gui/TranslationTextEdit.h \
../includes/AccentsNormalizer.h \
- ../includes/DictDialog.h
+ ../includes/DictDialog.h \
+ gui/DBusAdapter.h
RESOURCES += ../../../data/icons/gui.qrc
unix {
# VARIABLES
# MAKE INSTALL
INSTALLS += target \
desktop \
- icon64
+ icon64 \
+ service
+
target.path = $$BINDIR
maemo5 {
desktop.path = $$DATADIR/applications/hildon
}
desktop.files += ../../../data/other/$${TARGET}.desktop
icon64.files += ../../../data/icons/64x64/$${TARGET}.png
+
+ service.path = $$DATADIR/dbus-1/services
+ service.files += ../../../data/other/com.comarch.mdictionary.service
}
RESOURCES += xslt2.qrc
--- /dev/null
+/*******************************************************************************
+
+ 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 "DBusAdapter.h"
+#include <QDebug>
+
+DBusAdapter::DBusAdapter(MainWindow *w):
+ QDBusAbstractAdaptor(w)
+{
+ mainWindow = w;
+}
+
+void DBusAdapter::search(QString word) {
+ mainWindow->searchExact(word);
+ if(!mainWindow->isVisible())
+ mainWindow->show();
+}
+
+int DBusAdapter::top_application() {
+ qDebug()<<"top";
+ return 0;
+}
--- /dev/null
+/*******************************************************************************
+
+ 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 DBUSADAPTER_H
+#define DBUSADAPTER_H
+
+#include <QDBusAbstractAdaptor>
+#include "MainWindow.h"
+
+class DBusAdapter : public QDBusAbstractAdaptor
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "com.comarch.mdictionary")
+public:
+ explicit DBusAdapter(MainWindow* w);
+
+public slots:
+ void search(QString);
+ Q_SCRIPTABLE int top_application();
+
+private:
+ MainWindow* mainWindow;
+
+};
+
+#endif // DBUSADAPTER_H
#include "../backbone/backbone.h"
#include "../../includes/translation.h"
#include "../../includes/Notify.h"
+#include "DBusAdapter.h"
#include <QDebug>
+#include <QDBusConnection>
+
QStringList parseParameters(int argc, char *argv[]) {
qRegisterMetaType<Notify::NotifyType>("Notify::NotifyType");
Backbone backbone;
MainWindow w(&backbone);
+
+ DBusAdapter* adapter = new DBusAdapter(&w);
+
+ QDBusConnection::sessionBus().registerObject("/mainWindow",
+ &w);
+ QDBusConnection::sessionBus().registerService("com.comarch.mdictionary");
+
+
w.show();
+
if(search.count() > 0) {
w.setExactSearch(true);
w.searchExact(search[0]);
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <QtGui/QX11Info>
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusPendingCall>
+#include <QList>
+#include <QDebug>
-MainWidget::MainWidget(QWidget *parent) :
+MainWidget::MainWidget(QWidget *parent):
QWidget(parent)
{
QCoreApplication::instance()->setApplicationName(
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,
layout = new QVBoxLayout;
setLayout(layout);
+ title = new QLabel("mDictionary");
+ layout->addWidget(title,0, Qt::AlignHCenter);
+
+
searchStringLineEdit = new QLineEdit;
searchButton = new QPushButton(tr("Search"));
- layout->addWidget(searchStringLineEdit);
- layout->addWidget(searchButton);
+ horizontalLayout = new QHBoxLayout;
+ horizontalLayout->addWidget(searchStringLineEdit);
+ horizontalLayout->addWidget(searchButton);
+
+ layout->addLayout(horizontalLayout);
+
+ connect(searchButton, SIGNAL(clicked()),
+ this, SLOT(search()));
+}
+
+void MainWidget::search() {
+ QDBusMessage message =
+ QDBusMessage::createMethodCall("com.comarch.mdictionary",
+ "/mainWindow",
+ "com.comarch.mdictionary",
+ "search");
+
+ QList<QVariant> args;
+ args.append(searchStringLineEdit->text());
+ message.setArguments(args);
+
+ QDBusConnection::sessionBus().send(message);
}
#include <QWidget>
#include <QtGui>
+#include <QtDBus/QDBusConnection>
class MainWidget : public QWidget
{
public:
explicit MainWidget(QWidget *parent = 0);
+private slots:
+ void search();
+
private:
QLineEdit* searchStringLineEdit;
QPushButton* searchButton;
+ QLabel* title;
QVBoxLayout* layout;
+ QHBoxLayout* horizontalLayout;
};
#endif // MAINWIDGET_H
# -------------------------------------------------
# Project created by QtCreator 2010-08-03T08:54:27
# -------------------------------------------------
-QT += core \
- gui \
+QT += core gui dbus
TARGET = mdictionarywidget
#include <QtGui/QApplication>
#include "MainWidget.h"
#include <X11/extensions/Xrender.h>
+#include <QtDBus/QDBusConnection>
int main(int argc, char *argv[]) {
exit(1);
}
-
QApplication a(dpy, argc, argv);
QApplication::setOrganizationName("Comarch S.A.");
QApplication::setOrganizationDomain("comarch.com");