Skip to content

Commit

Permalink
Update qucs.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
dsm authored Dec 5, 2024
1 parent 4cdc32c commit a703d1c
Showing 1 changed file with 36 additions and 18 deletions.
54 changes: 36 additions & 18 deletions qucs/qucs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,37 +172,53 @@ QucsApp::QucsApp()
}
}

if (QucsSettings.firstRun) { // try to find Ngspice
auto findExecutable = [](const QString &binDir, const QString &exeName) -> QString {
#ifdef Q_OS_WIN
QString ngspice_exe1 = QDir(QucsSettings.BinDir).absoluteFilePath("ngspice_con.exe");
QString ngspice_exe2 = "C:\\Spice64\\bin\\ngspice_con.exe";
QString qucsator_exe = QDir(QucsSettings.BinDir).absoluteFilePath("qucsator_rf.exe");
QString executableName = exeName + ".exe"; // Windows için .exe ekle
#else
QString ngspice_exe1 = QDir(QucsSettings.BinDir).absoluteFilePath("ngspice_con");
QString qucsator_exe = QDir(QucsSettings.BinDir).absoluteFilePath("qucsator_rf");
QString executableName = exeName; // Diğer platformlarda isim olduğu gibi kalır
#endif

QDir dir(binDir);
QString filePath = dir.absoluteFilePath(executableName);

QFileInfo fileInfo(filePath);
if (fileInfo.exists() && fileInfo.isExecutable()) {
return filePath; // Dosya bulundu ve çalıştırılabilir
}
return QString(); // Bulunamadı
};

if (QucsSettings.firstRun) { // try to find Ngspice
QString ngspice_exe1 = findExecutable(QucsSettings.BinDir, "ngspice_con");
QString qucsator_exe = findExecutable(QucsSettings.BinDir, "qucsator_rf");
#ifdef Q_OS_WIN
QString ngspice_exe2 = findExecutable("C:/Spice64/bin/","ngspice_con");
#else
QString ngspice_exe;
bool ngspice_found = false;
if (QFile::exists(ngspice_exe1)) {
if (!ngspice_exe1.isEmpty() {
ngspice_found = true;
ngspice_exe = ngspice_exe1;
ngspice_exe = QDir::toNativeSeparators(ngspice_exe1);
}
bool qucsator_found = false;
if (QFile::exists(qucsator_exe)) {
if (!qucsator_exe.isEmpty()) {
qucsator_found = true;
QucsSettings.Qucsator = qucsator_exe;
QucsSettings.Qucsator = QDir::toNativeSeparators(qucsator_exe);
_settings::Get().setItem<QString>("QucsatorExecutable",QucsSettings.Qucsator);
_settings::Get().setItem<QString>("QucsatorBinDir",QucsSettings.BinDir);
}
#ifdef Q_OS_WIN
if (!ngspice_found && QFile::exists(ngspice_exe2)) {
if (!ngspice_found && !ngspice_exe2.isEmpty()) {
ngspice_found = true;
ngspice_exe = ngspice_exe2;
ngspice_exe = QDir::toNativeSeparators(ngspice_exe2);
}
#endif
ngspice_exe = QDir::toNativeSeparators(ngspice_exe);
QString info_string;
if (ngspice_found) {
QucsSettings.DefaultSimulator = spicecompat::simNgspice;
QucsSettings.NgspiceExecutable = ngspice_exe;
_settings::Get().setItem<QString>("NgspiceExecutable",QucsSettings.NgspiceExecutable);
info_string += tr("Ngspice found at: ") + ngspice_exe + "\n";
}
if (qucsator_found) {
Expand All @@ -226,12 +242,14 @@ QucsApp::QucsApp()
}
QucsSettings.firstRun = false;
} else if (!QFile::exists(QucsSettings.Qucsator)) {
QucsSettings.Qucsator = QDir(QucsSettings.BinDir).absoluteFilePath("qucsator_rf");
#ifdef Q_OS_WIN
QucsSettings.Qucsator += ".exe";
#endif
QMessageBox::information(this, "Qucs",
QucsSettings.Qucsator = findExecutable(QucsSettings.BinDir,qucsator_rf);
_settings::Get().setItem<QString>("QucsatorExecutable",QucsSettings.Qucsator);
_settings::Get().setItem<QString>("QucsatorBinDir",QucsSettings.BinDir);
if(!(QucsSettings.Qucsator.isEmpty())){
QMessageBox::information(this, "Qucs",
tr("QucsatorRF found at: ") + QucsSettings.Qucsator + "\n");
}

}

// fillLibrariesTreeView();
Expand Down

0 comments on commit a703d1c

Please sign in to comment.