From ea95d5787a9a0d9047d8e0df559110fbebd3b2ac Mon Sep 17 00:00:00 2001 From: Alexander Diamadis Date: Sun, 7 Nov 2021 14:57:50 +0100 Subject: [PATCH] Minor Improvements --- source/about.ui | 24 ++++++++-- source/library.cpp | 104 +++++++++++++++++++++++++----------------- source/library.h | 3 ++ source/library.ui | 32 ++++++++++--- source/mainwindow.cpp | 1 + 5 files changed, 112 insertions(+), 52 deletions(-) diff --git a/source/about.ui b/source/about.ui index d8bac60..b41759b 100644 --- a/source/about.ui +++ b/source/about.ui @@ -10,6 +10,24 @@ 307 + + + 0 + 0 + + + + + 639 + 307 + + + + + 639 + 307 + + About PA Calculator @@ -33,7 +51,7 @@ 10 - 10 + 20 256 256 @@ -59,7 +77,7 @@ 290 10 - 231 + 331 21 @@ -79,7 +97,7 @@ 290 70 - 271 + 321 16 diff --git a/source/library.cpp b/source/library.cpp index ee7191a..c4b9211 100644 --- a/source/library.cpp +++ b/source/library.cpp @@ -17,6 +17,9 @@ library::library(QWidget *parent) : unsaved=false; speakerUnsaved=false; dacUnsaved=false; + initAmps=false; + initDacs=false; + initSpeaker=false; } library::~library() @@ -73,8 +76,6 @@ cdac *library::getDacs() void library::open() { - - ui->listWidget_ampView->setCurrentRow(0); QSettings settings("DKM-Tech","Pa-Calculator"); if (settings.value("library/path","")==""){ settings.setValue("library/path",QFileDialog::getSaveFileName(this,"Select Library Storage File","","Pa Calculator Library File (*.palib)")); @@ -131,10 +132,6 @@ void library::refreshModeOverview() } } } - //std::cerr<<"refreshModeOverview started"<lineEdit_ampName->text()!=QString::fromStdString(m_pCamp[getCurrentAmpIndex()].getName()) && unsaved==false){ ui->listWidget_ampView->currentItem()->setText(ui->listWidget_ampView->currentItem()->text()+QString::fromStdString("*")); unsaved =true; } @@ -183,7 +180,7 @@ void library::ampEdited() void library::speakerEdited() { - if (speakerUnsaved==false){ + if (ui->lineEdit_speakerName->text() != QString::fromStdString(m_pSpeaker[getCurrentSpeakerIndex()].getName()) && speakerUnsaved==false){ ui->listWidget_speakerView->currentItem()->setText(ui->listWidget_speakerView->currentItem()->text()+QString::fromStdString("*")); speakerUnsaved =true; } @@ -191,7 +188,7 @@ void library::speakerEdited() void library::dacEdited() { - if (dacUnsaved==false){ + if (ui->lineEdit_dacName->text()!= QString::fromStdString(m_pDac[getCurrentDacIndex()].name()) && dacUnsaved==false){ ui->listWidget_dacView->currentItem()->setText(ui->listWidget_dacView->currentItem()->text()+QString::fromStdString("*")); dacUnsaved =true; } @@ -257,19 +254,30 @@ void library::printAllAmps() void library::on_listWidget_ampView_currentRowChanged(int currentRow) { - if (currentRow>=0){ - ui->lineEdit_ampName->setText(QString::fromStdString(m_pCamp[currentRow].getName())); - ui->comboBox_sensUnit->setCurrentIndex(m_pCamp[currentRow].getSensivityUnit()); - ui->doubleSpinBox_inputSensitivity->setValue(m_pCamp[currentRow].getSensitivity()); - refreshModeOverview(); - ui->listWidget_modeSelector->setCurrentRow(0); - ui->lineEdit_ampName->setEnabled(true); - ui->doubleSpinBox_inputSensitivity->setEnabled(true); - }else - { - ui->lineEdit_ampName->setEnabled(false); - ui->doubleSpinBox_inputSensitivity->setEnabled(false); + if (initAmps){ + if (currentRow>=0){ + ui->lineEdit_ampName->setText(QString::fromStdString(m_pCamp[currentRow].getName())); + ui->comboBox_sensUnit->setCurrentIndex(m_pCamp[currentRow].getSensivityUnit()); + ui->doubleSpinBox_inputSensitivity->setValue(m_pCamp[currentRow].getSensitivity()); + refreshModeOverview(); + ui->listWidget_modeSelector->setCurrentRow(0); + ui->lineEdit_ampName->setEnabled(true); + ui->doubleSpinBox_inputSensitivity->setEnabled(true); + ui->comboBox_sensUnit->setEnabled(true); + ui->lineEdit_modeName->setEnabled(true); + ui->listWidget_modeSelector->setEnabled(true); + ui->spinBox_ratedImp->setEnabled(true); + ui->spinBox_ratedPower->setEnabled(true); + + }else + { + ui->lineEdit_ampName->setEnabled(false); + ui->doubleSpinBox_inputSensitivity->setEnabled(false); + } + }else { + initAmps =true; } + } @@ -428,25 +436,29 @@ void library::on_pushButton_addSpeaker_clicked() void library::on_listWidget_speakerView_currentRowChanged(int currentRow) { - if (currentRow>=0){ - ui->lineEdit_speakerName->setText(QString::fromStdString(m_pSpeaker[currentRow].getName())); - ui->spinBox_speakerImp->setValue(m_pSpeaker[currentRow].getImpedance()); - ui->spinBox_speakerRMSPower->setValue(m_pSpeaker[currentRow].getRMSPower()); - ui->spinBox_speakerPeakPower->setValue(m_pSpeaker[currentRow].getPeakPower()); - ui->spinBox_speakerHPF->setValue(m_pSpeaker[currentRow].getHPF()); + if (initSpeaker){ + if (currentRow>=0){ + ui->lineEdit_speakerName->setText(QString::fromStdString(m_pSpeaker[currentRow].getName())); + ui->spinBox_speakerImp->setValue(m_pSpeaker[currentRow].getImpedance()); + ui->spinBox_speakerRMSPower->setValue(m_pSpeaker[currentRow].getRMSPower()); + ui->spinBox_speakerPeakPower->setValue(m_pSpeaker[currentRow].getPeakPower()); + ui->spinBox_speakerHPF->setValue(m_pSpeaker[currentRow].getHPF()); - ui->lineEdit_speakerName->setEnabled(true); - //ui->spinBox_speakerImp->setEnabled(true); - //ui->spinBox_speakerRMSPower->setEnabled(true); - //ui->spinBox_speakerPeakPower->setEnabled(true); - //ui->spinBox_speakerHPF->setEnabled(true); + ui->lineEdit_speakerName->setEnabled(true); + ui->spinBox_speakerImp->setEnabled(true); + ui->spinBox_speakerRMSPower->setEnabled(true); + ui->spinBox_speakerPeakPower->setEnabled(true); + ui->spinBox_speakerHPF->setEnabled(true); - }else { - ui->lineEdit_speakerName->setEnabled(false); - //ui->spinBox_speakerImp->setEnabled(false); - //ui->spinBox_speakerRMSPower->setEnabled(false); - //ui->spinBox_speakerPeakPower->setEnabled(false); - //ui->spinBox_speakerHPF->setEnabled(false); + }else { + ui->lineEdit_speakerName->setEnabled(false); + //ui->spinBox_speakerImp->setEnabled(false); + //ui->spinBox_speakerRMSPower->setEnabled(false); + //ui->spinBox_speakerPeakPower->setEnabled(false); + //ui->spinBox_speakerHPF->setEnabled(false); + } + }else{ + initSpeaker=true; } } @@ -567,13 +579,19 @@ void library::on_pushButton_Apply_clicked() void library::on_listWidget_dacView_currentRowChanged(int currentRow) { - if (currentRow>=0){ - ui->lineEdit_dacName->setText(QString::fromStdString(m_pDac[currentRow].name())); - ui->spinBox_dacOutputLevel->setValue(m_pDac[currentRow].outputLevel()); - ui->lineEdit_dacName->setEnabled(true); + if (initDacs){ + if (currentRow>=0){ + ui->lineEdit_dacName->setText(QString::fromStdString(m_pDac[currentRow].name())); + ui->spinBox_dacOutputLevel->setValue(m_pDac[currentRow].outputLevel()); + ui->lineEdit_dacName->setEnabled(true); + ui->spinBox_dacOutputLevel->setEnabled(true); + }else{ + ui->lineEdit_dacName->setEnabled(false); + } }else{ - ui->lineEdit_dacName->setEnabled(false); + initDacs=true; } + } diff --git a/source/library.h b/source/library.h index e521a02..282ea65 100644 --- a/source/library.h +++ b/source/library.h @@ -128,6 +128,9 @@ private: bool speakerUnsaved; bool dacUnsaved; + bool initAmps; + bool initSpeaker; + bool initDacs; }; #endif // LIBRARY_H diff --git a/source/library.ui b/source/library.ui index 22677ff..1b26e9f 100644 --- a/source/library.ui +++ b/source/library.ui @@ -106,6 +106,9 @@ + + false + in Volt @@ -136,7 +139,11 @@ - + + + false + + @@ -147,6 +154,9 @@ + + false + W @@ -167,6 +177,9 @@ + + false + Ohm @@ -184,7 +197,11 @@ - + + + false + + @@ -281,7 +298,7 @@ - true + false Ohm @@ -304,7 +321,7 @@ - true + false W @@ -327,7 +344,7 @@ - true + false W @@ -350,7 +367,7 @@ - true + false Hz @@ -429,6 +446,9 @@ + + false + dBU diff --git a/source/mainwindow.cpp b/source/mainwindow.cpp index 0787234..de6853e 100644 --- a/source/mainwindow.cpp +++ b/source/mainwindow.cpp @@ -312,6 +312,7 @@ void MainWindow::on_actionOpen_Library_triggered() loadLibrary(); refreshLibraryAmps(); refreshLibrarySpeaker(); + refreshLibraryDacs(); }