#include <boost/signal.hpp> // FIXME: Is this needed? (Lgb)
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
+#include "frontends/WorkArea.h"
+#include "GuiImplementation.h"
#include "QtView.h"
#include "lcolorcache.h"
#include "qfont_loader.h"
using lyx::support::ltrim;
using lyx::support::package;
+using lyx::frontend::Gui;
+using lyx::frontend::GuiImplementation;
using lyx::frontend::QtView;
namespace os = lyx::support::os;
extern BufferList bufferlist;
+// FIXME: wrong place !
+LyXServer * lyxserver;
+LyXServerSocket * lyxsocket;
+
namespace {
int getDPI()
map<int, shared_ptr<socket_callback> > socket_callbacks;
-} // namespace anon
+void cleanup()
+{
+ delete lyxsocket;
+ lyxsocket = 0;
+ delete lyxserver;
+ lyxserver = 0;
+}
-// FIXME: wrong place !
-LyXServer * lyxserver;
-LyXServerSocket * lyxsocket;
+} // namespace anon
// in QLyXKeySym.C
extern void initEncodings();
#endif
#ifdef Q_WS_MACX
-extern bool macEventFilter(EventRef event);
extern pascal OSErr
handleOpenDocuments(const AppleEvent* inEvent, AppleEvent* /*reply*/,
long /*refCon*/);
{
public:
LQApplication(int & argc, char ** argv);
- ~LQApplication();
+ //
+ Gui & gui() { return gui_; }
+
#ifdef Q_WS_X11
bool x11EventFilter (XEvent * ev) { return lyxX11EventFilter(ev); }
#endif
#ifdef Q_WS_MACX
bool macEventFilter(EventRef event);
#endif
+
+private:
+ ///
+ GuiImplementation gui_;
};
}
-LQApplication::~LQApplication()
-{}
-
-
#ifdef Q_WS_MACX
bool LQApplication::macEventFilter(EventRef event)
{
}
#endif
+LQApplication * theApp;
namespace lyx_gui {
bool use_gui = true;
-void parse_init(int & argc, char * argv[])
+
+int exec(int & argc, char * argv[])
{
// Force adding of font path _before_ QApplication is initialized
FontLoader::initFontPath();
- static LQApplication app(argc, argv);
+ LQApplication app(argc, argv);
+ theApp = &app;
#if QT_VERSION >= 0x030200
// install translation file for Qt built-in dialogs
// These are only installed since Qt 3.2.x
- static QTranslator qt_trans(0);
+ QTranslator qt_trans(0);
if (qt_trans.load(QString("qt_") + QTextCodec::locale(),
qInstallPathTranslations())) {
- app.installTranslator(&qt_trans);
+ qApp->installTranslator(&qt_trans);
// even if the language calls for RtL, don't do that
- app.setReverseLayout(false);
+ qApp->setReverseLayout(false);
lyxerr[Debug::GUI]
<< "Successfully installed Qt translations for locale "
<< QTextCodec::locale() << std::endl;
// These translations are meant to break Qt/Mac menu merging
// algorithm on some entries. It lists the menu names that
// should not be moved to the LyX menu
- static QTranslator aqua_trans(0);
+ QTranslator aqua_trans(0);
aqua_trans.insert(QTranslatorMessage("QMenuBar", "Setting", 0,
"do_not_merge_me"));
aqua_trans.insert(QTranslatorMessage("QMenuBar", "Config", 0,
aqua_trans.insert(QTranslatorMessage("QMenuBar", "Setup", 0,
"do_not_merge_me"));
- app.installTranslator(&aqua_trans);
+ qApp->installTranslator(&aqua_trans);
#endif
using namespace lyx::graphics;
lyxrc.dpi = getDPI();
LoaderQueue::setPriority(10,100);
+
+ return LyX::ref().exec2(argc, argv);
}
{}
-void start(string const & batch, vector<string> const & files,
- int width, int height, int posx, int posy)
+LyXView* create_view(unsigned int width, unsigned int height, int posx, int posy,
+ bool maximize)
{
// this can't be done before because it needs the Languages object
initEncodings();
- boost::shared_ptr<QtView> view_ptr(new QtView(width, height));
- LyX::ref().addLyXView(view_ptr);
-
- QtView & view = *view_ptr.get();
+ int view_id = theApp->gui().newView(width, height);
+ QtView & view = static_cast<QtView &> (theApp->gui().view(view_id));
+ theApp->gui().newWorkArea(width, height, 0);
- if (posx != -1 && posy != -1)
- view.move(QPoint(posx, posy));
+ LyX::ref().addLyXView(&view);
- view.show();
view.init();
+ if (width != 0 && height != 0) {
+ view.initFloatingGeometry(QRect(posx, posy, width, height));
+ view.resize(width, height);
+ if (posx != -1 && posy != -1)
+ view.move(posx, posy);
+ view.show();
+ if (maximize)
+ view.setWindowState(Qt::WindowMaximized);
+ } else
+ view.show();
+
+ return &view;
+}
+
+
+int start(LyXView * view, string const & batch)
+{
// FIXME: some code below needs moving
- lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
- lyxsocket = new LyXServerSocket(&view.getLyXFunc(),
+ lyxserver = new LyXServer(&view->getLyXFunc(), lyxrc.lyxpipes);
+ lyxsocket = new LyXServerSocket(&view->getLyXFunc(),
os::internal_path(package().temp_dir() + "/lyxsocket"));
- for_each(files.begin(), files.end(),
- bind(&BufferView::loadLyXFile, view.view(), _1, true));
-
// handle the batch commands the user asked for
if (!batch.empty()) {
- view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
+ view->getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
}
- qApp->exec();
+ int const status = qApp->exec();
// FIXME
- delete lyxsocket;
- delete lyxserver;
- lyxserver = 0;
+ cleanup();
+ return status;
}
}
-void exit()
+void exit(int status)
{
- delete lyxsocket;
- delete lyxserver;
- lyxserver = 0;
-
- // we cannot call qApp->exit(0) - that could return us
- // into a static dialog return in the lyx code (for example,
- // load autosave file QMessageBox. We have to just get the hell
- // out.
-
- ::exit(0);
+ cleanup();
+ QApplication::exit(status);
}
{
FuncStatus flag;
switch (ev.action) {
- case LFUN_DIALOG_SHOW:
- if (ev.argument == "preamble")
- flag.unknown(true);
- break;
case LFUN_TOOLTIPS_TOGGLE:
flag.unknown(true);
break;