#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;
{
public:
LQApplication(int & argc, char ** argv);
+ //
+ 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_;
};
}
#endif
+LQApplication * theApp;
namespace lyx_gui {
bool use_gui = true;
-void exec(int & argc, char * argv[])
+int exec(int & argc, char * argv[])
{
// Force adding of font path _before_ QApplication is initialized
FontLoader::initFontPath();
LQApplication app(argc, argv);
+ theApp = &app;
#if QT_VERSION >= 0x030200
// install translation file for Qt built-in dialogs
LoaderQueue::setPriority(10,100);
- LyX::ref().exec2(argc, argv);
+ return LyX::ref().exec2(argc, argv);
}
{}
-void start(string const & batch, vector<string> const & files,
- unsigned int width, unsigned int height, int posx, int posy, bool)
+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);
+ int view_id = theApp->gui().newView(width, height);
+ QtView & view = static_cast<QtView &> (theApp->gui().view(view_id));
+ theApp->gui().newWorkArea(width, height, 0);
- QtView & view = *view_ptr.get();
+ LyX::ref().addLyXView(&view);
- if (posx != -1 && posy != -1)
- view.move(QPoint(posx, posy));
-
- 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
cleanup();
+ return status;
}
void exit(int status)
{
cleanup();
-
- // we cannot call QApplication::exit(status) - 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(status);
+ 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;