[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project

src/klfdbus.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   file klfdbus.cpp
00003  *   This file is part of the KLatexFormula Project.
00004  *   Copyright (C) 2007 by Philippe Faist
00005  *   philippe.faist at bluewin.ch
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  ***************************************************************************/
00022 /* $Id: klfdbus.cpp 498 2010-09-21 00:41:03Z philippe $ */
00023 
00024 #include "klfmainwin.h"
00025 #include "klfdbus.h"
00026 
00027 
00028 KLFDBusAppAdaptor::KLFDBusAppAdaptor(QApplication *application, KLFMainWin *mainWin)
00029   : QDBusAbstractAdaptor(application), app(application), _mainwin(mainWin)
00030 {
00031 }
00032 
00033 
00034 KLFDBusAppAdaptor::~KLFDBusAppAdaptor()
00035 {
00036 }
00037 
00038 void KLFDBusAppAdaptor::raiseWindow()
00039 {
00040   if ( ! _mainwin->isVisible() )
00041     _mainwin->show();
00042 
00043   _mainwin->setWindowState(_mainwin->windowState() & ~Qt::WindowMinimized);
00044   _mainwin->raise();
00045   _mainwin->activateWindow();
00046 }
00047 
00048 Q_NOREPLY void KLFDBusAppAdaptor::quit()
00049 {
00050   app->quit();
00051 }
00052 
00053 void KLFDBusAppAdaptor::setInputData(const QString& key, const QString& svalue, int ivalue)
00054 {
00055   if (key == "latex") {
00056     _mainwin->slotSetLatex(svalue);
00057   } else if (key == "fgcolor") {
00058     _mainwin->slotSetFgColor(svalue);
00059   } else if (key == "bgcolor") {
00060     _mainwin->slotSetBgColor(svalue);
00061   } else if (key == "mathmode") {
00062     _mainwin->slotSetMathMode(svalue);
00063   } else if (key == "preamble") {
00064     _mainwin->slotSetPreamble(svalue);
00065   } else if (key == "dpi") {
00066     _mainwin->slotSetDPI(ivalue);
00067   }
00068 }
00069 
00070 void KLFDBusAppAdaptor::setAlterSetting_i(int setting, int value)
00071 {
00072   _mainwin->alterSetting((KLFMainWin::altersetting_which)setting, value);
00073 }
00074 void KLFDBusAppAdaptor::setAlterSetting_s(int setting, const QString& value)
00075 {
00076   _mainwin->alterSetting((KLFMainWin::altersetting_which)setting, value);
00077 }
00078 
00079 void KLFDBusAppAdaptor::evaluateAndSave(const QString& output, const QString& fmt)
00080 {
00081   _mainwin->slotEvaluateAndSave(output, fmt);
00082 }
00083 
00084 void KLFDBusAppAdaptor::openFile(const QString& fileName)
00085 {
00086   klfDbg("opening file: "<<fileName) ;
00087   _mainwin->openFile(fileName);
00088 }
00089 void KLFDBusAppAdaptor::openFiles(const QStringList& fileNameList)
00090 {
00091   klfDbg("opening files: "<<fileNameList) ;
00092   _mainwin->openFiles(fileNameList);
00093 }
00094 void KLFDBusAppAdaptor::openData(const QByteArray& data)
00095 {
00096   klfDbg("opening data: length="<<data.length()<<", data="<<data) ;
00097   _mainwin->openData(data);
00098 }
00099 
00100 void KLFDBusAppAdaptor::importCmdlKLFFiles(const QStringList& files)
00101 {
00102   klfDbg("opening files: "<<files) ;
00103   _mainwin->openLibFiles(files);
00104 }
00105 
00106 
00107 
00108 KLFDBusAppInterface::KLFDBusAppInterface(const QString &service, const QString &path,
00109                                          const QDBusConnection &connection, QObject *parent)
00110      : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
00111 {
00112 }
00113 
00114 KLFDBusAppInterface::~KLFDBusAppInterface()
00115 {
00116 }
00117 
00118 QDBusReply<void> KLFDBusAppInterface::quit()
00119 {
00120   QList<QVariant> argumentList;
00121   return callWithArgumentList(QDBus::Block, QString("quit"), argumentList);
00122 }
00123 
00124 QDBusReply<void> KLFDBusAppInterface::raiseWindow()
00125 {
00126   QList<QVariant> argumentList;
00127   return callWithArgumentList(QDBus::Block, QString("raiseWindow"), argumentList);
00128 }
00129 
00130 QDBusReply<void> KLFDBusAppInterface::setInputData(const QString& key, const QString& svalue, int ivalue)
00131 {
00132   QList<QVariant> argumentList;
00133   argumentList << QVariant(key) << QVariant(svalue) << QVariant(ivalue);
00134   return callWithArgumentList(QDBus::Block, QString("setInputData"), argumentList);
00135 }
00136 
00137 QDBusReply<void> KLFDBusAppInterface::setAlterSetting_i(int setting, int value)
00138 {
00139   QList<QVariant> argumentList;
00140   argumentList << QVariant(setting) << QVariant(value);
00141   return callWithArgumentList(QDBus::Block, QString("setAlterSetting_i"), argumentList);
00142 }
00143 
00144 QDBusReply<void> KLFDBusAppInterface::setAlterSetting_s(int setting, const QString& value)
00145 {
00146   QList<QVariant> argumentList;
00147   argumentList << QVariant(setting) << QVariant(value);
00148   return callWithArgumentList(QDBus::Block, QString("setAlterSetting_s"), argumentList);
00149 }
00150 
00151 QDBusReply<void> KLFDBusAppInterface::evaluateAndSave(const QString& output, const QString& fmt)
00152 {
00153   return callWithArgumentList( QDBus::Block, QString("evaluateAndSave"),
00154                                QList<QVariant>() << QVariant(output) << QVariant(fmt) );
00155 }
00156 
00157 QDBusReply<void> KLFDBusAppInterface::openFile(const QString& fileName)
00158 {
00159   return callWithArgumentList( QDBus::Block, QString("openFile"),
00160                                QList<QVariant>() << QVariant(fileName) );
00161 }
00162 QDBusReply<void> KLFDBusAppInterface::openFiles(const QStringList& fileNameList)
00163 {
00164   return callWithArgumentList( QDBus::Block, QString("openFiles"),
00165                                QList<QVariant>() << QVariant(fileNameList) );
00166 }
00167 QDBusReply<void> KLFDBusAppInterface::openData(const QByteArray& data)
00168 {
00169   return callWithArgumentList( QDBus::Block, QString("openData"),
00170                                QList<QVariant>() << QVariant(data) );
00171 }
00172 
00173 QDBusReply<void> KLFDBusAppInterface::importCmdlKLFFiles(const QStringList& fnames)
00174 {
00175   QList<QVariant> argumentList;
00176   argumentList << QVariant(fnames);
00177   return callWithArgumentList(QDBus::Block, QString("importCmdlKLFFiles"), argumentList);
00178 }

Generated by doxygen 1.7.3