]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiApplication.cpp
The core is now clean enough that we don't need the NoGuiFontLoader/Metrics anymore...
[lyx.git] / src / frontends / qt4 / GuiApplication.cpp
index 76e82b3e1294c437f484693588181afbf516a62b..705b9acec70637c38ead3a4fc019e3f5074535fc 100644 (file)
 
 #include "frontends/alert.h"
 #include "frontends/Application.h"
-#include "frontends/NoGuiFontLoader.h"
-#include "frontends/NoGuiFontMetrics.h"
 #include "frontends/FontLoader.h"
 #include "frontends/FontMetrics.h"
 
 #include "support/ExceptionMessage.h"
 #include "support/FileName.h"
+#include "support/ForkedCalls.h"
 #include "support/lstrings.h"
 #include "support/os.h"
 #include "support/Package.h"
@@ -201,6 +200,11 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
 
        if (lyxrc.typewriter_font_name.empty())
                lyxrc.typewriter_font_name = fromqstr(typewriterFontName());
+
+       general_timer_.setInterval(500);
+       connect(&general_timer_, SIGNAL(timeout()),
+               this, SLOT(handleRegularEvents()));
+       general_timer_.start();
 }
 
 
@@ -372,6 +376,24 @@ void GuiApplication::execBatchCommands()
 }
 
 
+void GuiApplication::restoreGuiSession()
+{
+       if (!lyxrc.load_session)
+               return;
+
+       Session & session = LyX::ref().session();
+       vector<FileName> const & lastopened = session.lastOpened().getfiles();
+       // do not add to the lastfile list since these files are restored from
+       // last session, and should be already there (regular files), or should
+       // not be added at all (help files).
+       for_each(lastopened.begin(), lastopened.end(),
+               bind(&GuiView::loadDocument, current_view_, _1, false));
+
+       // clear this list to save a few bytes of RAM
+       session.lastOpened().clear();
+}
+
+
 QString const GuiApplication::romanFontName()
 {
        QFont font;
@@ -405,6 +427,12 @@ QString const GuiApplication::typewriterFontName()
 }
 
 
+void GuiApplication::handleRegularEvents()
+{
+       ForkedCallsController::handleCompletedProcesses();
+}
+
+
 bool GuiApplication::event(QEvent * e)
 {
        switch(e->type()) {
@@ -417,7 +445,7 @@ bool GuiApplication::event(QEvent * e)
                        // So we acknowledge the event and delay the file opening
                        // until LyX is ready.
                        // FIXME UNICODE: FileName accept an utf8 encoded string.
-                       LyX::ref().addFileToLoad(FileName(fromqstr(foe->file())));
+                       LyX::ref().addFileToLoad(fromqstr(foe->file()));
                else
                        lyx::dispatch(FuncRequest(LFUN_FILE_OPEN,
                                qstring_to_ucs4(foe->file())));
@@ -651,11 +679,6 @@ bool GuiApplication::x11EventFilter(XEvent * xev)
 
 frontend::FontLoader & theFontLoader()
 {
-       static frontend::NoGuiFontLoader no_gui_font_loader;
-
-       if (!use_gui)
-               return no_gui_font_loader;
-
        BOOST_ASSERT(frontend::guiApp);
        return frontend::guiApp->fontLoader();
 }
@@ -669,11 +692,6 @@ frontend::FontMetrics const & theFontMetrics(Font const & f)
 
 frontend::FontMetrics const & theFontMetrics(FontInfo const & f)
 {
-       static frontend::NoGuiFontMetrics no_gui_font_metrics;
-
-       if (!use_gui)
-               return no_gui_font_metrics;
-
        BOOST_ASSERT(frontend::guiApp);
        return frontend::guiApp->fontLoader().metrics(f);
 }