]> git.lyx.org Git - lyx.git/blobdiff - src/support/Package.cpp
Let paragraph::requestSpellcheck() consider contained insets
[lyx.git] / src / support / Package.cpp
index de06c19d60cb73b10ce2e30beb75f261af7c12e9..a779544f9999893e416985db15a6e441e10e1fcd 100644 (file)
@@ -43,6 +43,7 @@
 # include "support/qstring_helpers.h"
 # include <QDir>
 # include <QDesktopServices>
+# include <QStandardPaths>
 #endif
 
 using namespace std;
@@ -55,7 +56,7 @@ namespace {
 Package package_;
 bool initialised_ = false;
 
-} // namespace anon
+} // namespace
 
 
 void init_package(string const & command_line_arg0,
@@ -101,7 +102,7 @@ string const & with_version_suffix();
 
 string const fix_dir_name(string const & name);
 
-} // namespace anon
+} // namespace
 
 
 Package::Package(string const & command_line_arg0,
@@ -193,7 +194,9 @@ void Package::set_temp_dir(FileName const & temp_dir) const
 FileName Package::messages_file(string const & c) const
 {
        if (in_build_dir_) {
-               FileName res = FileName(lyx_dir().absFileName() + "/../po/" + c + ".gmo");
+               FileName res = FileName(lyx_dir().absFileName() + "/po/" + c + ".gmo");
+               if (!res.isReadableFile())
+                       res = FileName(lyx_dir().absFileName() + "../po/" + c + ".gmo");
                if (!res.isReadableFile())
                        res = FileName(top_srcdir().absFileName() + "/po/" + c + ".gmo");
                return res;
@@ -247,7 +250,7 @@ string const & with_version_suffix()
        return program_suffix.empty() ? program_suffix : with_version_suffix;
 }
 
-} // namespace anon
+} // namespace
 
 
 FileName const & Package::top_srcdir()
@@ -302,8 +305,8 @@ bool isBuildDir(FileName const & abs_binary, string const & dir_location,
         return true;
     }
     //  cmake file, no Makefile in lib
-    FileName build_boost_dir = FileName(addPath(search_dir + "/3rdparty", "boost"));
-    if (!fileSearch(build_boost_dir.absFileName(), "cmake_install.cmake").empty()) {
+    FileName build_src_dir = FileName(addPath(search_dir, "src"));
+    if (!fileSearch(build_src_dir.absFileName(), "cmake_install.cmake").empty()) {
         return true;
     }
 
@@ -323,12 +326,12 @@ bool inBuildDir(FileName const & abs_binary,
 
        // Note that the name of the lyx binary may be a symbolic link.
        // If that is the case, then we follow the links too.
-    FileName binary = abs_binary;
+       FileName binary = abs_binary;
        while (true) {
                // Try and find "lyxrc.defaults".
-               if( isBuildDir(binary, "../", build_support_dir) ||
-            isBuildDir(binary, "../../", build_support_dir))
-        {
+               if ( isBuildDir(binary, "../", build_support_dir)
+                   || isBuildDir(binary, "../../", build_support_dir))
+               {
                        // Try and find "chkconfig.ltx".
                        system_support_dir =
                                FileName(addPath(Package::top_srcdir().absFileName(), "lib"));
@@ -357,30 +360,27 @@ bool inBuildDir(FileName const & abs_binary,
        system_support_dir = FileName();
        build_support_dir = FileName();
 
-    return false;
+       return false;
 }
 
 
 bool doesFileExist(FileName & result, string const & search_dir, string const & name)
 {
     result = fileSearch(search_dir, name);
-    if (!result.empty()) {
-        return true;
-    }
-    return false;
+    return !result.empty();
 }
 
 
 bool lyxBinaryPath(FileName & lyx_binary, string const & search_dir, string const & ext)
 {
     lyx_binary = FileName();
-    if(false) {   
+    if(false) {
     } else if (doesFileExist(lyx_binary, search_dir, "lyx" + ext)) {
     } else if (doesFileExist(lyx_binary, search_dir, "LyX" + ext)) {
     } else if (doesFileExist(lyx_binary, search_dir, "lyx" + string(PROGRAM_SUFFIX) + ext)) {
     } else if (doesFileExist(lyx_binary, search_dir, "LyX" + string(PROGRAM_SUFFIX) + ext)){
     }
-    return !lyx_binary.empty() ? true : false;
+    return !lyx_binary.empty();
 }
 
 
@@ -397,9 +397,9 @@ FileName findLyxBinary(FileName const & abs_binary)
     else if (!abs_binary.extension().empty()) {
         ext = "." + abs_binary.extension();
     }
-    
+
     string binary_dir = onlyPath(abs_binary.absFileName());
-      
+
     FileName lyx_binary;
     if (lyxBinaryPath(lyx_binary, binary_dir, ext))
         return lyx_binary;
@@ -407,7 +407,7 @@ FileName findLyxBinary(FileName const & abs_binary)
     string search_dir = onlyPath(FileName(addPath(binary_dir, "/../")).absFileName());
     if (lyxBinaryPath(lyx_binary, search_dir, ext))
         return lyx_binary;
-    
+
     return FileName();
 }
 
@@ -506,9 +506,9 @@ FileName const get_binary_path(string const & exe)
                // This will do nothing if *it is already absolute.
                string const exe_dir = makeAbsPath(*it).absFileName();
 
-               FileName const exe_path(addName(exe_dir, exe_name));
-               if (exe_path.exists())
-                       return exe_path;
+               FileName const exe_path2(addName(exe_dir, exe_name));
+               if (exe_path2.exists())
+                       return exe_path2;
        }
 
        // Didn't find anything.
@@ -651,9 +651,6 @@ get_system_support_dir(FileName const & abs_binary,
                                "to the LyX system directory containing the "
                                "file `chkconfig.ltx'."),
                          from_utf8(searched_dirs_str), from_ascii(LYX_DIR_VER)));
-
-       // Keep the compiler happy.
-       return FileName();
 }
 
 
@@ -691,7 +688,7 @@ FileName const get_default_user_support_dir(FileName const & home_dir)
 
 #elif defined (USE_MACOSX_PACKAGING) && (QT_VERSION >= 0x050000)
        (void)home_dir; // Silence warning about unused variable.
-       return FileName(addPath(fromqstr(QStandardPaths::writableLocation(QStandardPaths::DataLocation)), PACKAGE));
+       return FileName(addPath(fromqstr(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)), PACKAGE));
 
 #elif defined (USE_MACOSX_PACKAGING)
        (void)home_dir; // Silence warning about unused variable.
@@ -802,7 +799,7 @@ string const relative_system_support_dir()
        return result;
 }
 
-} // namespace anon
+} // namespace
 
 } // namespace support
 } // namespace lyx