mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
some remnaming
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20298 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
93196b1f73
commit
50de85396c
@ -203,8 +203,8 @@ public:
|
|||||||
* add a callback for socket read notification
|
* add a callback for socket read notification
|
||||||
* @param fd socket descriptor (file/socket/etc)
|
* @param fd socket descriptor (file/socket/etc)
|
||||||
*/
|
*/
|
||||||
virtual void registerSocketCallback(
|
typedef boost::function<void()> SocketCallback;
|
||||||
int fd, boost::function<void()> func) = 0;
|
virtual void registerSocketCallback( int fd, SocketCallback func) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* remove a I/O read callback
|
* remove a I/O read callback
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
#include "GuiImage.h"
|
#include "GuiImage.h"
|
||||||
#include "SocketCallback.h"
|
|
||||||
|
|
||||||
#include "frontends/LyXView.h"
|
#include "frontends/LyXView.h"
|
||||||
|
|
||||||
@ -45,6 +44,7 @@
|
|||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include <QSessionManager>
|
#include <QSessionManager>
|
||||||
|
#include <QSocketNotifier>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
@ -73,12 +73,30 @@ frontend::Application * createApplication(int & argc, char * argv[])
|
|||||||
|
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
|
class SocketNotifier : public QSocketNotifier
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// connect a connection notification from the LyXServerSocket
|
||||||
|
SocketNotifier(QObject * parent, int fd, Application::SocketCallback func)
|
||||||
|
: QSocketNotifier(fd, QSocketNotifier::Read, parent), func_(func)
|
||||||
|
{}
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// The callback function
|
||||||
|
Application::SocketCallback func_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Mac specific stuff goes here...
|
// Mac specific stuff goes here...
|
||||||
|
|
||||||
class MenuTranslator : public QTranslator
|
class MenuTranslator : public QTranslator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
MenuTranslator(QObject * parent)
|
||||||
|
: QTranslator(parent)
|
||||||
|
{}
|
||||||
|
|
||||||
QString translate(const char * /*context*/,
|
QString translate(const char * /*context*/,
|
||||||
const char * sourceText,
|
const char * sourceText,
|
||||||
const char * /*comment*/ = 0)
|
const char * /*comment*/ = 0)
|
||||||
@ -105,7 +123,7 @@ GuiApplication * guiApp;
|
|||||||
|
|
||||||
|
|
||||||
GuiApplication::GuiApplication(int & argc, char ** argv)
|
GuiApplication::GuiApplication(int & argc, char ** argv)
|
||||||
: QApplication(argc, argv), Application(argc, argv), menu_trans_(0)
|
: QApplication(argc, argv), Application(argc, argv)
|
||||||
{
|
{
|
||||||
// Qt bug? setQuitOnLastWindowClosed(true); does not work
|
// Qt bug? setQuitOnLastWindowClosed(true); does not work
|
||||||
setQuitOnLastWindowClosed(false);
|
setQuitOnLastWindowClosed(false);
|
||||||
@ -165,8 +183,7 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
|
|||||||
|
|
||||||
GuiApplication::~GuiApplication()
|
GuiApplication::~GuiApplication()
|
||||||
{
|
{
|
||||||
delete menu_trans_;
|
socket_notifiers_.clear();
|
||||||
socket_callbacks_.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -321,15 +338,23 @@ void GuiApplication::updateColor(Color_color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiApplication::registerSocketCallback(int fd, boost::function<void()> func)
|
void GuiApplication::registerSocketCallback(int fd, SocketCallback func)
|
||||||
{
|
{
|
||||||
socket_callbacks_[fd] = new SocketCallback(this, fd, func);
|
SocketNotifier * sn = new SocketNotifier(this, fd, func);
|
||||||
|
socket_notifiers_[fd] = sn;
|
||||||
|
connect(sn, SIGNAL(activated(int)), this, SLOT(socketDataReceived(int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiApplication::socketDataReceived(int fd)
|
||||||
|
{
|
||||||
|
socket_notifiers_[fd]->func_();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiApplication::unregisterSocketCallback(int fd)
|
void GuiApplication::unregisterSocketCallback(int fd)
|
||||||
{
|
{
|
||||||
socket_callbacks_.erase(fd);
|
socket_notifiers_.erase(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -383,8 +408,7 @@ bool GuiApplication::x11EventFilter(XEvent * xev)
|
|||||||
|
|
||||||
void GuiApplication::addMenuTranslator()
|
void GuiApplication::addMenuTranslator()
|
||||||
{
|
{
|
||||||
menu_trans_ = new MenuTranslator();
|
installTranslator(new MenuTranslator(this));
|
||||||
installTranslator(menu_trans_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,12 +29,12 @@ class QSessionManager;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
class BufferView;
|
class BufferView;
|
||||||
class SocketCallback;
|
|
||||||
|
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
class GuiWorkArea;
|
class GuiWorkArea;
|
||||||
class MenuTranslator;
|
class MenuTranslator;
|
||||||
|
class SocketNotifier;
|
||||||
|
|
||||||
/// The Qt main application class
|
/// The Qt main application class
|
||||||
/**
|
/**
|
||||||
@ -69,8 +69,7 @@ public:
|
|||||||
virtual bool getRgbColor(Color_color col, RGBColor & rgbcol);
|
virtual bool getRgbColor(Color_color col, RGBColor & rgbcol);
|
||||||
virtual std::string const hexName(Color_color col);
|
virtual std::string const hexName(Color_color col);
|
||||||
virtual void updateColor(Color_color col);
|
virtual void updateColor(Color_color col);
|
||||||
virtual void registerSocketCallback(
|
virtual void registerSocketCallback(int fd, SocketCallback func);
|
||||||
int fd, boost::function<void()> func);
|
|
||||||
void unregisterSocketCallback(int fd);
|
void unregisterSocketCallback(int fd);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
@ -89,6 +88,8 @@ public:
|
|||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
///
|
///
|
||||||
void execBatchCommands();
|
void execBatchCommands();
|
||||||
|
///
|
||||||
|
void socketDataReceived(int fd);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
@ -104,7 +105,7 @@ private:
|
|||||||
///
|
///
|
||||||
QTranslator qt_trans_;
|
QTranslator qt_trans_;
|
||||||
///
|
///
|
||||||
std::map<int, SocketCallback *> socket_callbacks_;
|
std::map<int, SocketNotifier *> socket_notifiers_;
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
public:
|
public:
|
||||||
|
@ -111,7 +111,6 @@ SOURCEFILES = \
|
|||||||
LyXFileDialog.cpp \
|
LyXFileDialog.cpp \
|
||||||
PanelStack.cpp \
|
PanelStack.cpp \
|
||||||
qt_helpers.cpp \
|
qt_helpers.cpp \
|
||||||
SocketCallback.cpp \
|
|
||||||
TocModel.cpp \
|
TocModel.cpp \
|
||||||
TocWidget.cpp \
|
TocWidget.cpp \
|
||||||
Validator.cpp
|
Validator.cpp
|
||||||
@ -194,7 +193,6 @@ MOCHEADER = \
|
|||||||
LyXFileDialog.h \
|
LyXFileDialog.h \
|
||||||
PanelStack.h \
|
PanelStack.h \
|
||||||
qlkey.h \
|
qlkey.h \
|
||||||
SocketCallback.h \
|
|
||||||
TocModel.h \
|
TocModel.h \
|
||||||
TocWidget.h \
|
TocWidget.h \
|
||||||
Validator.h
|
Validator.h
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
/**
|
|
||||||
* \file io_callback.C
|
|
||||||
* This file is part of LyX, the document processor.
|
|
||||||
* Licence details can be found in the file COPYING.
|
|
||||||
*
|
|
||||||
* \author unknown
|
|
||||||
* \author John Levon
|
|
||||||
* \author João Luis M. Assirati
|
|
||||||
*
|
|
||||||
* Full author contact details are available in file CREDITS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include "SocketCallback.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
|
||||||
|
|
||||||
SocketCallback::SocketCallback(QObject * parent,
|
|
||||||
int fd, boost::function<void()> func)
|
|
||||||
: QObject(parent), func_(func)
|
|
||||||
{
|
|
||||||
sn_ = new QSocketNotifier(fd, QSocketNotifier::Read, this);
|
|
||||||
connect(sn_, SIGNAL(activated(int)), this, SLOT(dataReceived()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SocketCallback::dataReceived()
|
|
||||||
{
|
|
||||||
func_();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace lyx
|
|
||||||
|
|
||||||
#include "SocketCallback_moc.cpp"
|
|
@ -1,55 +0,0 @@
|
|||||||
// -*- C++ -*-
|
|
||||||
/**
|
|
||||||
* \file io_callback.h
|
|
||||||
* This file is part of LyX, the document processor.
|
|
||||||
* Licence details can be found in the file COPYING.
|
|
||||||
*
|
|
||||||
* \author unknown
|
|
||||||
* \author John Levon
|
|
||||||
* \author João Luis M. Assirati
|
|
||||||
*
|
|
||||||
* Full author contact details are available in file CREDITS.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SOCKET_CALLBACK_H
|
|
||||||
#define SOCKET_CALLBACK_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QSocketNotifier>
|
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* socket_callback - a simple wrapper for asynchronous socket notification
|
|
||||||
*
|
|
||||||
* This is used by the lyxsocket to notice the socket is ready to be
|
|
||||||
* connected/read.
|
|
||||||
*
|
|
||||||
* FIXME: this code apparently will not work on Windows.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class SocketCallback : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// connect a connection notification from the LyXServerSocket
|
|
||||||
SocketCallback(QObject * parent, int fd, boost::function<void()> func);
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
void dataReceived();
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// Our notifier
|
|
||||||
QSocketNotifier * sn_;
|
|
||||||
/// The callback function
|
|
||||||
boost::function<void()> func_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
|
||||||
|
|
||||||
#endif // SOCKET_CALLBACK_H
|
|
Loading…
Reference in New Issue
Block a user