Skip to content

Commit

Permalink
Merge pull request #1018 from ra3xdh/951_fix
Browse files Browse the repository at this point in the history
Apply path conversion only for saved schematic or schematic in projects
  • Loading branch information
ra3xdh authored Oct 24, 2024
2 parents 8fc712e + 0ff0ed0 commit 12d5cfe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
20 changes: 14 additions & 6 deletions qucs/components/componentdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,12 +1088,20 @@ void ComponentDialog::slotBrowseFile()
// snip path if file in current directory
QFileInfo file(s);
lastDir = file.absolutePath();
currDir = schematicFileInfo.canonicalPath();
if ( file.canonicalFilePath().startsWith(currDir) ) {
s = QDir(currDir).relativeFilePath(s);
} else if(QucsSettings.QucsWorkDir.exists(file.fileName()) &&
QucsSettings.QucsWorkDir.absolutePath() == file.absolutePath()) {
s = file.fileName();
if (!schematicFileName.isEmpty()) {
currDir = schematicFileInfo.canonicalPath();
}

if (!(schematicFileName.isEmpty() &&
QucsMain->ProjName.isEmpty())) {
// unsaved schematic outside project; only absolute file name
// the schematic could be saved elsewhere and working directory may be changed
if ( file.canonicalFilePath().startsWith(currDir) ) {
s = QDir(currDir).relativeFilePath(s);
} else if(QucsSettings.QucsWorkDir.exists(file.fileName()) &&
QucsSettings.QucsWorkDir.absolutePath() == file.absolutePath()) {
s = file.fileName();
}
}
edit->setText(s);
int row = prop->currentRow();
Expand Down
22 changes: 16 additions & 6 deletions qucs/components/spicedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,23 @@ void SpiceDialog::slotButtBrowse()
// snip path if file in current directory
QFileInfo file(s);
lastDir = file.absolutePath();
currDir = schematicFileInfo.canonicalPath();
if ( file.canonicalFilePath().startsWith(currDir) ) {
s = QDir(currDir).relativeFilePath(s);
} else if(QucsSettings.QucsWorkDir.exists(file.fileName()) &&
QucsSettings.QucsWorkDir.absolutePath() == file.absolutePath()) {
s = file.fileName();

if (!schematicFileName.isEmpty()) {
currDir = schematicFileInfo.canonicalPath();
}

if (!(schematicFileName.isEmpty() &&
QucsMain->ProjName.isEmpty())) {
// unsaved schematic outside project; only absolute file name
// the schematic could be saved elsewhere and working directory may be changed
if ( file.canonicalFilePath().startsWith(currDir) ) {
s = QDir(currDir).relativeFilePath(s);
} else if(QucsSettings.QucsWorkDir.exists(file.fileName()) &&
QucsSettings.QucsWorkDir.absolutePath() == file.absolutePath()) {
s = file.fileName();
}
}

FileEdit->setText(s);
Comp->Props.at(1)->Value = "";
loadSpiceNetList(s);
Expand Down

0 comments on commit 12d5cfe

Please sign in to comment.