mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-02 18:14:13 +02:00
Merge pull request #559 from ispyisail/fix/554-resolve-data-paths-from-binary
Fix language (and data paths) when opening a .qet by double-click on Windows
This commit is contained in:
@@ -97,8 +97,13 @@
|
|||||||
<RegistryValue Root="HKCR" Key="QElectroTech.Document" Type="string" Value="QElectroTech Project" />
|
<RegistryValue Root="HKCR" Key="QElectroTech.Document" Type="string" Value="QElectroTech Project" />
|
||||||
<RegistryValue Root="HKCR" Key="QElectroTech.Document\DefaultIcon" Type="string"
|
<RegistryValue Root="HKCR" Key="QElectroTech.Document\DefaultIcon" Type="string"
|
||||||
Value="[INSTALLDIR]ico\qelectrotech.ico" />
|
Value="[INSTALLDIR]ico\qelectrotech.ico" />
|
||||||
|
<!-- Pass the same arguments as the shortcuts above: opening a .qet from
|
||||||
|
Explorer sets the working directory to the document's folder, so a
|
||||||
|
bare command line leaves QET unable to locate its data. Without the
|
||||||
|
lang-dir argument the UI falls back to the source language, which
|
||||||
|
is French. See issue #554. -->
|
||||||
<RegistryValue Root="HKCR" Key="QElectroTech.Document\shell\open\command" Type="string"
|
<RegistryValue Root="HKCR" Key="QElectroTech.Document\shell\open\command" Type="string"
|
||||||
Value=""[INSTALLDIR]bin\qelectrotech.exe" "%1"" />
|
Value=""[INSTALLDIR]bin\qelectrotech.exe" --common-elements-dir="[INSTALLDIR]elements/" --common-tbt-dir="[INSTALLDIR]titleblocks/" --lang-dir="[INSTALLDIR]lang/" $(var.QtPlatformArgs) "%1"" />
|
||||||
</Component>
|
</Component>
|
||||||
</ComponentGroup>
|
</ComponentGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,10 @@ if(WIN32)
|
|||||||
set(QET_BINARY_PATH "./")
|
set(QET_BINARY_PATH "./")
|
||||||
set(QET_COMMON_COLLECTION_PATH "elements/")
|
set(QET_COMMON_COLLECTION_PATH "elements/")
|
||||||
set(QET_COMMON_TBT_PATH "titleblocks/")
|
set(QET_COMMON_TBT_PATH "titleblocks/")
|
||||||
set(QET_LANG_PATH "l10n/")
|
# "lang/" and not "l10n/": that is where every Windows packaging actually
|
||||||
|
# puts the .qm files (see build-aux/windows/QElectroTech.wxs and the
|
||||||
|
# windows-build workflow), and what the shortcuts pass as --lang-dir.
|
||||||
|
set(QET_LANG_PATH "lang/")
|
||||||
set(QET_LICENSE_PATH "./")
|
set(QET_LICENSE_PATH "./")
|
||||||
# Liste des ressources Windows
|
# Liste des ressources Windows
|
||||||
#RC_FILE = qelectrotech.rc
|
#RC_FILE = qelectrotech.rc
|
||||||
|
|||||||
+46
-3
@@ -539,6 +539,48 @@ TitleBlockTemplatesCollection *QETApp::titleBlockTemplatesCollection(
|
|||||||
return(nullptr);
|
return(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief resolveConfiguredDataPath
|
||||||
|
Resolve a data directory baked in at compile time.
|
||||||
|
|
||||||
|
An absolute path is returned unchanged. A relative one used to be
|
||||||
|
interpreted against the process working directory, which is only correct
|
||||||
|
when QET is started from its own installation folder: opening a document
|
||||||
|
from a file manager sets the working directory to the document's folder,
|
||||||
|
so the data was not found there. Resolve it against the executable
|
||||||
|
instead, trying the folder next to the binary and then its parent -- some
|
||||||
|
packagings put the binary in a "bin" subfolder with the data beside it
|
||||||
|
(see issue #86).
|
||||||
|
|
||||||
|
The working-directory interpretation is still attempted first, so any
|
||||||
|
setup that relied on it keeps working.
|
||||||
|
|
||||||
|
\~French Resout un dossier de donnees fixe a la compilation.
|
||||||
|
@param configured : the compile-time path
|
||||||
|
@return an existing directory if one is found, @a configured otherwise
|
||||||
|
*/
|
||||||
|
static QString resolveConfiguredDataPath(const QString &configured)
|
||||||
|
{
|
||||||
|
if (configured.isEmpty() || QDir::isAbsolutePath(configured)) {
|
||||||
|
return(configured);
|
||||||
|
}
|
||||||
|
if (QDir(configured).exists()) {
|
||||||
|
return(configured);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString bin_dir = QCoreApplication::applicationDirPath();
|
||||||
|
const QStringList candidates = {
|
||||||
|
QDir::cleanPath(bin_dir + "/" + configured) + "/",
|
||||||
|
QDir::cleanPath(bin_dir + "/../" + configured) + "/"
|
||||||
|
};
|
||||||
|
for (const QString &candidate : candidates) {
|
||||||
|
if (QDir(candidate).exists()) {
|
||||||
|
return(candidate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(configured);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QETApp::commonElementsDir
|
@brief QETApp::commonElementsDir
|
||||||
@return the dir path of the common elements collection.
|
@return the dir path of the common elements collection.
|
||||||
@@ -586,7 +628,8 @@ QString QETApp::commonElementsDir()
|
|||||||
/* the compilation option represents a classic absolute
|
/* the compilation option represents a classic absolute
|
||||||
* or relative path
|
* or relative path
|
||||||
*/
|
*/
|
||||||
m_common_element_dir = QUOTE(QET_COMMON_COLLECTION_PATH);
|
m_common_element_dir =
|
||||||
|
resolveConfiguredDataPath(QUOTE(QET_COMMON_COLLECTION_PATH));
|
||||||
return m_common_element_dir;
|
return m_common_element_dir;
|
||||||
#else
|
#else
|
||||||
/* the compilation option represents a path
|
/* the compilation option represents a path
|
||||||
@@ -754,7 +797,7 @@ QString QETApp::commonTitleBlockTemplatesDir()
|
|||||||
#ifndef QET_COMMON_COLLECTION_PATH_RELATIVE_TO_BINARY_PATH
|
#ifndef QET_COMMON_COLLECTION_PATH_RELATIVE_TO_BINARY_PATH
|
||||||
// the compile-time option represents a usual path
|
// the compile-time option represents a usual path
|
||||||
// (be it absolute or relative)
|
// (be it absolute or relative)
|
||||||
return(QUOTE(QET_COMMON_TBT_PATH));
|
return(resolveConfiguredDataPath(QUOTE(QET_COMMON_TBT_PATH)));
|
||||||
#else
|
#else
|
||||||
/* the compile-time option represents a path relative
|
/* the compile-time option represents a path relative
|
||||||
* to the directory that contains the executable binary
|
* to the directory that contains the executable binary
|
||||||
@@ -1261,7 +1304,7 @@ QString QETApp::languagesPath()
|
|||||||
* l'option de compilation represente
|
* l'option de compilation represente
|
||||||
* un chemin absolu ou relatif classique
|
* un chemin absolu ou relatif classique
|
||||||
*/
|
*/
|
||||||
return(QUOTE(QET_LANG_PATH));
|
return(resolveConfiguredDataPath(QUOTE(QET_LANG_PATH)));
|
||||||
#else
|
#else
|
||||||
/* the compilation option represents a path relative
|
/* the compilation option represents a path relative
|
||||||
* to the folder containing the executable binary
|
* to the folder containing the executable binary
|
||||||
|
|||||||
Reference in New Issue
Block a user