Resolved issue #582. Issue with standard path to shared data on Linux.
--HG-- branch : develop
This commit is contained in:
parent
4930414432
commit
3e8f8a8069
|
@ -44,6 +44,7 @@
|
|||
- [#577] 10 new colors added for the lines
|
||||
- [#570] Tiled PDF : Margin values correctly taken into account
|
||||
- [#580] Extend the list of heights.
|
||||
- [#582] Issue with standard path to shared data on Linux.
|
||||
|
||||
# Version 0.4.5 October 15, 2016
|
||||
- [#435] Valentina doesn't change the cursor.
|
||||
|
|
|
@ -51,6 +51,12 @@
|
|||
VAbstractConverter::VAbstractConverter(const QString &fileName)
|
||||
:VDomDocument(), ver(0x0), fileName(fileName)
|
||||
{
|
||||
QFileInfo info(fileName);
|
||||
if (info.isSymLink() && not info.isWritable())
|
||||
{
|
||||
ReplaceSymLink();
|
||||
}
|
||||
|
||||
this->setXMLContent(fileName);
|
||||
const QString version = GetVersionStr();
|
||||
ver = GetVersion(version);
|
||||
|
@ -187,6 +193,23 @@ void VAbstractConverter::ReserveFile() const
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractConverter::ReplaceSymLink() const
|
||||
{
|
||||
// See issue #582. Issue with standard path to shared data on Linux
|
||||
// https://bitbucket.org/dismine/valentina/issues/582/issue-with-standard-path-to-shared-data-on
|
||||
QFileInfo info(fileName);
|
||||
if (info.isSymLink() && not info.isWritable())
|
||||
{
|
||||
QString error;
|
||||
if (not SafeCopy(info.symLinkTarget(), fileName, error))
|
||||
{
|
||||
const QString errorMsg(tr("Error replacing a synlink by real file: %1.").arg(error));
|
||||
throw VException(errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractConverter::Replace(QString &formula, const QString &newName, int position, const QString &token,
|
||||
int &bias) const
|
||||
|
|
|
@ -88,6 +88,7 @@ private:
|
|||
static void ValidateVersion(const QString &version);
|
||||
|
||||
void ReserveFile() const;
|
||||
void ReplaceSymLink() const;
|
||||
};
|
||||
|
||||
#endif // VABSTRACTCONVERTER_H
|
||||
|
|
|
@ -113,6 +113,18 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
|
|||
// Connect this slot with VApplication::aboutToQuit.
|
||||
Settings()->sync();
|
||||
});
|
||||
|
||||
#if !defined(Q_OS_WIN)
|
||||
QDir standardPath(VCommonSettings::unixStandardSharePath);
|
||||
const QDir localdata (QDir::homePath() + QDir::separator() + VCommonSettings::valentinaUnixHomeFolder);
|
||||
if (standardPath.exists() && not localdata.exists())
|
||||
{
|
||||
if (localdata.mkdir(localdata.absolutePath()))
|
||||
{
|
||||
SymlinkCopyDirRecursive(standardPath.absolutePath(), localdata.absolutePath(), true);
|
||||
}
|
||||
}
|
||||
#endif // !defined(Q_OS_WIN)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -382,3 +394,54 @@ void VAbstractApplication::ClearTranslation()
|
|||
delete pmsTranslator;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VAbstractApplication::SymlinkCopyDirRecursive(const QString &fromDir, const QString toDir, bool replaceOnConflit)
|
||||
{
|
||||
QDir dir;
|
||||
dir.setPath(fromDir);
|
||||
|
||||
foreach (QString copyFile, dir.entryList(QDir::Files))
|
||||
{
|
||||
const QString from = fromDir + QDir::separator() + copyFile;
|
||||
const QString to = toDir + QDir::separator() + copyFile;
|
||||
|
||||
if (QFile::exists(to))
|
||||
{
|
||||
if (replaceOnConflit)
|
||||
{
|
||||
if (QFile::remove(to) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (QFile::link(from, to) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (QString copyDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
||||
{
|
||||
const QString from = fromDir + QDir::separator() + copyDir;
|
||||
const QString to = toDir + QDir::separator() + copyDir;
|
||||
|
||||
if (dir.mkpath(to) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SymlinkCopyDirRecursive(from, to, replaceOnConflit) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -149,6 +149,8 @@ private:
|
|||
bool openingPattern;
|
||||
|
||||
void ClearTranslation();
|
||||
|
||||
static bool SymlinkCopyDirRecursive(const QString &fromDir, const QString toDir, bool replaceOnConflit);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -75,6 +75,11 @@ const QString VCommonSettings::SettingUserDefinedMaterials = QStringLitera
|
|||
|
||||
static const QString commonIniFilename = QStringLiteral("common");
|
||||
|
||||
#if !defined(Q_OS_WIN)
|
||||
const QString VCommonSettings::unixStandardSharePath = QStringLiteral("/usr/share/valentina");
|
||||
const QString VCommonSettings::valentinaUnixHomeFolder = QStringLiteral(".valentina");
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCommonSettings::VCommonSettings(Format format, Scope scope, const QString &organization,
|
||||
const QString &application, QObject *parent)
|
||||
|
@ -82,13 +87,12 @@ VCommonSettings::VCommonSettings(Format format, Scope scope, const QString &orga
|
|||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VCommonSettings::StandardTablesPath() const
|
||||
QString VCommonSettings::SharePath(const QString &shareItem)
|
||||
{
|
||||
const QString stPath = QStringLiteral("/tables/standard");
|
||||
#ifdef Q_OS_WIN
|
||||
return QApplication::applicationDirPath() + stPath;
|
||||
return QApplication::applicationDirPath() + shareItem;
|
||||
#elif defined(Q_OS_MAC)
|
||||
QDir dirBundle(QApplication::applicationDirPath() + QStringLiteral("/../Resources") + stPath);
|
||||
QDir dirBundle(QApplication::applicationDirPath() + QStringLiteral("/../Resources") + shareItem);
|
||||
if (dirBundle.exists())
|
||||
{
|
||||
return dirBundle.absolutePath();
|
||||
|
@ -99,33 +103,61 @@ QString VCommonSettings::StandardTablesPath() const
|
|||
appDir.cdUp();
|
||||
appDir.cdUp();
|
||||
appDir.cdUp();
|
||||
QDir dir(appDir.absolutePath() + stPath);
|
||||
QDir dir(appDir.absolutePath() + shareItem);
|
||||
if (dir.exists())
|
||||
{
|
||||
return dir.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
return QStringLiteral("/usr/share/valentina/tables/standard");
|
||||
QDir dir(QDir::homePath() + QDir::separator() + VCommonSettings::valentinaUnixHomeFolder + shareItem);
|
||||
if (dir.exists())
|
||||
{
|
||||
return dir.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
return VCommonSettings::unixStandardSharePath + shareItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else // Unix
|
||||
#ifdef QT_DEBUG
|
||||
return QApplication::applicationDirPath() + stPath;
|
||||
return QApplication::applicationDirPath() + shareItem;
|
||||
#else
|
||||
QDir dir(QApplication::applicationDirPath() + stPath);
|
||||
QDir dir(QApplication::applicationDirPath() + shareItem);
|
||||
if (dir.exists())
|
||||
{
|
||||
return dir.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
return QStringLiteral("/usr/share/valentina/tables/standard");
|
||||
QDir dir(QDir::homePath() + QDir::separator() + VCommonSettings::valentinaUnixHomeFolder + shareItem);
|
||||
if (dir.exists())
|
||||
{
|
||||
return dir.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
return VCommonSettings::unixStandardSharePath + shareItem;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VCommonSettings::StandardTablesPath()
|
||||
{
|
||||
return SharePath(QStringLiteral("/tables/standard"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VCommonSettings::TemplatesPath()
|
||||
{
|
||||
return SharePath(QStringLiteral("/tables/templates"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VCommonSettings::GetPathIndividualMeasurements() const
|
||||
{
|
||||
|
@ -172,49 +204,6 @@ void VCommonSettings::SetPathTemplate(const QString &value)
|
|||
settings.sync();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VCommonSettings::TemplatesPath() const
|
||||
{
|
||||
const QString stPath = QStringLiteral("/tables/templates");
|
||||
const QString unixFullPath = QStringLiteral("/usr/share/valentina/tables/templates");
|
||||
#ifdef Q_OS_WIN
|
||||
return QApplication::applicationDirPath() + stPath;
|
||||
#elif defined(Q_OS_MAC)
|
||||
QDir dirBundle(QApplication::applicationDirPath() + QStringLiteral("/../Resources") + stPath);
|
||||
if (dirBundle.exists())
|
||||
{
|
||||
return dirBundle.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
QDir dir(QApplication::applicationDirPath() + stPath);
|
||||
if (dir.exists())
|
||||
{
|
||||
return dir.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
return unixFullPath;
|
||||
}
|
||||
}
|
||||
#else // Unix
|
||||
#ifdef QT_DEBUG
|
||||
Q_UNUSED(unixFullPath);
|
||||
return QApplication::applicationDirPath() + stPath;
|
||||
#else
|
||||
QDir dir(QApplication::applicationDirPath() + stPath);
|
||||
if (dir.exists())
|
||||
{
|
||||
return dir.absolutePath();
|
||||
}
|
||||
else
|
||||
{
|
||||
return unixFullPath;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VCommonSettings::GetOsSeparator() const
|
||||
{
|
||||
|
|
|
@ -47,10 +47,11 @@ class VCommonSettings : public QSettings
|
|||
Q_OBJECT
|
||||
public:
|
||||
VCommonSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
|
||||
QObject *parent = 0);
|
||||
QObject *parent = nullptr);
|
||||
|
||||
QString StandardTablesPath() const;
|
||||
QString TemplatesPath() const;
|
||||
static QString SharePath(const QString &shareItem);
|
||||
static QString StandardTablesPath();
|
||||
static QString TemplatesPath();
|
||||
|
||||
QString GetPathIndividualMeasurements() const;
|
||||
void SetPathIndividualMeasurements(const QString &value);
|
||||
|
@ -125,6 +126,11 @@ public:
|
|||
bool GetForbidWorkpieceFlipping() const;
|
||||
void SetForbidWorkpieceFlipping(bool value);
|
||||
|
||||
#if !defined(Q_OS_WIN)
|
||||
static const QString unixStandardSharePath;
|
||||
static const QString valentinaUnixHomeFolder;
|
||||
#endif
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VCommonSettings)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user