HPP += pch.h
HPP += qlkey.h
HPP += qt_helpers.h
-HPP += socket_callback.h
+HPP += SocketCallback.h
HPP += TocModel.h
HPP += TocWidget.h
HPP += Validator.h
CPP += LyXFileDialog.cpp
CPP += PanelStack.cpp
CPP += qt_helpers.cpp
-CPP += socket_callback.cpp
+CPP += SocketCallback.cpp
CPP += TocModel.cpp
CPP += TocWidget.cpp
CPP += Validator.cpp
Validator.h
qlkey.h
qt_helpers.h
- socket_callback.h
+ SocketCallback.h
''')
Validator.cpp
alert_pimpl.cpp
qt_helpers.cpp
- socket_callback.cpp
+ SocketCallback.cpp
''')
/// Start the main event loop.
/// The batch command is programmed to be execute once
/// the event loop is started.
- virtual int const exec() = 0;
+ virtual int exec() = 0;
/// Quit running LyX.
/**
#include "qt_helpers.h"
#include "GuiImage.h"
-#include "socket_callback.h"
+#include "SocketCallback.h"
#include "frontends/LyXView.h"
using std::string;
using std::endl;
-///////////////////////////////////////////////////////////////
-// You can find other X11 specific stuff
-// at the end of this file...
-///////////////////////////////////////////////////////////////
-namespace {
+namespace lyx {
-int getDPI()
+frontend::Application * createApplication(int & argc, char * argv[])
{
- QWidget w;
- return int(0.5 * (w.logicalDpiX() + w.logicalDpiY()));
+ return new frontend::GuiApplication(argc, argv);
}
-} // namespace anon
+namespace frontend {
-namespace lyx {
-
-using support::FileName;
+////////////////////////////////////////////////////////////////////////
+// Mac specific stuff goes here...
-frontend::Application * createApplication(int & argc, char * argv[])
+class MenuTranslator : public QTranslator
{
- return new frontend::GuiApplication(argc, argv);
-}
+public:
+ QString translate(const char * /*context*/,
+ const char * sourceText,
+ const char * /*comment*/ = 0)
+ {
+ string const s = sourceText;
+ if (s == N_("About %1") || s == N_("Preferences")
+ || s == N_("Reconfigure") || s == N_("Quit %1"))
+ return qt_(s);
+ else
+ return QString();
+ }
+};
-namespace frontend {
+///////////////////////////////////////////////////////////////
+// You can find more platform specific stuff
+// at the end of this file...
+///////////////////////////////////////////////////////////////
-GuiApplication * guiApp;
+using support::FileName;
-GuiApplication::~GuiApplication()
-{
- socket_callbacks_.clear();
-}
+GuiApplication * guiApp;
GuiApplication::GuiApplication(int & argc, char ** argv)
- : QApplication(argc, argv), Application(argc, argv)
+ : QApplication(argc, argv), Application(argc, argv), menu_trans_(0)
{
// Qt bug? setQuitOnLastWindowClosed(true); does not work
setQuitOnLastWindowClosed(false);
Image::loadableFormats = boost::bind(&GuiImage::loadableFormats);
// needs to be done before reading lyxrc
- lyxrc.dpi = getDPI();
+ QWidget w;
+ lyxrc.dpi = (w.logicalDpiX() + w.logicalDpiY()) / 2;
LoaderQueue::setPriority(10,100);
}
-Clipboard& GuiApplication::clipboard()
+GuiApplication::~GuiApplication()
+{
+ delete menu_trans_;
+ socket_callbacks_.clear();
+}
+
+
+Clipboard & GuiApplication::clipboard()
{
return clipboard_;
}
-Selection& GuiApplication::selection()
+Selection & GuiApplication::selection()
{
return selection_;
}
-int const GuiApplication::exec()
+int GuiApplication::exec()
{
QTimer::singleShot(1, this, SLOT(execBatchCommands()));
return QApplication::exec();
string const GuiApplication::hexName(Color_color col)
{
- return lyx::support::ltrim(fromqstr(color_cache_.get(col).name()), "#");
+ return support::ltrim(fromqstr(color_cache_.get(col).name()), "#");
}
void GuiApplication::registerSocketCallback(int fd, boost::function<void()> func)
{
- socket_callbacks_[fd] =
- boost::shared_ptr<socket_callback>(new socket_callback(fd, func));
+ socket_callbacks_[fd] = new SocketCallback(this, fd, func);
}
}
#endif
-
-////////////////////////////////////////////////////////////////////////
-// Mac specific stuff goes here...
-
-class MenuTranslator : public QTranslator {
-public:
- virtual ~MenuTranslator() {};
- virtual QString translate(const char * context,
- const char * sourceText,
- const char * comment = 0) const;
-};
-
-
-QString MenuTranslator::translate(const char * /*context*/,
- const char * sourceText,
- const char *) const
-{
- string const s = sourceText;
- if (s == N_("About %1") || s == N_("Preferences")
- || s == N_("Reconfigure") || s == N_("Quit %1"))
- return qt_(s);
- else
- return QString();
-}
-
-
void GuiApplication::addMenuTranslator()
{
- menu_trans_.reset(new MenuTranslator());
- installTranslator(menu_trans_.get());
+ menu_trans_ = new MenuTranslator();
+ installTranslator(menu_trans_);
}
#include "frontends/Application.h"
-#include <boost/scoped_ptr.hpp>
-
#include <QApplication>
#include <QTranslator>
namespace lyx {
class BufferView;
-class socket_callback;
+class SocketCallback;
namespace frontend {
virtual Clipboard & clipboard();
virtual Selection & selection();
virtual FontLoader & fontLoader() { return font_loader_; }
- virtual int const exec();
+ virtual int exec();
virtual Gui & gui() { return gui_; }
virtual void exit(int status);
virtual bool event(QEvent * e);
///
QTranslator qt_trans_;
///
- std::map<int, boost::shared_ptr<socket_callback> > socket_callbacks_;
+ std::map<int, SocketCallback *> socket_callbacks_;
#ifdef Q_WS_X11
public:
- bool x11EventFilter (XEvent * ev);
+ bool x11EventFilter(XEvent * ev);
#endif
/// A translator suitable for the entries in the LyX menu.
/// Only needed with Qt/Mac.
void addMenuTranslator();
///
- boost::scoped_ptr<MenuTranslator> menu_trans_;
+ MenuTranslator * menu_trans_;
}; // GuiApplication
extern GuiApplication * guiApp;
LyXFileDialog.cpp \
PanelStack.cpp \
qt_helpers.cpp \
- socket_callback.cpp \
+ SocketCallback.cpp \
TocModel.cpp \
TocWidget.cpp \
Validator.cpp
LyXFileDialog.h \
PanelStack.h \
qlkey.h \
- socket_callback.h \
+ SocketCallback.h \
TocModel.h \
TocWidget.h \
Validator.h
--- /dev/null
+/**
+ * \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"
--- /dev/null
+// -*- 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
+++ /dev/null
-/**
- * \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 "socket_callback.h"
-
-
-namespace lyx {
-
-socket_callback::socket_callback(int fd, boost::function<void()> func)
- : func_(func)
-{
- sn_.reset(new QSocketNotifier(fd, QSocketNotifier::Read, this));
- connect(sn_.get(), SIGNAL(activated(int)), this, SLOT(data_received()));
-}
-
-
-void socket_callback::data_received()
-{
- func_();
-}
-
-} // namespace lyx
-
-#include "socket_callback_moc.cpp"
+++ /dev/null
-// -*- 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/scoped_ptr.hpp>
-#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 socket_callback : public QObject {
- Q_OBJECT
-public:
- /// connect a connection notification from the LyXServerSocket
- socket_callback(int fd, boost::function<void()> func);
-public Q_SLOTS:
- void data_received();
-private:
- /// our notifier
- boost::scoped_ptr<QSocketNotifier> sn_;
- /// The callback function
- boost::function<void()> func_;
-};
-
-
-} // namespace lyx
-
-#endif // SOCKET_CALLBACK_H