]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/lyx_gui.C
rename LFUN enum values according to their command (as used in th minibuffer/bind...
[lyx.git] / src / frontends / qt4 / lyx_gui.C
index 4bd4d4e386a0d134ad08417d22cc7ea38de61792..eceb39eec088a37a4c0773f1a960aa84576709a3 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * \file qt2/lyx_gui.C
+ * \file qt4/lyx_gui.C
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
@@ -16,6 +16,7 @@
 // FIXME: move this stuff out again
 #include "bufferlist.h"
 #include "BufferView.h"
+#include "Color.h"
 #include "funcrequest.h"
 #include "LColor.h"
 #include "lyx_main.h"
 #include "lyxrc.h"
 #include "lyxserver.h"
 #include "lyxsocket.h"
+#include "session.h"
 
 #include "graphics/LoaderQueue.h"
 
 #include "support/lstrings.h"
+#include "support/convert.h"
 #include "support/os.h"
 #include "support/package.h"
 #include "debug.h"
@@ -160,7 +163,6 @@ void parse_init(int & argc, char * argv[])
 
        static LQApplication app(argc, argv);
 
-#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);
@@ -176,9 +178,8 @@ void parse_init(int & argc, char * argv[])
                lyxerr[Debug::GUI]
                        << "Could not find  Qt translations for locale "
                        << QTextCodec::locale() << std::endl;
-#endif
 
-#ifdef Q_WS_MACX
+/*#ifdef Q_WS_MACX
        // 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
@@ -194,7 +195,7 @@ void parse_init(int & argc, char * argv[])
 
        app.installTranslator(&aqua_trans);
 #endif
-
+*/
        using namespace lyx::graphics;
 
        Image::newImage = boost::bind(&QLImage::newImage);
@@ -219,11 +220,37 @@ void start(string const & batch, vector<string> const & files)
        // initial geometry
        unsigned int width = 690;
        unsigned int height = 510;
+       // first try lyxrc
+       if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) {
+               width = lyxrc.geometry_width;
+               height = lyxrc.geometry_height;
+       }
+       // if lyxrc returns (0,0), then use session info
+       else {
+               string val = LyX::ref().session().loadSessionInfo("WindowWidth");
+               if (val != "")
+                       width = convert<unsigned int>(val);
+               val = LyX::ref().session().loadSessionInfo("WindowHeight");
+               if (val != "")
+                       height = convert<unsigned int>(val);
+       }
 
        boost::shared_ptr<QtView> view_ptr(new QtView(width, height));
        LyX::ref().addLyXView(view_ptr);
 
        QtView & view = *view_ptr.get();
+
+       // if user wants to restore window position
+       if (lyxrc.geometry_xysaved) {
+               QPoint p = view.pos();
+               string val = LyX::ref().session().loadSessionInfo("WindowPosX");
+               if (val != "")
+                       p.setX(convert<unsigned int>(val));
+               val = LyX::ref().session().loadSessionInfo("WindowPosY");
+               if (val != "")
+                       p.setY(convert<unsigned int>(val));
+               view.move(p);
+       }
        view.show();
        view.init();
 
@@ -285,7 +312,7 @@ FuncStatus getStatus(FuncRequest const & ev)
                if (ev.argument == "preamble")
                        flag.unknown(true);
                break;
-       case LFUN_TOOLTIPS_TOGGLE:
+       case LFUN_TOGGLE_TOOLTIPS:
                flag.unknown(true);
                break;
        default:
@@ -296,6 +323,22 @@ FuncStatus getStatus(FuncRequest const & ev)
 }
 
 
+bool getRGBColor(LColor_color col, lyx::RGBColor & rgbcol)
+{
+       QColor const & qcol = lcolorcache.get(col);
+       if (!qcol.isValid()) {
+               rgbcol.r = 0;
+               rgbcol.g = 0;
+               rgbcol.b = 0;
+               return false;
+       }
+       rgbcol.r = qcol.red();
+       rgbcol.g = qcol.green();
+       rgbcol.b = qcol.blue();
+       return true;
+}
+
+
 string const hexname(LColor_color col)
 {
        return ltrim(fromqstr(lcolorcache.get(col).name()), "#");