Skip to content

Commit

Permalink
Merge pull request #1124 from dsm/fix_path
Browse files Browse the repository at this point in the history
fix path.
  • Loading branch information
ra3xdh authored Dec 10, 2024
2 parents 1a3ce17 + 5913133 commit 0fe4bc4
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 30 deletions.
8 changes: 4 additions & 4 deletions qucs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ bool loadSettings()
QFileInfo inf(QucsSettings.Qucsator);
QucsSettings.QucsatorDir = inf.canonicalPath() + QDir::separator();
if (QucsSettings.Qucsconv.isEmpty())
QucsSettings.Qucsconv = QucsSettings.QucsatorDir + QDir::separator() + "qucsconv_rf" + executableSuffix;
QucsSettings.Qucsconv = QStandardPaths::findExecutable("qucsconv_rf",{QucsSettings.QucsatorDir});
} else {
QucsSettings.Qucsator = QucsSettings.BinDir + "qucsator_rf" + executableSuffix;
QucsSettings.Qucsator = QStandardPaths::findExecutable("qucsator_rf",{QucsSettings.BinDir});
QucsSettings.QucsatorDir = QucsSettings.BinDir;
if (QucsSettings.Qucsconv.isEmpty())
QucsSettings.Qucsconv = QucsSettings.BinDir + "qucsconv_rf" + executableSuffix;
QucsSettings.Qucsconv = QStandardPaths::findExecutable("qucsconv_rf",{QucsSettings.BinDir});
}

QucsSettings.AdmsXmlBinDir.setPath(_settings::Get().item<QString>("AdmsXmlBinDir"));
Expand Down Expand Up @@ -806,7 +806,7 @@ int main(int argc, char *argv[])
QucsDir.cdUp();
#endif

QucsSettings.BinDir = QucsDir.absolutePath() + "/bin/";
QucsSettings.BinDir = QucsApplicationPath.contains("bin") ? QucsApplicationPath : QucsDir.absoluteFilePath("bin");
QucsSettings.LangDir = QucsDir.canonicalPath() + "/share/" QUCS_NAME "/lang/";

QucsSettings.LibDir = QucsDir.canonicalPath() + "/share/" QUCS_NAME "/library/";
Expand Down
78 changes: 52 additions & 26 deletions qucs/qucs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ QucsApp::QucsApp()

select->setChecked(true); // switch on the 'select' action
switchSchematicDoc(true); // "untitled" document is schematic

lastExportFilename = QDir::homePath() + QDir::separator() + "export.png";
QDir homeDir = QDir::homePath();
lastExportFilename = homeDir.absoluteFilePath("export.png");

// load documents given as command line arguments
for(int z=1; z<qApp->arguments().size(); z++) {
Expand All @@ -172,42 +172,59 @@ QucsApp::QucsApp()
}
}

QDir QucsBinDir(QucsSettings.BinDir);
if (QucsSettings.firstRun) { // try to find Ngspice
QString ngspice_exe_name = "ngspice";
#ifdef Q_OS_WIN
QString ngspice_exe1 = QucsSettings.BinDir + QDir::separator() + "ngspice_con.exe";
QString ngspice_exe2 = "C:\\Spice64\\bin\\ngspice_con.exe";
QString qucsator_exe = QucsSettings.BinDir + QDir::separator() + "qucsator_rf.exe";
ngspice_exe_name+="_con";
#endif
/* search own path */
#ifdef Q_OS_MACOS
QString ngspice_exe1 = QStandardPaths::findExecutable(ngspice_exe_name,{"/opt/homebrew/bin"});
#else
QString ngspice_exe1 = QucsSettings.BinDir + QDir::separator() + "ngspice";
QString qucsator_exe = QucsSettings.BinDir + QDir::separator() + "qucsator_rf";
QString ngspice_exe1 = QStandardPaths::findExecutable(ngspice_exe_name,{QucsBinDir.absolutePath()});
#endif

/* search system path */
QString ngspice_exe2 = QStandardPaths::findExecutable(ngspice_exe_name);

/* search own path */
QString qucsator_exe1 = QStandardPaths::findExecutable("qucsator_rf",{QucsBinDir.absolutePath()});
/* search system path */
QString qucsator_exe2 = QStandardPaths::findExecutable("qucsator_rf");

QString ngspice_exe;
bool ngspice_found = false;
if (QFile::exists(ngspice_exe1)) {
if(!ngspice_exe1.isEmpty()){
ngspice_found = true;
ngspice_exe = ngspice_exe1;
}else if(!ngspice_exe2.isEmpty()){
ngspice_found = true;
ngspice_exe = ngspice_exe2;
}

QString qucsator_exe;
bool qucsator_found = false;
if (QFile::exists(qucsator_exe)) {
if(!qucsator_exe1.isEmpty()){
qucsator_found = true;
QucsSettings.Qucsator = qucsator_exe;
}
#ifdef Q_OS_WIN
if (!ngspice_found && QFile::exists(ngspice_exe2)) {
ngspice_found = true;
ngspice_exe = ngspice_exe2;
qucsator_exe = qucsator_exe1;
}else if(!qucsator_exe2.isEmpty()){
qucsator_found = true;
qucsator_exe = qucsator_exe2;
}
#endif
ngspice_exe = QDir::toNativeSeparators(ngspice_exe);

QString info_string;
if (ngspice_found) {
QucsSettings.DefaultSimulator = spicecompat::simNgspice;
QucsSettings.DefaultSimulator = spicecompat::simNgspice;
QucsSettings.NgspiceExecutable = ngspice_exe;
info_string += tr("Ngspice found at: ") + ngspice_exe + "\n";
}
if (qucsator_found) {

if(qucsator_found){
QucsSettings.Qucsator = qucsator_exe;
info_string += tr("QucsatorRF found at: ") + qucsator_exe + "\n";
}

info_string += tr("\nYou can specify another location later"
" using Simulation->Simulators Setings\n");
if (!ngspice_found && qucsator_found) {
Expand All @@ -220,18 +237,27 @@ QucsApp::QucsApp()
QMessageBox::information(nullptr,tr("Set simulator"), info_string);
fillSimulatorsComboBox();
} else {
#ifdef Q_OS_WIN
QucsSettings.NgspiceExecutable = "ngspice_con.exe";
QucsSettings.Qucsator = "qucsator_rf.exe";
#else
QucsSettings.NgspiceExecutable = "ngspice";
QucsSettings.Qucsator = "qucsator_rf";
#endif
QMessageBox::information(this,tr("Qucs"),tr("No simulators found automatically. Please specify simulators"
" in the next dialog window."));
slotSimSettings();
}
QucsSettings.firstRun = false;
} else if (!QFile::exists(QucsSettings.Qucsator)) {
QucsSettings.Qucsator = QucsSettings.BinDir + QDir::separator() + "qucsator_rf";
#ifdef Q_OS_WIN
QucsSettings.Qucsator += ".exe";
#endif
QMessageBox::information(this, "Qucs",
tr("QucsatorRF found at: ") + QucsSettings.Qucsator + "\n");
} else {
if (!QucsSettings.Qucsator.contains("qucsator_rf")) {
QucsSettings.Qucsator = QStandardPaths::findExecutable("qucsator_rf",{QucsBinDir.absolutePath()});

if(!QucsSettings.Qucsator.isEmpty()){
QMessageBox::information(this, "Qucs",
tr("QucsatorRF found at: ") + QucsSettings.Qucsator + "\n");
}
}
}

// fillLibrariesTreeView();
Expand Down

0 comments on commit 0fe4bc4

Please sign in to comment.